AnalyzeTrucoXieYi.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. var GameProtocol = require("TrucoGameProtocol")
  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_GAME_CONTINUE: { //
  20. return this.analyze_GameContinue(dataview);
  21. }
  22. case GameProtocol.SUB_S_OPERATE_FAIL: { //操作失败
  23. return this.analyze_OperateFail(dataview);
  24. }
  25. case GameProtocol.SUB_S_TRUCO: {
  26. return this.analyze_GameTruco(dataview);
  27. }
  28. case GameProtocol.SUB_S_TRUCO_CHOOSE: {
  29. return this.analyze_GameTrucoChoose(dataview);
  30. }
  31. case GameProtocol.SUB_S_TRUCO_SET: {
  32. return this.analyze_TrucoSet(dataview);
  33. }
  34. case GameProtocol.SUB_S_COMPARE_CARD: {
  35. return this.analyze_CompareCard(dataview);
  36. }
  37. case GameProtocol.SUB_S_ROUND_START: { //
  38. return this.analyze_RoundStart(dataview);
  39. }
  40. case GameProtocol.SUB_S_OUT_CARD: { //玩家出牌
  41. return this.analyze_OutCard(dataview);
  42. }
  43. case GameProtocol.SUB_S_WAIT_START:{//等待开始
  44. return this.analyze_waitStart(dataview);
  45. }
  46. case GameProtocol.SUB_S_TRUSTEE_STATUS:{
  47. return this.analyze_Trustee(dataview);
  48. }
  49. case GameProtocol.SUB_S_FORCE_LEAVE_CHOOSE:{
  50. return this.analyze_ForceLeave(dataview);
  51. }
  52. case GameProtocol.SUB_S_CELL_SCORE:{
  53. return this.analyze_CellScore(dataview);
  54. }
  55. case GameProtocol.SUB_S_FINAL_ROUND:{
  56. return this.analyze_FinalRound(dataview);
  57. }
  58. case GameProtocol.SUB_S_FINAL_CHOOSE:{
  59. return this.analyze_FinalChoose(dataview);
  60. }
  61. default:
  62. break;
  63. }
  64. return null;
  65. },
  66. analyze_StatusFree:function(dataview) {//游戏状态free
  67. var dataList = {};
  68. dataview.pos = 0;
  69. dataList.lCellScore = Global.GetInt32(dataview);//底分
  70. return dataList;
  71. },
  72. analyze_StatusPlay:function(dataview) {//游戏状态play
  73. var dataList = {};
  74. dataview.pos = 0;
  75. dataList.lCellScore = Global.GetInt32(dataview);//底分
  76. dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
  77. dataList.cbMagicShowCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
  78. dataList.cbMagicCardValue = Global.GetInt8(dataview);//明牌堆翻的第一张牌
  79. dataList.cbCardCount = [];
  80. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  81. dataList.cbCardCount[i] = Global.GetInt8(dataview);//用户状态
  82. }
  83. dataList.cbCardOut = [];
  84. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  85. dataList.cbCardOut[i] = Global.GetInt8(dataview);//用户状态
  86. }
  87. dataList.cbCardData = [];
  88. //0,1,2 空闲,游戏,放弃
  89. for(let i = 0;i<GameProtocol.HAND_CARD_COUNT;i++){
  90. dataList.cbCardData[i] = Global.GetInt8(dataview);//用户状态
  91. }
  92. dataList.cbUserTrustee = [];
  93. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  94. dataList.cbUserTrustee[i] = Global.GetInt8(dataview);//用户状态
  95. }
  96. dataList.cbTimeCount = Global.GetInt8(dataview);
  97. dataList.cbTeam = Global.GetInt8(dataview);
  98. dataList.cbPlayCount = Global.GetInt8(dataview);
  99. dataList.cbNowScore = Global.GetInt8(dataview);
  100. dataList.cbTrucoScore = Global.GetInt8(dataview);
  101. dataList.cbTruco = Global.GetInt8(dataview);
  102. dataList.cbTrucoStatus = [];
  103. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  104. dataList.cbTrucoStatus[i] = Global.GetInt8(dataview);//用户状态
  105. }
  106. dataList.cbRoundResult = [];
  107. for(let i = 0;i<GameProtocol.ROUND_MAX;i++){
  108. dataList.cbRoundResult[i] = [];
  109. for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
  110. dataList.cbRoundResult[i][j] = Global.GetInt8(dataview);
  111. }
  112. }
  113. dataList.cTotalScore = [];
  114. for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
  115. dataList.cTotalScore[j] = Global.GetInt8(dataview);
  116. }
  117. dataList.wTrucoChair = Global.GetInt16(dataview);
  118. dataList.cbForceLeaveChoose = [];
  119. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  120. dataList.cbForceLeaveChoose[i] = Global.GetInt8(dataview);//用户状态
  121. }
  122. dataList.nCellMulti = Global.GetInt32(dataview);
  123. dataList.wFirstUser = Global.GetInt32(dataview);
  124. dataList.cbFinalRound = Global.GetInt8(dataview);
  125. dataList.cbFinalTeam = Global.GetInt8(dataview);
  126. dataList.cbFinalStatus = [];
  127. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  128. dataList.cbFinalStatus[i] = Global.GetInt8(dataview);//用户状态
  129. }
  130. return dataList;
  131. },
  132. analyze_GameFree:function(dataview){//空闲时间
  133. var dataList = {};
  134. dataview.pos = 0;
  135. return dataList;
  136. },
  137. analyze_ForceLeave:function(dataview){
  138. var dataList = {};
  139. dataview.pos = 0;
  140. return dataList;
  141. },
  142. analyze_GameStart:function(dataview) {//游戏开始
  143. var dataList = {};
  144. dataview.pos = 0;
  145. dataList.cbTeam = Global.GetInt8(dataview);//
  146. return dataList;
  147. },
  148. analyze_GameEnd:function(dataview) {//游戏结束
  149. var dataList = {};
  150. dataview.pos = 0;
  151. dataList.cbWinSide = Global.GetInt8(dataview);
  152. dataList.lUserScore = [];//玩家成绩
  153. for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
  154. dataList.lUserScore.push(Global.GetInt32(dataview));
  155. }
  156. dataList.cTotalScore = [];
  157. for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
  158. dataList.cTotalScore[j] = Global.GetInt8(dataview);
  159. }
  160. return dataList;
  161. },
  162. analyze_GameContinue(dataview) {
  163. var dataList = {};
  164. dataview.pos = 0;
  165. dataList.wCurrentUser = Global.GetInt16(dataview);
  166. dataList.cbTimeCount = Global.GetInt8(dataview);
  167. return dataList;
  168. },
  169. analyze_OperateFail:function(dataview){//操作失败
  170. var dataList = {};
  171. dataview.pos = 0;
  172. //dataList.OperateType = Global.GetInt8(dataview);//操作类型
  173. //dataList.szDescribeString = Global.Read2Char(dataview,128);//错误消息
  174. dataList.cbFailCode = Global.GetInt8(dataview);//错误类型;
  175. return dataList;
  176. },
  177. analyze_GameTruco:function(dataview){//
  178. var dataList = {};
  179. dataview.pos = 0;
  180. dataList.wTrucoUser = Global.GetInt16(dataview);//抓牌玩家
  181. dataList.cbTrucoSide = Global.GetInt8(dataview);//
  182. dataList.cbTrucoScore = Global.GetInt8(dataview);//
  183. dataList.cbTimeCount = Global.GetInt8(dataview);//
  184. return dataList;
  185. },
  186. analyze_GameTrucoChoose:function(dataview){//
  187. var dataList = {};
  188. dataview.pos = 0;
  189. dataList.wTrucoUser = Global.GetInt16(dataview);//抓牌玩家
  190. dataList.cbTrucoChoose = Global.GetInt8(dataview);//
  191. return dataList;
  192. },
  193. analyze_TrucoSet(dataview) {
  194. var dataList = {};
  195. dataview.pos = 0;
  196. dataList.cbTrucoScore = Global.GetInt8(dataview);
  197. return dataList;
  198. },
  199. analyze_CompareCard(dataview) {
  200. var dataList = {};
  201. dataview.pos = 0;
  202. dataList.cbWinSide = Global.GetInt8(dataview);//抓牌玩家
  203. dataList.cbRoundScore = [];//
  204. for(let i = 0; i < GameProtocol.SIDE_NUM; ++i) {
  205. dataList.cbRoundScore.push(Global.GetInt8(dataview));
  206. }
  207. dataList.cbRoundResult = [];
  208. for(let i = 0;i<GameProtocol.ROUND_MAX;i++){
  209. dataList.cbRoundResult[i] = [];
  210. for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
  211. dataList.cbRoundResult[i][j] = Global.GetInt8(dataview);
  212. }
  213. }
  214. dataList.wWinChairID = Global.GetInt16(dataview);
  215. dataList.cbPlayCount = Global.GetInt8(dataview);
  216. dataList.cbTimeCount = Global.GetInt8(dataview);
  217. dataList.cbRoundEnd = Global.GetInt8(dataview);
  218. return dataList;
  219. },
  220. analyze_RoundStart(dataview) {
  221. var dataList = {};
  222. dataview.pos = 0;
  223. dataList.wCurrentUser = Global.GetInt16(dataview);//抓牌玩家
  224. dataList.cbMagicShowCardData = Global.GetInt8(dataview);//
  225. dataList.cbMagicCardValue = Global.GetInt8(dataview);//
  226. dataList.cbCardData = [];
  227. for(let i = 0; i < GameProtocol.HAND_CARD_COUNT; ++i) {
  228. dataList.cbCardData.push(Global.GetInt8(dataview));
  229. }
  230. dataList.cbTimeCount = Global.GetInt8(dataview);//
  231. dataList.cTotalScore = [];
  232. for(let i = 0; i < GameProtocol.SIDE_NUM; ++i) {
  233. dataList.cTotalScore.push(Global.GetInt8(dataview));
  234. }
  235. // dataList.cbFinalRound = Global.GetInt8(dataview);
  236. // dataList.cbFinalTeam = Global.GetInt8(dataview);
  237. return dataList;
  238. },
  239. analyze_OutCard:function(dataview){//出牌结果
  240. var dataList = {};
  241. dataview.pos = 0;
  242. dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
  243. dataList.wOutCardUser = Global.GetInt16(dataview);//出牌玩家
  244. dataList.cbOutCardData = Global.GetInt8(dataview);//出牌数据
  245. dataList.cbTimeCount = Global.GetInt8(dataview);
  246. return dataList;
  247. },
  248. analyze_CellScore(dataview) {
  249. var dataList = {};
  250. dataview.pos = 0;
  251. dataList.nMulti = Global.GetInt32(dataview);
  252. return dataList;
  253. },
  254. analyze_FinalRound(dataview) {
  255. var dataList = {};
  256. dataview.pos = 0;
  257. dataList.cbTeamCardData = [];
  258. for(let i = 0; i < GameProtocol.HAND_CARD_COUNT; ++i) {
  259. dataList.cbTeamCardData.push(Global.GetInt8(dataview));
  260. }
  261. dataList.cbTimeCount = Global.GetInt8(dataview);
  262. dataList.cbFinalRound = Global.GetInt8(dataview);
  263. dataList.cbFinalTeam = Global.GetInt8(dataview);
  264. return dataList;
  265. },
  266. analyze_FinalChoose(dataview) {
  267. var dataList = {};
  268. dataview.pos = 0;
  269. dataList.wFinalUser = Global.GetInt16(dataview);
  270. dataList.cbFinalChoose = Global.GetInt8(dataview);
  271. return dataList;
  272. },
  273. analyze_waitStart:function(dataview){
  274. var dataList = {};
  275. dataview.pos = 0;
  276. dataList.cbTimeCount = Global.GetInt8(dataview);
  277. return dataList;
  278. },
  279. analyze_Trustee(dataview) {
  280. var dataList = {};
  281. dataview.pos = 0;
  282. dataList.wChairID = Global.GetInt16(dataview);
  283. dataList.cbStatus = Global.GetInt8(dataview);
  284. return dataList;
  285. }
  286. },
  287. start () {
  288. },
  289. // update (dt) {},
  290. });