123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- var GameProtocol = require("TrucoGameProtocol")
- var Global = require("Global");
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- statics: {
- analyzeData(m, s, dataview) {
- switch (s) {
- case GameProtocol.SUB_S_GAME_FREE: {//空闲状态
- return this.analyze_GameFree(dataview);
- }
- case GameProtocol.SUB_S_GAME_START: {//游戏开始
- return this.analyze_GameStart(dataview);
- }
- case GameProtocol.SUB_S_GAME_END: { //游戏结束
- return this.analyze_GameEnd(dataview);
- }
- case GameProtocol.SUB_S_GAME_CONTINUE: { //
- return this.analyze_GameContinue(dataview);
- }
- case GameProtocol.SUB_S_OPERATE_FAIL: { //操作失败
- return this.analyze_OperateFail(dataview);
- }
- case GameProtocol.SUB_S_TRUCO: {
- return this.analyze_GameTruco(dataview);
- }
- case GameProtocol.SUB_S_TRUCO_CHOOSE: {
- return this.analyze_GameTrucoChoose(dataview);
- }
- case GameProtocol.SUB_S_TRUCO_SET: {
- return this.analyze_TrucoSet(dataview);
- }
- case GameProtocol.SUB_S_COMPARE_CARD: {
- return this.analyze_CompareCard(dataview);
- }
- case GameProtocol.SUB_S_ROUND_START: { //
- return this.analyze_RoundStart(dataview);
- }
- case GameProtocol.SUB_S_OUT_CARD: { //玩家出牌
- return this.analyze_OutCard(dataview);
- }
- case GameProtocol.SUB_S_WAIT_START:{//等待开始
- return this.analyze_waitStart(dataview);
- }
- case GameProtocol.SUB_S_TRUSTEE_STATUS:{
- return this.analyze_Trustee(dataview);
- }
- case GameProtocol.SUB_S_FORCE_LEAVE_CHOOSE:{
- return this.analyze_ForceLeave(dataview);
- }
- case GameProtocol.SUB_S_CELL_SCORE:{
- return this.analyze_CellScore(dataview);
- }
- case GameProtocol.SUB_S_FINAL_ROUND:{
- return this.analyze_FinalRound(dataview);
- }
- case GameProtocol.SUB_S_FINAL_CHOOSE:{
- return this.analyze_FinalChoose(dataview);
- }
- default:
- break;
- }
- return null;
- },
- analyze_StatusFree:function(dataview) {//游戏状态free
- var dataList = {};
- dataview.pos = 0;
- dataList.lCellScore = Global.GetInt32(dataview);//底分
-
- return dataList;
- },
- analyze_StatusPlay:function(dataview) {//游戏状态play
- var dataList = {};
- dataview.pos = 0;
- dataList.lCellScore = Global.GetInt32(dataview);//底分
- dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
- dataList.cbMagicShowCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
- dataList.cbMagicCardValue = Global.GetInt8(dataview);//明牌堆翻的第一张牌
- dataList.cbCardCount = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbCardCount[i] = Global.GetInt8(dataview);//用户状态
- }
- dataList.cbCardOut = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbCardOut[i] = Global.GetInt8(dataview);//用户状态
- }
- dataList.cbCardData = [];
- //0,1,2 空闲,游戏,放弃
- for(let i = 0;i<GameProtocol.HAND_CARD_COUNT;i++){
- dataList.cbCardData[i] = Global.GetInt8(dataview);//用户状态
- }
- dataList.cbUserTrustee = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbUserTrustee[i] = Global.GetInt8(dataview);//用户状态
- }
- dataList.cbTimeCount = Global.GetInt8(dataview);
- dataList.cbTeam = Global.GetInt8(dataview);
-
- dataList.cbPlayCount = Global.GetInt8(dataview);
- dataList.cbNowScore = Global.GetInt8(dataview);
- dataList.cbTrucoScore = Global.GetInt8(dataview);
- dataList.cbTruco = Global.GetInt8(dataview);
- dataList.cbTrucoStatus = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbTrucoStatus[i] = Global.GetInt8(dataview);//用户状态
- }
-
- dataList.cbRoundResult = [];
- for(let i = 0;i<GameProtocol.ROUND_MAX;i++){
- dataList.cbRoundResult[i] = [];
- for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
- dataList.cbRoundResult[i][j] = Global.GetInt8(dataview);
- }
- }
- dataList.cTotalScore = [];
- for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
- dataList.cTotalScore[j] = Global.GetInt8(dataview);
- }
- dataList.wTrucoChair = Global.GetInt16(dataview);
- dataList.cbForceLeaveChoose = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbForceLeaveChoose[i] = Global.GetInt8(dataview);//用户状态
- }
- dataList.nCellMulti = Global.GetInt32(dataview);
- dataList.wFirstUser = Global.GetInt32(dataview);
- dataList.cbFinalRound = Global.GetInt8(dataview);
- dataList.cbFinalTeam = Global.GetInt8(dataview);
- dataList.cbFinalStatus = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbFinalStatus[i] = Global.GetInt8(dataview);//用户状态
- }
- return dataList;
- },
- analyze_GameFree:function(dataview){//空闲时间
- var dataList = {};
- dataview.pos = 0;
- return dataList;
- },
- analyze_ForceLeave:function(dataview){
- var dataList = {};
- dataview.pos = 0;
- return dataList;
- },
- analyze_GameStart:function(dataview) {//游戏开始
- var dataList = {};
- dataview.pos = 0;
- dataList.cbTeam = Global.GetInt8(dataview);//
- return dataList;
- },
- analyze_GameEnd:function(dataview) {//游戏结束
- var dataList = {};
- dataview.pos = 0;
- dataList.cbWinSide = Global.GetInt8(dataview);
- dataList.lUserScore = [];//玩家成绩
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.lUserScore.push(Global.GetInt32(dataview));
- }
- dataList.cTotalScore = [];
- for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
- dataList.cTotalScore[j] = Global.GetInt8(dataview);
- }
- return dataList;
- },
- analyze_GameContinue(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.wCurrentUser = Global.GetInt16(dataview);
- dataList.cbTimeCount = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_OperateFail:function(dataview){//操作失败
- var dataList = {};
- dataview.pos = 0;
- //dataList.OperateType = Global.GetInt8(dataview);//操作类型
- //dataList.szDescribeString = Global.Read2Char(dataview,128);//错误消息
- dataList.cbFailCode = Global.GetInt8(dataview);//错误类型;
- return dataList;
- },
- analyze_GameTruco:function(dataview){//
- var dataList = {};
- dataview.pos = 0;
- dataList.wTrucoUser = Global.GetInt16(dataview);//抓牌玩家
- dataList.cbTrucoSide = Global.GetInt8(dataview);//
- dataList.cbTrucoScore = Global.GetInt8(dataview);//
- dataList.cbTimeCount = Global.GetInt8(dataview);//
- return dataList;
- },
- analyze_GameTrucoChoose:function(dataview){//
- var dataList = {};
- dataview.pos = 0;
- dataList.wTrucoUser = Global.GetInt16(dataview);//抓牌玩家
- dataList.cbTrucoChoose = Global.GetInt8(dataview);//
- return dataList;
- },
- analyze_TrucoSet(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.cbTrucoScore = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_CompareCard(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.cbWinSide = Global.GetInt8(dataview);//抓牌玩家
- dataList.cbRoundScore = [];//
- for(let i = 0; i < GameProtocol.SIDE_NUM; ++i) {
- dataList.cbRoundScore.push(Global.GetInt8(dataview));
- }
- dataList.cbRoundResult = [];
- for(let i = 0;i<GameProtocol.ROUND_MAX;i++){
- dataList.cbRoundResult[i] = [];
- for(let j = 0; j < GameProtocol.SIDE_NUM; ++j) {
- dataList.cbRoundResult[i][j] = Global.GetInt8(dataview);
- }
- }
- dataList.wWinChairID = Global.GetInt16(dataview);
- dataList.cbPlayCount = Global.GetInt8(dataview);
- dataList.cbTimeCount = Global.GetInt8(dataview);
- dataList.cbRoundEnd = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_RoundStart(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.wCurrentUser = Global.GetInt16(dataview);//抓牌玩家
- dataList.cbMagicShowCardData = Global.GetInt8(dataview);//
- dataList.cbMagicCardValue = Global.GetInt8(dataview);//
- dataList.cbCardData = [];
- for(let i = 0; i < GameProtocol.HAND_CARD_COUNT; ++i) {
- dataList.cbCardData.push(Global.GetInt8(dataview));
- }
- dataList.cbTimeCount = Global.GetInt8(dataview);//
- dataList.cTotalScore = [];
- for(let i = 0; i < GameProtocol.SIDE_NUM; ++i) {
- dataList.cTotalScore.push(Global.GetInt8(dataview));
- }
- // dataList.cbFinalRound = Global.GetInt8(dataview);
- // dataList.cbFinalTeam = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_OutCard:function(dataview){//出牌结果
- var dataList = {};
- dataview.pos = 0;
- dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
- dataList.wOutCardUser = Global.GetInt16(dataview);//出牌玩家
- dataList.cbOutCardData = Global.GetInt8(dataview);//出牌数据
- dataList.cbTimeCount = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_CellScore(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.nMulti = Global.GetInt32(dataview);
- return dataList;
- },
- analyze_FinalRound(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.cbTeamCardData = [];
- for(let i = 0; i < GameProtocol.HAND_CARD_COUNT; ++i) {
- dataList.cbTeamCardData.push(Global.GetInt8(dataview));
- }
- dataList.cbTimeCount = Global.GetInt8(dataview);
- dataList.cbFinalRound = Global.GetInt8(dataview);
- dataList.cbFinalTeam = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_FinalChoose(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.wFinalUser = Global.GetInt16(dataview);
- dataList.cbFinalChoose = Global.GetInt8(dataview);
- return dataList;
- },
-
- analyze_waitStart:function(dataview){
- var dataList = {};
- dataview.pos = 0;
- dataList.cbTimeCount = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_Trustee(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.wChairID = Global.GetInt16(dataview);
- dataList.cbStatus = Global.GetInt8(dataview);
- return dataList;
- }
-
- },
- start () {
- },
- // update (dt) {},
- });
|