syntax = "proto3";  //指定版本，必须要写（proto3、proto2）  
option go_package="./;gameproto";
package gameproto;

import "google/protobuf/any.proto";

enum NotifyTypeEnum {
    NotifyTypePing = 0;
    NotifyTypeJoinRoom = 1;
    NotifyTypeLeaveRoom = 2;
    NotifyTypeCreateRoom = 3;
    NotifyTypeConnect = 4;
    NotifyTypeDisconnect = 5;
    NotifyTypeReady = 6;
    NotifyTypeUnReady = 7;
    NotifyTypeStart = 8;
    NotifyTypeChooseMaster = 9;
    NotifyTypeChooseMasterFinish = 10;
    NotifyTypeChooseMul = 11;
    NotifyTypeChooseMulFinish = 12;
    NotifyTypeGameInit = 13; 
    NotifyTypeOpen = 14;
    NotifyTypeOpenFinish = 15;
    NotifyTypeMsgResp = 16;  //简单的返回
    NotifyTypeWaitReady = 17;
    NotifyTypeRoomInfo = 18;
}

enum DataType {
    DataTypeNormal = 0;     //0x00000000
    DataTypeGZip   = 2;     //0x00000010
    DataTypeEnc    = 4;     //0x00000100
}

enum RoomType {
    RoomTypeFree = 0;    
    RoomTypeNormal = 1;
}

enum RespStatus {
    RespStatusSucc = 0;    
    RespStatusFailed = 1;
}

//Ping
message Ping {
}

message MsgResp {
    string once = 1;
    RespStatus status = 2;
    string msg = 3;
    google.protobuf.Any data = 4;
}

message Room {
    uint32 ID  = 1;
    string Name = 2;
    bool needPwd = 10;
    RoomType RoomType = 3;
    double BaseAmount = 4;
    uint32 ChairUserID1 = 5;
    uint32 ChairUserID2 = 6;
    uint32 ChairUserID3 = 7;
    uint32 ChairUserID4 = 8;
    uint32 ChairUserID5 = 9;
    uint32 Status = 11;
}

message TableInfo {
    repeated Room roomList = 1;
    repeated User userList = 2;
}

message RoomDetail {
    uint32 ID  = 1;
    string Name = 2;
    bool needPwd = 10;
    RoomType RoomType = 3;
    double BaseAmount = 4;
    uint32 ChairUserID1 = 5;
    uint32 ChairUserID2 = 6;
    uint32 ChairUserID3 = 7;
    uint32 ChairUserID4 = 8;
    uint32 ChairUserID5 = 9;
    uint32 Status = 11;
    int64 StatusStartTime = 13;
    repeated RoomUser RoomUserList = 12;
    int64 TimeNow = 14;
}

message RoomUser {
    uint32 UserID = 1;
    repeated uint32 CardList = 2;
    float WinAmount = 3;
    bool IsMaster = 4;
    uint32 MasterMul = 5;
    uint32 Mul = 6;
    uint32 Status = 7;
    double Balance = 8;
    double Credits = 9;
}

message Game {
    Room Room = 1;  //房间信息
    repeated RoomUser RoomUserList = 2;
}

message User {
    uint32 UserID = 1;
    string Name = 2;
    string Img = 3;
}

message Connect {
    uint32 UserID = 1;
    int64 LogID = 2;
    string Name = 3;
    string Img = 4;
    double Balance = 5;
    Game Game = 6;
    repeated Room RoomList = 7;
    repeated User UserList = 8;
    RoomDetail RoomDetail = 9;          //用户当前房间的详情
    double Credits = 10;
}

message Disconnect {
    uint32 UserID = 1;
}

message JoinRoom {
    uint32 RoomID = 1;
    uint32 ChairID = 2;
    uint32 UserID = 3;
    uint32 GameStatus = 4;
    User User = 5;
    RoomDetail RoomDetail = 6;
}

message LeaveRoom {
    uint32 RoomID = 1;
    uint32 ChairID = 2;
    uint32 UserID = 3;
    User User = 5;
}

message CreateRoom {
    uint32 ID  = 1;
    uint32 CreatorID  = 11;
    string Name = 2;
    bool needPwd = 10;
    RoomType RoomType = 3;
    double BaseAmount = 4;
    uint32 ChairUserID1 = 5;
    uint32 ChairUserID2 = 6;
    uint32 ChairUserID3 = 7;
    uint32 ChairUserID4 = 8;
    uint32 ChairUserID5 = 9;
}

message Ready {
    uint32 RoomID = 1;
    uint32 UserID = 3;
}

message UnReady {
    uint32 RoomID = 1;
    uint32 UserID = 3;
}

//开始等待其他人准备
message WaitReady {
    uint32 RoomID = 1;
    string Issue = 2;
}

//准备人数够，开始游戏
message Start {
    uint32 RoomID = 1;
    repeated uint32 ChooseMasterMulList = 2;    //抢庄倍数列表
    string issue = 3;
    repeated uint32 CardList = 4; //牌型列表
}

//选庄
message ChooseMaster {
    uint32 UserID = 1;
    uint32 Mul = 2;                 //0,1,2,3 - 0表示不抢
    uint32 RoomID = 3;
}

//选倍数
message ChooseMul {
    uint32 UserID = 1;
    uint32 Mul = 2;         //1,2,3 - 倍数
    uint32 RoomID = 3;
    repeated uint32 CardList = 4; //牌型列表
}

//选庄完成
message ChooseMasterFinish {
    uint32 MasterUserID = 1;     //庄家的ID
    repeated uint32 MulList = 2; //倍数列表
    uint32 RoomID = 3;
}

//选倍数完成
message ChooseMulFinish {
    uint32 RoomID = 3;
}

message PayoutInfo {
    uint32 UserID = 1;
    double Balance = 2;
    string winAmount = 3;
    bool isMaster = 4;
    double Credits = 5;
}

//选倍数完成
message OpenFinish {
    uint32 RoomID = 1;
    repeated PayoutInfo PayoutInfoList = 2;
}

//开牌
message Open {
    uint32 RoomID = 1;
    uint32 UserID = 2;
    repeated uint32 CardList = 3; //牌型列表
}

//游戏初始化
message GameInit {
    uint32 RoomID = 1;
}

message GameRecordItem {
    int64 CreatedAt = 1;	
	int64 RoomID = 2;
	int32 RoomType = 3;
	string Issue = 4;
	string OpenNumber = 5;
	string BaseAmount = 6;
	int32 IsDraw = 7;
	int64 DrawTime = 8;
	int32 IsMaster = 9;
	int32 MasterMul = 10;
	int32 Mul = 11;
	int32 IsWin = 12;
	string WinAmount = 13;
}

message GameRecordResp {
    int32 Total = 1;
    repeated GameRecordItem RecordList = 2;
}

message GameOpenRecordItem {
	int64 RoomID = 1;
	int32 RoomType = 2;
	string Issue = 3;
	string OpenNumber1 = 4;
    string OpenNumber2 = 5;
    string OpenNumber3 = 6;
    string OpenNumber4 = 7;
    string OpenNumber5 = 8;
    int64 OpenTime = 9;
    string Hash = 10;
}

message GameOpenRecordResp {
    int32 Total = 1;
    repeated GameOpenRecordItem OpenRecordList = 2;
}