AnalyzeCachetaXieYi.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. var GameProtocol = require("CachetaGameProtocol")
  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 GameProtocol.SUB_S_GAME_FREE: {//空闲状态
  11. return this.analyze_GameFree(dataview);
  12. }
  13. case GameProtocol.SUB_S_GAME_START: {//游戏开始
  14. return this.analyze_GameStart(dataview);
  15. }
  16. case GameProtocol.SUB_S_GAME_END: { //游戏结束
  17. return this.analyze_GameEnd(dataview);
  18. }
  19. case GameProtocol.SUB_S_STATE_INFO: { //游戏结束
  20. return this.analyze_StateInfo(dataview);
  21. }
  22. case GameProtocol.SUB_S_OPERATE_FAIL: { //操作失败
  23. return this.analyze_OperateFail(dataview);
  24. }
  25. case GameProtocol.SUB_S_GET_CARD: { //玩家抓牌
  26. return this.analyze_GetCard(dataview);
  27. }
  28. case GameProtocol.SUB_S_OUT_CARD: { //玩家出牌
  29. return this.analyze_OutCard(dataview);
  30. }
  31. case GameProtocol.SUB_S_MING_CARD: { //玩家出牌
  32. return this.analyze_MingCard(dataview);
  33. }
  34. case GameProtocol.SUB_S_WAIT_START:{//等待开始
  35. return this.analyze_waitStart(dataview);
  36. }
  37. case GameProtocol.SUB_S_GAME_INFO:{
  38. return this.analyze_GameInfo(dataview);
  39. }
  40. case GameProtocol.SUB_S_TRUSTEE_STATUS:{
  41. return this.analyze_Trustee(dataview);
  42. }
  43. default:
  44. break;
  45. }
  46. return null;
  47. },
  48. analyze_StatusFree:function(dataview) {//游戏状态free
  49. var dataList = {};
  50. dataview.pos = 0;
  51. dataList.lCellScore = Global.GetInt32(dataview);//底分
  52. return dataList;
  53. },
  54. analyze_StatusPlay:function(dataview) {//游戏状态play
  55. var dataList = {};
  56. dataview.pos = 0;
  57. dataList.lCellScore = Global.GetInt32(dataview);//底分
  58. dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
  59. dataList.cbPlayStatusArr = [];
  60. //0,1,2 空闲,游戏,放弃
  61. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  62. dataList.cbPlayStatusArr[i] = Global.GetInt8(dataview);//用户状态
  63. }
  64. dataList.cbGetCardData = Global.GetInt8(dataview);//抓取的扑克
  65. dataList.cbOpenCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
  66. dataList.cbMagicShowCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
  67. dataList.cbMagicCardData = [];
  68. dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
  69. dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
  70. dataList.cbCardData = [];//玩家牌组
  71. for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
  72. dataList.cbCardData.push(Global.GetInt8(dataview));
  73. }
  74. dataList.cbTingUser = [];
  75. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  76. dataList.cbTingUser[i] = Global.GetInt8(dataview);//用户状态
  77. }
  78. dataList.cbTimeCount = Global.GetInt8(dataview);
  79. dataList.cbTableCardCount = Global.GetInt8(dataview);
  80. dataList.cbUserTrustee = [];
  81. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  82. dataList.cbUserTrustee[i] = Global.GetInt8(dataview);//用户状态
  83. }
  84. return dataList;
  85. },
  86. analyze_GameFree:function(dataview){//空闲时间
  87. var dataList = {};
  88. dataview.pos = 0;
  89. return dataList;
  90. },
  91. analyze_GameStart:function(dataview) {//游戏开始
  92. var dataList = {};
  93. dataview.pos = 0;
  94. dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
  95. dataList.cbMagicShowCardData = Global.GetInt8(dataview);
  96. dataList.cbMagicCardData = [];
  97. dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
  98. dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
  99. dataList.cbCardData = [];
  100. for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
  101. dataList.cbCardData.push(Global.GetInt8(dataview));
  102. }
  103. dataList.cbTimeCount = Global.GetInt8(dataview);
  104. dataList.cbPlayStateArr = [];
  105. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  106. dataList.cbPlayStateArr[i] = Global.GetInt8(dataview);//用户状态
  107. }
  108. return dataList;
  109. },
  110. analyze_GameEnd:function(dataview) {//游戏结束
  111. var dataList = {};
  112. dataview.pos = 0;
  113. dataList.wWinner = Global.GetInt16(dataview);//赢家
  114. dataList.cbHuType = Global.GetInt8(dataview);//0:流局,1:9张,2:10张
  115. dataList.cbHuDst = Global.GetInt8(dataview);//0:流局,1:自摸 2 点炮
  116. dataList.PlayerInfo = [];
  117. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  118. let Info = {};
  119. Info.dwUserID = Global.GetInt32(dataview);
  120. Info.szNickName = Global.gbk2Utf8(Global.Read2Char(dataview,32));
  121. Info.wFaceID = Global.GetInt16(dataview);
  122. dataList.PlayerInfo.push(Info);
  123. }
  124. dataList.lUserScore = [];//玩家成绩
  125. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  126. dataList.lUserScore.push(Global.GetInt32(dataview));
  127. }
  128. dataList.cbCardData = [];
  129. for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
  130. dataList.cbCardData[idx] = [];
  131. for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
  132. // var teamData = {};
  133. // teamData.cbCardType = Global.GetInt8(dataview);
  134. // teamData.lLostScore = Global.GetInt32(dataview);
  135. // teamData.cbCardCount = Global.GetInt8(dataview);
  136. // teamData.cbCardDataArr = [];
  137. // for(let j = 0;j < GameProtocol.HAND_CARD_COUNT+1;j++){
  138. // let cardData = Global.GetInt8(dataview);
  139. // teamData.cbCardDataArr.push(cardData);
  140. // }
  141. dataList.cbCardData[idx].push(Global.GetInt8(dataview));
  142. }
  143. }
  144. dataList.cbHuCardData = [];
  145. for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
  146. dataList.cbHuCardData.push(Global.GetInt8(dataview));
  147. }
  148. return dataList;
  149. },
  150. analyze_StateInfo(dataview) {
  151. var dataList = {};
  152. dataview.pos = 0;
  153. dataList.cbHu10 = Global.GetInt8(dataview);
  154. dataList.cbHu9 = Global.GetInt8(dataview);
  155. dataList.cbHuCard = [];
  156. for(let i = 0; i < GameProtocol.HAND_CARD_COUNT+1; ++i) {
  157. dataList.cbHuCard.push(Global.GetInt8(dataview));
  158. }
  159. dataList.cbTing = Global.GetInt8(dataview);
  160. dataList.cbTingCard = [];
  161. for(let i = 0; i < GameProtocol.HAND_CARD_COUNT+1; ++i) {
  162. dataList.cbTingCard.push(Global.GetInt8(dataview));
  163. }
  164. return dataList;
  165. },
  166. analyze_OperateFail:function(dataview){//操作失败
  167. var dataList = {};
  168. dataview.pos = 0;
  169. //dataList.OperateType = Global.GetInt8(dataview);//操作类型
  170. //dataList.szDescribeString = Global.Read2Char(dataview,128);//错误消息
  171. dataList.cbFailCode = Global.GetInt8(dataview);//错误类型;
  172. return dataList;
  173. },
  174. analyze_GetCard:function(dataview){//抓牌结果
  175. var dataList = {};
  176. dataview.pos = 0;
  177. dataList.wGetCardUser = Global.GetInt16(dataview);//抓牌玩家
  178. dataList.bGetTableCard = Global.GetInt8(dataview);//抓桌面牌(true=暗牌堆,false=明牌堆)
  179. dataList.cbGetCardData = Global.GetInt8(dataview);//抓牌数据
  180. dataList.cbOpenCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
  181. dataList.cbTimeCount = Global.GetInt8(dataview);
  182. return dataList;
  183. },
  184. analyze_OutCard:function(dataview){//出牌结果
  185. var dataList = {};
  186. dataview.pos = 0;
  187. dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
  188. dataList.wOutCardUser = Global.GetInt16(dataview);//出牌玩家
  189. dataList.cbOutCardData = Global.GetInt8(dataview);//出牌数据
  190. dataList.cbOpenCardData = Global.GetInt8(dataview);//0出牌,1胡牌,2诈胡
  191. dataList.bTing = Global.GetInt8(dataview);//听牌标记
  192. dataList.cbTimeCount = Global.GetInt8(dataview);
  193. return dataList;
  194. },
  195. analyze_MingCard(dataview) {
  196. var dataList = {};
  197. dataview.pos = 0;
  198. dataList.cbTingCard = [];
  199. for(let i = 0; i < 104; ++i) {
  200. dataList.cbTingCard.push(Global.GetInt8(dataview));
  201. }
  202. // dataList.bTing = Global.GetInt8(dataview);//听牌标记
  203. return dataList;
  204. },
  205. analyze_waitStart:function(dataview){
  206. var dataList = {};
  207. dataview.pos = 0;
  208. dataList.cbTimeCount = Global.GetInt8(dataview);
  209. return dataList;
  210. },
  211. analyze_GameInfo(dataview) {
  212. var dataList = {};
  213. dataview.pos = 0;
  214. dataList.cbHandCardData = [];
  215. for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
  216. dataList.cbHandCardData[idx] = [];
  217. for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
  218. dataList.cbHandCardData[idx].push(Global.GetInt8(dataview));
  219. }
  220. }
  221. let tagControlInfo = {};
  222. tagControlInfo.cbControlType = Global.GetInt8(dataview);
  223. tagControlInfo.cbControlReslut = Global.GetInt8(dataview);
  224. tagControlInfo.wControlUser = Global.GetInt16(dataview);
  225. tagControlInfo.wControlWinUser = Global.GetInt16(dataview);
  226. tagControlInfo.wControlLoseUser = Global.GetInt16(dataview);
  227. tagControlInfo.nControlRadian = [];
  228. for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
  229. tagControlInfo.nControlRadian[idx] = Global.GetInt32(dataview);
  230. }
  231. tagControlInfo.nRnd = Global.GetInt32(dataview);
  232. tagControlInfo.nControlValue = [];
  233. for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
  234. tagControlInfo.nControlValue[idx] = Global.GetInt32(dataview);
  235. }
  236. tagControlInfo.lRet = [];
  237. for(let idx = 0;idx<7;idx++){
  238. tagControlInfo.lRet[idx] = Global.Read2ll(dataview);
  239. }
  240. dataList.tagControlInfo = tagControlInfo;
  241. return dataList;
  242. },
  243. analyze_Trustee(dataview) {
  244. var dataList = {};
  245. dataview.pos = 0;
  246. dataList.wChairID = Global.GetInt16(dataview);
  247. dataList.cbStatus = Global.GetInt8(dataview);
  248. return dataList;
  249. }
  250. },
  251. start () {
  252. },
  253. // update (dt) {},
  254. });