# game-api **Repository Path**: dearmm/game-api ## Basic Information - **Project Name**: game-api - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-06-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 金币模式房间 #### 房间配置列表 path : /api/config/global ``` [ { title - 标题 subtitle - 副标题 room_tag - 房间标识 [ tag50 ... ] game_type - 游戏类型 card_ratio - 每一份扣除金币数 room_consume - 开房每个人消费得金币数 min_score - 最低进入积分要求 } ] ``` ``` { "state":1, "data":[ { "name":"pdk", "content":{ "scorelist":[ 1000, 2000, 3000 ], "gameconfig":[ { "gamecount":10, "roomcard":3 }, { "gamecount":20, "roomcard":6 }, { "gamecount":30, "roomcard":9 } ] } }, { "name":"horse_race_lamp", "content":{ "title":"通知", "content":[ "官方声明,本游戏绝无外挂,请广大玩家放心使用。切勿上当受骗。", "请文明游戏,禁止赌博。祝您玩的愉快。", "官方唯一技术支持微信号:18169599493" ] } }, { "name":"avatar", "content":{ "imglist":[ { "imgid":1, "imgpath":"http://localhost/gamehall/www/statics/images/avavtar/default_01.png" }, { "imgid":2, "imgpath":"http://localhost/gamehall/www/statics/images/avavtar/default_02.jpg" }, { "imgid":3, "imgpath":"http://localhost/gamehall/www/statics/images/avavtar/default_03.jpg" }, { "imgid":4, "imgpath":"http://localhost/gamehall/www/statics/images/avavtar/default_04.jpg" } ] } }, { "name":"pdk_gold_room", "content":[ { "id":1, "title":"50金币房", "subtitle":"50金币房。。。", "room_tag":"g50", "card_ratio":10, "room_consume":20 } ] } ] } ``` #### 金币房间 游戏开始 扣金币接口 ``` post : /api/game/start request: { room_tag - string 房间标识 user_list: [ ... uid ] - 用户列表 game_type - 游戏种类 access_token } response : { code:0, // [ 0 :ok -1 :error ] // 数据中的 id 为游戏的id game_id "data": {"room_tag":"g50","game_type":"PDK","addtime":1503822838,"id":5} } test: $ curl -d '{"room_tag":"g50","game_type":"PDK","user_list":[1,2,3]}' http://localhost/gamehall/www/api/game/start ``` ### 积分房 判断用户是否满足最低分数 ``` post : api/game/enough-gold request: { user_list:[uid, ... ], // 用户ID room_tag // 房间类型 game_type //游戏类型 PDK } reponse{ code: 0 // ok -1 错误 msg:[ {uid:uid ,score:score , enable:ture} //enable 是否满足最低积分 ... ] } test: $ curl -d '{"room_tag":"g50","game_type":"PDK","user_list":[1,2,3]}' http://localhost/gamehall/www/api/game/enough-gold ``` #### 积分房 游戏结束 结算、录像接口 每局会产生一次结算 和 录像 ``` post : api/game/end request :{ game_id  - 游戏ID game_type - 游戏类型 PDK room_tag - 房间标识 person_num - 游戏参与人数 halfway_quit_uid - 中途退出玩家的ID [默认是0 ,游戏正常结束] result:[ - 游戏结果 { uid - uid score_change - 分数变化 }, ... ], video_content, // 录像内容 access_token } response: { code: // 0 : OK -1: 游戏已经结算 data: { xxxx } } eg : {"code":0,"data":[{"uid":1,"change":100},{"uid":3,"change":150},{"uid":5,"change":200}]} test: $ curl -d '{"video_content":"sdfadfasdfasdfasdfasdfadsf","room_tag":"g50","game_id":2,"person_num":3,"game_type":"PDK","result":[{"uid":1,"score_change":2},{"uid":3,"score_change":3},{"uid":5,"score_change":4}]}' http://localhost/gamehall/www/api/game/end ``` #### 普通房 , 游戏录像 在扣房卡接口中增加 游戏ID的 返回字段 ``` request : { game_id - 游戏ID user_data: [ { uid , score_change , // 牌面分数 } ] video_content - 录像内容 game_order - 第几场 } ``` ### 金币放战绩列表接口 ``` get: api/game/recoder?uid=uid query : { uid } // 返回样例 response: [ { "score_change":"2", "last_gold":"83", "video_content":"sdfadfasdfasdfasdfasdfadsf", "room_tag":"g50", "game_type":"PDK" }, { "score_change":"2", "last_gold":"80", "video_content":"sdfadfasdfasdfasdfasdfadsf", "room_tag":"g50", "game_type":"PDK" } ... ] test: http://localhost/gamehall/www/api/game/recoder?uid=1 ``` #### 在线人数 ``` get: /api/server/online // 游戏server 提供真实shujv response:{ score_room: xxx - 积分房人数 card_room: xxx - 房卡房人数 } ``` ## SERVER ``` http://118.178.181.89/ ``` #### USER 模块 ``` 获取用户信息 @ get post path : /api/user/info param : token response:{ id , //用户id room_card, // 房卡数量 isvip, // 是否是vip vip_date , // vip 到期时间 score , // 金币 name , // 名字 imgid , // 头像id imgpath , // 头像 path } ``` ## 扣除房卡 ``` @get post path : /api/user/deduction-room-card params:{ token:xxx , game:'xxx' , mode:'xxx' , DEDUCTION_EVERYONE (每个人都扣) 或者 DEDUCTION_ALONE (一个扣除) uids:1-2-3 // 一个人扣除的时候给一个就行了 gamecount:10 // 游戏局数 } response: game_id // 本轮游戏的ID ``` ### Auth 模块 ``` 登录页面 , 登录成功 发送 postMessage path : /api/auth/login ``` ### 配置模块 ``` 全局配置 path /api/config/global 返回 { "state":1, "data":[ { "name":"pdk", "content":{ "scorelist":[ // 分数类型 ], "gameconfig":[ // 游戏配置 ] } }, { "name":"horse_race_lamp", // 跑马灯 "content":{ "title":"跑马灯", // 标题 "content":"跑马灯内容 ..." //内容 } }, { "name":"avatar", //默认头像 "content":{ "imglist":[ //默认头像的数据有4条 ] } } ] } ``` ## Pages 模块 ####抽奖页面 ``` path /api/pages/Lucky-draw ```` ####帮助页面 ``` path /api/pages/helper { "state":1, "data":{ "content":"帮助文本 。。。" // 文本内容 } } ``` ####用户协议页面 ``` path /api/pages/member-agreement { "state":1, "data":{ "content":"帮助文本 。。。" //文本内容 } } ```