123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- var GameProtocol = require("CachetaGameProtocol")
- 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_STATE_INFO: { //游戏结束
- return this.analyze_StateInfo(dataview);
- }
- case GameProtocol.SUB_S_OPERATE_FAIL: { //操作失败
- return this.analyze_OperateFail(dataview);
- }
- case GameProtocol.SUB_S_GET_CARD: { //玩家抓牌
- return this.analyze_GetCard(dataview);
- }
- case GameProtocol.SUB_S_OUT_CARD: { //玩家出牌
- return this.analyze_OutCard(dataview);
- }
- case GameProtocol.SUB_S_MING_CARD: { //玩家出牌
- return this.analyze_MingCard(dataview);
- }
- case GameProtocol.SUB_S_WAIT_START:{//等待开始
- return this.analyze_waitStart(dataview);
- }
- case GameProtocol.SUB_S_GAME_INFO:{
- return this.analyze_GameInfo(dataview);
- }
- case GameProtocol.SUB_S_TRUSTEE_STATUS:{
- return this.analyze_Trustee(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.cbPlayStatusArr = [];
- //0,1,2 空闲,游戏,放弃
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbPlayStatusArr[i] = Global.GetInt8(dataview);//用户状态
- }
-
- dataList.cbGetCardData = Global.GetInt8(dataview);//抓取的扑克
- dataList.cbOpenCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
- dataList.cbMagicShowCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
- dataList.cbMagicCardData = [];
- dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
- dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
- dataList.cbCardData = [];//玩家牌组
- for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
- dataList.cbCardData.push(Global.GetInt8(dataview));
- }
- dataList.cbTingUser = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbTingUser[i] = Global.GetInt8(dataview);//用户状态
- }
- dataList.cbTimeCount = Global.GetInt8(dataview);
- dataList.cbTableCardCount = Global.GetInt8(dataview);
- dataList.cbUserTrustee = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbUserTrustee[i] = Global.GetInt8(dataview);//用户状态
- }
- return dataList;
- },
- analyze_GameFree:function(dataview){//空闲时间
- var dataList = {};
- dataview.pos = 0;
- return dataList;
- },
- analyze_GameStart:function(dataview) {//游戏开始
- var dataList = {};
- dataview.pos = 0;
- dataList.wCurrentUser = Global.GetInt16(dataview);//当前玩家
- dataList.cbMagicShowCardData = Global.GetInt8(dataview);
- dataList.cbMagicCardData = [];
- dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
- dataList.cbMagicCardData.push(Global.GetInt8(dataview));//百变牌
-
- dataList.cbCardData = [];
- for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
- dataList.cbCardData.push(Global.GetInt8(dataview));
- }
- dataList.cbTimeCount = Global.GetInt8(dataview);
- dataList.cbPlayStateArr = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.cbPlayStateArr[i] = Global.GetInt8(dataview);//用户状态
- }
- return dataList;
- },
- analyze_GameEnd:function(dataview) {//游戏结束
- var dataList = {};
- dataview.pos = 0;
- dataList.wWinner = Global.GetInt16(dataview);//赢家
- dataList.cbHuType = Global.GetInt8(dataview);//0:流局,1:9张,2:10张
- dataList.cbHuDst = Global.GetInt8(dataview);//0:流局,1:自摸 2 点炮
- dataList.PlayerInfo = [];
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- let Info = {};
- Info.dwUserID = Global.GetInt32(dataview);
- Info.szNickName = Global.gbk2Utf8(Global.Read2Char(dataview,32));
- Info.wFaceID = Global.GetInt16(dataview);
- dataList.PlayerInfo.push(Info);
- }
- dataList.lUserScore = [];//玩家成绩
- for(let i = 0;i<GameProtocol.GAME_PLAYER;i++){
- dataList.lUserScore.push(Global.GetInt32(dataview));
- }
-
- dataList.cbCardData = [];
- for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
- dataList.cbCardData[idx] = [];
- for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
- // var teamData = {};
- // teamData.cbCardType = Global.GetInt8(dataview);
- // teamData.lLostScore = Global.GetInt32(dataview);
- // teamData.cbCardCount = Global.GetInt8(dataview);
- // teamData.cbCardDataArr = [];
- // for(let j = 0;j < GameProtocol.HAND_CARD_COUNT+1;j++){
- // let cardData = Global.GetInt8(dataview);
- // teamData.cbCardDataArr.push(cardData);
- // }
- dataList.cbCardData[idx].push(Global.GetInt8(dataview));
- }
- }
- dataList.cbHuCardData = [];
- for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
- dataList.cbHuCardData.push(Global.GetInt8(dataview));
- }
- return dataList;
- },
- analyze_StateInfo(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.cbHu10 = Global.GetInt8(dataview);
- dataList.cbHu9 = Global.GetInt8(dataview);
- dataList.cbHuCard = [];
- for(let i = 0; i < GameProtocol.HAND_CARD_COUNT+1; ++i) {
- dataList.cbHuCard.push(Global.GetInt8(dataview));
- }
- dataList.cbTing = Global.GetInt8(dataview);
- dataList.cbTingCard = [];
- for(let i = 0; i < GameProtocol.HAND_CARD_COUNT+1; ++i) {
- dataList.cbTingCard.push(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_GetCard:function(dataview){//抓牌结果
- var dataList = {};
- dataview.pos = 0;
- dataList.wGetCardUser = Global.GetInt16(dataview);//抓牌玩家
- dataList.bGetTableCard = Global.GetInt8(dataview);//抓桌面牌(true=暗牌堆,false=明牌堆)
- dataList.cbGetCardData = Global.GetInt8(dataview);//抓牌数据
- dataList.cbOpenCardData = Global.GetInt8(dataview);//明牌堆翻的第一张牌
- dataList.cbTimeCount = 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.cbOpenCardData = Global.GetInt8(dataview);//0出牌,1胡牌,2诈胡
- dataList.bTing = Global.GetInt8(dataview);//听牌标记
- dataList.cbTimeCount = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_MingCard(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.cbTingCard = [];
- for(let i = 0; i < 104; ++i) {
- dataList.cbTingCard.push(Global.GetInt8(dataview));
- }
- // dataList.bTing = Global.GetInt8(dataview);//听牌标记
- return dataList;
- },
-
- analyze_waitStart:function(dataview){
- var dataList = {};
- dataview.pos = 0;
- dataList.cbTimeCount = Global.GetInt8(dataview);
- return dataList;
- },
- analyze_GameInfo(dataview) {
- var dataList = {};
- dataview.pos = 0;
- dataList.cbHandCardData = [];
- for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
- dataList.cbHandCardData[idx] = [];
- for(let i = 0;i<GameProtocol.HAND_CARD_COUNT+1;i++){
- dataList.cbHandCardData[idx].push(Global.GetInt8(dataview));
- }
- }
- let tagControlInfo = {};
- tagControlInfo.cbControlType = Global.GetInt8(dataview);
- tagControlInfo.cbControlReslut = Global.GetInt8(dataview);
- tagControlInfo.wControlUser = Global.GetInt16(dataview);
- tagControlInfo.wControlWinUser = Global.GetInt16(dataview);
- tagControlInfo.wControlLoseUser = Global.GetInt16(dataview);
- tagControlInfo.nControlRadian = [];
- for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
- tagControlInfo.nControlRadian[idx] = Global.GetInt32(dataview);
- }
- tagControlInfo.nRnd = Global.GetInt32(dataview);
- tagControlInfo.nControlValue = [];
- for(let idx = 0;idx<GameProtocol.GAME_PLAYER;idx++){
- tagControlInfo.nControlValue[idx] = Global.GetInt32(dataview);
- }
- tagControlInfo.lRet = [];
- for(let idx = 0;idx<7;idx++){
- tagControlInfo.lRet[idx] = Global.Read2ll(dataview);
- }
- dataList.tagControlInfo = tagControlInfo;
- 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) {},
- });
|