# 妙問答 遊戲封包
```
剛進遊戲
client送
command:"create" 或者將來送 "tablelist"
data:"{}"
game server回傳
public class ResultToGame {
private int state = 0;
private long Credit = 0L;
private final String PackageVersion = "0.0.1";
private String command = null;
private String data = null;
private String jackpot = null;
private String ErrorCode = null;
private int ResultCode = 0;
}
ResultCode = 1為成功,其他都失敗,代碼再找時間定義
command = "create"
client收到以data為主,依據command命令會有不同的格式
client會收到TableList,裡面的字串為TableInfo的json格式
public class TableList {
private ArrayList<String> table;
private String playerName;
private long balance;
private int lasttabletype; //-1表示沒有復原桌
private int lasttablelevel;//-1表示沒有復原桌
private long wincoin; //是否贏錢
private String round; //桌回合
private String announe; //公告
private int serverStatus;//有復原時,此桌的server到哪個階段
private String ver; //gs版號內含機率版號
private String currency; //玩家的幣別,client需要記起來,將來用在廣播的handrecord發現跟自己的幣別依樣才更新,因會會收到不同幣別的handrecord
private long rank; //玩家品級
private long points;//玩家點數
private long vip; //玩家VIP等級
private long lv; //玩家目前等級
private long next; //下次升級經驗值
private long exp; //目前經驗值
private long totalbet;//表示玩家使用的金額.
}
公告格式:{\"announce\":\"System under maintenance, we will be back at 08:00 07/09 2021 UTC+8\",\"action\":0}
public class TableDesc {
private int tableid; //桌號
private int tabletype; //0萬人桌 1:5人桌
private long minlimit; //最小限紅
private long maxlimit; //最大限紅
private int tableplayer; //桌內人數
private String option; //client可以選擇下注項目
private String currency; //此桌幣別
private int tablelevel; // 等級限制
private int vip; // vip限制
private int quest; //需答題數
private int reward; //答題數獎勵
private int difficulty; //難度
private int rank; //品級
private int tokens; //報名費
private boolean recommend;;//true為推薦桌
private float taxi; //抽稅(贏家)
}
PS:要能接受沒有桌子的情況
```
```
準備入桌
client送
command:"jointable"
data:"{"tabletype":0,tablenum":0}"
tabletype = 0 萬人桌
tablenum 加入桌號
game server回傳
public class ResultToGame {
private int state = 0;
private long Credit = 0L;
private final String PackageVersion = "0.0.1";
private String command = null;
private String data = null;
private String jackpot = null;
private String ErrorCode = null;
private int ResultCode = 0;
}
ResultCode = 1為成功,其他都失敗,代碼再找時間定義
command = "jointable"
client會收到TableInfo的json格式
public class TableInfo {
private ArrayList<Integer> totalbethorse; //萬人桌目前所有馬匹累積投注人數(0~35含獨贏),配合桌內人數client自成一個比例表現
private int tabletype; //0萬人桌 1五人桌
private long coin; //玩家目前身上餘額
private int serverstatus; //目前server到哪個流程
private int defoption; //玩家入桌後的預設押住選項
private int tableid;
private String command;
private int waitsec; //倒數秒數
private int resutlCode; //1進桌成功 其他都失敗
private int tableplayer; //桌內人數
private String round; //回合
private int quest; //需答題數
private int questindex;//0為基底,目前答第幾題
}
public class ServerStatus { //server的狀態代碼,不排除將來還會有新增狀態
public static final int SERVER_INIT = 0; // 初始狀態
public static final int SERVER_WAITPLAYER = 1; // 等待玩家加入
public static final int SERVER_STARTGAME = 2; // 開始遊戲表演動畫
public static final int SERVER_BET = 3; //下注
public static final int SERVER_BETSTOP = 4; // 停止下注
public static final int SERVER_WAITANI = 5; //等待client跑馬表演動畫含結算面板顯示
public static final int SERVER_NOSERVICE = 9; //此桌不在服務
}
```
```
遊戲開始
client不需要送,由server主動觸發
game server回傳
public class ResultToGame {
private int state = 0;
private long Credit = 0L;
private final String PackageVersion = "0.0.1";
private String command = null;
private String data = null;
private String jackpot = null;
private String ErrorCode = null;
private int ResultCode = 0;
}
ResultCode = 1為成功,其他都失敗,代碼再找時間定義
command = "gamestart"
client會收到StartGame的json格式
public class StartGame {
private int waitsec; //倒數秒數
private int tableid; //此桌編號
private String round; //這局名稱
private int tableplayer; //桌人數
}
```
```
client在表演動畫或結算的狀態,若表演結束時,client上傳一個封包讓server知道表演結束,在server判斷全部client都表演完或者server時間到就會往下一個階段
client送
command:"play" //目前lobby只接受play命令可以不用等回傳
data:"{}" //預留將來也許有其他要用
data:"{“updatcoin":10000}" //通知gs更新玩家餘額變成1元
data:"{“again":1}" //妙問答繼續下一局
data:"{“lang":"TW"}" //玩家選擇的語系
server不會回傳任何封包
```
```
通知client使用表情符號
client收到
command: "emoticon"
public class Emoticon {
private String nickname; //玩家暱稱
private int horsenum; //馬匹編號
private int emot; //表情圖組
}
public class EmoticonArray {
private ArrayList<Emoticon> emots; //client會收到使用表情符賀的玩家陣列
}
```
```
client打算離開這一桌回到桌列表
client送
command:"returnlobby"
data:{}
game server回傳
public class ResultToGame {
private int state = 0;
private long Credit = 0L;
private final String PackageVersion = "0.0.1";
private String command = null;
private String data = null;
private String jackpot = null;
private String ErrorCode = null;
private int ResultCode = 0;
}
ResultCode = 1為成功,其他都失敗,代碼再找時間定義
command = "returnlobby"
public class ReturnLobby {
private long balance; //玩家身上餘額
private int ResultCode; //離桌原因
private int tableid;
}
ResultCode:
1:正常離桌
其他代碼都是不允許
```
```
通知client可以下注
client收到
command:"firstbet"
就能下注,注意倒數秒數到就不能再下注
client會收到FirstBet的json格式
public class FirstBet { //收到這個可以下注
private int waitsec; //倒數秒數
private int tableid; //此桌編號
private String round; //局號
private int quest; //需答題數
private int questindex;//0為基底,目前答第幾題
private QuestionClientData gamequest;
private int aianswer; //AI回答第幾題
private String sound; //AI語音mp3會暫時固定
}
public class FirstResult { //下注結果
private int waitsec; //倒數秒數
private long balance; //玩家目前贏錢後的餘額
private int tableid; //此桌編號
private long sn; //server序號,方便debug
private String round; //局號
private long totalbet; //這次總投注
private long totalscore; //這次總派彩
private int quest; //需答題數
private int questindex;//0為基底,目前答第幾題
private int option;//答案編號
private int correct;//答對數量
private int score;//表示得分點數
private int free;//表示參加費用
private long reward;//表示獎金
//////////////結算會更新底下資料/////////////////
private int order;//玩家這場排名
private int vip; //玩家VIP等級
private int rank;//玩家品級.
private int lv;//玩家目前等級.
private int next;//下次升級經驗值
private int exp;//目前經驗值.
private int points;//玩家點數
}
public class QuestionClientData {
private ArrayList<QtypeData> Qtype;
private String C_Pic;
private String B_Pic;
private String D_Pic;
private String A_Pic;
private String Stype;
private String Difficulty;
private ArrayList<ItemData> Items;
//private String Items;
///////////
private int id; //此題在db的id欄位,將來可以用來避免出相同圖庫
private int resultCode; //這次取題目是否成功,1:成功,其他值失敗
}
client收到"firstbet"表示可以下注
client送上來
command:"bet"
data:"{"option":5,"betobject":0}"
option:0~3答案四選一
object: 目前無用處,先直接給0
game server回傳
public class ResultToGame {
private int state = 0;
private long Credit = 0L;
private final String PackageVersion = "0.0.1";
private String command = null;
private String data = null;
private String jackpot = null;
private String ErrorCode = null;
private int ResultCode = 0;
}
ResultCode = 1為成功,其他都失敗,代碼再找時間定義
command = "bet"
client會收到BetResult的json格式
public class BetResult {
private int bet; //玩家選擇哪個答案
private long coin; //玩家目前的餘額
private int tableid;
private int resultcode; //這次下注結果
private int option;//選擇哪一個答案
}
resultcode
1:下注成功
0:下注失敗(原因可能是不是下注階段或者餘額不足統稱下注失敗)
**不提供client批次下次功能**
```
```
通知client 離桌
client收到
command:kickplayer
此命令萬人桌要回到桌列表
五人桌可能要表現成觀局或者回到桌列表,再討論
public class LeaveTable {
private long balance; //玩家身上餘額
private int reason; //離桌原因
private int tableid; //確認是哪一桌送來的,client要判斷目前是否同一個桌號
}
reason:
0 未投注
1:餘額不足
2:系統維護
3:正常離桌
```
```
通知client公告
client收到
command:announce
此命令是一些公告
public class Announce{
private String announce; //公告內容,tim說都英文
private int action; //玩家需要動作
}
action
0:不用特別動作(用在先提醒玩家)
1:桌內玩家這回合結束就不能再下注,桌列表也不給桌子
2:有緊急狀況,server馬上要下線
```
```
通知client表演籌碼投注
client收到
command:showcoin
此命令萬人桌要表演很多人投注情況用,在投注階段大概每200ms會收到一次這個封包,所以會有點密集
public class ShowCoin{
private ArrayList<Integer> totalbethorse; //萬人桌目前所有馬匹累積投注人數(0~35含獨贏),配合桌內人數client自成一個比例表現
private int tableplayer; //桌內玩家
private int tableid; //此桌編號
private String command;
}
```
```
通知client更新每手紀錄
client收到
command:refreshtable
public class RefreshTable {
private int tableid; //桌id
private String currency; //幣別
private ArrayList<Integer> horserecord;// 8X6 = 48: 馬編號 /近5場名次 //
private ArrayList<Integer> datarecord; //最近100場紀錄
private int noghorsecount; //黃金馬未開次數
private int noclassicrace; //經典賽未開次數
private int tableplayer; //桌內人數
}
**只有currency與create的tableist同一個幣別才更新
```