GameClientEngine_21201.js 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235
  1. var CGameLogic = require("GameLogic_21201");
  2. cc.Class({
  3. extends: cc.GameEngine,
  4. properties:
  5. {
  6. m_ViewNode: cc.Node,
  7. m_BtDissolve: cc.Node,
  8. m_BtExit: cc.Node,
  9. },
  10. // use this for initialization
  11. start: function () {
  12. this.Init();
  13. },
  14. Init: function () {
  15. if (this.m_bInit == true) return;
  16. this.m_bInit = true;
  17. //this.SInit();
  18. this.m_UserLocation = new Array();
  19. this.m_GameLogic = new CGameLogic(); //游戏逻辑
  20. GameDef.g_GameLogic = this.m_GameLogic;
  21. GameDef.g_GameEngine = this;
  22. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  23. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  24. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  25. }
  26. }
  27. // this.m_LeaveControl = this.node.getChildByName('LeaveCtrl').getComponent('LeaveControl');
  28. // this.m_LeaveControl.SetClientEngine(this);
  29. // this.m_LeaveControl.ShowView(false);
  30. },
  31. ctor: function () {
  32. //游戏变量
  33. this.m_wBankerUser = 0;
  34. this.m_wCurrentUser = 0;
  35. this.m_wActionMask = 0;
  36. this.m_bStustee = false;
  37. this.m_wTimeOutCount = 0;
  38. this.m_cbLeftCardCount = 0; //发牌数目
  39. this.m_GameLogic = null; //游戏逻辑
  40. this.m_WeaveItemArray = new Array();
  41. this.m_cbWeaveCount = new Array();
  42. this.m_bListen = new Array();
  43. for (var i = 0; i < 4; i++) {
  44. this.m_bListen[i] = false;
  45. this.m_cbWeaveCount[i] = 0;
  46. this.m_WeaveItemArray[i] = new Array();
  47. }
  48. this.m_cbCardIndex = new Array();
  49. for (var i = 0; i < 42; ++i) {//GameDef.MAX_INDEX
  50. this.m_cbCardIndex[i] = 0;
  51. }
  52. //玩家变量
  53. this.m_wCurrentUser = INVALID_CHAIR;
  54. this.m_SoundArr = new Array(
  55. ['BGM', 'BGM'],//.mp3
  56. ['GAME_START', 'GAME_START'],
  57. ['GAME_END', 'GAME_END'],
  58. ['GAME_WARN', 'GAME_WARN'],
  59. ['SEND_CARD', 'SEND_CARD'],
  60. ['CHUPAI', 'CHUPAI'],
  61. ['TIPAI', 'TIPAI'],
  62. // //女
  63. // ['W_CHI', 'w/CHI'],
  64. // ['W_HU', 'w/CHI_HU'],
  65. // ['W_ZIMO', 'w/ZIMO'],
  66. // ['W_GANG', 'w/GANG'],
  67. // ['W_PENG', 'w/PENG'],
  68. // ['W_TING', 'w/TING'],
  69. // ['W_ZHUNBEI', 'w/zhunbei'],
  70. // //男
  71. // ['M_CHI', 'm/CHI'],
  72. // ['M_HU', 'm/CHI_HU'],
  73. // ['M_ZIMO', 'm/ZIMO'],
  74. // ['M_GANG', 'm/GANG'],
  75. // ['M_PENG', 'm/PENG'],
  76. // ['M_TING', 'm/TING'],
  77. // ['M_ZHUNBEI', 'm/zhunbei'],
  78. );
  79. //出牌声音
  80. for (var j = 0; j < 4; j++) {
  81. //女
  82. this.m_SoundArr[this.m_SoundArr.length] = ["W_CHIL" + j, 'w/CHIL' + j];
  83. this.m_SoundArr[this.m_SoundArr.length] = ["W_HUL" + j, 'w/CHI_HUL' + j];
  84. this.m_SoundArr[this.m_SoundArr.length] = ["W_ZIMOL" + j, 'w/ZIMOL' + j];
  85. this.m_SoundArr[this.m_SoundArr.length] = ["W_GANGL" + j, 'w/GANGL' + j];
  86. this.m_SoundArr[this.m_SoundArr.length] = ["W_PENGL" + j, 'w/PENGL' + j];
  87. this.m_SoundArr[this.m_SoundArr.length] = ["W_TINGL" + j, 'w/TINGL' + j];
  88. this.m_SoundArr[this.m_SoundArr.length] = ["W_ZHUNBEIL" + j, 'w/zhunbeiL' + j];
  89. this.m_SoundArr[this.m_SoundArr.length] = ["W_BUHUAL" + j, 'w/BUHUAL' + j];
  90. //男
  91. this.m_SoundArr[this.m_SoundArr.length] = ["M_CHIL" + j, 'm/CHIL' + j];
  92. this.m_SoundArr[this.m_SoundArr.length] = ["M_HUL" + j, 'm/CHI_HUL' + j];
  93. this.m_SoundArr[this.m_SoundArr.length] = ["M_ZIMOL" + j, 'm/ZIMOL' + j];
  94. this.m_SoundArr[this.m_SoundArr.length] = ["M_GANGL" + j, 'm/GANGL' + j];
  95. this.m_SoundArr[this.m_SoundArr.length] = ["M_PENGL" + j, 'm/PENGL' + j];
  96. this.m_SoundArr[this.m_SoundArr.length] = ["M_TINGL" + j, 'm/TINGL' + j];
  97. this.m_SoundArr[this.m_SoundArr.length] = ["M_ZHUNBEIL" + j, 'm/zhunbeiL' + j];
  98. this.m_SoundArr[this.m_SoundArr.length] = ["M_BUHUAL" + j, 'm/BUHUAL' + j];
  99. for (var i = 1; i < 10; ++i) {
  100. this.m_SoundArr[this.m_SoundArr.length] = ["M_W_" + i + "L" + j, 'm/W_' + i + "L" + j];
  101. this.m_SoundArr[this.m_SoundArr.length] = ['W_W_' + i + "L" + j, 'w/W_' + i + "L" + j];
  102. this.m_SoundArr[this.m_SoundArr.length] = ["M_S_" + i + "L" + j, 'm/S_' + i + "L" + j];
  103. this.m_SoundArr[this.m_SoundArr.length] = ['W_S_' + i + "L" + j, 'w/S_' + i + "L" + j];
  104. this.m_SoundArr[this.m_SoundArr.length] = ["M_T_" + i + "L" + j, 'm/T_' + i + "L" + j];
  105. this.m_SoundArr[this.m_SoundArr.length] = ['W_T_' + i + "L" + j, 'w/T_' + i + "L" + j];
  106. this.m_SoundArr[this.m_SoundArr.length] = ["M_F_" + i + "L" + j, 'm/F_' + i + "L" + j];
  107. this.m_SoundArr[this.m_SoundArr.length] = ['W_F_' + i + "L" + j, 'w/F_' + i + "L" + j];
  108. }
  109. for (var i = 0; i < 12; ++i) {
  110. var num = "w_" + i;
  111. this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_w" + (i + 1), 'ShortcutPhrase/' + num];
  112. num = "m_" + i;
  113. this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_m" + (i + 1), 'ShortcutPhrase/' + num];
  114. }
  115. // for (var i = 0; i < 12; ++i) {
  116. // var num = "w_" + i+"L"+j;
  117. // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_w" + (i + 1)+"L"+j, 'ShortcutPhrase/' + num];
  118. // num = "m_" + i+"L"+j;
  119. // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_m" + (i + 1)+"L"+j, 'ShortcutPhrase/' + num];
  120. // }
  121. }
  122. // //出牌声音
  123. // for(var i=1;i<10;++i){
  124. // this.m_SoundArr[this.m_SoundArr.length] = ["M_W_"+i,'m/W_'+i];
  125. // this.m_SoundArr[this.m_SoundArr.length] = ['W_W_'+i,'w/W_'+i];
  126. // this.m_SoundArr[this.m_SoundArr.length] = ["M_S_"+i,'m/S_'+i];
  127. // this.m_SoundArr[this.m_SoundArr.length] = ['W_S_'+i,'w/S_'+i];
  128. // this.m_SoundArr[this.m_SoundArr.length] = ["M_T_"+i,'m/T_'+i];
  129. // this.m_SoundArr[this.m_SoundArr.length] = ['W_T_'+i,'w/T_'+i];
  130. // this.m_SoundArr[this.m_SoundArr.length] = ["M_F_"+i,'m/F_'+i];
  131. // this.m_SoundArr[this.m_SoundArr.length] = ['W_F_'+i,'w/F_'+i];
  132. // }
  133. // for (var i = 0; i < 12; ++i) {
  134. // var num = "w_" + i;
  135. // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_w" + (i + 1), 'ShortcutPhrase/' + num];
  136. // num = "m_" + i;
  137. // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_m" + (i + 1), 'ShortcutPhrase/' + num];
  138. // }
  139. this.m_szText = new Array(
  140. '快點動手!你是來打牌還是來當雕像?',
  141. '哇靠~盯這麼緊?打張牌來吃吃吧!',
  142. '拖什麼拖!我還得趕去談生意咧!',
  143. '等等,我接個電話,別偷牌啊!',
  144. '想這麼久幹嘛?出張二筒吧!',
  145. '不是阿大哥,在忙啥,動作這麼慢?',
  146. '有種再打同一張!這把我要胡到你哭!',
  147. '又是我放槍?這牌桌有毒吧!',
  148. ' 你家網路是撥接的喔?卡成這樣!',
  149. '老子回來了!看你急得跟什麼一樣!',
  150. ' 又胡!?這人是不是開外掛啦!',
  151. // '這咋又胡了呢,腦瓜子嗡一下子',
  152. );
  153. this.m_cbGameStatus = 0;
  154. this.m_bCanShowBigEnd = false;
  155. this.m_bEnd = false;
  156. this.m_bInit = false;
  157. this.m_bFirstCard = false;
  158. },
  159. //网络消息
  160. OnEventGameMessage: function (wSubCmdID, pData, wDataSize) {
  161. switch (wSubCmdID) {
  162. case GameDef.SUB_S_GAME_START: //游戏开始
  163. {
  164. return this.OnSubGameStart(pData, wDataSize);
  165. }
  166. case GameDef.SUB_S_OUT_CARD: //用户出牌
  167. {
  168. return this.OnSubOutCard(pData, wDataSize);
  169. }
  170. case GameDef.SUB_S_SEND_CARD: //发牌消息
  171. {
  172. return this.OnSubSendCard(pData, wDataSize);
  173. }
  174. case GameDef.SUB_S_OPERATE_NOTIFY: //操作提示
  175. {
  176. return this.OnSubOperateNotify(pData, wDataSize);
  177. }
  178. case GameDef.SUB_S_OPERATE_TIMER://别人有提示显示时间
  179. {
  180. return this.OnSubOperateTimer(pData, wDataSize);
  181. }
  182. case GameDef.SUB_S_OPERATE_RESULT: //操作结果
  183. {
  184. return this.OnSubOperateResult(pData, wDataSize);
  185. }
  186. case GameDef.SUB_S_GAME_END: //游戏结束
  187. {
  188. return this.OnSubGameEnd(pData, wDataSize);
  189. }
  190. case GameDef.SUB_S_TRUSTEE: //用户托管
  191. {
  192. return this.OnSubTrustee(pData, wDataSize);
  193. }
  194. case GameDef.SUB_S_LEAVE: //用户托管
  195. {
  196. return this.OnSubLeave(pData, wDataSize);
  197. }
  198. case GameDef.SUB_S_NEXT_READY: //下局准备
  199. {
  200. return this.OnSubNextReady(pData, wDataSize);
  201. }
  202. case GameDef.SUB_S_USER_DOUBLE: //用户加刚
  203. {
  204. return this.OnSubPlayerDouble(pData, wDataSize);
  205. }
  206. case GameDef.SUB_S_GAME_DOUBLE: //开始选刚
  207. {
  208. return this.OnSubStartDouble(pData, wDataSize);
  209. }
  210. case GameDef.SUB_S_UPDATE_CARD: //刷新
  211. {
  212. return this.OnUpdateCardData(pData, wDataSize);
  213. }
  214. case GameDef.SUB_S_TING:
  215. {
  216. return this.OnTing(pData, wDataSize);
  217. }
  218. case GameDef.SUB_S_REPLACE_CARD: //用户补牌
  219. {
  220. return this.OnSubReplaceCard(pData, wDataSize);
  221. }
  222. case GameDef.SUB_S_BANKER_CAN_OUT:
  223. {
  224. this.m_wCurrentUser = this.m_wBankerUser;
  225. this.m_bFirstCard = false;
  226. this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(true);
  227. }
  228. }
  229. return true;
  230. },
  231. //游戏场景
  232. OnEventSceneMessage: function (cbGameStatus, bLookonUser, pData, wDataSize) {
  233. if (GameDef.TMP_TEST) {
  234. this.__test();
  235. return true;
  236. }
  237. //this.m_GameClientView.m_BtFriend.active = (this.m_dwRoomID != 0 && this.m_wGameProgress == 0);
  238. this.m_cbGameStatus = cbGameStatus;
  239. switch (cbGameStatus) {
  240. case GameDef.GAME_SCENE_FREE: //空闲状态
  241. {
  242. var pStatusFree = GameDef.CMD_S_StatusFree();
  243. if (wDataSize != gCByte.Bytes2Str(pStatusFree, pData)) return false;
  244. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  245. if (this.GetClientUserItem(i) == null) continue;
  246. var OtherViewID = this.SwitchViewChairID(i);
  247. this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, pStatusFree.lSumGameScore[i])
  248. }
  249. return true;
  250. }
  251. case GameDef.GAME_SCENE_DOUBLE: //加倍状态
  252. {
  253. // function binaryData(ev) {
  254. // return JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(ev.data)))
  255. // }
  256. var pStatusFree = GameDef.CMD_S_StatusFree();
  257. if (wDataSize != gCByte.Bytes2Str(pStatusFree, pData)) return false;
  258. console.log("pStatusFree--", pStatusFree)
  259. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  260. this.m_GameClientView.SetTrustee(i, pStatusFree.bTrustee[i]);
  261. }
  262. var wMeChairID = this.GetMeChairID();
  263. this.m_bStustee = pStatusFree.bTrustee[wMeChairID];
  264. if (this.m_wGameProgress == 0) {
  265. var kernel = gClientKernel.get();
  266. if (this.m_dwCreater != 0 && this.m_dwCreater == kernel.mMeUserItem.GetUserID()) {
  267. this.m_BtExit.active = false;
  268. this.m_BtDissolve.active = true;
  269. }
  270. else {
  271. this.m_BtExit.active = true;
  272. this.m_BtDissolve.active = false;
  273. }
  274. }
  275. else {
  276. this.m_BtExit.active = false;
  277. this.m_BtDissolve.active = true;
  278. // 没开始不用计时
  279. if (this.m_bStustee) {
  280. this.checkTotalEnd(true);
  281. }
  282. // else
  283. // {
  284. // //计算时间
  285. // var wTimeCount=this.GetOperateTime() - pStatusFree.dwOperateTime;
  286. // this.SetGameClock(this.m_wCurrentUser,GameDef.IDI_OPERATE_CARD,wTimeCount);
  287. // }
  288. }
  289. //this.m_GameClientView.m_BtStart.active = !this.m_bStustee;
  290. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  291. // this.m_GameClientView.SetHuangZhuang(pStatusFree.wHuangZhuangCount);
  292. var kernel = gClientKernel.get();
  293. if (GameDef.GAME_SCENE_DOUBLE == cbGameStatus && !kernel.IsLookonMode()) {
  294. this.m_GameClientView.m_BtStart.active = false;
  295. var cbDoubleT = pStatusFree.cbDouble[this.GetMeChairID()];
  296. if (cbDoubleT == 0) {
  297. this.m_GameClientView.SetGangOperator(1);
  298. }
  299. else {
  300. //计算时间
  301. var wTimeCount = this.GetOperateTime() - pStatusFree.dwOperateTime;
  302. this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, wTimeCount);
  303. this.m_GameClientView.SetGangOperator(2);
  304. }
  305. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  306. var viewId = this.SwitchViewChairID(i);
  307. var cbDouble = pStatusFree.cbDouble[i];
  308. this.m_GameClientView.m_UserInfo[viewId].SetGang(cbDouble);
  309. }
  310. }
  311. return true;
  312. }
  313. case GameDef.GAME_SCENE_PLAY: //游戏状态
  314. {
  315. var BankViewID = this.SwitchViewChairID(0);
  316. this.m_GameClientView.m_BtFriend.active = false;
  317. //效验数据
  318. var pStatusPlay = GameDef.CMD_S_StatusPlay();
  319. pStatusPlay.weaveItem = this.m_WeaveItemArray;
  320. pStatusPlay.cbWeaveCount = this.m_cbWeaveCount;
  321. if (wDataSize != gCByte.Bytes2Str(pStatusPlay, pData)) return false;
  322. console.log("pStatusPlay--", pStatusPlay)
  323. var displayF = true;
  324. var displayC = true;
  325. if (GameDef.GAME_RULE_SP_16 & GameDef.m_dwGameRuleArr[0]) displayF = false;
  326. if (this.m_cbGameStatus & GameDef.GAME_SCENE_PLAY) displayC = false;
  327. this.m_wGameProgress = pStatusPlay.cbQuan + 1;
  328. this.m_GameClientView.UpdateRoomProgress();
  329. //风局
  330. this.m_GameClientView.Fengju(pStatusPlay.cbQuan, pStatusPlay.cbFeng, displayF);
  331. //骰子
  332. this.m_GameClientView.DiceNum(pStatusPlay.cbSick)
  333. //风位
  334. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  335. if (this.GetClientUserItem(i) == null) continue;
  336. var OtherViewID = this.SwitchViewChairID(i);
  337. this.m_GameClientView.m_UserInfo[OtherViewID].SetFeng(pStatusPlay.cbQuan, pStatusPlay.cbUserDNXB[i], displayF);
  338. }
  339. //花牌数据
  340. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  341. if (this.GetClientUserItem(i) == null) continue;
  342. var OtherViewID = this.SwitchViewChairID(i);
  343. this.m_GameClientView.m_UserInfo[OtherViewID].SetFlower(OtherViewID, pStatusPlay.cbFlowerCount[i], pStatusPlay.cbCardDataFlower[i], displayF, displayC);
  344. this.m_GameClientView.showGotFlowers(OtherViewID, displayC);
  345. }
  346. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  347. this.m_GameClientView.m_CardView.ResetView();
  348. //设置刚状态
  349. var wViewChairID = new Array();
  350. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  351. wViewChairID[i] = this.SwitchViewChairID(i);
  352. this.m_bListen[i] = pStatusPlay.bListen[i];
  353. // cbDouble= pStatusPlay.cbDouble[i];
  354. this.m_GameClientView.SetTrustee(i, pStatusPlay.bTrustee[i]);
  355. this.m_GameClientView.m_UserInfo[wViewChairID[i]].SetTing(this.m_bListen[i]);
  356. var cbDouble = pStatusPlay.cbDouble[i];
  357. this.m_GameClientView.m_UserInfo[wViewChairID[i]].SetGang(cbDouble);
  358. }
  359. var wMeChairID = this.GetMeChairID();
  360. this.m_bStustee = pStatusPlay.bTrustee[wMeChairID];
  361. //会牌
  362. this.m_GameClientView.m_CardView.SetMakeMagicIndex(pStatusPlay.cbMakeMagicIndex);
  363. //this.m_HuiCardDate = this.m_GameLogic.GetNextCardIndex( pStatusPlay.cbMakeMagicIndex);
  364. // this.m_GameClientView.m_CardView.SetMagicIndex(this.m_HuiCardDate);
  365. //this.m_HuiCardDate = this.m_GameLogic.SwitchToCardData(this.m_HuiCardDate);
  366. this.m_DingHuiCardDate = this.m_GameLogic.SwitchToCardData(pStatusPlay.cbMakeMagicIndex);
  367. //this.m_GameClientView.SetHuiPai(this.m_DingHuiCardDate,this.m_HuiCardDate);
  368. //GameDef.m_cbMagicData = this.m_HuiCardDate;
  369. this.m_wBankerUser = pStatusPlay.wBankerUser;
  370. this.m_wCurrentUser = pStatusPlay.wCurrentUser;
  371. this.m_cbLeftCardCount = pStatusPlay.cbLeftCardCount;
  372. // this.m_GameClientView.SetHuangZhuang(pStatusPlay.wHuangZhuangCount);
  373. //玩家变量
  374. //for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  375. //用户名字
  376. // var kernel = gClientKernel.get();
  377. // var pIClientUserItem = kernel.GetTableUserItem(i);
  378. // if (pIClientUserItem == null) continue;
  379. // this.m_GameClientView.SetScoreInfo(this.SwitchViewChairID(i), pIClientUserItem.GetUserScore() + pStatusPlay.lGangScore[i]);
  380. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  381. if (this.GetClientUserItem(i) == null) continue;
  382. var OtherViewID = this.SwitchViewChairID(i);
  383. this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, pStatusPlay.lSumGameScore[i])
  384. }
  385. this.m_GameClientView.SetLeftCardCount(this.m_cbLeftCardCount);
  386. this.m_GameLogic.SwitchToCardIndex3(pStatusPlay.cbCardData, pStatusPlay.cbCardCount, this.m_cbCardIndex);
  387. //界面设置
  388. this.m_GameClientView.SetCellScore(pStatusPlay.lCellScore);
  389. this.m_GameClientView.SetBankerUser(wViewChairID[this.m_wBankerUser]);
  390. //组合扑克
  391. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  392. // var wOperateViewID = this.SwitchViewChairID(i);
  393. for (var j = 0; j < this.m_cbWeaveCount[i]; j++) {
  394. this.m_GameClientView.m_CardView.SetWeaveData(wViewChairID[i], j, this.m_WeaveItemArray[i][j].cbCardData, this.m_WeaveItemArray[i][j].cbCardCount);
  395. this.m_GameClientView.m_CardView.SetWeaveState(wViewChairID[i], j, this.m_WeaveItemArray[i][j]);
  396. }
  397. }
  398. //用户扑克
  399. if (this.m_wCurrentUser == wMeChairID &&
  400. this.m_cbCardIndex[this.m_GameLogic.SwitchToCardIndex(pStatusPlay.cbSendCardData)] > 0) {
  401. this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, pStatusPlay.cbSendCardData, this.m_bListen[wMeChairID], pStatusPlay.cbCantOutCard);
  402. } else {
  403. this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, 0, this.m_bListen[wMeChairID], pStatusPlay.cbCantOutCard);
  404. }
  405. //扑克设置
  406. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  407. if (this.GetClientUserItem(i) == null) continue;
  408. //用户扑克
  409. var cbCardCount = GameDef.MAX_COUNT - this.m_cbWeaveCount[i] * 3 - 1;
  410. if (i != wMeChairID) {
  411. if (pStatusPlay.wCurrentUser == i) {
  412. cbCardCount++;
  413. }
  414. var wUserCardIndex = wViewChairID[i];
  415. this.m_GameClientView.m_CardView.SetCardData(wUserCardIndex, null, cbCardCount);
  416. }
  417. //丢弃扑克
  418. this.m_GameClientView.m_CardView.SetDiscardCardDate(wViewChairID[i], pStatusPlay.cbDiscardCard[i], pStatusPlay.cbDiscardCount[i]);
  419. }
  420. //丢弃效果
  421. if (pStatusPlay.wOutCardUser != INVALID_CHAIR) {
  422. this.m_GameClientView.m_CardView.AddDiscard(wViewChairID[pStatusPlay.wOutCardUser], pStatusPlay.cbOutCardData);
  423. this.m_GameClientView.m_CardView.SetDiscardTip(this.SwitchViewChairID(pStatusPlay.wOutCardUser));
  424. }
  425. //控制设置
  426. this.m_GameClientView.m_CardView.SetPositively(true);
  427. //操作界面
  428. if (pStatusPlay.wActionMask != GameDef.WIK_NULL) {
  429. //获取变量
  430. this.m_wActionMask = pStatusPlay.wActionMask;
  431. }
  432. this.m_GameClientView.SetCurrentUser(this.m_wCurrentUser);
  433. //设置时间
  434. if (this.m_wCurrentUser != INVALID_CHAIR) {
  435. //计算时间
  436. var wTimeCount = this.GetOperateTime() - pStatusPlay.dwOperateTime;
  437. //设置时间
  438. if (pStatusPlay.bLeave[this.m_wCurrentUser]) {
  439. this.m_GameClientView.SetUserTimer(this.SwitchViewChairID(this.m_wCurrentUser), 0);
  440. } else {
  441. this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, wTimeCount);
  442. }
  443. }
  444. this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(pStatusPlay.bCanOutCard);
  445. this.m_BtExit.active = false;
  446. this.m_BtDissolve.active = true;
  447. return true;
  448. // }
  449. }
  450. return false;
  451. }
  452. },
  453. SetGameClock: function (wChairID, nTimerID, nElapse) {
  454. this.m_GameClientView.SetUserTimer(wChairID, nElapse, 1);
  455. if (this.m_ReplayMode) return
  456. g_TimerEngine.SetGameTimer(wChairID, nTimerID, nElapse * 1000, null, this, 'OnTimerMessage');
  457. },
  458. //删除定时器
  459. KillGameClock: function (nTimerID) {
  460. this.m_GameClientView.SetUserTimer(INVALID_CHAIR, 0);
  461. g_TimerEngine.KillGameTimer();
  462. return true;
  463. },
  464. //时间消息
  465. OnTimerMessage: function (wChairID, CountDown, nTimerID, Progress) {
  466. var nElapse = parseInt(CountDown / 1000) + 1;
  467. if (CountDown == 0) nElapse = 0;
  468. this.m_GameClientView.SetUserTimer(wChairID, nElapse);
  469. return true;
  470. },
  471. StusteeOperateCard: function (wChairID) {
  472. if (this.m_bStustee == false) {
  473. this.ListenAutoOutCard(wChairID);
  474. return false;
  475. }
  476. // if (this.m_bStustee){
  477. // if(this.m_wActionMask & GameDef.WIK_CHI_HU){
  478. // this.OnCardOperate(GameDef.WIK_CHI_HU, 0);
  479. // return true;
  480. // }
  481. // }
  482. //获取位置
  483. var wMeChairID = this.GetMeChairID();
  484. //动作处理
  485. if (wChairID == wMeChairID) {
  486. // //玩家未听牌,且未托管,则累加超时次数
  487. // if( this.m_bStustee==false && ++this.m_wTimeOutCount>=3 )
  488. // {
  489. // this.m_wTimeOutCount = 0;
  490. // this.OnStusteeControl(0,TRUE);
  491. // }
  492. if (this.m_wCurrentUser == wMeChairID) {
  493. //获取扑克
  494. var wViewID = this.SwitchViewChairID(wChairID);
  495. var cbCardData = this.m_GameClientView.m_CardView.GetHandCurrentCard(wViewID);
  496. //出牌效验
  497. if (this.VerdictOutCard(cbCardData) == false) {
  498. for (var i = 0; i < 42; i++)//GameDef.MAX_INDEX
  499. {
  500. //出牌效验
  501. if (this.m_cbCardIndex[i] == 0) continue;
  502. if (this.VerdictOutCard(this.m_GameLogic.SwitchToCardData(i)) == false)
  503. continue;
  504. //设置变量
  505. cbCardData = this.m_GameLogic.SwitchToCardData(i);
  506. }
  507. }
  508. //出牌动作
  509. var sequence = cc.sequence(
  510. cc.callFunc(function () {
  511. // this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(false);
  512. if (this.m_wCurrentUser != wChairID) {
  513. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(false);
  514. return;
  515. }
  516. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true);
  517. }, this),
  518. cc.delayTime(1),
  519. cc.callFunc(function () {
  520. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetOutCard(cbCardData);
  521. // this.OnOutCard(0, 0, cbCardData);
  522. }, this
  523. ));
  524. this.node.runAction(sequence);
  525. } else {
  526. this.OnCardOperate(0, 0);
  527. if (this.m_cbGameStatus == GameDef.GAME_SCENE_PLAY) {
  528. //过
  529. var sequence = cc.sequence(
  530. cc.delayTime(1),
  531. cc.callFunc(function () {
  532. this.OnCardOperate(0, 0);
  533. }, this
  534. ));
  535. this.node.runAction(sequence);
  536. }
  537. else if (this.m_cbGameStatus == GameDef.GAME_SCENE_DOUBLE) {
  538. //不下
  539. this.OnDoubleOperate(1);
  540. this.m_GameClientView.SetGangOperator(2);
  541. }
  542. }
  543. }
  544. return true;
  545. },
  546. ListenAutoOutCard: function (wChairID) {
  547. if (this.m_bStustee == true) return; //托管不走这
  548. var wMeChairID = this.GetMeChairID();
  549. if (wMeChairID != wChairID) return;
  550. if (this.m_wCurrentUser != wMeChairID) return;
  551. if (this.m_bListen[wChairID] == false) return;
  552. //可以杠
  553. if (this.m_wActionMask & (GameDef.WIK_GANG | GameDef.WIK_CHI_HU)) {
  554. return;
  555. }
  556. //获取扑克
  557. var wViewID = this.SwitchViewChairID(wChairID);
  558. var cbCardData = this.m_GameClientView.m_CardView.GetHandCurrentCard(wViewID);
  559. //出牌效验
  560. if (this.VerdictOutCard(cbCardData) == false) {
  561. for (var i = 0; i < 42; i++)//GameDef.MAX_INDEX
  562. {
  563. //出牌效验
  564. if (this.m_cbCardIndex[i] == 0) continue;
  565. if (this.VerdictOutCard(this.m_GameLogic.SwitchToCardData(i)) == false)
  566. continue;
  567. //设置变量
  568. cbCardData = this.m_GameLogic.SwitchToCardData(i);
  569. }
  570. }
  571. //出牌动作
  572. var sequence = cc.sequence(
  573. cc.callFunc(function () {
  574. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(false);
  575. }, this),
  576. cc.delayTime(1),
  577. cc.callFunc(function () {
  578. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetOutCard(cbCardData);
  579. this.OnOutCard(0, 0, cbCardData);
  580. }, this
  581. ));
  582. this.node.runAction(sequence);
  583. },
  584. //出牌判断
  585. VerdictOutCard: function (cbCardData) {
  586. return this.m_GameLogic.IsValidCard(cbCardData);
  587. },
  588. //游戏开始
  589. OnSubGameStart: function (pBuffer, wDataSize) {
  590. this.m_pGameStart = GameDef.CMD_S_GameStart();
  591. //效验
  592. if (wDataSize != gCByte.Bytes2Str(this.m_pGameStart, pBuffer)) return false;
  593. this.CleanView();
  594. if (this.m_EndLittleView) {
  595. this.m_EndLittleView.HideView();
  596. }
  597. this.m_GameClientView.SetGangOperator(0);
  598. this.m_cbGameStatus = GameDef.GAME_SCENE_PLAY;
  599. var pGameStart = this.m_pGameStart;
  600. console.log("pGameStart--", pGameStart);
  601. this.m_GameClientView.m_BtFriend.active = false;
  602. this.m_wGameProgress = this.m_pGameStart.cbQuan + 1;
  603. this.m_GameClientView.UpdateRoomProgress();
  604. //郑骰子
  605. this.m_GameClientView.OnRollDice(this.m_pGameStart.cbSick);
  606. setTimeout(() => {
  607. this.starts();
  608. }, 1500);
  609. this.m_bEnd = false;
  610. return true;
  611. },
  612. starts: function () {
  613. var display = true;
  614. if (GameDef.m_dwGameRuleArr[0] & GameDef.GAME_RULE_SP_16) display = false;
  615. //骰子
  616. this.m_GameClientView.DiceNum(this.m_pGameStart.cbSick);
  617. //风局
  618. this.m_GameClientView.Fengju(this.m_pGameStart.cbQuan, this.m_pGameStart.cbFeng, display);
  619. //风位
  620. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  621. if (this.GetClientUserItem(i) == null) continue;
  622. var OtherViewID = this.SwitchViewChairID(i);
  623. this.m_GameClientView.m_UserInfo[OtherViewID].SetFeng(this.m_pGameStart.cbQuan, this.m_pGameStart.cbUserDNXB[i], display);
  624. }
  625. //初始花牌显示
  626. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  627. if (this.GetClientUserItem(i) == null) continue;
  628. var OtherViewID = this.SwitchViewChairID(i);
  629. this.m_GameClientView.m_UserInfo[OtherViewID].ClearFlower(display);
  630. }
  631. //会牌
  632. this.m_GameClientView.m_CardView.SetMakeMagicIndex(this.m_pGameStart.cbMakeMagicIndex);
  633. //this.m_HuiCardDate = this.m_GameLogic.GetNextCardIndex( pGameStart.cbMakeMagicIndex );
  634. // this.m_GameClientView.m_CardView.SetMagicIndex(this.m_HuiCardDate);
  635. if (!this.m_bRollBack)
  636. this.m_GameClientView.SetMakeMagicIndex(this.m_pGameStart.cbMakeMagicIndex);
  637. //this.m_HuiCardDate = this.m_GameLogic.SwitchToCardData(this.m_HuiCardDate);
  638. // GameDef.m_cbMagicData = this.m_HuiCardDate;
  639. var BankViewID = this.SwitchViewChairID(this.m_pGameStart.wBankerUser);
  640. this.m_GameClientView.m_CardView.SetPositively(false);
  641. var wMeChairID = this.GetMeChairID();
  642. this.m_bStustee = this.m_pGameStart.bTrustee[wMeChairID];
  643. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  644. if (this.GetClientUserItem(i) == null) continue;
  645. var viewId = this.SwitchViewChairID(i);
  646. this.m_GameClientView.m_UserInfo[viewId].SetTing(false);
  647. var cbDouble = this.m_pGameStart.cbDouble[i];
  648. this.m_GameClientView.m_UserInfo[viewId].SetGang(cbDouble);
  649. this.m_GameClientView.SetTrustee(i, this.m_pGameStart.bTrustee[i]);
  650. }
  651. // this.m_GameClientView.SetHuangZhuang(pGameStart.wHuangZhuangCount);
  652. if (!this.m_bRollBack)
  653. cc.gSoundRes.PlayGameSound("GAME_START");
  654. //保存数据
  655. this.m_wBankerUser = this.m_pGameStart.wBankerUser;
  656. this.m_wCurrentUser = this.m_pGameStart.wCurrentUser;
  657. this.m_cbLeftCardCount = this.m_pGameStart.cbLastCardCount;
  658. this.m_wActionMask = this.m_pGameStart.wUserAction;
  659. this.m_GameClientView.SetLeftCardCount(this.m_cbLeftCardCount);
  660. //设置扑克
  661. var cbCardCount = (wMeChairID == this.m_wBankerUser) ? GameDef.MAX_COUNT : (GameDef.MAX_COUNT - 1);
  662. this.m_GameLogic.SwitchToCardIndex3(this.m_pGameStart.cbCardData, cbCardCount, this.m_cbCardIndex);
  663. //设置界面
  664. this.m_GameClientView.SetBankerUser(this.SwitchViewChairID(this.m_wBankerUser));
  665. this.m_GameClientView.m_CardView.SetPositively(true);
  666. this.m_GameClientView.m_BtStart.active = false;
  667. this.m_BtExit.active = false;
  668. this.m_BtDissolve.active = true;
  669. //扑克设置
  670. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  671. //听
  672. this.m_bListen[i] = false;
  673. //变量定义
  674. var wViewChairID = this.SwitchViewChairID(i);
  675. if (this.m_GameClientView.m_pIClientUserItem[wViewChairID] == null) continue;
  676. //用户扑克
  677. if (wViewChairID != GameDef.MYSELF_VIEW_ID) {
  678. this.m_GameClientView.m_CardView.SetCardData(wViewChairID, null, GameDef.MAX_COUNT - 1, null);
  679. } else {
  680. var cbCardData = new Array();
  681. this.m_GameLogic.SwitchToCardData2(this.m_cbCardIndex, cbCardData);
  682. var cbBankerCard = (i == this.m_wBankerUser ? cbCardData[GameDef.MAX_COUNT - 1] : null);
  683. this.m_GameClientView.m_CardView.SetSelfCardData(cbCardData, GameDef.MAX_COUNT - 1, cbBankerCard);
  684. }
  685. this.m_GameClientView.m_CardView.m_HandCard[wViewChairID].SetCanTouch(false);
  686. }
  687. //出牌提示
  688. // if (this.m_wCurrentUser != INVALID_CHAIR) {
  689. // this.m_GameClientView.SetCurrentUser(this.m_wCurrentUser);
  690. // this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  691. // }
  692. },
  693. //补
  694. OnSubReplaceCard: function (pData, wDataSize) {
  695. var pSendCard = GameDef.CMD_S_ReplaceCard();
  696. //效验
  697. if (wDataSize != gCByte.Bytes2Str(pSendCard, pData)) return false;
  698. var wCurrentUser = pSendCard.wReplaceUser;
  699. console.log("补OnSubReplaceCard--", pSendCard)
  700. var displayF = true;
  701. var displayC = true;
  702. if (GameDef.m_dwGameRuleArr[0] & GameDef.GAME_RULE_SP_16) displayF = false;
  703. // if(this.m_cbGameStatus & GameDef.GAME_SCENE_PLAY)displayC = true;
  704. if (this.GetClientUserItem(wCurrentUser) != null) {
  705. var OtherViewID = this.SwitchViewChairID(wCurrentUser);
  706. this.PlayActionSound(wCurrentUser, "BUHUA");
  707. this.m_GameClientView.m_UserInfo[OtherViewID].SetFlower(OtherViewID, pSendCard.cbFlowerCount[wCurrentUser], pSendCard.cbCardDataFlower[wCurrentUser], displayF, displayC);
  708. this.m_GameClientView.showGotFlowers(OtherViewID, displayC);
  709. }
  710. return true;
  711. },
  712. //发牌
  713. OnSubSendCard: function (pData, wDataSize) {
  714. var pSendCard = GameDef.CMD_S_SendCard();
  715. //效验
  716. if (wDataSize != gCByte.Bytes2Str(pSendCard, pData)) return false;
  717. console.log("发牌--", pSendCard, pSendCard.wActionMask)
  718. //清空听牌提示
  719. this.m_GameClientView.m_CardView.ShowTingData();
  720. this.m_GameClientView.m_CardView.ShowTingTip(0);
  721. this.m_bFirstCard = pSendCard.bFirstCard;
  722. var wMeChairID = this.GetMeChairID();
  723. var wViewChairID = this.SwitchViewChairID(pSendCard.wSendCardUser);
  724. var wChairId = pSendCard.wSendCardUser;
  725. var cbSendCardData = pSendCard.cbCardData;
  726. this.m_wCurrentUser = pSendCard.wCurrentUser;
  727. this.m_cbLeftCardCount = pSendCard.cbLeftCardCount;
  728. this.m_GameClientView.SetLeftCardCount(this.m_cbLeftCardCount);
  729. //取牌界面
  730. if (wViewChairID != GameDef.MYSELF_VIEW_ID) {
  731. if (this.m_ReplayMode) {
  732. this.m_GameClientView.m_CardView.SetCurrentCard(wViewChairID, cbSendCardData, this.m_bListen[wChairId]);
  733. } else {
  734. this.m_GameClientView.m_CardView.SetCurrentCard(wViewChairID, 0, this.m_bListen[wChairId]);
  735. }
  736. } else {
  737. this.m_GameClientView.m_CardView.SetCurrentCard(wViewChairID, cbSendCardData, this.m_bListen[wChairId]);
  738. //插入扑克
  739. this.m_cbCardIndex[this.m_GameLogic.SwitchToCardIndex(cbSendCardData)]++;
  740. }
  741. //当前用户
  742. if (this.m_wCurrentUser == wMeChairID) {
  743. this.m_wActionMask = pSendCard.wActionMask;
  744. this.StusteeOperateCard(this.m_wCurrentUser);
  745. var wViewID = this.SwitchViewChairID(wMeChairID);
  746. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(pSendCard.bCanOut);
  747. }
  748. this.m_GameClientView.SetCurrentUser(this.m_wCurrentUser);
  749. this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  750. cc.gSoundRes.PlayGameSound("SEND_CARD");
  751. console.log("cbSendCardData--", cbSendCardData)
  752. if (this.m_wCurrentUser == wMeChairID && cbSendCardData > 55) {
  753. // this.OnReplaceCard(cbSendCardData)
  754. }
  755. return true;
  756. },
  757. //出牌
  758. OnSubOutCard: function (pData, wDataSize) {
  759. // 创建一个CMD_S_OutCard对象,用于存储出牌信息
  760. var pOutCard = GameDef.CMD_S_OutCard();
  761. // 效验数据大小是否与出牌数据结构一致,不一致则返回false
  762. if (wDataSize != gCByte.Bytes2Str(pOutCard, pData)) return false;
  763. this.m_GameClientView.m_CardView.SetControlInfo(false);//关闭操作面板?
  764. // 将出牌用户的椅子ID转换为视角ID
  765. var wOutUserViewId = this.SwitchViewChairID(pOutCard.wOutCardUser);
  766. // 更新出牌数据
  767. this.m_cbOutCardData = pOutCard.cbOutCardData;
  768. // 清空听牌提示
  769. this.m_GameClientView.m_CardView.ShowTingData();
  770. // 隐藏听牌提示标志
  771. this.m_GameClientView.m_CardView.ShowTingTip(0);
  772. // 删除游戏计时器
  773. this.KillGameClock();
  774. // 播放出牌动作声音
  775. this.PlayActionSound(pOutCard.wOutCardUser, this.GetCardStr(this.m_cbOutCardData));
  776. // 设置扑克
  777. if (wOutUserViewId == GameDef.MYSELF_VIEW_ID) {
  778. // 从玩家的手牌中移除出的牌,失败则返回false
  779. if (!this.m_GameLogic.RemoveCard2(this.m_cbCardIndex, this.m_cbOutCardData)) return false;
  780. // 创建一个新的数组来存储手牌数据
  781. var cbHandCardData = new Array();
  782. // 获取更新后手牌的数量
  783. var cbCardCount = this.m_GameLogic.SwitchToCardData2(this.m_cbCardIndex, cbHandCardData);
  784. // 获取客户端内核实例
  785. var kernel = gClientKernel.get();
  786. // 如果是回放模式
  787. if (this.m_ReplayMode) {
  788. // 在回放中添加出的牌到弃牌堆
  789. this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true);
  790. // 更新手牌显示
  791. this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount);
  792. } else if (kernel.IsLookonMode()) {
  793. // 找到出牌在手牌中的索引位置
  794. var CardCtrl = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId];
  795. var OutIndex = 0;
  796. for (var i = 0; i < CardCtrl.m_CardItemArray.length; i++) {
  797. if (CardCtrl.m_CardItemArray[i].node.active == true && this.m_cbOutCardData == CardCtrl.m_CardItemArray[i].GetCardData()) {
  798. OutIndex = i;
  799. break;
  800. }
  801. }
  802. // 使用requestAnimationFrame来播放出牌动画
  803. requestAnimationFrame(() => {
  804. this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount);
  805. });
  806. } else {
  807. // 获取玩家选择的手牌数据和索引
  808. var selCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardData();
  809. var OutIndex = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardIndex();
  810. selCardData = this.m_cbOutCardData
  811. if (selCardData == 0 || this.m_bStustee == true) {
  812. selCardData = this.m_cbOutCardData
  813. this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].SetOutCard(this.m_cbOutCardData)
  814. }
  815. //如果选择的牌与出的牌相同,则播放出牌动画
  816. if (selCardData == this.m_cbOutCardData) {
  817. requestAnimationFrame(() => {
  818. this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount);
  819. });
  820. }
  821. // if (this.m_bStustee == true) {
  822. // if (selCardData == 0) {
  823. // selCardData = this.m_cbOutCardData
  824. // this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].SetOutCard(this.m_cbOutCardData)
  825. // }
  826. // requestAnimationFrame(() => {
  827. // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount);
  828. // });
  829. // } else {
  830. // //如果选择的牌与出的牌相同,则播放出牌动画
  831. // if (selCardData == this.m_cbOutCardData) {
  832. // requestAnimationFrame(() => {
  833. // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount);
  834. // });
  835. // }
  836. // }
  837. }
  838. } else {
  839. if (this.m_ReplayMode) {
  840. // 获取对手的手牌数据和数量
  841. var cbHandCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_cbCardData;
  842. var cbCardCount = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_wCardCount;
  843. // 创建一个数组来存储移除的牌
  844. var cbRemoveCard = new Array();
  845. cbRemoveCard[0] = this.m_cbOutCardData;
  846. // 从对手的手牌中移除出的牌,失败则返回false
  847. if (!this.m_GameLogic.RemoveCard4(cbHandCardData, cbCardCount, cbRemoveCard, 1)) {
  848. return false;
  849. }
  850. // 对手手牌重新排序
  851. this.m_GameLogic.SortCardList(cbHandCardData, cbCardCount - 1);
  852. // 更新对手手牌显示
  853. this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount - 1);
  854. // 在回放中添加出的牌到弃牌堆
  855. this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true);
  856. } else {
  857. // 设置当前玩家的出牌状态
  858. this.m_GameClientView.m_CardView.SetCurrentCard(wOutUserViewId, null, this.m_bListen[pOutCard.wOutCardUser]);
  859. // 播放对手出牌动画
  860. requestAnimationFrame(() => {
  861. this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData);
  862. });
  863. }
  864. }
  865. // 如果出牌用户不是当前玩家
  866. if (pOutCard.wOutCardUser != this.GetMeChairID()) {
  867. // 设置当前操作用户为无效
  868. this.m_wCurrentUser = INVALID_CHAIR;
  869. // 清空操作掩码
  870. this.m_wActionMask = 0;
  871. // 设置界面显示的当前操作用户为无效
  872. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  873. // 设置用户操作界面为无效
  874. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  875. }
  876. // 出牌处理完成,返回true
  877. return true;
  878. },
  879. // //出牌
  880. // OnSubOutCard: function (pData, wDataSize) {
  881. // var pOutCard = GameDef.CMD_S_OutCard();
  882. // //效验
  883. // if (wDataSize != gCByte.Bytes2Str(pOutCard, pData)) return false;
  884. // var wOutUserViewId = this.SwitchViewChairID(pOutCard.wOutCardUser);
  885. // this.m_cbOutCardData = pOutCard.cbOutCardData;
  886. // //清空听牌提示
  887. // this.m_GameClientView.m_CardView.ShowTingData();
  888. // this.m_GameClientView.m_CardView.ShowTingTip(0);
  889. // //删除定时器
  890. // this.KillGameClock();
  891. // //播放声音
  892. // this.PlayActionSound(pOutCard.wOutCardUser, this.GetCardStr(this.m_cbOutCardData));
  893. // //设置扑克
  894. // if (wOutUserViewId == GameDef.MYSELF_VIEW_ID) {
  895. // //删除扑克
  896. // if (!this.m_GameLogic.RemoveCard2(this.m_cbCardIndex, this.m_cbOutCardData)) return false;
  897. // var cbHandCardData = new Array();//[GameDef.MAX_COUNT];
  898. // var cbCardCount = this.m_GameLogic.SwitchToCardData2(this.m_cbCardIndex, cbHandCardData);
  899. // var kernel = gClientKernel.get();
  900. // if (this.m_ReplayMode) {
  901. // this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true);
  902. // this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount);
  903. // }
  904. // else if (kernel.IsLookonMode()) {
  905. // var CardCtrl = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId];
  906. // var OutIndex = 0;
  907. // for (var i = 0; i < CardCtrl.m_CardItemArray.length; i++) {
  908. // if (CardCtrl.m_CardItemArray[i].node.active == true && this.m_cbOutCardData == CardCtrl.m_CardItemArray[i].GetCardData()) {
  909. // OutIndex = i;
  910. // break;
  911. // }
  912. // }
  913. // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount);
  914. // }
  915. // else {
  916. // var selCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardData();
  917. // var OutIndex = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardIndex();
  918. // if (selCardData == this.m_cbOutCardData) {
  919. // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount);
  920. // }
  921. // }
  922. // } else {
  923. // if (this.m_ReplayMode) {
  924. // var cbHandCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_cbCardData;//[GameDef.MAX_COUNT];
  925. // var cbCardCount = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_wCardCount;
  926. // var cbRemoveCard = new Array();
  927. // cbRemoveCard[0] = this.m_cbOutCardData;
  928. // //删除扑克
  929. // if (!this.m_GameLogic.RemoveCard4(cbHandCardData, cbCardCount, cbRemoveCard, 1)) {
  930. // return false;
  931. // }
  932. // this.m_GameLogic.SortCardList(cbHandCardData, cbCardCount - 1);
  933. // this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount - 1);
  934. // this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true);
  935. // } else {
  936. // this.m_GameClientView.m_CardView.SetCurrentCard(wOutUserViewId, null, this.m_bListen[pOutCard.wOutCardUser]);
  937. // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData);
  938. // }
  939. // }
  940. // if (pOutCard.wOutCardUser != this.GetMeChairID()) {
  941. // //设置变量
  942. // this.m_wCurrentUser = INVALID_CHAIR;
  943. // this.m_wActionMask = 0;
  944. // //设置界面
  945. // this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  946. // this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  947. // }
  948. // return true;
  949. // },
  950. huAuto: function(){
  951. var OperateCard = GameDef.CMD_C_OperateCard();
  952. OperateCard.wOperateCode = GameDef.WIK_CHI_HU;
  953. this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard);
  954. },
  955. //操作提示
  956. OnSubOperateNotify: function (pData, wDataSize) {
  957. var pOperateNotify = GameDef.CMD_S_OperateNotify();
  958. var size = gCByte.Bytes2Str(pOperateNotify, pData);
  959. var pObj = new Object()
  960. pObj.pItem = new Array(pOperateNotify.wCount);
  961. for (var i = 0; i < pOperateNotify.wCount; i++) {
  962. pObj.pItem[i] = GameDef.CMD_WeaveItem();
  963. }
  964. //效验
  965. if (wDataSize != gCByte.Bytes2Str(pObj, pData, size) + size) return false;
  966. //回放、观战不显示选飘界面
  967. var kernel = gClientKernel.get();
  968. if (this.m_ReplayMode || kernel.IsLookonMode()) return true;
  969. console.log("操作提示--", pOperateNotify, pObj)
  970. //用户界面
  971. if (pOperateNotify.wActionMask != GameDef.WIK_NULL) {
  972. if (pOperateNotify.wActionMask & GameDef.WIK_CHI_HU) {
  973. console.log("操作提示-胡")
  974. this.scheduleOnce(() => {
  975. this.huAuto();
  976. // var OperateCard = GameDef.CMD_C_OperateCard();
  977. // OperateCard.wOperateCode = GameDef.WIK_CHI_HU;
  978. // OperateCard.cbOperateCard[0] = pOperateNotify.cbActionCard;
  979. // OperateCard.cbOperateCount = 1;
  980. // OperateCard.cbIndex = 0;
  981. // this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard);
  982. }, 0.3);
  983. }
  984. // if (pOperateNotify.wActionMask & GameDef.WIK_GANG) {
  985. // console.log("操作提示-杠")
  986. // }
  987. // if (pOperateNotify.wActionMask & GameDef.WIK_PENG) {
  988. // console.log("操作提示-碰")
  989. // }
  990. // if (pOperateNotify.wActionMask & GameDef.WIK_LEFT) {
  991. // console.log("操作提示-左吃")
  992. // }
  993. // if (pOperateNotify.wActionMask & GameDef.WIK_CENTER) {
  994. // console.log("操作提示-中吃")
  995. // }
  996. // if (pOperateNotify.wActionMask & GameDef.WIK_RIGHT) {
  997. // console.log("操作提示-右吃")
  998. // }
  999. //this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(false);
  1000. //获取变量
  1001. var wMeChairID = this.GetMeChairID();
  1002. this.m_wActionMask = pOperateNotify.wActionMask;
  1003. //设置界面
  1004. cc.error("OnSubOperateNotify ", pObj.pItem);
  1005. this.m_GameClientView.m_CardView.SetControlInfo(true, pObj.pItem, pObj.pItem.length);
  1006. //设置时间
  1007. this.m_GameClientView.SetCurrentUser(pOperateNotify.wResumeUser);
  1008. this.SetGameClock(wMeChairID, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1009. this.StusteeOperateCard(wMeChairID);
  1010. }
  1011. return true;
  1012. },
  1013. OnSubOperateTimer: function (pData, wDataSize) {
  1014. this.SetGameClock(INVALID_CHAIR, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1015. return true;
  1016. },
  1017. //操作提示
  1018. OnSubOperateResult: function (pData, wDataSize) {
  1019. var pOperateResult = GameDef.CMD_S_OperateResult();
  1020. //效验
  1021. if (wDataSize != gCByte.Bytes2Str(pOperateResult, pData)) return false;
  1022. console.log("pOperateResult--", pOperateResult)
  1023. var wOperateViewID = this.SwitchViewChairID(pOperateResult.wOperateUser);
  1024. if (pOperateResult.wOperateUser != pOperateResult.wProvideUser && pOperateResult.bQiangGang == false) {
  1025. var PrivideViewID = this.SwitchViewChairID(pOperateResult.wProvideUser);
  1026. this.m_GameClientView.m_CardView.StopDiscard(PrivideViewID, pOperateResult.cbCenterCard);
  1027. }
  1028. var wOperateUser = pOperateResult.wOperateUser;
  1029. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1030. this.m_GameClientView.SetUserAction(wOperateViewID, pOperateResult.wOperateCode);
  1031. //环境设置
  1032. if (pOperateResult.wOperateCode & (GameDef.WIK_GANG)) {
  1033. this.PlayActionSound(wOperateUser, "GANG");
  1034. // if (pOperateResult.dwGangScore > 0) {
  1035. // if (pOperateResult.wProvideUser == wOperateUser) {
  1036. // //暗杠,补杠
  1037. // var AddScore = 0;
  1038. // for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1039. // if (this.GetClientUserItem(i) == null) continue;
  1040. // if (i == wOperateUser) continue;
  1041. // var OtherViewID = this.SwitchViewChairID(i);
  1042. // this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, -pOperateResult.dwGangScore);// -
  1043. // AddScore += pOperateResult.dwGangScore;
  1044. // }
  1045. // // this.m_GameClientView.m_UserInfo[wOperateViewID].SetScore(OtherViewID, AddScore);//+ AddScore
  1046. // }
  1047. // else {
  1048. // //叉杠
  1049. // var PrivideViewID = this.SwitchViewChairID(pOperateResult.wProvideUser);
  1050. // this.m_GameClientView.m_UserInfo[PrivideViewID].SetScore(PrivideViewID, -pOperateResult.dwGangScore);;//-
  1051. // this.m_GameClientView.m_UserInfo[wOperateViewID].SetScore(wOperateViewID, pOperateResult.dwGangScore);;//+
  1052. // }
  1053. // }
  1054. }
  1055. else if (pOperateResult.wOperateCode & (GameDef.WIK_LEFT | GameDef.WIK_CENTER | GameDef.WIK_RIGHT))
  1056. this.PlayActionSound(wOperateUser, "CHI");
  1057. else if (pOperateResult.wOperateCode & GameDef.WIK_PENG)
  1058. this.PlayActionSound(wOperateUser, "PENG");
  1059. else if (pOperateResult.wOperateCode & GameDef.WIK_CHI_HU)
  1060. this.PlayActionSound(wOperateUser, "HU");
  1061. else if (pOperateResult.wOperateCode & GameDef.WIK_LISTEN) {
  1062. this.PlayActionSound(wOperateUser, "TING");
  1063. this.m_bListen[wOperateUser] = true;
  1064. var viewID = this.SwitchViewChairID(wOperateUser);
  1065. this.m_GameClientView.m_UserInfo[viewID].SetTing(true);
  1066. }
  1067. else if (pOperateResult.wOperateCode & GameDef.WIK_GANG_FENG) {
  1068. this.PlayActionSound(wOperateUser, "FENG");
  1069. }
  1070. else if (pOperateResult.wOperateCode & GameDef.WIK_DNJ) {
  1071. this.PlayActionSound(wOperateUser, "DNJ");
  1072. }
  1073. else if (pOperateResult.wOperateCode & GameDef.WIK_CAI_ZFB) {
  1074. this.PlayActionSound(wOperateUser, "ZFB");
  1075. }
  1076. //设置时间
  1077. if (pOperateResult.bBeiQiangGang) {
  1078. this.m_wCurrentUser = INVALID_CHAIR;
  1079. }
  1080. else {
  1081. this.m_wCurrentUser = wOperateUser;
  1082. }
  1083. var wMeChairID = this.GetMeChairID();
  1084. if (wOperateUser == wMeChairID) {
  1085. var wViewID = this.SwitchViewChairID(wMeChairID);
  1086. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true);
  1087. }
  1088. this.m_GameClientView.SetCurrentUser(wOperateUser);
  1089. this.SetGameClock(wOperateUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1090. return true;
  1091. },
  1092. OnSubGameEnd: function (pData, wDataSize) {
  1093. this.m_GameEnd = GameDef.CMD_S_GameEnd();
  1094. if (wDataSize != gCByte.Bytes2Str(this.m_GameEnd, pData)) return false;
  1095. GameDef.cbLianZhuangCount = this.m_GameEnd.cbLianZhuangCount;
  1096. console.log("連莊cbLianZhuangCount", GameDef.cbLianZhuangCount);
  1097. this.m_cbGameStatus = GameDef.GAME_SCENE_FREE;
  1098. console.log("this.m_GameEnd--", this.m_GameEnd);
  1099. this.m_bCanShowBigEnd = false;
  1100. //清空听牌提示
  1101. this.m_GameClientView.m_CardView.ShowTingData();
  1102. this.m_GameClientView.m_CardView.ShowTingTip(0);
  1103. //删除定时器
  1104. this.KillGameClock();
  1105. GameDef.dwChiHuRightAdd = this.m_GameEnd.dwChiHuRightAdd;
  1106. this.m_wGameProgress = this.m_GameEnd.cbQuan + 1;
  1107. // this.m_GameClientView.UpdateRoomProgress();
  1108. this.MyChairID = this.GetMeChairID()
  1109. let isZimo = false;
  1110. //赢家
  1111. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1112. if (this.GetClientUserItem(i) == null) continue;
  1113. if (this.m_GameEnd.dwChiHuKind[i] == GameDef.WIK_CHI_HU) {
  1114. var viewID = this.SwitchViewChairID(i);
  1115. if (this.m_GameEnd.dwChiHuRight[i] & GameDef.CHR_ZI_MO) {
  1116. //自摸
  1117. this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_CHI_HU, GameDef.CHR_ZI_MO);
  1118. isZimo = true;
  1119. } else {
  1120. //胡牌
  1121. this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_CHI_HU);
  1122. }
  1123. }
  1124. }
  1125. //输家
  1126. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1127. if (this.m_GameEnd.lGameScore[i] >= 0) {
  1128. continue;
  1129. }
  1130. if (this.GetClientUserItem(i) == null) continue;
  1131. var viewID = this.SwitchViewChairID(i);
  1132. this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_FANG_PAO, isZimo ? GameDef.CHR_ZI_MO : 0);
  1133. }
  1134. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1135. if (this.GetClientUserItem(i) == null) continue;
  1136. var OtherViewID = this.SwitchViewChairID(i);
  1137. if (GameDef.m_dwGameRuleArr[3] > 0) {
  1138. this.m_GameClientView.m_UserInfo[OtherViewID].updateEndDimond(OtherViewID, this.m_GameEnd.lGangScore[i])
  1139. }else{
  1140. this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, this.m_GameEnd.lSumGameScore[i])
  1141. }
  1142. }
  1143. //设置控件
  1144. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1145. this.m_GameClientView.m_CardView.SetPositively(false);
  1146. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1147. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1148. if (this.GetClientUserItem(i) == null) continue;
  1149. for (var j = 0; j < this.m_GameEnd.cbWeaveCount[i]; ++j) {
  1150. var cbCenterCard = this.m_GameEnd.weaveItem[i][j].cbCenterCard;
  1151. var wWeaveKind = this.m_GameEnd.weaveItem[i][j].wWeaveKind;
  1152. var cbCardData = this.m_GameEnd.weaveItem[i][j].cbCardData;
  1153. var cbWeaveCardCount = this.m_GameEnd.weaveItem[i][j].cbCardCount;
  1154. var cbPublicCard = this.m_GameEnd.weaveItem[i][j].cbPublicCard;
  1155. var viewID = this.SwitchViewChairID(i);
  1156. this.m_GameClientView.m_CardView.SetWeaveData(viewID, j, cbCardData, cbWeaveCardCount, cbPublicCard);
  1157. this.m_GameClientView.m_CardView.SetWeaveState(viewID, j, this.m_GameEnd.weaveItem[i][j]);
  1158. if (cbWeaveCardCount == 4 && !cbPublicCard) {
  1159. this.m_GameClientView.m_CardView.SetWeaveState(viewID, j, GameDef.GAME_THREE_BACK_SELF);
  1160. }
  1161. }
  1162. }
  1163. //设置扑克
  1164. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1165. if (this.GetClientUserItem(i) == null) continue;
  1166. var cbCardData = this.m_GameEnd.cbCardData;
  1167. var wCardCount = this.m_GameEnd.cbCardCount[i];
  1168. var viewID = this.SwitchViewChairID(i);
  1169. if ((wCardCount + 1) % 3 == 0) {
  1170. var tmpCardData = new Array();
  1171. for (var j = 0; j < wCardCount; j++) {
  1172. tmpCardData[j] = cbCardData[i][j];
  1173. }
  1174. var cbRemoveCard = new Array();
  1175. if (this.m_GameEnd.cbProvideCard != 0) {
  1176. cbRemoveCard[0] = this.m_GameEnd.cbProvideCard;
  1177. } else {
  1178. cbRemoveCard[0] = tmpCardData[wCardCount - 1];
  1179. }
  1180. if (this.m_GameEnd.cbLastCardData[i]) {
  1181. cbRemoveCard[0] = this.m_GameEnd.cbLastCardData[i];
  1182. }
  1183. if (this.m_GameLogic.RemoveCard4(tmpCardData, wCardCount, cbRemoveCard, 1)) {
  1184. this.m_GameClientView.m_CardView.SetCardData(viewID, tmpCardData, wCardCount - 1);
  1185. this.m_GameClientView.m_CardView.SetCurrentCard(viewID, cbRemoveCard[0]);
  1186. }
  1187. } else {
  1188. this.m_GameClientView.m_CardView.SetCardData(viewID, cbCardData[i], wCardCount);
  1189. }
  1190. this.m_GameClientView.m_CardView.SetCardItemState(viewID, GameDef.HAND_STATE_SHOW);
  1191. }
  1192. //播放声音
  1193. if (this.m_GameEnd.wProvideUser != INVALID_CHAIR) {
  1194. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1195. if (this.m_GameEnd.dwChiHuKind[i] != GameDef.WIK_NULL) {
  1196. if (this.m_GameEnd.dwChiHuRight[i] & GameDef.CHR_ZI_MO) {
  1197. this.PlayActionSound(i, "ZIMO");
  1198. }
  1199. else {
  1200. this.PlayActionSound(i, "HU");
  1201. }
  1202. }
  1203. }
  1204. } else {
  1205. cc.gSoundRes.PlayGameSound("GAME_END");
  1206. }
  1207. var WaitTime = 3;
  1208. // if(this.m_GameEnd.cbBirdCardCount > 0)
  1209. // {
  1210. // this.m_GameClientView.ShowBird(this.m_GameEnd.cbBirdCard, this.m_GameEnd.cbBirdCardCount);
  1211. // WaitTime = 4;
  1212. // }
  1213. //设置定时
  1214. this.schedule(this.OnTimeIDI_PERFORM_END, WaitTime);
  1215. // this.OnTimeIDI_PERFORM_END();
  1216. return true;
  1217. },
  1218. //用户托管
  1219. OnSubTrustee: function (pData, wDataSize) {
  1220. var pTrustee = GameDef.CMD_S_Trustee();
  1221. if (wDataSize != gCByte.Bytes2Str(pTrustee, pData)) return false;
  1222. this.m_GameClientView.SetTrustee(pTrustee.wChairID, pTrustee.bTrustee);
  1223. var wMeChairID = this.GetMeChairID();
  1224. if (wMeChairID == pTrustee.wChairID) {
  1225. this.m_bStustee = pTrustee.bTrustee;
  1226. if (pTrustee.bTrustee) {
  1227. if (this.m_bEnd) {
  1228. if (this.m_EndLittleView) {
  1229. this.m_EndLittleView.HideView();
  1230. }
  1231. this.checkTotalEnd(true);
  1232. }
  1233. else {
  1234. this.StusteeOperateCard(pTrustee.wChairID);
  1235. }
  1236. }
  1237. }
  1238. console.log("是否托管---", this.m_bStustee)
  1239. return true;
  1240. },
  1241. OnSubLeave: function (pData, wDataSize) {
  1242. var pLeave = GameDef.CMD_S_Leave();
  1243. if (wDataSize != gCByte.Bytes2Str(pLeave, pData)) return false;
  1244. this.m_GameClientView.SetUserTimer(this.SwitchViewChairID(this.m_wCurrentUser), 0);
  1245. // for(var i = 0; i < GameDef.GAME_PLAYER; ++ i)
  1246. // this.m_GameClientView.SetLeave(this.SwitchViewChairID(i), pLeave.bLeave[i]);
  1247. return true;
  1248. },
  1249. OnSubPlayerDouble: function (pData, wDataSize) {
  1250. var pDouble = GameDef.CMD_S_Double();
  1251. if (wDataSize != gCByte.Bytes2Str(pDouble, pData)) return false;
  1252. var viewID = this.SwitchViewChairID(pDouble.wCallUser);
  1253. this.m_GameClientView.m_UserInfo[viewID].SetGang(pDouble.cbDouble);
  1254. return true;
  1255. },
  1256. UpdateHandActionCard: function () {
  1257. },
  1258. OnTing: function (pData, wDataSize) {
  1259. var pTing = new Object();
  1260. pTing.wCount = 0;
  1261. var size = gCByte.Bytes2Str(pTing, pData);
  1262. var pObj = new Object()
  1263. pObj.pItem = new Array(pTing.wCount);
  1264. for (var i = 0; i < pTing.wCount; i++) {
  1265. pObj.pItem[i] = GameDef.CMD_TingTip();
  1266. }
  1267. console.log("听--", pObj)
  1268. //效验
  1269. if (wDataSize != gCByte.Bytes2Str(pObj, pData, size) + size) return false;
  1270. var wMeChairID = this.GetMeChairID();
  1271. this.m_GameClientView.m_CardView.ShowTingData(pObj.pItem, this.m_bListen[wMeChairID]);
  1272. return true;
  1273. },
  1274. OnUpdateCardData: function (pData, wDataSize) {
  1275. var pHandCardData = GameDef.CMD_S_HandCardData();
  1276. if (wDataSize != gCByte.Bytes2Str(pHandCardData, pData)) return false;
  1277. console.log("刷新pHandCardData--", pHandCardData);
  1278. var wMeChairID = this.GetMeChairID();
  1279. if (pHandCardData.wChairID == wMeChairID) {
  1280. this.m_cbCardIndex = new Array();
  1281. this.m_GameLogic.SwitchToCardIndex3(pHandCardData.cbCardData, pHandCardData.wCardCount, this.m_cbCardIndex);
  1282. this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, pHandCardData.cbSendCardData, this.m_bListen[wMeChairID], pHandCardData.cbCantOutCard);
  1283. } else {
  1284. var viewID = this.SwitchViewChairID(pHandCardData.wChairID);
  1285. if (this.m_ReplayMode) {
  1286. if (pHandCardData.cbCardData[0] != 0) {
  1287. if ((pHandCardData.wCardCount + 1) % 3 == 0) {
  1288. var curCardData = pHandCardData.cbSendCardData;
  1289. if (curCardData == 0) curCardData = pHandCardData.cbCardData[0]
  1290. this.m_GameClientView.m_CardView.SetCardData(viewID, pHandCardData.cbCardData, pHandCardData.wCardCount, curCardData);
  1291. } else {
  1292. this.m_GameClientView.m_CardView.SetCardData(viewID, pHandCardData.cbCardData, pHandCardData.wCardCount);
  1293. }
  1294. }
  1295. } else {
  1296. // if((pHandCardData.wCardCount+1)%3==0){
  1297. // this.m_GameClientView.m_CardView.SetCardData(viewID,null,pHandCardData.wCardCount-1,0);
  1298. // }else{
  1299. // this.m_GameClientView.m_CardView.SetCardData(viewID,null,pHandCardData.wCardCount);
  1300. // }
  1301. this.m_GameClientView.m_CardView.SetCardData(viewID, null, pHandCardData.wCardCount);
  1302. }
  1303. }
  1304. var i = pHandCardData.wChairID;
  1305. this.m_cbWeaveCount[i] = pHandCardData.dwWeaveCount;
  1306. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1307. this.m_WeaveItemArray[i][j].wWeaveKind = pHandCardData.WeaveItem[j].wWeaveKind;
  1308. this.m_WeaveItemArray[i][j].cbCenterCard = pHandCardData.WeaveItem[j].cbCenterCard;
  1309. this.m_WeaveItemArray[i][j].cbPublicCard = pHandCardData.WeaveItem[j].cbPublicCard;
  1310. this.m_WeaveItemArray[i][j].wProvideUser = pHandCardData.WeaveItem[j].wProvideUser;
  1311. this.m_WeaveItemArray[i][j].cbCardCount = pHandCardData.WeaveItem[j].cbCardCount;
  1312. for (var k = 0; k < 4; ++k) {
  1313. this.m_WeaveItemArray[i][j].cbCardData[k] = pHandCardData.WeaveItem[j].cbCardData[k];
  1314. this.m_WeaveItemArray[i][j].cbExtraCount[k] = pHandCardData.WeaveItem[j].cbExtraCount[k];
  1315. }
  1316. }
  1317. var ViewID = this.SwitchViewChairID(i);
  1318. for (var j = 0; j < this.m_cbWeaveCount[i]; j++) {
  1319. this.m_GameClientView.m_CardView.SetWeaveData(ViewID, j, this.m_WeaveItemArray[i][j].cbCardData, this.m_WeaveItemArray[i][j].cbCardCount);
  1320. this.m_GameClientView.m_CardView.SetWeaveState(ViewID, j, this.m_WeaveItemArray[i][j]);
  1321. }
  1322. return true;
  1323. },
  1324. //开始选刚
  1325. OnSubStartDouble: function (pData, wDataSize) {
  1326. var pGameDouble = GameDef.CMD_S_Game_Double();
  1327. if (wDataSize != gCByte.Bytes2Str(pGameDouble, pData)) return false;
  1328. this.m_bStustee = false;
  1329. this.m_wBankerUser = pGameDouble.wBankerUser;
  1330. var bankerViewID = this.SwitchViewChairID(this.m_wBankerUser);
  1331. this.m_GameClientView.SetBankerUser(bankerViewID);
  1332. this.m_cbGameStatus = GameDef.GAME_SCENE_DOUBLE;
  1333. this.SetGameClock(INVALID_CHAIR, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1334. this.m_GameClientView.m_BtStart.active = false;
  1335. this.m_GameClientView.m_BtFriend.active = false;
  1336. this.m_BtExit.active = false;
  1337. this.m_BtDissolve.active = true;
  1338. //回放、观战不显示选飘界面
  1339. var kernel = gClientKernel.get();
  1340. if (this.m_ReplayMode || kernel.IsLookonMode()) return true;
  1341. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1342. if (this.GetClientUserItem(i) == null) continue;
  1343. var viewId = this.SwitchViewChairID(i);
  1344. this.m_GameClientView.m_UserInfo[viewId].SetTing(false);
  1345. this.m_GameClientView.m_UserInfo[viewId].SetGang(0);
  1346. this.m_GameClientView.SetTrustee(i, false);
  1347. }
  1348. this.m_GameClientView.SetGangOperator(1);
  1349. return true;
  1350. },
  1351. OnMessageStart: function () {
  1352. //this.ShowHead(true);
  1353. this.KillGameClock();
  1354. //隐藏按钮
  1355. this.m_GameClientView.m_BtStart.active = false;
  1356. //this.m_GameClientView.m_BtFriend.active = false;
  1357. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1358. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1359. //设置界面
  1360. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  1361. this.m_GameClientView.SetBankerUser(INVALID_CHAIR);
  1362. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1363. //关闭显示花,风位
  1364. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1365. if (this.GetClientUserItem(i) == null) continue;
  1366. var OtherViewID = this.SwitchViewChairID(i);
  1367. this.m_GameClientView.m_UserInfo[OtherViewID].SetShowFenganFlower();
  1368. }
  1369. //隐藏骰子
  1370. this.m_GameClientView.ShowDice(false);
  1371. this.m_GameClientView.m_CardView.ResetView();
  1372. //扑克设置
  1373. //游戏变量
  1374. this.m_wCurrentUser = INVALID_CHAIR;
  1375. this.m_wActionMask = 0;
  1376. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1377. this.m_cbWeaveCount[i] = 0;
  1378. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1379. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  1380. }
  1381. }
  1382. //扑克变量
  1383. this.m_cbLeftCardCount = 0;
  1384. for (var i = 0; i < 42; ++i)//GameDef.MAX_INDEX
  1385. {
  1386. this.m_cbCardIndex[i] = 0;
  1387. }
  1388. //if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7)
  1389. //{
  1390. // this.m_GameClientView.SetLeftCardCount(112);
  1391. //}
  1392. //else
  1393. //{
  1394. // this.m_GameClientView.SetLeftCardCount(108);
  1395. //}
  1396. this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY);
  1397. //设置用户动作
  1398. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1399. var kernel = gClientKernel.get();
  1400. if (kernel.IsLookonMode() == false) {
  1401. //发送准备
  1402. this.SendUserReady(null, 0);
  1403. }
  1404. },
  1405. CleanView: function (bOffLineBack) {
  1406. this.Init();
  1407. this.waitOperate = false;
  1408. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1409. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1410. //设置界面
  1411. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  1412. this.m_GameClientView.SetBankerUser(INVALID_CHAIR);
  1413. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1414. //扑克设置
  1415. this.m_GameClientView.m_CardView.ResetView();
  1416. //游戏变量
  1417. this.m_wCurrentUser = INVALID_CHAIR;
  1418. this.m_wActionMask = 0;
  1419. this.m_wTimeOutCount = 0;
  1420. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1421. this.m_cbWeaveCount[i] = 0;
  1422. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1423. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  1424. }
  1425. }
  1426. //扑克变量
  1427. this.m_cbLeftCardCount = 0;
  1428. for (var i = 0; i < 42; ++i)//GameDef.MAX_INDEX
  1429. {
  1430. this.m_cbCardIndex[i] = 0;
  1431. }
  1432. if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) {
  1433. this.m_GameClientView.SetLeftCardCount(112);
  1434. }
  1435. else {
  1436. this.m_GameClientView.SetLeftCardCount(108);
  1437. }
  1438. this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY);
  1439. //设置用户动作
  1440. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1441. },
  1442. //补牌
  1443. OnReplaceCard: function (cbCardData) {
  1444. //构造数据
  1445. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1446. var ReplaceCard = GameDef.CMD_C_ReplaceCard4();
  1447. ReplaceCard.cbCardData[0] = cbCardData;
  1448. ReplaceCard.cbCardCount = 1;
  1449. console.log("补花", cbCardData, ReplaceCard)
  1450. //发送数据
  1451. // if (this.m_ReplayMode) return 0;
  1452. this.SendGameData(GameDef.SUB_C_REPLACE_CARD, ReplaceCard);
  1453. return 0;
  1454. },
  1455. //出牌消息
  1456. OnOutCard: function (HandState, CardIndex, cbCardData, bAdd) {
  1457. //出牌判断
  1458. if (this.m_wCurrentUser != this.GetMeChairID()) return 0;
  1459. // 检查 cbOutCardData 是否大于 55
  1460. // if (cbCardData > 55) return 0;
  1461. //设置变量
  1462. this.m_wCurrentUser = INVALID_CHAIR;
  1463. this.m_wActionMask = 0;
  1464. var cbOutCardData = cbCardData;
  1465. //设置界面
  1466. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1467. //定义变量
  1468. var wMeChairId = this.GetMeChairID();
  1469. var wOutCardUser = this.GetMeChairID();
  1470. var wViewOutCardUser = this.SwitchViewChairID(wOutCardUser);
  1471. // this.PlayActionSound(wMeChairId,this.GetCardStr(cbOutCardData),true);
  1472. //环境设置
  1473. this.KillGameClock();
  1474. //设置变量
  1475. this.m_wCurrentUser = INVALID_CHAIR;
  1476. this.m_wActionMask = 0;
  1477. //设置界面
  1478. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1479. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1480. //构造数据
  1481. var OutCard = GameDef.CMD_C_OutCard();
  1482. OutCard.cbCardData = cbOutCardData;
  1483. OutCard.bAddGang = bAdd == true ? true : false;
  1484. //发送数据
  1485. this.SendGameData(GameDef.SUB_C_OUT_CARD, OutCard);
  1486. return 0;
  1487. },
  1488. //扑克操作
  1489. OnCardOperate: function (wOperateCode, cbOperateCard, cbCardCount, cbIndex) {
  1490. //变量定义
  1491. if (this.m_bFirstCard == false && wOperateCode == 0 && this.m_wCurrentUser == this.GetMeChairID()) {
  1492. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1493. var wViewID = this.SwitchViewChairID(this.GetMeChairID());
  1494. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true);
  1495. if (this.m_bStustee == false) {
  1496. this.ListenAutoOutCard(this.m_wCurrentUser);
  1497. }
  1498. return;
  1499. }
  1500. //补扭走打牌逻辑
  1501. if (wOperateCode & (GameDef.WIK_ADD_ZFB | GameDef.WIK_ADD_DNJ | GameDef.WIK_ADD_FENG)) {
  1502. this.m_GameClientView.m_CardView.m_HandCard[2].SetOutCard(cbOperateCard[0]);
  1503. this.OnOutCard(0, 0, cbOperateCard[0], true);
  1504. return;
  1505. }
  1506. //删除时间
  1507. this.KillGameClock();
  1508. this.m_wCurrentUser = INVALID_CHAIR;
  1509. this.m_wActionMask = 0;
  1510. //构造数据
  1511. var OperateCard = GameDef.CMD_C_OperateCard();
  1512. OperateCard.wOperateCode = wOperateCode;
  1513. OperateCard.cbOperateCard[0] = cbOperateCard[0];
  1514. OperateCard.cbOperateCard[1] = cbOperateCard[1];
  1515. OperateCard.cbOperateCard[2] = cbOperateCard[2];
  1516. OperateCard.cbOperateCard[3] = cbOperateCard[3];
  1517. OperateCard.cbOperateCount = cbCardCount;
  1518. OperateCard.cbIndex = cbIndex;
  1519. console.log("发送胡牌操作",OperateCard)
  1520. //发送数据
  1521. this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard);
  1522. this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(false);
  1523. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1524. return 0;
  1525. },
  1526. //扑克操作
  1527. OnDoubleOperate: function (cbDouble) {
  1528. this.KillGameClock();
  1529. var Double = GameDef.CMD_C_Double();
  1530. Double.cbDouble = cbDouble;
  1531. //发送数据
  1532. this.SendGameData(GameDef.SUB_C_USER_DOUBLE, Double);
  1533. return 0;
  1534. },
  1535. OnCancelTrustee: function (bTrustee) {
  1536. var Trustee = GameDef.CMD_C_Trustee();
  1537. Trustee.bTrustee = bTrustee;
  1538. //发送数据
  1539. this.SendGameData(GameDef.SUB_C_TRUSTEE, Trustee);
  1540. },
  1541. // //扑克操作
  1542. // OnStusteeControl:function(wParam, lParam){
  1543. // //设置变量
  1544. // this.m_wTimeOutCount=0;
  1545. // if(this.m_bStustee&&lParam==true)return 0;
  1546. // if(!this.m_bStustee&&lParam==0)return 0;
  1547. // //设置状态
  1548. // this.m_bStustee = this.m_bStustee?false:true;
  1549. // //构造数据
  1550. // var Trustee = GameDef.CMD_C_Trustee();
  1551. // Trustee.bTrustee = this.m_bStustee;
  1552. // //发送数据
  1553. // this.SendGameData(GameDef.SUB_C_TRUSTEE, Trustee);
  1554. // return 0;
  1555. // },
  1556. // //离开控制
  1557. // OnLeaveControl: function(event, customData){
  1558. // if(customData != 0){
  1559. // this.m_LeaveControl.ShowView(true);
  1560. // this.m_bLeave = true;
  1561. // }else{
  1562. // this.m_LeaveControl.ShowView(false);
  1563. // this.m_bLeave = false;
  1564. // this.SetGameClock(this.GetMeChairID(),GameDef.IDI_OPERATE_CARD,GameDef.TIME_OPERATE_CARD);
  1565. // }
  1566. // //构造数据
  1567. // var Leave = GameDef.CMD_C_Leave();
  1568. // Leave.bLeave = this.m_bLeave;
  1569. // //发送数据
  1570. // this.SendGameData(GameDef.SUB_C_LEAVE, Leave);
  1571. // return 0;
  1572. // },
  1573. OnNextReady: function () {
  1574. this.KillGameClock();
  1575. //游戏变量
  1576. this.m_lCellScore = 0;
  1577. //设置当前玩家
  1578. this.m_wCurrentUser = INVALID_CHAIR;
  1579. //隐藏按钮
  1580. this.m_GameClientView.m_BtStart.active = false;
  1581. //设置游戏状态
  1582. this.m_GameClientView.SetPlayStatus(INVALID_CHAIR, 0);
  1583. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1584. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1585. //设置界面
  1586. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  1587. this.m_GameClientView.SetBankerUser(INVALID_CHAIR);
  1588. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1589. //扑克设置
  1590. this.m_GameClientView.m_CardView.ResetView();
  1591. //游戏变量
  1592. this.m_wCurrentUser = INVALID_CHAIR;
  1593. this.m_wActionMask = 0;
  1594. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1595. this.m_cbWeaveCount[i] = 0;
  1596. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1597. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  1598. }
  1599. }
  1600. //扑克变量
  1601. this.m_cbLeftCardCount = 0;
  1602. for (var i = 0; i < 42; ++i) {//GameDef.MAX_INDEX
  1603. this.m_cbCardIndex[i] = 0;
  1604. }
  1605. if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) {
  1606. this.m_GameClientView.SetLeftCardCount(112);
  1607. }
  1608. else {
  1609. this.m_GameClientView.SetLeftCardCount(108);
  1610. }
  1611. this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY);
  1612. //设置用户动作
  1613. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1614. this.SendGameData(GameDef.SUB_C_NEXT_READY, null);
  1615. },
  1616. //执行结束
  1617. OnTimeIDI_PERFORM_END: function () {
  1618. this.unschedule(this.OnTimeIDI_PERFORM_END);
  1619. this.m_bEnd = true;
  1620. //成绩界面
  1621. this.ShowGamePrefab("LittleResultBG", GameDef.KIND_ID, this.node, function (Js) {
  1622. this.m_EndLittleView = Js;
  1623. //this.m_EndLittleView.SetTrustee(this.m_bStustee);
  1624. }.bind(this));
  1625. //this.ShowPrefabDLG('LittleResultBG_21201');
  1626. },
  1627. checkTotalEnd: function (bNext) {
  1628. this.m_bEnd = false;
  1629. if (this.m_RoomEnd) {
  1630. if (this.m_wGameProgress > 0 || this.m_ReplayMode) {
  1631. this.showRealEndView();
  1632. } else {
  1633. this.ShowAlert("該房間已被解散!", Alert_Yes, function (Res) {
  1634. this.m_pTableScene.ExitGame();
  1635. }.bind(this));
  1636. }
  1637. } else {
  1638. var kernel = gClientKernel.get();
  1639. if (!kernel.IsLookonMode() && bNext) this.OnMessageStart();
  1640. }
  1641. this.m_bCanShowBigEnd = true;
  1642. },
  1643. //发送准备
  1644. SendUserReady: function (pBuffer, wDataSize) {
  1645. var kernel = gClientKernel.get();
  1646. if (kernel == 0 || kernel == null || kernel.IsLookonMode()) return;
  1647. kernel.SendSocketData(MDM_GF_FRAME, SUB_GF_USER_READY, pBuffer, wDataSize);
  1648. },
  1649. //出牌声音字符串
  1650. GetCardStr: function (cbCardData) {
  1651. var str = "";
  1652. var color = cbCardData & 0xf0;
  1653. var value = cbCardData & 0x0f;
  1654. if (color == 0)
  1655. str = "W_";
  1656. if (color == 0x10)
  1657. str = "S_";
  1658. if (color == 0x20)
  1659. str = "T_";
  1660. if (color == 0x30)
  1661. str = "F_";
  1662. str = str + value.toString();
  1663. return str;
  1664. },
  1665. //播放操作声音
  1666. PlayActionSound: function (wChairId, byAction, chuyin) {
  1667. if (this.m_bRollBack) return;
  1668. //椅子效验
  1669. var kernel = gClientKernel.get();
  1670. var pIClientUserItem = kernel.GetTableUserItem(wChairId);
  1671. if (pIClientUserItem == null) return;
  1672. console.log(pIClientUserItem)
  1673. console.log(wChairId, byAction, chuyin)
  1674. if (pIClientUserItem.GetGender() == 1) {
  1675. cc.gSoundRes.PlayGameSound("M_" + byAction + "L" + wChairId);
  1676. }
  1677. else {
  1678. cc.gSoundRes.PlayGameSound("W_" + byAction + "L" + wChairId);
  1679. // cc.gSoundRes.PlayGameSound("W_" + byAction);
  1680. }
  1681. if (chuyin) {
  1682. cc.gSoundRes.PlayGameSound("CHUPAI");
  1683. }
  1684. },
  1685. OnExitGame: function () {
  1686. //退出游戏
  1687. this.m_TableViewFrame.ExitGame();
  1688. },
  1689. ExitGame: function () {
  1690. this.OnExitGame();
  1691. },
  1692. //////////////////////////////////////////////////////////////////////////
  1693. //获取用户
  1694. GetClientUserItem: function (wChairID) {
  1695. var kernel = gClientKernel.get();
  1696. if (kernel == 0 || kernel == null || kernel == undefined) return null;
  1697. return kernel.GetTableUserItem(wChairID);
  1698. },
  1699. GetGameStatus: function () {
  1700. var kernel = gClientKernel.get();
  1701. if (!kernel) return GAME_SCENE_FREE;
  1702. return kernel.GetGameStatus();
  1703. },
  1704. IsValidChairID: function (wChairID) {
  1705. if (wChairID >= 0 && wChairID < GameDef.GAME_PLAYER) return true;
  1706. return false;
  1707. },
  1708. // 获取座位
  1709. GetUserChairID: function (dwUserID) {
  1710. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1711. var pIClientUserItem = this.GetClientUserItem(i);
  1712. if (!pIClientUserItem) continue;
  1713. if (pIClientUserItem.GetUserID() == dwUserID) return i;
  1714. }
  1715. return INVALID_CHAIR;
  1716. },
  1717. SetViewRoomInfo: function (dwServerRules, dwRulesArr) {
  1718. if (this.m_GameClientView)
  1719. this.m_GameClientView.SetViewRoomInfo(dwRulesArr, dwServerRules);
  1720. GameDef.setRule(dwServerRules, dwRulesArr);
  1721. this.updateUserCount();
  1722. this.m_GameClientView.m_CardView.m_CenterViewCtrl.updateNorth();
  1723. this.m_GameClientView.updateGameRule();
  1724. //this.m_GameClientView.m_Trustee.string = GameDef.GetTrusteeString(this.m_dwRules);
  1725. },
  1726. OnEventRoomEnd: function (data, datasize) {
  1727. this.m_RoomEnd = GameDef.CMD_S_GameCustomInfo();
  1728. if (datasize != gCByte.Bytes2Str(this.m_RoomEnd, data)) return false;
  1729. console.log("总结束", this.m_RoomEnd)
  1730. this.m_RoomEnd.UserID = new Array();
  1731. //用户成绩
  1732. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1733. //变量定义
  1734. var pIClientUserItem = this.GetClientUserItem(i);
  1735. if (pIClientUserItem == null) continue;
  1736. this.m_RoomEnd.UserID[i] = pIClientUserItem.GetUserID();
  1737. }
  1738. if (this.m_wGameProgress > 0 || this.m_ReplayMode) {
  1739. this.m_GameClientView.m_BtStart.active = false;
  1740. this.KillGameClock();
  1741. if (this.m_bCanShowBigEnd) {
  1742. this.showRealEndView();
  1743. }
  1744. } else {
  1745. var self = this;
  1746. this.ShowAlert("該房間已被解散!", Alert_Yes, function (Res) {
  1747. self.m_pTableScene.ExitGame();
  1748. });
  1749. }
  1750. return true;
  1751. },
  1752. showRealEndView() {
  1753. this.RealShowEndView();
  1754. GameDef.m_AllCardItem = [];
  1755. },
  1756. //点击安全监测
  1757. OnBtClickedSafe: function () {
  1758. cc.gSoundRes.PlaySound('Button');
  1759. this.ShowGamePrefab('SafeCheck_21201');
  1760. },
  1761. ChangeCardBack: function (index) {
  1762. this.m_CardBack = index;
  1763. if (this.m_GameClientView.m_CardView == null) {
  1764. this.m_GameClientView.Init();
  1765. }
  1766. this.m_GameClientView.m_CardView.ChangeCardBack(this.node, index);
  1767. this.m_GameClientView.ChangeCardBack(index);
  1768. },
  1769. //震动会牌
  1770. ShockHuiPai: function () {
  1771. if (this.m_bRollBack) return;
  1772. this.m_GameClientView.ShockHuiPai();
  1773. },
  1774. updateUserCount: function () {
  1775. this.m_GameClientView.m_CardView.UpdateUserCount();
  1776. this.m_GameClientView.updateUserCount();
  1777. },
  1778. //邀请好友分享
  1779. OnFriend: function () {
  1780. if (cc.sys.isNative) {
  1781. this.ShowPrefabDLG("SharePre");
  1782. } else {
  1783. // this.m_GameClientView.m_FriendBg.node.active = true;
  1784. }
  1785. },
  1786. OnClearScene: function () {
  1787. if (this.m_EndLittleView) this.m_EndLittleView.HideView();
  1788. var CardBack = cc.sys.localStorage.getItem(window.Key_CardColor);
  1789. if (CardBack) {
  1790. this.ChangeCardBack(CardBack);
  1791. } else {
  1792. this.ChangeCardBack(0);
  1793. }
  1794. this.CleanView();
  1795. },
  1796. GetOperateTime: function () {
  1797. if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_15) {
  1798. return GameDef.TIME_OPERATE_CARD_15;
  1799. }
  1800. else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_30) {
  1801. return GameDef.TIME_OPERATE_CARD_30;
  1802. }
  1803. else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_60) {
  1804. return GameDef.TIME_OPERATE_CARD_60;
  1805. }
  1806. else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_NONE) {
  1807. return GameDef.TIME_OPERATE_CARD;
  1808. }
  1809. },
  1810. //测试
  1811. __test: function () {
  1812. this.m_GameClientView.m_CardView.setUserCount(4);
  1813. this.m_GameClientView.m_CardView.SetClientEngine(this);
  1814. this.m_CardData = new Array();
  1815. this.m_CardData =
  1816. [
  1817. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1818. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1819. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1820. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1821. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1822. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1823. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1824. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1825. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1826. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1827. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1828. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1829. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1830. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1831. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1832. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1833. ];
  1834. this.m_GameClientView.m_CardView.SetCardData(0, this.m_CardData, 10);
  1835. this.m_GameClientView.m_CardView.SetCardData(1, this.m_CardData, 10);
  1836. this.m_GameClientView.m_CardView.SetCardData(2, this.m_CardData, 10);
  1837. this.m_GameClientView.m_CardView.SetPositively(true);
  1838. var weaveCard = new Array();
  1839. weaveCard[0] = 0x21;
  1840. weaveCard[1] = 0x21;
  1841. weaveCard[2] = 0x21;
  1842. weaveCard[3] = 0x21;
  1843. this.m_GameClientView.m_CardView.SetWeaveData(0, 0, weaveCard, 4);
  1844. // this.m_GameClientView.m_CardView.SetWeaveData(1,0,weaveCard,4);
  1845. this.m_GameClientView.m_CardView.SetWeaveData(2, 0, weaveCard, 4);
  1846. // this.m_GameClientView.m_CardView.SetWeaveData(3,0,weaveCard,4);
  1847. // this.m_GameClientView.m_CardView.SetCardData(3,cardData,13,0x02);
  1848. this.DiscardDate = 0x22;
  1849. this.m_GameClientView.m_CardView.SetDiscardCardDate(0, this.m_CardData, 33);
  1850. this.m_GameClientView.m_CardView.SetDiscardCardDate(1, this.m_CardData, 33);
  1851. this.m_GameClientView.m_CardView.SetDiscardCardDate(2, this.m_CardData, 33);
  1852. this.m_GameClientView.m_CardView.SetDiscardCardDate(3, this.m_CardData, 33);
  1853. // this.m_GameClientView.m_CardView.PlayDiscard(0,13);
  1854. },
  1855. });