paohuziHandler.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. 'use strict';
  2. var quick = require('quick-pomelo');
  3. var P = quick.Promise;
  4. var _ = require('lodash');
  5. var C = require('../../../../share/constant');
  6. var Handler = function (app) {
  7. this.app = app;
  8. };
  9. module.exports = function (app) {
  10. return new Handler(app);
  11. };
  12. var proto = Handler.prototype;
  13. // 删除手牌
  14. proto.remove = function (handCards, cards) {
  15. if (typeof (cards) == 'number') {
  16. if (cards == handCards[handCards.length - 1]) {
  17. return (handCards.pop(), true);
  18. } else {
  19. let pos = handCards.indexOf(cards);
  20. if (pos == -1) return false;
  21. return (handCards.splice(pos, 1), true);
  22. }
  23. }
  24. // console.warn("删除手牌");
  25. var length = cards.length;
  26. for (let i = 0; i < length; ++i) {
  27. let pos = handCards.indexOf(cards[i]);
  28. if (pos == -1) return false;
  29. }
  30. for (let i = 0; i < length; ++i) {
  31. let pos = handCards.indexOf(cards[i]);
  32. if (pos == -1) return false;
  33. handCards.splice(pos, 1);
  34. }
  35. return true;
  36. };
  37. //整理手牌
  38. proto.groupCards = function (_Cards) {
  39. let Cards = _.cloneDeep(_Cards);
  40. let CardsCopy = _.cloneDeep(_Cards);
  41. // console.error("判断桌子是否存在 ");
  42. // let Cards = [101,102,102,102,103,106,106,106,107,108,201,202,202,203,203,205,205,206,206,207,208]
  43. // let CardsCopy = [101,102,102,102,103,106,106,106,107,108,201,202,202,203,203,205,205,206,206,207,208]
  44. // // // let group1 = _.groupBy(Cards, function (n) { return n % 100 })
  45. // // //// group1 = {"1":[101,201],"2":[102,102,102,202,202],"3":[103,203,203],"5":[205,205],"6":[106,106,106,206,206],"7":[107,207],"8":[108,208]}
  46. // // // let map1 = _.map(Object.keys(group1), function (n) { return Number(n) });
  47. // // //// map1 = [1,2,3,5,6,7,8]
  48. // let group2 = _.groupBy(Cards, function (n) { return n})
  49. // console.error("group2 = ",group2);
  50. // // // // group2 = {"101":[101],"102":[102,102,102],"103":[103],"106":[106,106,106],"107":[107],"108":[108],
  51. // // // // "201":[201],"202":[202,202],"203":[203,203],"205":[205,205],"206":[206,206],"207":[207],"208":[208]}
  52. // // let map2 = _.map(Object.keys(group2), function (n) { return Number(n) });
  53. // // // map2 [101,102,103,106,107,108,201,202,203,205,206,207,208]
  54. // // console.error("group2 = ",JSON.stringify(group2)," map2 ",JSON.stringify(map2));
  55. // // let order2 = _.sortBy((group2, function (n) { return n.length})
  56. // // console.error("group2 = ",group2," order2 ",order2);
  57. // var values2 = _.values(group2);
  58. // // values2 = [[101],[102,102,102],[103],[106,106,106],[107],[108],[201],[202,202],[203,203],[205,205],[206,206],[207],[208]]
  59. // console.error(" values2 ",values2,JSON.stringify(values2));
  60. // var sortVal = _.sortBy(values2, function (n) { return n.length }).reverse();
  61. // //sortVal = [[106,106,106],[102,102,102],[206,206],[205,205],[203,203],[202,202],[208],[207],[201],[108],[107],[103],[101]]
  62. // console.error(" sortVal ",sortVal,JSON.stringify(sortVal));
  63. let dspzs = [[201,202,203],[202,207,210]];//大顺的牌值列表
  64. let xspzs = [[201,202,203],[202,207,210]];//小顺的牌值列表
  65. let res = [];
  66. let gc = _.groupBy(Cards, function (n) { return n})
  67. let vc = _.values(gc);
  68. var sortVal = _.sortBy(vc, function (n) { return n.length }).reverse();
  69. // console.error(" sortVal ",sortVal);
  70. // console.error(" Cards111 ",JSON.stringify(Cards));
  71. let tikeList = [];//手牌中的提刻列表
  72. let dashunList = [];//手牌中的大顺列表
  73. let xiaoshunList = [];//手牌中的小顺列表
  74. let duiziList = [];//手牌中的对子列表
  75. let danpaiList = [];//手牌中的单牌列表
  76. for (var i = 0; i < sortVal.length; i++) {
  77. if(sortVal[i].length >= 3){
  78. tikeList.push(sortVal[i]);
  79. let issccg = this.remove(Cards,sortVal[i]);//从手牌中剔除可组成大顺的牌
  80. if(!issccg){//是否删除成功,不成功说明手牌中没有,据此可知代码出错了
  81. console.error("牌出错了111 ",JSON.stringify(Cards));
  82. return [];
  83. }
  84. // console.error(" Cards222 ",JSON.stringify(Cards));
  85. }
  86. }
  87. for (var j = 0; j < dspzs.length; j++) {
  88. for (var i = 0; i < 2; i++) {//手牌中剔除刻子之后最多2个大顺
  89. let issccg = this.remove(Cards,dspzs[j]);//从手牌中剔除可组成大顺的牌
  90. // if(issccg) console.error(" Cards222 ",JSON.stringify(Cards));
  91. if(issccg) dashunList.push(dspzs[j])
  92. else break;
  93. }
  94. }
  95. for (var j = 0; j < xspzs.length; j++) {
  96. for (var i = 0; i < 2; i++) {//手牌中剔除刻子之后最多2个小顺
  97. let issccg = this.remove(Cards,xspzs[j]);//从手牌中剔除可组成小顺的牌
  98. // if(issccg) console.error(" Cards333 ",JSON.stringify(Cards));
  99. if(issccg) xiaoshunList.push(dspzs[j])
  100. else break;
  101. }
  102. }
  103. let gc2 = _.groupBy(Cards, function (n) { return n})
  104. let vc2 = _.values(gc2);
  105. for (var i = 0; i < vc2.length; i++) {
  106. if(vc2[i].length == 1) danpaiList = danpaiList.concat(vc2[i]);
  107. else if(vc2[i].length == 2) duiziList.push(vc2[i]);
  108. else {
  109. console.error("牌出错了222 ",JSON.stringify(CardsCopy));
  110. return [];
  111. }
  112. }
  113. danpaiList = _.chunk(danpaiList, 3);
  114. // console.warn("手牌中的提刻列表 ",tikeList);//
  115. // console.warn("手牌中的大顺列表 ",dashunList);//
  116. // console.warn("手牌中的小顺列表 ",xiaoshunList);//
  117. // console.warn("手牌中的对子列表 ",duiziList);//
  118. // console.warn("手牌中的单牌列表 ",danpaiList);//
  119. res = res.concat(tikeList);//
  120. res = res.concat(dashunList);//
  121. res = res.concat(xiaoshunList);//
  122. res = res.concat(duiziList);//
  123. res = res.concat(danpaiList);//
  124. // console.error(" res ",res);
  125. let zlzh = [];//整理之后的牌
  126. for (var i = 0; i < res.length; i++) {
  127. zlzh = zlzh.concat(res[i]);
  128. }
  129. zlzh = _.sortBy(zlzh);///降序排序
  130. let lygdys = _.difference(zlzh,CardsCopy);////另一个队员的人数
  131. let lygdys2 = _.difference(CardsCopy,zlzh);////另一个队员的人数
  132. if(lygdys.length > 0 || lygdys2.length > 0 || zlzh.length != CardsCopy.length){
  133. console.error("111==============================这把派出错了 =======",zlzh);
  134. console.error("222==============================这把派出错了 =======",CardsCopy);
  135. return [];
  136. }
  137. return res;
  138. // console.error("111==============================这把派没问题 =======",zlzh);
  139. };
  140. // 判断桌子是否存在
  141. proto.isTableExist = P.coroutine(function* (msg, session, next) {
  142. // let fptj = [];
  143. // for (var i = 0; i < 15; i++) {
  144. // fptj[i] = 0;
  145. // }
  146. // console.warn("下面是调试发牌算法");
  147. // let cscs = 1//测试次数
  148. // for (var i = 0; i < cscs; i++) {
  149. // let pc = [
  150. // 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, //一到十
  151. // 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
  152. // 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
  153. // 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
  154. // 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, //壹到拾
  155. // 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
  156. // 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
  157. // 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
  158. // ];
  159. // pc = _.shuffle(pc);////随机打乱一个数组
  160. // pc = _.shuffle(pc);////洗第二次牌
  161. // let hc = _.take(pc,20);
  162. // hc = [101,103,103,104,104,104,105,106,107,107,110,201,201,202,202,204,205,207,207,209,210]
  163. // let tzzh = this.groupCards(hc);
  164. // fptj[tzzh.length]++;
  165. // }
  166. // let cxcs = 0;//出现次数
  167. // for (var i = 0; i < fptj.length; i++) {
  168. // if(fptj[i] > 0) console.warn("分为 "+i+" 组出现的次数为 "+fptj[i]);
  169. // cxcs+=fptj[i];
  170. // }
  171. // if(cxcs != cscs) console.error("次数对不上 ")
  172. // console.warn("XXXXXXXXXXXXXX000");
  173. if (!session.uid) {
  174. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  175. }
  176. if (!msg.tableId) {
  177. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  178. }
  179. var reload = parseInt(msg.reload) || 0;//ts++重入 1为重入
  180. return this.app.controllers.paohuzi.isTableExistAsync(session.uid, String(msg.tableId),reload).nodeify(next);
  181. });
  182. // 加入桌子
  183. proto.joinTable = P.coroutine(function* (msg, session, next) {
  184. if (!session.uid) {
  185. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  186. }
  187. if (!msg.tableId) {
  188. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  189. }
  190. return this.app.controllers.paohuzi.joinTableAsync(session.uid, String(msg.tableId)).nodeify(next);
  191. });
  192. //////TL++创建或者加入桌子,用于玩家通过战绩分享进来之后
  193. proto.creatOrjoinTable = P.coroutine(function* (msg, session, next) {
  194. if (!session.uid) {
  195. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  196. }
  197. if (!msg.upId) {
  198. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  199. }
  200. if (!msg.other) {
  201. if(msg.other != 0){
  202. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  203. }
  204. }
  205. var round = parseInt(msg.round);
  206. var type = parseInt(msg.type) || 0;
  207. if(!type){
  208. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  209. }
  210. var kind = parseInt(msg.kind) || 1;////游戏类型 = 1代表全名堂 = 2代表大小子 = 3表示土跑胡
  211. if(kind != 1 && kind != 2 && kind != 3){
  212. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });/////既不是平搓也不是冲刺
  213. }
  214. var playercount = parseInt(msg.playercount) || 3;////游戏人数 = 2表示2人局 = 3表示3人局 = 4表示4人局
  215. var other = parseInt(msg.other) || 1000000;////是个7位数字,百分位至十万分位表示可选十分位表示充囤情况,个位表示封顶情况
  216. if (other < 1000000 || other > 1200000) {
  217. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  218. }
  219. var upId = msg.upId;////TL++主动创建房间的话此值为"",通过战绩分享自动创建的房间此变量有值
  220. // console.warn("创建房间的22other",other,msg.other);
  221. if(round != 10 && round != 16 && round != 8){//////游戏局数不合法
  222. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  223. }
  224. if(playercount != 2 && playercount != 3){//////游戏人数不合法
  225. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  226. }
  227. var agentId=msg.agentId || "";//数据库中agenter(推广员)数据表的主键(_id)
  228. // console.warn("创建或者加入桌子 agentId "+agentId+" session.uid "+session.uid);
  229. return this.app.controllers.paohuzi.creatOrjoinTableAsync(session.uid, round,type, kind,playercount,upId,other,agentId).nodeify(next);
  230. // return this.app.controllers.paohuzi.creatOrjoinTableAsync(session.uid, msg).nodeify(next);
  231. });
  232. // 创建桌子
  233. proto.createTable = P.coroutine(function* (msg, session, next) {
  234. if (!session.uid) {
  235. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  236. }
  237. if (!msg.other) {
  238. if(msg.other != 0){
  239. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  240. }
  241. }
  242. var round = parseInt(msg.round);
  243. var type = parseInt(msg.type) || 0;
  244. if(!type){
  245. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });/////充囤和封顶情况错误
  246. }
  247. var gameKindTL = parseInt(msg.gameKindTL) || 1;////游戏类型 = 1代表全名堂 = 2代表大小子 = 3表示土跑胡
  248. if(gameKindTL != 1 && gameKindTL != 2 && gameKindTL != 3){
  249. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });/////既不是平搓也不是冲刺
  250. }
  251. var playerAllCount = parseInt(msg.playerAllCount) || 3;////游戏人数 = 2表示2人局 = 3表示3人局 = 4表示4人局
  252. var other = parseInt(msg.other) || 1000000;////是个7位数字,百分位至十万分位表示可选十分位表示充囤情况,个位表示封顶情况
  253. if (other < 1000000 || other > 1200000) {
  254. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  255. }
  256. var upId = msg.upId || "";////TL++主动创建房间的话此值为"",通过战绩分享自动创建的房间此变量有值
  257. // console.warn("创建房间的other",other,msg.other);
  258. if(round != 10 && round != 16 && round != 8){//////游戏局数不合法
  259. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  260. }
  261. if(playerAllCount != 2 && playerAllCount != 3){//////游戏人数不合法
  262. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  263. }
  264. var agentId=msg.agentId || "";
  265. // console.warn("创建桌子, "+agentId+" session.uid "+session.uid);//数据库中agenter(推广员)数据表的主键(_id)
  266. return this.app.controllers.paohuzi.createTableAsync(session.uid, round, type,gameKindTL,playerAllCount,upId,other,agentId).nodeify(next);/////修改局数
  267. });
  268. // TL++,得到玩家位置
  269. proto.sendLocation = P.coroutine(function* (msg, session, next) {
  270. if (!session.uid) {
  271. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  272. }
  273. return this.app.controllers.paohuzi.sendLocationAsync(session.uid, msg).nodeify(next);
  274. });
  275. // 得到玩家位置
  276. proto.getLocation = P.coroutine(function* (msg, session, next) {
  277. if (!session.uid) {
  278. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  279. }
  280. return this.app.controllers.paohuzi.getLocationAsync(session.uid, msg).nodeify(next);
  281. });
  282. // 离开桌子
  283. proto.leaveTable = P.coroutine(function* (msg, session, next) {
  284. if (!session.uid) {
  285. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  286. }
  287. return this.app.controllers.paohuzi.leaveTableAsync(session.uid).nodeify(next);
  288. });
  289. // 坐下
  290. proto.seat = P.coroutine(function* (msg, session, next) {
  291. if (!session.uid) {
  292. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  293. }
  294. var chairId = parseInt(msg.chairId);
  295. if (!chairId && chairId != 0) {
  296. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  297. }
  298. return this.app.controllers.paohuzi.seatAsync(session.uid, chairId).nodeify(next);
  299. });
  300. // 站起
  301. proto.stand = P.coroutine(function* (msg, session, next) {
  302. if (!session.uid) {
  303. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  304. }
  305. return this.app.controllers.paohuzi.standAsync(session.uid).nodeify(next);
  306. });
  307. // 准备
  308. proto.ready = P.coroutine(function* (msg, session, next) {
  309. if (!session.uid) {
  310. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  311. }
  312. return this.app.controllers.paohuzi.readyGameAsync(session.uid).nodeify(next);
  313. });
  314. // 开始
  315. proto.startGame = P.coroutine(function* (msg, session, next) {
  316. if (!session.uid) {
  317. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  318. }
  319. return this.app.controllers.paohuzi.startGameAsync(session.uid).nodeify(next);
  320. });
  321. // 调整牌
  322. proto.adjustCard = P.coroutine(function* (msg, session, next) {
  323. console.warn(" 调整牌hander ",msg);
  324. if (!session.uid) {
  325. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  326. }
  327. var card = parseInt(msg.card);
  328. var oldIndex = msg.oldIndex;
  329. var newIndex = msg.newIndex;
  330. var isfy = parseInt(msg.isfy);//是否复原形式调整牌,若是则不需要传上面那些参数
  331. if (!isfy){
  332. if (!card || card < 101 || card > 210 || (card > 110 && card < 201)) {
  333. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  334. }
  335. let isArr = msg.oldIndex instanceof Array;////////判断参数是否是个数组
  336. if (!oldIndex || !isArr || oldIndex.length != 2 || oldIndex[0] < 0 || oldIndex[1] < 0 || oldIndex[0] > 9 || oldIndex[1] > 3 ) {
  337. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  338. }
  339. isArr = msg.newIndex instanceof Array;////////判断参数是否是个数组
  340. if (!newIndex || !isArr || newIndex.length != 2 || newIndex[0] < 0 || newIndex[1] < 0 || newIndex[0] > 9 || newIndex[1] > 3 ) {
  341. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  342. }
  343. }
  344. return this.app.controllers.paohuzi.adjustCardAsync(session.uid, isfy,card,oldIndex,newIndex).nodeify(next);
  345. });
  346. // 出牌
  347. proto.outCard = P.coroutine(function* (msg, session, next) {
  348. if (!session.uid) {
  349. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  350. }
  351. var card = parseInt(msg.card);
  352. if (!card || card < 101 || card > 210 || (card > 110 && card < 201)) {
  353. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  354. }
  355. var oldIndex = msg.oldIndex;
  356. let isArr = msg.oldIndex instanceof Array;////////判断参数是否是个数组
  357. if (!oldIndex || !isArr || oldIndex.length != 2 || oldIndex[0] < 0 || oldIndex[1] < 0 || oldIndex[0] > 9 || oldIndex[1] > 3 ) {
  358. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  359. }
  360. return this.app.controllers.paohuzi.outCardAsync(session.uid, card,oldIndex).nodeify(next);
  361. });
  362. // 杠牌
  363. proto.gangCard = P.coroutine(function* (msg, session, next) {
  364. if (!session.uid) {
  365. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  366. }
  367. var card = parseInt(msg.card);
  368. var type = parseInt(msg.type);
  369. if (!card || !type) {
  370. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  371. }
  372. return this.app.controllers.paohuzi.gangCardAsync(session.uid, card, type).nodeify(next);
  373. });
  374. // 碰牌
  375. proto.pengCard = P.coroutine(function* (msg, session, next) {
  376. if (!session.uid) {
  377. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  378. }
  379. var card = parseInt(msg.card);
  380. if (!card) {
  381. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  382. }
  383. return this.app.controllers.paohuzi.pengCardAsync(session.uid, card).nodeify(next);
  384. });
  385. // 吃牌
  386. proto.eatCard = P.coroutine(function* (msg, session, next) {
  387. if (!session.uid) {
  388. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  389. }
  390. var card = parseInt(msg.card);
  391. var type = parseInt(msg.type);
  392. if (!card || !type) {
  393. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  394. }
  395. var bi1Type = parseInt(msg.bi1Type) || 0;
  396. var bi2Type = parseInt(msg.bi2Type) || 0;
  397. return this.app.controllers.paohuzi.eatCardAsync(session.uid, card, type, bi1Type, bi2Type).nodeify(next);
  398. });
  399. // 胡牌
  400. proto.succCard = P.coroutine(function* (msg, session, next) {
  401. if (!session.uid) {
  402. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  403. }
  404. return this.app.controllers.paohuzi.succCardAsync(session.uid).nodeify(next);
  405. });
  406. // 放弃
  407. proto.giveUp = P.coroutine(function* (msg, session, next) {
  408. if (!session.uid) {
  409. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  410. }
  411. return this.app.controllers.paohuzi.giveUpAsync(session.uid).nodeify(next);
  412. });
  413. /////TL++,海底捞月
  414. proto.haidilaoyue = P.coroutine(function* (msg, session, next) {
  415. if (!session.uid) {
  416. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  417. }
  418. return this.app.controllers.paohuzi.haiDiLaoYue(session.uid,msg).nodeify(next);
  419. });
  420. /////TL++,操作是否自动出牌
  421. proto.autoOutCard = P.coroutine(function* (msg, session, next) {
  422. if (!session.uid) {
  423. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  424. }
  425. return next(null, { code: C.FAILD, msg: "敬请期待" });
  426. // return this.app.controllers.paohuzi.autoOutCard(session.uid).nodeify(next);
  427. });
  428. // 聊天
  429. proto.chat = P.coroutine(function* (msg, session, next) {
  430. if (!session.uid) {
  431. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  432. }
  433. return this.app.controllers.paohuzi.sendMsgAsync(session.uid, msg).nodeify(next);
  434. });
  435. // 收费聊天
  436. proto.vchat = P.coroutine(function* (msg, session, next) {
  437. if (!session.uid) {
  438. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  439. }
  440. var chairId = parseInt(msg.chairId);
  441. if (!(chairId >= 0)) {
  442. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  443. }
  444. if (!msg.msg) {
  445. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  446. }
  447. return this.app.controllers.paohuzi.vsendMsgAsync(session.uid, chairId, msg.msg).nodeify(next);
  448. });
  449. // 角色信息
  450. proto.roleInfo = P.coroutine(function* (msg, session, next) {
  451. if (!session.uid) {
  452. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  453. }
  454. var chairId = parseInt(msg.chairId);
  455. if (!(chairId >= 0)) {
  456. return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
  457. }
  458. return this.app.controllers.paohuzi.roleInfoAsync(session.uid, chairId).nodeify(next);
  459. });
  460. // 请求结束
  461. proto.overTable = P.coroutine(function* (msg, session, next) {
  462. if (!session.uid) {
  463. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  464. }
  465. return this.app.controllers.paohuzi.overTableAsync(session.uid).nodeify(next);
  466. });
  467. // 拒绝结束
  468. proto.refuseOver = P.coroutine(function* (msg, session, next) {
  469. if (!session.uid) {
  470. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  471. }
  472. return this.app.controllers.paohuzi.refuseOverAsync(session.uid).nodeify(next);
  473. });
  474. // 同意结束
  475. proto.agreeOver = P.coroutine(function* (msg, session, next) {
  476. if (!session.uid) {
  477. return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
  478. }
  479. return this.app.controllers.paohuzi.agreeOverAsync(session.uid).nodeify(next);
  480. });