AnalyzeBRTPXieYi.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. var BRTPGameProtocol = require("BRTPGameProtocol")
  2. var Global = require("Global")
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. },
  7. statics: {
  8. analyzeData(m, s, dataview) {
  9. switch (s) {
  10. case BRTPGameProtocol.SUB_S_GAME_FREE: {//空闲状态
  11. return this.analyze_GameFree(dataview);
  12. }
  13. break;
  14. case BRTPGameProtocol.SUB_S_GAME_START: {//游戏开始
  15. return this.analyze_GameStart(dataview);
  16. }
  17. break;
  18. case BRTPGameProtocol.SUB_S_PLACE_JETTON: { //下注
  19. return this.analyze_PlaceJetton(dataview);
  20. }
  21. break;
  22. case BRTPGameProtocol.SUB_S_PLACE_JETTON_FAIL: { //下注失败
  23. return this.analyze_PlaceBetFail(dataview);
  24. }
  25. break;
  26. case BRTPGameProtocol.SUB_S_GAME_END: { //游戏结束
  27. return this.analyze_GameEnd(dataview);
  28. }
  29. break;
  30. case BRTPGameProtocol.SUB_S_APPLY_BANKER: { //申请庄家
  31. return this.analyze_ApplyBanker(dataview);
  32. }
  33. break;
  34. case BRTPGameProtocol.SUB_S_APPLEY_BANKER_FAILURE: { //申请庄家失败
  35. return this.analyze_ApplyFailed(dataview);
  36. }
  37. break;
  38. case BRTPGameProtocol.SUB_S_CHANGE_BANKER: { //切换庄家
  39. return this.analyze_ChangeBanker(dataview);
  40. }
  41. break;
  42. case BRTPGameProtocol.SUB_S_CANCEL_BANKER: { //取消申请庄家
  43. return this.analyze_CancelBanker(dataview);
  44. }
  45. break;
  46. case BRTPGameProtocol.SUB_S_CANCEL_FAILURE:{//取消庄家失败
  47. return this.analyze_CancelFailed(dataview);
  48. }
  49. break;
  50. case BRTPGameProtocol.SUB_S_BANK_LIST:{//庄家列表
  51. return this.analyze_bankerList(dataview);
  52. }
  53. break;
  54. case BRTPGameProtocol.SUB_S_ONLINE_PLAYER:{//在线用户
  55. return this.analyze_UserList(dataview);
  56. }
  57. break;
  58. case BRTPGameProtocol.SUB_S_SEND_RECORD:{//游戏记录
  59. return this.analyze_record(dataview);
  60. }
  61. break;
  62. case BRTPGameProtocol.SUB_S_SEND_WINLOST:{//游戏输赢统计
  63. return this.analyze_winLost(dataview);
  64. }
  65. break;
  66. case BRTPGameProtocol.SUB_S_OTHER_JETTON:{//其它玩家下注
  67. return this.analyze_PlaceJetton(dataview);
  68. }
  69. break;
  70. case BRTPGameProtocol.SUB_S_SEAT_JETTON:{//占位玩家下注
  71. return this.analyze_PlaceJetton(dataview);
  72. }
  73. break;
  74. case BRTPGameProtocol.SUB_S_SEND_CONTROL_INFO:{
  75. return this.analyzeSendControlInfo(dataview);
  76. }
  77. case BRTPGameProtocol.SUB_S_GAME_RECORD_INFO:{
  78. return this.analyzeGameRecord(dataview);
  79. }
  80. default:
  81. break;
  82. }
  83. return null;
  84. },
  85. analyze_StatusFree:function(dataview) {//游戏状态free
  86. var dataList = {};
  87. dataview.pos = 0;
  88. dataList.cbHighTimes = Global.GetInt8(dataview);//是否是高倍场
  89. dataList.cbTimeLeave = Global.GetInt8(dataview);//剩余时间
  90. dataList.nChip = [];
  91. for(let i = 0;i< BRTPGameProtocol.MAX_CHIP_COUNT;i++){
  92. dataList.nChip[i] = Global.GetInt32(dataview);//筹码配置
  93. }
  94. dataList.wSeatUser = [];
  95. for(let i = 0;i< BRTPGameProtocol.MAX_SEAT_COUNT;i++){
  96. dataList.wSeatUser[i] = Global.GetInt16(dataview);//6个椅子玩家的椅子号
  97. }
  98. dataList.wBankerUser = Global.GetInt16(dataview);//当前庄家的GameID
  99. dataList.lBankerScore = Global.unify(Global.GetUint64(dataview));//庄家分数
  100. dataList.lAreaLimitScore = Global.unify(Global.GetUint64(dataview));//区域限制
  101. dataList.lApplyBankerCondition = Global.unify(Global.GetUint64(dataview));//申请条件
  102. dataList.lMinXianHong = Global.unify(Global.GetUint64(dataview));//
  103. dataList.lMaxXianHong = Global.unify(Global.GetUint64(dataview));//
  104. return dataList;
  105. },
  106. analyze_StatusPlay:function(dataview) {//游戏状态play
  107. var dataList = {};
  108. dataview.pos = 0;
  109. dataList.cbHighTimes = Global.GetInt8(dataview);//是否是高倍场
  110. dataList.cbTimeLeave = Global.GetInt8(dataview);//剩余时间
  111. dataList.nChip = [];
  112. for(let i = 0;i< BRTPGameProtocol.MAX_CHIP_COUNT;i++){
  113. dataList.nChip[i] = Global.GetInt32(dataview);//筹码配置
  114. }
  115. dataList.wSeatUser = [];
  116. for(let i = 0;i< BRTPGameProtocol.MAX_SEAT_COUNT;i++){
  117. dataList.wSeatUser[i] = Global.GetInt16(dataview);//6个椅子玩家的椅子号
  118. }
  119. dataList.wBankerUser = Global.GetInt16(dataview);//当前庄家的GameID
  120. dataList.lBankerScore = Global.unify(Global.GetUint64(dataview));//庄家分数
  121. dataList.lAreaLimitScore = Global.unify(Global.GetUint64(dataview));//区域限制
  122. dataList.lApplyBankerCondition = Global.unify(Global.GetUint64(dataview));//申请条件
  123. dataList.lMinXianHong = Global.unify(Global.GetUint64(dataview));//
  124. dataList.lMaxXianHong = Global.unify(Global.GetUint64(dataview));//
  125. dataList.lPlayerJettonScore = [];
  126. for(let i = 0;i< BRTPGameProtocol.AREA_MAX+1;i++){
  127. dataList.lPlayerJettonScore[i] = Global.unify(Global.GetUint64(dataview));//玩家下的注
  128. }
  129. dataList.lAllJettonScore = [];
  130. for(let i = 0;i< BRTPGameProtocol.AREA_MAX+1;i++){
  131. dataList.lAllJettonScore[i] = Global.unify(Global.GetUint64(dataview));//所有玩家下的注
  132. }
  133. dataList.cbTableCardArray = [];
  134. for(let i = 0;i< 5;i++){
  135. dataList.cbTableCardArray[i] = []
  136. for(let j = 0;j< 5;j++){
  137. dataList.cbTableCardArray[i][j] = Global.GetInt8(dataview);//桌面扑克
  138. }
  139. }
  140. dataList.cbCardType = [];
  141. for(let i = 0;i< BRTPGameProtocol.AREA_MAX+1;i++){
  142. dataList.cbCardType[i] = Global.GetInt8(dataview);//牌型
  143. }
  144. dataList.cbResult = [];
  145. for(let i = 0;i< BRTPGameProtocol.AREA_MAX;i++){
  146. dataList.cbResult[i] = Global.GetInt8(dataview);//结果
  147. }
  148. dataList.lBankerWinScore = Global.unify(Global.GetUint64(dataview));//庄家赢分
  149. dataList.lPlayerWinScore = Global.unify(Global.GetUint64(dataview));//玩家赢分
  150. dataList.lSeatUserWinScore = [];
  151. for(let i = 0;i< BRTPGameProtocol.MAX_SEAT_COUNT;i++){
  152. dataList.lSeatUserWinScore[i] = Global.unify(Global.GetUint64(dataview));//坐下的玩家输赢
  153. }
  154. dataList.lPlayerRestScore = Global.unify(Global.GetUint64(dataview));//玩家还剩多少钱
  155. dataList.lBankerRestScore = Global.unify(Global.GetUint64(dataview));//庄家还剩多少钱
  156. dataList.cbStatus = Global.GetInt8(dataview);//当前状态1=下注状态,2=结算状态
  157. return dataList;
  158. },
  159. analyze_GameFree:function(dataview){//空闲时间
  160. var dataList = {};
  161. dataview.pos = 0;
  162. dataList.cbTimeLeave = Global.GetInt32(dataview);//剩余时间
  163. return dataList;
  164. },
  165. analyze_GameStart:function(dataview) {//游戏开始
  166. var dataList = {};
  167. dataview.pos = 0;
  168. // 剩余时间
  169. dataList.cbTimeLeave = Global.GetInt8(dataview);
  170. // 6个椅子玩家的椅子号
  171. dataList.wSeatUser = new Array(BRTPGameProtocol.MAX_SEAT_COUNT);
  172. for(let i = 0;i<BRTPGameProtocol.MAX_SEAT_COUNT;i++){
  173. dataList.wSeatUser[i] = Global.GetInt16(dataview);
  174. }
  175. // 连庄次数
  176. dataList.BankTimes = Global.GetInt32(dataview);
  177. // 当前局下注上限
  178. dataList.lBankerScore = Global.unify(Global.GetUint64(dataview),2);
  179. // 桌面扑克
  180. dataList.cbTableCardArray = new Array(5);
  181. for(let i = 0; i < 5; i++) {
  182. let arr = new Array(5);
  183. for(let j = 0; j < 5; j++) {
  184. arr[j] = Global.GetInt8(dataview);
  185. }
  186. dataList.cbTableCardArray[i] = arr;
  187. }
  188. return dataList;
  189. },
  190. analyze_PlaceJetton:function(dataview) {//用户下注
  191. var dataList = {};
  192. dataview.pos = 0;
  193. dataList.wChairID = Global.GetInt16(dataview);//用户位置
  194. dataList.cbBetArea = Global.GetInt8(dataview);//筹码区域
  195. dataList.lBetScore = Global.unify(Global.GetUint64(dataview));//加注数目
  196. dataList.lPlayerRestScore = Global.unify(Global.GetUint64(dataview));//下注玩家剩余金币
  197. return dataList;
  198. },
  199. analyze_PlaceBetFail:function(dataview) {//下注失败
  200. var dataList = {};
  201. dataview.pos = 0;
  202. dataList.szBuffer = Global.Read2Char(dataview,64);//描述信息
  203. return dataList;
  204. },
  205. analyze_GameEnd:function(dataview) {//游戏结束
  206. var dataList = {};
  207. dataview.pos = 0;
  208. dataList.cbEarlyOpenFlag = Global.GetInt8(dataview);//提前开牌标识
  209. dataList.lPlayAreaScore = [];
  210. for(let i = 0;i< BRTPGameProtocol.AREA_MAX;i++){
  211. dataList.lPlayAreaScore[i] = Global.unify(Global.GetUint64(dataview));//玩家成绩
  212. }
  213. dataList.lPlayerWinScore = Global.unify(Global.GetUint64(dataview));//玩家赢的钱
  214. dataList.lPlayerRestScore = Global.unify(Global.GetUint64(dataview));//玩家还剩多少钱
  215. dataList.lBankerWinScore = Global.unify(Global.GetUint64(dataview));//庄家成绩
  216. dataList.lBankerRestScore = Global.unify(Global.GetUint64(dataview));//庄家还剩多少钱
  217. dataList.lSeatUserWinScore = [];
  218. for(let i = 0;i< BRTPGameProtocol.MAX_SEAT_COUNT;i++){
  219. dataList.lSeatUserWinScore[i] = Global.unify(Global.GetUint64(dataview));//坐下的玩家输赢
  220. }
  221. dataList.cbTableCardArray = [];
  222. for(let i = 0;i< 5;i++){
  223. dataList.cbTableCardArray[i] = [];
  224. for(let j = 0;j<5;j++){
  225. dataList.cbTableCardArray[i][j] = Global.GetUint8(dataview);//桌面扑克
  226. }
  227. }
  228. dataList.cbCardType = [];
  229. for(let i = 0;i< BRTPGameProtocol.AREA_MAX+1;i++){
  230. dataList.cbCardType[i] = Global.GetInt8(dataview);//牌型
  231. }
  232. dataList.cbResult = [];
  233. for(let i = 0;i< BRTPGameProtocol.AREA_MAX;i++){
  234. dataList.cbResult[i] = Global.GetInt8(dataview);//结果
  235. }
  236. dataList.cbTimeLeave = Global.GetInt32(dataview);//剩余时间
  237. dataList.lOtherPlayerWinScore = Global.unify(Global.GetUint64(dataview));//除了座位上玩家其他玩家的输赢总值
  238. dataList.lBankAreaWinScore = [];
  239. for(let i = 0;i< BRTPGameProtocol.AREA_MAX;i++){
  240. dataList.lBankAreaWinScore[i] = Global.unify(Global.GetUint64(dataview));//庄家各个区域的输赢
  241. }
  242. //坐下的玩家输赢
  243. dataList.lSeatUserArerScore = [];
  244. for(let i = 0; i < BRTPGameProtocol.MAX_SEAT_COUNT; i++){
  245. let arr = new Array();
  246. for(let i = 0; i < BRTPGameProtocol.AREA_MAX; i++){
  247. arr.push(Global.unify(Global.GetUint64(dataview)));
  248. }
  249. dataList.lSeatUserArerScore.push(arr);
  250. }
  251. // 倍率
  252. dataList.cbMulti = [];
  253. for(let i = 0;i< BRTPGameProtocol.AREA_MAX;i++){
  254. dataList.cbMulti[i] = Global.GetInt8(dataview);
  255. }
  256. return dataList;
  257. },
  258. analyze_ApplyBanker:function(dataview) {//申请庄家成功
  259. var dataList = {};
  260. dataview.pos = 0;
  261. dataList.wApplyUser = Global.GetInt8(dataview);//申请玩家
  262. return dataList;
  263. },
  264. analyze_ApplyFailed:function(dataview) {//申请庄家失败
  265. var dataList = {};
  266. dataview.pos = 0;
  267. dataList.szBuffer = Global.Read2Char(dataview,64);//描述信息
  268. return dataList;
  269. },
  270. analyze_CancelBanker:function(dataview) {//取消庄家成功
  271. var dataList = {};
  272. dataview.pos = 0;
  273. dataList.wCancelUser = Global.GetInt8(dataview);//取消玩家
  274. return dataList;
  275. },
  276. analyze_CancelFailed:function(dataview) {//取消庄家失败
  277. var dataList = {};
  278. dataview.pos = 0;
  279. dataList.szBuffer = Global.Read2Char(dataview,64);//描述信息
  280. return dataList;
  281. },
  282. analyze_ChangeBanker:function(dataview) {//切换庄家
  283. var dataList = {};
  284. dataview.pos = 0;
  285. dataList.wPreviousBanker = Global.GetInt16(dataview);//上一个当庄玩家
  286. dataList.wBankerUser = Global.GetInt16(dataview);//当庄玩家
  287. dataList.lBankerScore = Global.unify(Global.GetUint64(dataview));//庄家金币
  288. return dataList;
  289. },
  290. analyze_record:function(dataview){//前7局输赢
  291. var dataList = {};
  292. dataview.pos = 0;
  293. dataList.record = [];
  294. var cnt = dataview.byteLength/4;
  295. for(var i = 0;i<cnt;i++){
  296. var data = {};
  297. data.bWinTian = Global.GetInt8(dataview);
  298. data.bWinDi = Global.GetInt8(dataview);
  299. data.bWinXuan = Global.GetInt8(dataview);
  300. data.bWinHuang = Global.GetInt8(dataview);
  301. dataList.record.push(data);
  302. }
  303. return dataList;
  304. },
  305. analyze_winLost:function(dataview){//
  306. var dataList = {};
  307. dataview.pos = 0;
  308. dataList.record = [];
  309. var cnt = dataview.byteLength/40;
  310. for(var i = 0;i<cnt;i++){
  311. var data = {};
  312. data.lDrawCount = Global.GetUint64(dataview);
  313. data.lWinTian = Global.GetUint64(dataview);
  314. data.lWinDi = Global.GetUint64(dataview);
  315. data.lWinXuan = Global.GetUint64(dataview);
  316. data.lWinHuang = Global.GetUint64(dataview);
  317. dataList.record.push(data);
  318. }
  319. return dataList;
  320. },
  321. analyze_bankerList:function(dataview) {//玩家列表
  322. var dataList = {};
  323. dataview.pos = 0;
  324. dataList.BankLists = [];
  325. for(let i = 0;i<20;i++){
  326. dataList.BankLists[i] = Global.GetInt32(dataview);
  327. }
  328. return dataList;
  329. },
  330. analyze_UserList:function(dataview) {//玩家列表
  331. var dataList = {};
  332. dataview.pos = 0;
  333. dataList.wCount = Global.GetInt8(dataview);//数组数量
  334. dataList.bEnd = Global.GetInt8(dataview);//是否结束
  335. dataList.cbIndex = [];
  336. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  337. dataList.cbIndex[i] = Global.GetInt8(dataview);//排名
  338. }
  339. dataList.szUserNick = [];
  340. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  341. dataList.szUserNick[i] = Global.Read2Char(dataview,32);//昵称
  342. }
  343. dataList.lBetScore = [];
  344. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  345. dataList.lBetScore[i] = Global.unify(Global.GetUint64(dataview));//近20局下注金额
  346. }
  347. dataList.cbWinTimes = [];
  348. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  349. dataList.cbWinTimes[i] = Global.GetUint64(dataview);//近20局赢了多少局
  350. }
  351. dataList.lUserScore = [];
  352. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  353. dataList.lUserScore[i] = Global.unify(Global.GetUint64(dataview));//玩家金币
  354. }
  355. dataList.wFaceID = [];
  356. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  357. dataList.wFaceID[i] = Global.GetUint8(dataview);//玩家头像
  358. }
  359. dataList.wChairID = [];
  360. for(let i = 0;i< BRTPGameProtocol.USER_LIST_COUNT;i++){
  361. dataList.wChairID[i] = Global.GetUint16(dataview);//
  362. }
  363. return dataList;
  364. },
  365. analyze_UserListInfo:function(dataview) {//玩家列表单个数据
  366. var dataList = {};
  367. dataview.pos = 0;
  368. dataList.wWinNum = Global.GetUint16(dataview);//获胜次数
  369. dataList.lAllBet = Global.unify(Global.GetUint64(dataview));//下注分数
  370. dataList.lUserScore = Global.unify(Global.GetUint64(dataview));//用户积分
  371. dataList.szNickName = Global.gbk2Utf8(Global.Read2Char(dataview,32));//用户昵称
  372. dataList.wFaceID = Global.GetUint8(dataview);//玩家头像
  373. dataList.wChairID = Global.GetUint16(dataview);//
  374. return dataList;
  375. },
  376. analyzeSendControlInfo:function(dataview) {
  377. const areaNum = 4;
  378. let data = {};
  379. dataview.pos = 0;
  380. data.areaInfo = new Array(areaNum);
  381. for(let i = 0; i < areaNum; ++i) {
  382. let item = {};
  383. item.RoomSha = Global.GetInt16(dataview); // WORD 房间杀率
  384. item.RoomWin = Global.GetInt16(dataview); // WORD 系统赢
  385. item.RoomLost = Global.GetInt16(dataview); // WORD 系统输
  386. item.RoomSuiRate = Global.GetInt16(dataview); // WORD 当前随到
  387. item.RoomResult = Global.GetInt8(dataview); // BYTE 控制结果 0无控制 1系统赢 2系统输
  388. item.QunState = Global.GetInt8(dataview); // BYTE 是否需要判断控制 0不需要1需要
  389. item.QunStock = Global.unify(Global.Read2ll(dataview)); // SCORE 群控库存
  390. item.IsDanKong = Global.GetInt8(dataview); // BYTE 单控是否生效 1是
  391. item.DanRate = Global.GetInt16(dataview); // WORD 单控概率
  392. item.DanStocks = Global.unify(Global.GetInt32(dataview)); // int 单控库存
  393. item.DanSuiRate = Global.GetInt16(dataview); // WORD 单控随机值
  394. item.DanType = Global.GetInt8(dataview); // BYTE 控制结果0无控制 1控制系统赢 2控制系统输
  395. item.DanMinBet = Global.unify(Global.GetInt32(dataview)); // int 单控门槛
  396. item.szNickName = Global.gbk2Utf8(Global.Read2Char(dataview,32)); // TCHAR 单控玩家
  397. data.areaInfo[i] = item;
  398. }
  399. return data;
  400. },
  401. analyzeGameRecord: function(dataview) {
  402. dataview.pos = 0;
  403. let data = [];
  404. let count = Global.GetInt8(dataview);
  405. for(let i = 0; i < count; i++) {
  406. let item = {};
  407. item.nBet = Global.unify(Global.GetInt32(dataview));
  408. item.nWimLost = Global.unify(Global.GetInt32(dataview));
  409. item.nTime = new Date(Global.GetInt32(dataview) * 1000); // 服务器单位秒
  410. data.push(item);
  411. }
  412. return data;
  413. }
  414. },
  415. start () {
  416. },
  417. });