guandan.dev

guandan.dev

https://git.tonybtw.com/guandan.dev.git git://git.tonybtw.com/guandan.dev.git
2,825 bytes raw
1
package protocol
2
3
import "guandanbtw/game"
4
5
type Msg_Type string
6
7
const (
8
	Msg_Join_Room     Msg_Type = "join_room"
9
	Msg_Create_Room   Msg_Type = "create_room"
10
	Msg_Room_State    Msg_Type = "room_state"
11
	Msg_Game_Start    Msg_Type = "game_start"
12
	Msg_Deal_Cards    Msg_Type = "deal_cards"
13
	Msg_Play_Cards    Msg_Type = "play_cards"
14
	Msg_Pass          Msg_Type = "pass"
15
	Msg_Turn          Msg_Type = "turn"
16
	Msg_Play_Made     Msg_Type = "play_made"
17
	Msg_Hand_End      Msg_Type = "hand_end"
18
	Msg_Tribute       Msg_Type = "tribute"
19
	Msg_Tribute_Give  Msg_Type = "tribute_give"
20
	Msg_Tribute_Recv  Msg_Type = "tribute_recv"
21
	Msg_Game_End      Msg_Type = "game_end"
22
	Msg_Error         Msg_Type = "error"
23
	Msg_Player_Joined Msg_Type = "player_joined"
24
	Msg_Player_Left   Msg_Type = "player_left"
25
	Msg_Fill_Bots     Msg_Type = "fill_bots"
26
)
27
28
type Message struct {
29
	Type    Msg_Type    `json:"type"`
30
	Payload interface{} `json:"payload"`
31
}
32
33
type Join_Room_Payload struct {
34
	Room_Id     string `json:"room_id"`
35
	Player_Name string `json:"player_name"`
36
}
37
38
type Create_Room_Payload struct {
39
	Player_Name string `json:"player_name"`
40
}
41
42
type Room_State_Payload struct {
43
	Room_Id     string        `json:"room_id"`
44
	Players     []Player_Info `json:"players"`
45
	Game_Active bool          `json:"game_active"`
46
	Your_Id     string        `json:"your_id"`
47
}
48
49
type Player_Info struct {
50
	Id       string `json:"id"`
51
	Name     string `json:"name"`
52
	Seat     int    `json:"seat"`
53
	Team     int    `json:"team"`
54
	Is_Ready bool   `json:"is_ready"`
55
}
56
57
type Deal_Cards_Payload struct {
58
	Cards []game.Card `json:"cards"`
59
	Level game.Rank   `json:"level"`
60
}
61
62
type Play_Cards_Payload struct {
63
	Card_Ids []int `json:"card_ids"`
64
}
65
66
type Turn_Payload struct {
67
	Player_Id       string           `json:"player_id"`
68
	Seat            int              `json:"seat"`
69
	Lead_Combo_Type game.Combination `json:"lead_combo_type,omitempty"`
70
	Can_Pass        bool             `json:"can_pass"`
71
}
72
73
type Play_Made_Payload struct {
74
	Player_Id  string      `json:"player_id"`
75
	Seat       int         `json:"seat"`
76
	Cards      []game.Card `json:"cards"`
77
	Combo_Type string      `json:"combo_type"`
78
	Is_Pass    bool        `json:"is_pass"`
79
}
80
81
type Hand_End_Payload struct {
82
	Finish_Order  []string `json:"finish_order"`
83
	Winning_Team  int      `json:"winning_team"`
84
	Level_Advance int      `json:"level_advance"`
85
	New_Levels    [2]int   `json:"new_levels"`
86
}
87
88
type Tribute_Payload struct {
89
	From_Seat int `json:"from_seat"`
90
	To_Seat   int `json:"to_seat"`
91
}
92
93
type Tribute_Give_Payload struct {
94
	Card_Id int `json:"card_id"`
95
}
96
97
type Tribute_Recv_Payload struct {
98
	Card game.Card `json:"card"`
99
}
100
101
type Game_End_Payload struct {
102
	Winning_Team int    `json:"winning_team"`
103
	Final_Levels [2]int `json:"final_levels"`
104
}
105
106
type Error_Payload struct {
107
	Message string `json:"message"`
108
}