/
actions.go
96 lines (83 loc) · 2.82 KB
/
actions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Actions represent a change in the game state
// Different actions will have different fields
// Any actions implemented here must also be accounted for in the "restoreTables()" function
package main
// Used to implement the "Slow-Witted" detrimental character
type ActionCardIdentity struct {
Type string `json:"type"`
PlayerIndex int `json:"playerIndex"` // Needed so that we can validate who holds the card
Order int `json:"order"`
SuitIndex int `json:"suitIndex"`
Rank int `json:"rank"`
}
type ActionClue struct {
Type string `json:"type"`
Clue Clue `json:"clue"`
Giver int `json:"giver"`
List []int `json:"list"` // The list of cards that the clue "touches"
Target int `json:"target"`
// The client records the turn that each clue is given (for the clue log)
Turn int `json:"turn"`
}
type ActionDiscard struct {
Type string `json:"type"`
PlayerIndex int `json:"playerIndex"`
Order int `json:"order"` // The ID of the card (based on its order in the deck)
SuitIndex int `json:"suitIndex"`
Rank int `json:"rank"`
Failed bool `json:"failed"`
}
type ActionDraw struct {
Type string `json:"type"`
PlayerIndex int `json:"playerIndex"`
Order int `json:"order"` // The ID of the card, based on its ordering in the deck
SuitIndex int `json:"suitIndex"`
Rank int `json:"rank"`
}
type ActionGameOver struct {
Type string `json:"type"`
EndCondition int `json:"endCondition"`
PlayerIndex int `json:"playerIndex"`
}
type ActionPlay struct {
Type string `json:"type"`
PlayerIndex int `json:"playerIndex"`
Order int `json:"order"` // The ID of the card (based on its order in the deck)
SuitIndex int `json:"suitIndex"`
Rank int `json:"rank"`
}
type ActionPlayerTimes struct {
Type string `json:"type"`
PlayerTimes []int64 `json:"playerTimes"`
Duration int64 `json:"duration"`
}
type ActionStrike struct {
Type string `json:"type"`
Num int `json:"num"` // Whether it was the first strike, the second strike, etc.
Turn int `json:"turn"` // The turn that the strike happened
Order int `json:"order"` // The order of the card that was played
}
type ActionStatus struct {
Type string `json:"type"`
Clues int `json:"clues"`
Score int `json:"score"`
MaxScore int `json:"maxScore"`
}
type ActionTurn struct {
Type string `json:"type"`
Num int `json:"num"`
CurrentPlayerIndex int `json:"currentPlayerIndex"`
}
type Clue struct {
Type int `json:"type"`
Value int `json:"value"`
}
func NewClue(d *CommandData) Clue {
return Clue{
// A color clue is action type 2
// A rank clue is action type 3
// Remap these to 0 and 1, respectively
Type: d.Type - 2,
Value: d.Value,
}
}