GameClientEngine_21201.js 91 KB

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