GameClientEngine_21201.js 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219
  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_PENG) {
  985. // console.log("操作提示-碰")
  986. // }
  987. // if (pOperateNotify.wActionMask & GameDef.WIK_LEFT) {
  988. // console.log("操作提示-左吃")
  989. // }
  990. // if (pOperateNotify.wActionMask & GameDef.WIK_CENTER) {
  991. // console.log("操作提示-中吃")
  992. // }
  993. // if (pOperateNotify.wActionMask & GameDef.WIK_RIGHT) {
  994. // console.log("操作提示-右吃")
  995. // }
  996. //this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(false);
  997. //获取变量
  998. var wMeChairID = this.GetMeChairID();
  999. this.m_wActionMask = pOperateNotify.wActionMask;
  1000. //设置界面
  1001. this.m_GameClientView.m_CardView.SetControlInfo(true, pObj.pItem, pObj.pItem.length);
  1002. //设置时间
  1003. this.m_GameClientView.SetCurrentUser(pOperateNotify.wResumeUser);
  1004. this.SetGameClock(wMeChairID, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1005. this.StusteeOperateCard(wMeChairID);
  1006. }
  1007. return true;
  1008. },
  1009. OnSubOperateTimer: function (pData, wDataSize) {
  1010. this.SetGameClock(INVALID_CHAIR, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1011. return true;
  1012. },
  1013. //操作提示
  1014. OnSubOperateResult: function (pData, wDataSize) {
  1015. var pOperateResult = GameDef.CMD_S_OperateResult();
  1016. //效验
  1017. if (wDataSize != gCByte.Bytes2Str(pOperateResult, pData)) return false;
  1018. console.log("pOperateResult--", pOperateResult)
  1019. var wOperateViewID = this.SwitchViewChairID(pOperateResult.wOperateUser);
  1020. if (pOperateResult.wOperateUser != pOperateResult.wProvideUser && pOperateResult.bQiangGang == false) {
  1021. var PrivideViewID = this.SwitchViewChairID(pOperateResult.wProvideUser);
  1022. this.m_GameClientView.m_CardView.StopDiscard(PrivideViewID, pOperateResult.cbCenterCard);
  1023. }
  1024. var wOperateUser = pOperateResult.wOperateUser;
  1025. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1026. this.m_GameClientView.SetUserAction(wOperateViewID, pOperateResult.wOperateCode);
  1027. //环境设置
  1028. if (pOperateResult.wOperateCode & (GameDef.WIK_GANG)) {
  1029. this.PlayActionSound(wOperateUser, "GANG");
  1030. // if (pOperateResult.dwGangScore > 0) {
  1031. // if (pOperateResult.wProvideUser == wOperateUser) {
  1032. // //暗杠,补杠
  1033. // var AddScore = 0;
  1034. // for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1035. // if (this.GetClientUserItem(i) == null) continue;
  1036. // if (i == wOperateUser) continue;
  1037. // var OtherViewID = this.SwitchViewChairID(i);
  1038. // this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, -pOperateResult.dwGangScore);// -
  1039. // AddScore += pOperateResult.dwGangScore;
  1040. // }
  1041. // // this.m_GameClientView.m_UserInfo[wOperateViewID].SetScore(OtherViewID, AddScore);//+ AddScore
  1042. // }
  1043. // else {
  1044. // //叉杠
  1045. // var PrivideViewID = this.SwitchViewChairID(pOperateResult.wProvideUser);
  1046. // this.m_GameClientView.m_UserInfo[PrivideViewID].SetScore(PrivideViewID, -pOperateResult.dwGangScore);;//-
  1047. // this.m_GameClientView.m_UserInfo[wOperateViewID].SetScore(wOperateViewID, pOperateResult.dwGangScore);;//+
  1048. // }
  1049. // }
  1050. }
  1051. else if (pOperateResult.wOperateCode & (GameDef.WIK_LEFT | GameDef.WIK_CENTER | GameDef.WIK_RIGHT))
  1052. this.PlayActionSound(wOperateUser, "CHI");
  1053. else if (pOperateResult.wOperateCode & GameDef.WIK_PENG)
  1054. this.PlayActionSound(wOperateUser, "PENG");
  1055. else if (pOperateResult.wOperateCode & GameDef.WIK_CHI_HU)
  1056. this.PlayActionSound(wOperateUser, "HU");
  1057. else if (pOperateResult.wOperateCode & GameDef.WIK_LISTEN) {
  1058. this.PlayActionSound(wOperateUser, "TING");
  1059. this.m_bListen[wOperateUser] = true;
  1060. var viewID = this.SwitchViewChairID(wOperateUser);
  1061. this.m_GameClientView.m_UserInfo[viewID].SetTing(true);
  1062. }
  1063. else if (pOperateResult.wOperateCode & GameDef.WIK_GANG_FENG) {
  1064. this.PlayActionSound(wOperateUser, "FENG");
  1065. }
  1066. else if (pOperateResult.wOperateCode & GameDef.WIK_DNJ) {
  1067. this.PlayActionSound(wOperateUser, "DNJ");
  1068. }
  1069. else if (pOperateResult.wOperateCode & GameDef.WIK_CAI_ZFB) {
  1070. this.PlayActionSound(wOperateUser, "ZFB");
  1071. }
  1072. //设置时间
  1073. if (pOperateResult.bBeiQiangGang) {
  1074. this.m_wCurrentUser = INVALID_CHAIR;
  1075. }
  1076. else {
  1077. this.m_wCurrentUser = wOperateUser;
  1078. }
  1079. var wMeChairID = this.GetMeChairID();
  1080. if (wOperateUser == wMeChairID) {
  1081. var wViewID = this.SwitchViewChairID(wMeChairID);
  1082. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true);
  1083. }
  1084. this.m_GameClientView.SetCurrentUser(wOperateUser);
  1085. this.SetGameClock(wOperateUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1086. return true;
  1087. },
  1088. OnSubGameEnd: function (pData, wDataSize) {
  1089. this.m_GameEnd = GameDef.CMD_S_GameEnd();
  1090. if (wDataSize != gCByte.Bytes2Str(this.m_GameEnd, pData)) return false;
  1091. GameDef.cbLianZhuangCount = this.m_GameEnd.cbLianZhuangCount;
  1092. console.log("連莊cbLianZhuangCount", GameDef.cbLianZhuangCount);
  1093. this.m_cbGameStatus = GameDef.GAME_SCENE_FREE;
  1094. console.log("this.m_GameEnd--", this.m_GameEnd);
  1095. this.m_bCanShowBigEnd = false;
  1096. //清空听牌提示
  1097. this.m_GameClientView.m_CardView.ShowTingData();
  1098. this.m_GameClientView.m_CardView.ShowTingTip(0);
  1099. //删除定时器
  1100. this.KillGameClock();
  1101. GameDef.dwChiHuRightAdd = this.m_GameEnd.dwChiHuRightAdd;
  1102. this.m_wGameProgress = this.m_GameEnd.cbQuan + 1;
  1103. // this.m_GameClientView.UpdateRoomProgress();
  1104. this.MyChairID = this.GetMeChairID()
  1105. let isZimo = false;
  1106. //赢家
  1107. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1108. if (this.GetClientUserItem(i) == null) continue;
  1109. if (this.m_GameEnd.dwChiHuKind[i] == GameDef.WIK_CHI_HU) {
  1110. var viewID = this.SwitchViewChairID(i);
  1111. if (this.m_GameEnd.dwChiHuRight[i] & GameDef.CHR_ZI_MO) {
  1112. //自摸
  1113. this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_CHI_HU, GameDef.CHR_ZI_MO);
  1114. isZimo = true;
  1115. } else {
  1116. //胡牌
  1117. this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_CHI_HU);
  1118. }
  1119. }
  1120. }
  1121. //输家
  1122. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1123. if (this.m_GameEnd.lGameScore[i] >= 0) {
  1124. continue;
  1125. }
  1126. if (this.GetClientUserItem(i) == null) continue;
  1127. var viewID = this.SwitchViewChairID(i);
  1128. this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_FANG_PAO, isZimo ? GameDef.CHR_ZI_MO : 0);
  1129. }
  1130. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1131. if (this.GetClientUserItem(i) == null) continue;
  1132. var OtherViewID = this.SwitchViewChairID(i);
  1133. this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, this.m_GameEnd.lSumGameScore[i])
  1134. }
  1135. //设置控件
  1136. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1137. this.m_GameClientView.m_CardView.SetPositively(false);
  1138. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1139. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1140. if (this.GetClientUserItem(i) == null) continue;
  1141. for (var j = 0; j < this.m_GameEnd.cbWeaveCount[i]; ++j) {
  1142. var cbCenterCard = this.m_GameEnd.weaveItem[i][j].cbCenterCard;
  1143. var wWeaveKind = this.m_GameEnd.weaveItem[i][j].wWeaveKind;
  1144. var cbCardData = this.m_GameEnd.weaveItem[i][j].cbCardData;
  1145. var cbWeaveCardCount = this.m_GameEnd.weaveItem[i][j].cbCardCount;
  1146. var cbPublicCard = this.m_GameEnd.weaveItem[i][j].cbPublicCard;
  1147. var viewID = this.SwitchViewChairID(i);
  1148. this.m_GameClientView.m_CardView.SetWeaveData(viewID, j, cbCardData, cbWeaveCardCount, cbPublicCard);
  1149. this.m_GameClientView.m_CardView.SetWeaveState(viewID, j, this.m_GameEnd.weaveItem[i][j]);
  1150. if (cbWeaveCardCount == 4 && !cbPublicCard) {
  1151. this.m_GameClientView.m_CardView.SetWeaveState(viewID, j, GameDef.GAME_THREE_BACK_SELF);
  1152. }
  1153. }
  1154. }
  1155. //设置扑克
  1156. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1157. if (this.GetClientUserItem(i) == null) continue;
  1158. var cbCardData = this.m_GameEnd.cbCardData;
  1159. var wCardCount = this.m_GameEnd.cbCardCount[i];
  1160. var viewID = this.SwitchViewChairID(i);
  1161. if ((wCardCount + 1) % 3 == 0) {
  1162. var tmpCardData = new Array();
  1163. for (var j = 0; j < wCardCount; j++) {
  1164. tmpCardData[j] = cbCardData[i][j];
  1165. }
  1166. var cbRemoveCard = new Array();
  1167. if (this.m_GameEnd.cbProvideCard != 0) {
  1168. cbRemoveCard[0] = this.m_GameEnd.cbProvideCard;
  1169. } else {
  1170. cbRemoveCard[0] = tmpCardData[wCardCount - 1];
  1171. }
  1172. if (this.m_GameEnd.cbLastCardData[i]) {
  1173. cbRemoveCard[0] = this.m_GameEnd.cbLastCardData[i];
  1174. }
  1175. if (this.m_GameLogic.RemoveCard4(tmpCardData, wCardCount, cbRemoveCard, 1)) {
  1176. this.m_GameClientView.m_CardView.SetCardData(viewID, tmpCardData, wCardCount - 1);
  1177. this.m_GameClientView.m_CardView.SetCurrentCard(viewID, cbRemoveCard[0]);
  1178. }
  1179. } else {
  1180. this.m_GameClientView.m_CardView.SetCardData(viewID, cbCardData[i], wCardCount);
  1181. }
  1182. this.m_GameClientView.m_CardView.SetCardItemState(viewID, GameDef.HAND_STATE_SHOW);
  1183. }
  1184. //播放声音
  1185. if (this.m_GameEnd.wProvideUser != INVALID_CHAIR) {
  1186. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1187. if (this.m_GameEnd.dwChiHuKind[i] != GameDef.WIK_NULL) {
  1188. if (this.m_GameEnd.dwChiHuRight[i] & GameDef.CHR_ZI_MO) {
  1189. this.PlayActionSound(i, "ZIMO");
  1190. }
  1191. else {
  1192. this.PlayActionSound(i, "HU");
  1193. }
  1194. }
  1195. }
  1196. } else {
  1197. cc.gSoundRes.PlayGameSound("GAME_END");
  1198. }
  1199. var WaitTime = 3;
  1200. // if(this.m_GameEnd.cbBirdCardCount > 0)
  1201. // {
  1202. // this.m_GameClientView.ShowBird(this.m_GameEnd.cbBirdCard, this.m_GameEnd.cbBirdCardCount);
  1203. // WaitTime = 4;
  1204. // }
  1205. //设置定时
  1206. this.schedule(this.OnTimeIDI_PERFORM_END, WaitTime);
  1207. // this.OnTimeIDI_PERFORM_END();
  1208. return true;
  1209. },
  1210. //用户托管
  1211. OnSubTrustee: function (pData, wDataSize) {
  1212. var pTrustee = GameDef.CMD_S_Trustee();
  1213. if (wDataSize != gCByte.Bytes2Str(pTrustee, pData)) return false;
  1214. this.m_GameClientView.SetTrustee(pTrustee.wChairID, pTrustee.bTrustee);
  1215. var wMeChairID = this.GetMeChairID();
  1216. if (wMeChairID == pTrustee.wChairID) {
  1217. this.m_bStustee = pTrustee.bTrustee;
  1218. if (pTrustee.bTrustee) {
  1219. if (this.m_bEnd) {
  1220. if (this.m_EndLittleView) {
  1221. this.m_EndLittleView.HideView();
  1222. }
  1223. this.checkTotalEnd(true);
  1224. }
  1225. else {
  1226. this.StusteeOperateCard(pTrustee.wChairID);
  1227. }
  1228. }
  1229. }
  1230. console.log("是否托管---", this.m_bStustee)
  1231. return true;
  1232. },
  1233. OnSubLeave: function (pData, wDataSize) {
  1234. var pLeave = GameDef.CMD_S_Leave();
  1235. if (wDataSize != gCByte.Bytes2Str(pLeave, pData)) return false;
  1236. this.m_GameClientView.SetUserTimer(this.SwitchViewChairID(this.m_wCurrentUser), 0);
  1237. // for(var i = 0; i < GameDef.GAME_PLAYER; ++ i)
  1238. // this.m_GameClientView.SetLeave(this.SwitchViewChairID(i), pLeave.bLeave[i]);
  1239. return true;
  1240. },
  1241. OnSubPlayerDouble: function (pData, wDataSize) {
  1242. var pDouble = GameDef.CMD_S_Double();
  1243. if (wDataSize != gCByte.Bytes2Str(pDouble, pData)) return false;
  1244. var viewID = this.SwitchViewChairID(pDouble.wCallUser);
  1245. this.m_GameClientView.m_UserInfo[viewID].SetGang(pDouble.cbDouble);
  1246. return true;
  1247. },
  1248. UpdateHandActionCard: function () {
  1249. },
  1250. OnTing: function (pData, wDataSize) {
  1251. var pTing = new Object();
  1252. pTing.wCount = 0;
  1253. var size = gCByte.Bytes2Str(pTing, pData);
  1254. var pObj = new Object()
  1255. pObj.pItem = new Array(pTing.wCount);
  1256. for (var i = 0; i < pTing.wCount; i++) {
  1257. pObj.pItem[i] = GameDef.CMD_TingTip();
  1258. }
  1259. console.log("听--", pObj)
  1260. //效验
  1261. if (wDataSize != gCByte.Bytes2Str(pObj, pData, size) + size) return false;
  1262. var wMeChairID = this.GetMeChairID();
  1263. this.m_GameClientView.m_CardView.ShowTingData(pObj.pItem, this.m_bListen[wMeChairID]);
  1264. return true;
  1265. },
  1266. OnUpdateCardData: function (pData, wDataSize) {
  1267. var pHandCardData = GameDef.CMD_S_HandCardData();
  1268. if (wDataSize != gCByte.Bytes2Str(pHandCardData, pData)) return false;
  1269. console.log("刷新pHandCardData--", pHandCardData);
  1270. var wMeChairID = this.GetMeChairID();
  1271. if (pHandCardData.wChairID == wMeChairID) {
  1272. this.m_cbCardIndex = new Array();
  1273. this.m_GameLogic.SwitchToCardIndex3(pHandCardData.cbCardData, pHandCardData.wCardCount, this.m_cbCardIndex);
  1274. this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, pHandCardData.cbSendCardData, this.m_bListen[wMeChairID], pHandCardData.cbCantOutCard);
  1275. } else {
  1276. var viewID = this.SwitchViewChairID(pHandCardData.wChairID);
  1277. if (this.m_ReplayMode) {
  1278. if (pHandCardData.cbCardData[0] != 0) {
  1279. if ((pHandCardData.wCardCount + 1) % 3 == 0) {
  1280. var curCardData = pHandCardData.cbSendCardData;
  1281. if (curCardData == 0) curCardData = pHandCardData.cbCardData[0]
  1282. this.m_GameClientView.m_CardView.SetCardData(viewID, pHandCardData.cbCardData, pHandCardData.wCardCount, curCardData);
  1283. } else {
  1284. this.m_GameClientView.m_CardView.SetCardData(viewID, pHandCardData.cbCardData, pHandCardData.wCardCount);
  1285. }
  1286. }
  1287. } else {
  1288. // if((pHandCardData.wCardCount+1)%3==0){
  1289. // this.m_GameClientView.m_CardView.SetCardData(viewID,null,pHandCardData.wCardCount-1,0);
  1290. // }else{
  1291. // this.m_GameClientView.m_CardView.SetCardData(viewID,null,pHandCardData.wCardCount);
  1292. // }
  1293. this.m_GameClientView.m_CardView.SetCardData(viewID, null, pHandCardData.wCardCount);
  1294. }
  1295. }
  1296. var i = pHandCardData.wChairID;
  1297. this.m_cbWeaveCount[i] = pHandCardData.dwWeaveCount;
  1298. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1299. this.m_WeaveItemArray[i][j].wWeaveKind = pHandCardData.WeaveItem[j].wWeaveKind;
  1300. this.m_WeaveItemArray[i][j].cbCenterCard = pHandCardData.WeaveItem[j].cbCenterCard;
  1301. this.m_WeaveItemArray[i][j].cbPublicCard = pHandCardData.WeaveItem[j].cbPublicCard;
  1302. this.m_WeaveItemArray[i][j].wProvideUser = pHandCardData.WeaveItem[j].wProvideUser;
  1303. this.m_WeaveItemArray[i][j].cbCardCount = pHandCardData.WeaveItem[j].cbCardCount;
  1304. for (var k = 0; k < 4; ++k) {
  1305. this.m_WeaveItemArray[i][j].cbCardData[k] = pHandCardData.WeaveItem[j].cbCardData[k];
  1306. this.m_WeaveItemArray[i][j].cbExtraCount[k] = pHandCardData.WeaveItem[j].cbExtraCount[k];
  1307. }
  1308. }
  1309. var ViewID = this.SwitchViewChairID(i);
  1310. for (var j = 0; j < this.m_cbWeaveCount[i]; j++) {
  1311. this.m_GameClientView.m_CardView.SetWeaveData(ViewID, j, this.m_WeaveItemArray[i][j].cbCardData, this.m_WeaveItemArray[i][j].cbCardCount);
  1312. this.m_GameClientView.m_CardView.SetWeaveState(ViewID, j, this.m_WeaveItemArray[i][j]);
  1313. }
  1314. return true;
  1315. },
  1316. //开始选刚
  1317. OnSubStartDouble: function (pData, wDataSize) {
  1318. var pGameDouble = GameDef.CMD_S_Game_Double();
  1319. if (wDataSize != gCByte.Bytes2Str(pGameDouble, pData)) return false;
  1320. this.m_bStustee = false;
  1321. this.m_wBankerUser = pGameDouble.wBankerUser;
  1322. var bankerViewID = this.SwitchViewChairID(this.m_wBankerUser);
  1323. this.m_GameClientView.SetBankerUser(bankerViewID);
  1324. this.m_cbGameStatus = GameDef.GAME_SCENE_DOUBLE;
  1325. this.SetGameClock(INVALID_CHAIR, GameDef.IDI_OPERATE_CARD, this.GetOperateTime());
  1326. this.m_GameClientView.m_BtStart.active = false;
  1327. this.m_GameClientView.m_BtFriend.active = false;
  1328. this.m_BtExit.active = false;
  1329. this.m_BtDissolve.active = true;
  1330. //回放、观战不显示选飘界面
  1331. var kernel = gClientKernel.get();
  1332. if (this.m_ReplayMode || kernel.IsLookonMode()) return true;
  1333. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1334. if (this.GetClientUserItem(i) == null) continue;
  1335. var viewId = this.SwitchViewChairID(i);
  1336. this.m_GameClientView.m_UserInfo[viewId].SetTing(false);
  1337. this.m_GameClientView.m_UserInfo[viewId].SetGang(0);
  1338. this.m_GameClientView.SetTrustee(i, false);
  1339. }
  1340. this.m_GameClientView.SetGangOperator(1);
  1341. return true;
  1342. },
  1343. OnMessageStart: function () {
  1344. //this.ShowHead(true);
  1345. this.KillGameClock();
  1346. //隐藏按钮
  1347. this.m_GameClientView.m_BtStart.active = false;
  1348. //this.m_GameClientView.m_BtFriend.active = false;
  1349. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1350. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1351. //设置界面
  1352. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  1353. this.m_GameClientView.SetBankerUser(INVALID_CHAIR);
  1354. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1355. //关闭显示花,风位
  1356. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1357. if (this.GetClientUserItem(i) == null) continue;
  1358. var OtherViewID = this.SwitchViewChairID(i);
  1359. this.m_GameClientView.m_UserInfo[OtherViewID].SetShowFenganFlower();
  1360. }
  1361. //隐藏骰子
  1362. this.m_GameClientView.ShowDice(false);
  1363. this.m_GameClientView.m_CardView.ResetView();
  1364. //扑克设置
  1365. //游戏变量
  1366. this.m_wCurrentUser = INVALID_CHAIR;
  1367. this.m_wActionMask = 0;
  1368. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1369. this.m_cbWeaveCount[i] = 0;
  1370. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1371. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  1372. }
  1373. }
  1374. //扑克变量
  1375. this.m_cbLeftCardCount = 0;
  1376. for (var i = 0; i < 42; ++i)//GameDef.MAX_INDEX
  1377. {
  1378. this.m_cbCardIndex[i] = 0;
  1379. }
  1380. //if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7)
  1381. //{
  1382. // this.m_GameClientView.SetLeftCardCount(112);
  1383. //}
  1384. //else
  1385. //{
  1386. // this.m_GameClientView.SetLeftCardCount(108);
  1387. //}
  1388. this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY);
  1389. //设置用户动作
  1390. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1391. var kernel = gClientKernel.get();
  1392. if (kernel.IsLookonMode() == false) {
  1393. //发送准备
  1394. this.SendUserReady(null, 0);
  1395. }
  1396. },
  1397. CleanView: function (bOffLineBack) {
  1398. this.Init();
  1399. this.waitOperate = false;
  1400. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1401. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1402. //设置界面
  1403. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  1404. this.m_GameClientView.SetBankerUser(INVALID_CHAIR);
  1405. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1406. //扑克设置
  1407. this.m_GameClientView.m_CardView.ResetView();
  1408. //游戏变量
  1409. this.m_wCurrentUser = INVALID_CHAIR;
  1410. this.m_wActionMask = 0;
  1411. this.m_wTimeOutCount = 0;
  1412. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1413. this.m_cbWeaveCount[i] = 0;
  1414. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1415. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  1416. }
  1417. }
  1418. //扑克变量
  1419. this.m_cbLeftCardCount = 0;
  1420. for (var i = 0; i < 42; ++i)//GameDef.MAX_INDEX
  1421. {
  1422. this.m_cbCardIndex[i] = 0;
  1423. }
  1424. if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) {
  1425. this.m_GameClientView.SetLeftCardCount(112);
  1426. }
  1427. else {
  1428. this.m_GameClientView.SetLeftCardCount(108);
  1429. }
  1430. this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY);
  1431. //设置用户动作
  1432. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1433. },
  1434. //补牌
  1435. OnReplaceCard: function (cbCardData) {
  1436. //构造数据
  1437. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1438. var ReplaceCard = GameDef.CMD_C_ReplaceCard4();
  1439. ReplaceCard.cbCardData[0] = cbCardData;
  1440. ReplaceCard.cbCardCount = 1;
  1441. console.log("补花", cbCardData, ReplaceCard)
  1442. //发送数据
  1443. // if (this.m_ReplayMode) return 0;
  1444. this.SendGameData(GameDef.SUB_C_REPLACE_CARD, ReplaceCard);
  1445. return 0;
  1446. },
  1447. //出牌消息
  1448. OnOutCard: function (HandState, CardIndex, cbCardData, bAdd) {
  1449. //出牌判断
  1450. if (this.m_wCurrentUser != this.GetMeChairID()) return 0;
  1451. // 检查 cbOutCardData 是否大于 55
  1452. // if (cbCardData > 55) return 0;
  1453. //设置变量
  1454. this.m_wCurrentUser = INVALID_CHAIR;
  1455. this.m_wActionMask = 0;
  1456. var cbOutCardData = cbCardData;
  1457. //设置界面
  1458. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1459. //定义变量
  1460. var wMeChairId = this.GetMeChairID();
  1461. var wOutCardUser = this.GetMeChairID();
  1462. var wViewOutCardUser = this.SwitchViewChairID(wOutCardUser);
  1463. // this.PlayActionSound(wMeChairId,this.GetCardStr(cbOutCardData),true);
  1464. //环境设置
  1465. this.KillGameClock();
  1466. //设置变量
  1467. this.m_wCurrentUser = INVALID_CHAIR;
  1468. this.m_wActionMask = 0;
  1469. //设置界面
  1470. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1471. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1472. //构造数据
  1473. var OutCard = GameDef.CMD_C_OutCard();
  1474. OutCard.cbCardData = cbOutCardData;
  1475. OutCard.bAddGang = bAdd == true ? true : false;
  1476. //发送数据
  1477. this.SendGameData(GameDef.SUB_C_OUT_CARD, OutCard);
  1478. return 0;
  1479. },
  1480. //扑克操作
  1481. OnCardOperate: function (wOperateCode, cbOperateCard, cbCardCount, cbIndex) {
  1482. //变量定义
  1483. if (this.m_bFirstCard == false && wOperateCode == 0 && this.m_wCurrentUser == this.GetMeChairID()) {
  1484. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1485. var wViewID = this.SwitchViewChairID(this.GetMeChairID());
  1486. this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true);
  1487. if (this.m_bStustee == false) {
  1488. this.ListenAutoOutCard(this.m_wCurrentUser);
  1489. }
  1490. return;
  1491. }
  1492. //补扭走打牌逻辑
  1493. if (wOperateCode & (GameDef.WIK_ADD_ZFB | GameDef.WIK_ADD_DNJ | GameDef.WIK_ADD_FENG)) {
  1494. this.m_GameClientView.m_CardView.m_HandCard[2].SetOutCard(cbOperateCard[0]);
  1495. this.OnOutCard(0, 0, cbOperateCard[0], true);
  1496. return;
  1497. }
  1498. //删除时间
  1499. this.KillGameClock();
  1500. this.m_wCurrentUser = INVALID_CHAIR;
  1501. this.m_wActionMask = 0;
  1502. //构造数据
  1503. var OperateCard = GameDef.CMD_C_OperateCard();
  1504. OperateCard.wOperateCode = wOperateCode;
  1505. OperateCard.cbOperateCard[0] = cbOperateCard[0];
  1506. OperateCard.cbOperateCard[1] = cbOperateCard[1];
  1507. OperateCard.cbOperateCard[2] = cbOperateCard[2];
  1508. OperateCard.cbOperateCard[3] = cbOperateCard[3];
  1509. OperateCard.cbOperateCount = cbCardCount;
  1510. OperateCard.cbIndex = cbIndex;
  1511. console.log("发送胡牌操作",OperateCard)
  1512. //发送数据
  1513. this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard);
  1514. this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(false);
  1515. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1516. return 0;
  1517. },
  1518. //扑克操作
  1519. OnDoubleOperate: function (cbDouble) {
  1520. this.KillGameClock();
  1521. var Double = GameDef.CMD_C_Double();
  1522. Double.cbDouble = cbDouble;
  1523. //发送数据
  1524. this.SendGameData(GameDef.SUB_C_USER_DOUBLE, Double);
  1525. return 0;
  1526. },
  1527. OnCancelTrustee: function (bTrustee) {
  1528. var Trustee = GameDef.CMD_C_Trustee();
  1529. Trustee.bTrustee = bTrustee;
  1530. //发送数据
  1531. this.SendGameData(GameDef.SUB_C_TRUSTEE, Trustee);
  1532. },
  1533. // //扑克操作
  1534. // OnStusteeControl:function(wParam, lParam){
  1535. // //设置变量
  1536. // this.m_wTimeOutCount=0;
  1537. // if(this.m_bStustee&&lParam==true)return 0;
  1538. // if(!this.m_bStustee&&lParam==0)return 0;
  1539. // //设置状态
  1540. // this.m_bStustee = this.m_bStustee?false:true;
  1541. // //构造数据
  1542. // var Trustee = GameDef.CMD_C_Trustee();
  1543. // Trustee.bTrustee = this.m_bStustee;
  1544. // //发送数据
  1545. // this.SendGameData(GameDef.SUB_C_TRUSTEE, Trustee);
  1546. // return 0;
  1547. // },
  1548. // //离开控制
  1549. // OnLeaveControl: function(event, customData){
  1550. // if(customData != 0){
  1551. // this.m_LeaveControl.ShowView(true);
  1552. // this.m_bLeave = true;
  1553. // }else{
  1554. // this.m_LeaveControl.ShowView(false);
  1555. // this.m_bLeave = false;
  1556. // this.SetGameClock(this.GetMeChairID(),GameDef.IDI_OPERATE_CARD,GameDef.TIME_OPERATE_CARD);
  1557. // }
  1558. // //构造数据
  1559. // var Leave = GameDef.CMD_C_Leave();
  1560. // Leave.bLeave = this.m_bLeave;
  1561. // //发送数据
  1562. // this.SendGameData(GameDef.SUB_C_LEAVE, Leave);
  1563. // return 0;
  1564. // },
  1565. OnNextReady: function () {
  1566. this.KillGameClock();
  1567. //游戏变量
  1568. this.m_lCellScore = 0;
  1569. //设置当前玩家
  1570. this.m_wCurrentUser = INVALID_CHAIR;
  1571. //隐藏按钮
  1572. this.m_GameClientView.m_BtStart.active = false;
  1573. //设置游戏状态
  1574. this.m_GameClientView.SetPlayStatus(INVALID_CHAIR, 0);
  1575. this.m_GameClientView.m_CardView.SetControlInfo(false);
  1576. this.m_GameClientView.SetCurrentUser(INVALID_CHAIR);
  1577. //设置界面
  1578. this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR);
  1579. this.m_GameClientView.SetBankerUser(INVALID_CHAIR);
  1580. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1581. //扑克设置
  1582. this.m_GameClientView.m_CardView.ResetView();
  1583. //游戏变量
  1584. this.m_wCurrentUser = INVALID_CHAIR;
  1585. this.m_wActionMask = 0;
  1586. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1587. this.m_cbWeaveCount[i] = 0;
  1588. for (var j = 0; j < GameDef.MAX_WEAVE; ++j) {
  1589. this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem();
  1590. }
  1591. }
  1592. //扑克变量
  1593. this.m_cbLeftCardCount = 0;
  1594. for (var i = 0; i < 42; ++i) {//GameDef.MAX_INDEX
  1595. this.m_cbCardIndex[i] = 0;
  1596. }
  1597. if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) {
  1598. this.m_GameClientView.SetLeftCardCount(112);
  1599. }
  1600. else {
  1601. this.m_GameClientView.SetLeftCardCount(108);
  1602. }
  1603. this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY);
  1604. //设置用户动作
  1605. this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0);
  1606. this.SendGameData(GameDef.SUB_C_NEXT_READY, null);
  1607. },
  1608. //执行结束
  1609. OnTimeIDI_PERFORM_END: function () {
  1610. this.unschedule(this.OnTimeIDI_PERFORM_END);
  1611. this.m_bEnd = true;
  1612. //成绩界面
  1613. this.ShowGamePrefab("LittleResultBG", GameDef.KIND_ID, this.node, function (Js) {
  1614. this.m_EndLittleView = Js;
  1615. //this.m_EndLittleView.SetTrustee(this.m_bStustee);
  1616. }.bind(this));
  1617. //this.ShowPrefabDLG('LittleResultBG_21201');
  1618. },
  1619. checkTotalEnd: function (bNext) {
  1620. this.m_bEnd = false;
  1621. if (this.m_RoomEnd) {
  1622. if (this.m_wGameProgress > 0 || this.m_ReplayMode) {
  1623. this.RealShowEndView();
  1624. } else {
  1625. this.ShowAlert("該房間已被解散!", Alert_Yes, function (Res) {
  1626. this.m_pTableScene.ExitGame();
  1627. }.bind(this));
  1628. }
  1629. } else {
  1630. var kernel = gClientKernel.get();
  1631. if (!kernel.IsLookonMode() && bNext) this.OnMessageStart();
  1632. }
  1633. this.m_bCanShowBigEnd = true;
  1634. },
  1635. //发送准备
  1636. SendUserReady: function (pBuffer, wDataSize) {
  1637. var kernel = gClientKernel.get();
  1638. if (kernel == 0 || kernel == null || kernel.IsLookonMode()) return;
  1639. kernel.SendSocketData(MDM_GF_FRAME, SUB_GF_USER_READY, pBuffer, wDataSize);
  1640. },
  1641. //出牌声音字符串
  1642. GetCardStr: function (cbCardData) {
  1643. var str = "";
  1644. var color = cbCardData & 0xf0;
  1645. var value = cbCardData & 0x0f;
  1646. if (color == 0)
  1647. str = "W_";
  1648. if (color == 0x10)
  1649. str = "S_";
  1650. if (color == 0x20)
  1651. str = "T_";
  1652. if (color == 0x30)
  1653. str = "F_";
  1654. str = str + value.toString();
  1655. return str;
  1656. },
  1657. //播放操作声音
  1658. PlayActionSound: function (wChairId, byAction, chuyin) {
  1659. if (this.m_bRollBack) return;
  1660. //椅子效验
  1661. var kernel = gClientKernel.get();
  1662. var pIClientUserItem = kernel.GetTableUserItem(wChairId);
  1663. if (pIClientUserItem == null) return;
  1664. console.log(pIClientUserItem)
  1665. console.log(wChairId, byAction, chuyin)
  1666. if (pIClientUserItem.GetGender() == 1) {
  1667. cc.gSoundRes.PlayGameSound("M_" + byAction + "L" + wChairId);
  1668. }
  1669. else {
  1670. cc.gSoundRes.PlayGameSound("W_" + byAction + "L" + wChairId);
  1671. // cc.gSoundRes.PlayGameSound("W_" + byAction);
  1672. }
  1673. if (chuyin) {
  1674. cc.gSoundRes.PlayGameSound("CHUPAI");
  1675. }
  1676. },
  1677. OnExitGame: function () {
  1678. //退出游戏
  1679. this.m_TableViewFrame.ExitGame();
  1680. },
  1681. ExitGame: function () {
  1682. this.OnExitGame();
  1683. },
  1684. //////////////////////////////////////////////////////////////////////////
  1685. //获取用户
  1686. GetClientUserItem: function (wChairID) {
  1687. var kernel = gClientKernel.get();
  1688. if (kernel == 0 || kernel == null || kernel == undefined) return null;
  1689. return kernel.GetTableUserItem(wChairID);
  1690. },
  1691. GetGameStatus: function () {
  1692. var kernel = gClientKernel.get();
  1693. if (!kernel) return GAME_SCENE_FREE;
  1694. return kernel.GetGameStatus();
  1695. },
  1696. IsValidChairID: function (wChairID) {
  1697. if (wChairID >= 0 && wChairID < GameDef.GAME_PLAYER) return true;
  1698. return false;
  1699. },
  1700. // 获取座位
  1701. GetUserChairID: function (dwUserID) {
  1702. for (var i = 0; i < GameDef.GAME_PLAYER; ++i) {
  1703. var pIClientUserItem = this.GetClientUserItem(i);
  1704. if (!pIClientUserItem) continue;
  1705. if (pIClientUserItem.GetUserID() == dwUserID) return i;
  1706. }
  1707. return INVALID_CHAIR;
  1708. },
  1709. SetViewRoomInfo: function (dwServerRules, dwRulesArr) {
  1710. if (this.m_GameClientView)
  1711. this.m_GameClientView.SetViewRoomInfo(dwRulesArr, dwServerRules);
  1712. GameDef.setRule(dwServerRules, dwRulesArr);
  1713. this.updateUserCount();
  1714. this.m_GameClientView.m_CardView.m_CenterViewCtrl.updateNorth();
  1715. //this.m_GameClientView.m_Trustee.string = GameDef.GetTrusteeString(this.m_dwRules);
  1716. },
  1717. OnEventRoomEnd: function (data, datasize) {
  1718. this.m_RoomEnd = GameDef.CMD_S_GameCustomInfo();
  1719. if (datasize != gCByte.Bytes2Str(this.m_RoomEnd, data)) return false;
  1720. console.log("总结束", this.m_RoomEnd)
  1721. this.m_RoomEnd.UserID = new Array();
  1722. //用户成绩
  1723. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  1724. //变量定义
  1725. var pIClientUserItem = this.GetClientUserItem(i);
  1726. if (pIClientUserItem == null) continue;
  1727. this.m_RoomEnd.UserID[i] = pIClientUserItem.GetUserID();
  1728. }
  1729. if (this.m_wGameProgress > 0 || this.m_ReplayMode) {
  1730. this.m_GameClientView.m_BtStart.active = false;
  1731. this.KillGameClock();
  1732. if (this.m_bCanShowBigEnd) {
  1733. this.RealShowEndView();
  1734. }
  1735. } else {
  1736. var self = this;
  1737. this.ShowAlert("該房間已被解散!", Alert_Yes, function (Res) {
  1738. self.m_pTableScene.ExitGame();
  1739. });
  1740. }
  1741. return true;
  1742. },
  1743. //点击安全监测
  1744. OnBtClickedSafe: function () {
  1745. cc.gSoundRes.PlaySound('Button');
  1746. this.ShowGamePrefab('SafeCheck_21201');
  1747. },
  1748. ChangeCardBack: function (index) {
  1749. this.m_CardBack = index;
  1750. if (this.m_GameClientView.m_CardView == null) {
  1751. this.m_GameClientView.Init();
  1752. }
  1753. this.m_GameClientView.m_CardView.ChangeCardBack(this.node, index);
  1754. this.m_GameClientView.ChangeCardBack(index);
  1755. },
  1756. //震动会牌
  1757. ShockHuiPai: function () {
  1758. if (this.m_bRollBack) return;
  1759. this.m_GameClientView.ShockHuiPai();
  1760. },
  1761. updateUserCount: function () {
  1762. this.m_GameClientView.m_CardView.UpdateUserCount();
  1763. this.m_GameClientView.updateUserCount();
  1764. },
  1765. //邀请好友分享
  1766. OnFriend: function () {
  1767. if (cc.sys.isNative) {
  1768. this.ShowPrefabDLG("SharePre");
  1769. } else {
  1770. // this.m_GameClientView.m_FriendBg.node.active = true;
  1771. }
  1772. },
  1773. OnClearScene: function () {
  1774. if (this.m_EndLittleView) this.m_EndLittleView.HideView();
  1775. var CardBack = cc.sys.localStorage.getItem(window.Key_CardColor);
  1776. if (CardBack) {
  1777. this.ChangeCardBack(CardBack);
  1778. } else {
  1779. this.ChangeCardBack(0);
  1780. }
  1781. this.CleanView();
  1782. },
  1783. GetOperateTime: function () {
  1784. if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_15) {
  1785. return GameDef.TIME_OPERATE_CARD_15;
  1786. }
  1787. else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_30) {
  1788. return GameDef.TIME_OPERATE_CARD_30;
  1789. }
  1790. else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_60) {
  1791. return GameDef.TIME_OPERATE_CARD_60;
  1792. }
  1793. else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_NONE) {
  1794. return GameDef.TIME_OPERATE_CARD;
  1795. }
  1796. },
  1797. //测试
  1798. __test: function () {
  1799. this.m_GameClientView.m_CardView.setUserCount(4);
  1800. this.m_GameClientView.m_CardView.SetClientEngine(this);
  1801. this.m_CardData = new Array();
  1802. this.m_CardData =
  1803. [
  1804. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1805. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1806. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1807. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子
  1808. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1809. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1810. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1811. 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子
  1812. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1813. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1814. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1815. 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子
  1816. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1817. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1818. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1819. 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子
  1820. ];
  1821. this.m_GameClientView.m_CardView.SetCardData(0, this.m_CardData, 10);
  1822. this.m_GameClientView.m_CardView.SetCardData(1, this.m_CardData, 10);
  1823. this.m_GameClientView.m_CardView.SetCardData(2, this.m_CardData, 10);
  1824. this.m_GameClientView.m_CardView.SetPositively(true);
  1825. var weaveCard = new Array();
  1826. weaveCard[0] = 0x21;
  1827. weaveCard[1] = 0x21;
  1828. weaveCard[2] = 0x21;
  1829. weaveCard[3] = 0x21;
  1830. this.m_GameClientView.m_CardView.SetWeaveData(0, 0, weaveCard, 4);
  1831. // this.m_GameClientView.m_CardView.SetWeaveData(1,0,weaveCard,4);
  1832. this.m_GameClientView.m_CardView.SetWeaveData(2, 0, weaveCard, 4);
  1833. // this.m_GameClientView.m_CardView.SetWeaveData(3,0,weaveCard,4);
  1834. // this.m_GameClientView.m_CardView.SetCardData(3,cardData,13,0x02);
  1835. this.DiscardDate = 0x22;
  1836. this.m_GameClientView.m_CardView.SetDiscardCardDate(0, this.m_CardData, 33);
  1837. this.m_GameClientView.m_CardView.SetDiscardCardDate(1, this.m_CardData, 33);
  1838. this.m_GameClientView.m_CardView.SetDiscardCardDate(2, this.m_CardData, 33);
  1839. this.m_GameClientView.m_CardView.SetDiscardCardDate(3, this.m_CardData, 33);
  1840. // this.m_GameClientView.m_CardView.PlayDiscard(0,13);
  1841. },
  1842. });