File tree Expand file tree Collapse file tree 6 files changed +64
-14
lines changed Expand file tree Collapse file tree 6 files changed +64
-14
lines changed Original file line number Diff line number Diff line change 1
1
publish :
2
2
address : 224.5.23.1:10003
3
- global :
3
+ game :
4
4
yellow-card-duration : 2m
5
- normal :
6
- half-duration : 5m
7
- half-time-duration : 5m
8
- timeout-duration : 5m
9
- timeouts : 4
10
- break-after : 5m
11
- overtime :
12
- half-duration : 2m30s
13
- half-time-duration : 2m
14
- timeout-duration : 5m
15
- timeouts : 2
16
- break-after : 2m
5
+ default-division : Div A
6
+ normal :
7
+ half-duration : 5m
8
+ half-time-duration : 5m
9
+ timeout-duration : 5m
10
+ timeouts : 4
11
+ break-after : 5m
12
+ overtime :
13
+ half-duration : 2m30s
14
+ half-time-duration : 2m
15
+ timeout-duration : 5m
16
+ timeouts : 2
17
+ break-after : 2m
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type ConfigSpecial struct {
19
19
// ConfigGame holds configs that are valid for the whole game
20
20
type ConfigGame struct {
21
21
YellowCardDuration time.Duration `yaml:"yellow-card-duration"`
22
+ DefaultDivision Division `yaml:"default-division"`
22
23
Normal ConfigSpecial `yaml:"normal"`
23
24
Overtime ConfigSpecial `yaml:"overtime"`
24
25
}
@@ -74,6 +75,8 @@ func DefaultConfig() (c Config) {
74
75
c .Game .Overtime .TimeoutDuration = 5 * time .Minute
75
76
c .Game .Overtime .BreakAfter = 2 * time .Minute
76
77
78
+ c .Game .DefaultDivision = DivA
79
+
77
80
return
78
81
}
79
82
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ func (e *Engine) ResetGame() {
35
35
e .State .TeamState [TeamBlue ].TimeoutsLeft = e .config .Normal .Timeouts
36
36
e .State .TeamState [TeamYellow ].TimeoutsLeft = e .config .Normal .Timeouts
37
37
e .RefereeEvents = []RefereeEvent {}
38
+ e .State .Division = e .config .DefaultDivision
38
39
}
39
40
40
41
// Tick updates the times of the state and removes cards, if necessary
@@ -239,6 +240,18 @@ func (e *Engine) processCommand(c *EventCommand) error {
239
240
}
240
241
241
242
func (e * Engine ) processModify (m * EventModifyValue ) error {
243
+ // process team-independent modifies
244
+ if m .Division != nil {
245
+ if * m .Division == DivA || * m .Division == DivB {
246
+ e .State .Division = * m .Division
247
+ log .Printf ("Processed modification %v" , m )
248
+ return nil
249
+ } else {
250
+ return errors .Errorf ("Invalid divsion: %v" , * m .Division )
251
+ }
252
+ }
253
+
254
+ // process team-dependent modifies
242
255
if m .ForTeam .Unknown () {
243
256
return errors .Errorf ("Unknown team: %v" , m .ForTeam )
244
257
}
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ type EventModifyValue struct {
104
104
BotCollisions * int `json:"botCollisions"`
105
105
BallPlacementFailures * int `json:"ballPlacementFailures"`
106
106
BotSpeedInfringements * int `json:"botSpeedInfringements"`
107
+ Division * Division `json:"division"`
107
108
}
108
109
109
110
func (m EventModifyValue ) String () string {
@@ -144,6 +145,9 @@ func (m EventModifyValue) String() string {
144
145
if m .BotSpeedInfringements != nil {
145
146
return fmt .Sprintf ("%v BotSpeedInfringements=%v" , str , * m .BotSpeedInfringements )
146
147
}
148
+ if m .Division != nil {
149
+ return fmt .Sprintf ("%v Division=%v" , str , * m .Division )
150
+ }
147
151
return fmt .Sprintf ("%v undefined" , str )
148
152
}
149
153
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ func (t Team) Known() bool {
37
37
return ! t .Unknown ()
38
38
}
39
39
40
+ type Division string
41
+
42
+ const (
43
+ DivA Division = "Div A"
44
+ DivB Division = "Div B"
45
+ )
46
+
40
47
// Stage represents the different stages of a game
41
48
type Stage string
42
49
@@ -221,6 +228,7 @@ type State struct {
221
228
MatchTimeStart time.Time `json:"matchTimeStart"`
222
229
MatchDuration time.Duration `json:"matchDuration"`
223
230
TeamState map [Team ]* TeamInfo `json:"teamState"`
231
+ Division Division `json:"division"`
224
232
}
225
233
226
234
// NewState creates a new state, initialized for the start of a new game
@@ -242,6 +250,8 @@ func NewState() (s *State) {
242
250
* s .TeamState [TeamBlue ] = newTeamInfo ()
243
251
s .TeamState [TeamBlue ].OnPositiveHalf = ! s .TeamState [TeamYellow ].OnPositiveHalf
244
252
253
+ s .Division = DivA
254
+
245
255
return
246
256
}
247
257
Original file line number Diff line number Diff line change 34
34
:disabled =" forbidMatchControls || noNextStage" >
35
35
End of Game
36
36
</b-button >
37
+ <div class =" divisions btn-group-toggle btn-group" >
38
+ <label :class =" {btn:true, 'btn-secondary': true, active: isDivA}" @click =" switchDivision('Div A')" >Div
39
+ A</label >
40
+ <label :class =" {btn:true, 'btn-secondary': true, active: !isDivA}" @click =" switchDivision('Div B')" >Div
41
+ B</label >
42
+ </div >
37
43
</div >
38
44
</template >
39
45
40
46
<script >
41
47
export default {
42
48
name: " ControlMatch" ,
49
+ data () {
50
+ return {
51
+ selected: ' Div A' ,
52
+ }
53
+ },
43
54
methods: {
44
55
resetMatch : function () {
45
56
this .$socket .sendObj ({
76
87
' stage' : {' stageOperation' : ' endGame' }
77
88
})
78
89
},
90
+ switchDivision (division ) {
91
+ this .$socket .sendObj ({
92
+ ' modify' : {' division' : division}
93
+ })
94
+ }
79
95
},
80
96
computed: {
81
97
state () {
82
98
return this .$store .state .refBoxState
83
99
},
100
+ isDivA () {
101
+ return this .$store .state .refBoxState .division === ' Div A' ;
102
+ },
84
103
halted () {
85
104
return this .state .command === ' halt' ;
86
105
},
101
120
</script >
102
121
103
122
<style scoped>
104
- button {
123
+ button , .divisions {
105
124
margin : 0.5em ;
106
125
}
107
126
</style >
You can’t perform that action at this time.
0 commit comments