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 11publish :
22 address : 224.5.23.1:10003
3- global :
3+ game :
44 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 {
1919// ConfigGame holds configs that are valid for the whole game
2020type ConfigGame struct {
2121 YellowCardDuration time.Duration `yaml:"yellow-card-duration"`
22+ DefaultDivision Division `yaml:"default-division"`
2223 Normal ConfigSpecial `yaml:"normal"`
2324 Overtime ConfigSpecial `yaml:"overtime"`
2425}
@@ -74,6 +75,8 @@ func DefaultConfig() (c Config) {
7475 c .Game .Overtime .TimeoutDuration = 5 * time .Minute
7576 c .Game .Overtime .BreakAfter = 2 * time .Minute
7677
78+ c .Game .DefaultDivision = DivA
79+
7780 return
7881}
7982
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ func (e *Engine) ResetGame() {
3535 e .State .TeamState [TeamBlue ].TimeoutsLeft = e .config .Normal .Timeouts
3636 e .State .TeamState [TeamYellow ].TimeoutsLeft = e .config .Normal .Timeouts
3737 e .RefereeEvents = []RefereeEvent {}
38+ e .State .Division = e .config .DefaultDivision
3839}
3940
4041// Tick updates the times of the state and removes cards, if necessary
@@ -239,6 +240,18 @@ func (e *Engine) processCommand(c *EventCommand) error {
239240}
240241
241242func (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
242255 if m .ForTeam .Unknown () {
243256 return errors .Errorf ("Unknown team: %v" , m .ForTeam )
244257 }
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ type EventModifyValue struct {
104104 BotCollisions * int `json:"botCollisions"`
105105 BallPlacementFailures * int `json:"ballPlacementFailures"`
106106 BotSpeedInfringements * int `json:"botSpeedInfringements"`
107+ Division * Division `json:"division"`
107108}
108109
109110func (m EventModifyValue ) String () string {
@@ -144,6 +145,9 @@ func (m EventModifyValue) String() string {
144145 if m .BotSpeedInfringements != nil {
145146 return fmt .Sprintf ("%v BotSpeedInfringements=%v" , str , * m .BotSpeedInfringements )
146147 }
148+ if m .Division != nil {
149+ return fmt .Sprintf ("%v Division=%v" , str , * m .Division )
150+ }
147151 return fmt .Sprintf ("%v undefined" , str )
148152}
149153
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ func (t Team) Known() bool {
3737 return ! t .Unknown ()
3838}
3939
40+ type Division string
41+
42+ const (
43+ DivA Division = "Div A"
44+ DivB Division = "Div B"
45+ )
46+
4047// Stage represents the different stages of a game
4148type Stage string
4249
@@ -221,6 +228,7 @@ type State struct {
221228 MatchTimeStart time.Time `json:"matchTimeStart"`
222229 MatchDuration time.Duration `json:"matchDuration"`
223230 TeamState map [Team ]* TeamInfo `json:"teamState"`
231+ Division Division `json:"division"`
224232}
225233
226234// NewState creates a new state, initialized for the start of a new game
@@ -242,6 +250,8 @@ func NewState() (s *State) {
242250 * s .TeamState [TeamBlue ] = newTeamInfo ()
243251 s .TeamState [TeamBlue ].OnPositiveHalf = ! s .TeamState [TeamYellow ].OnPositiveHalf
244252
253+ s .Division = DivA
254+
245255 return
246256}
247257
Original file line number Diff line number Diff line change 3434 :disabled =" forbidMatchControls || noNextStage" >
3535 End of Game
3636 </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 >
3743 </div >
3844</template >
3945
4046<script >
4147 export default {
4248 name: " ControlMatch" ,
49+ data () {
50+ return {
51+ selected: ' Div A' ,
52+ }
53+ },
4354 methods: {
4455 resetMatch : function () {
4556 this .$socket .sendObj ({
7687 ' stage' : {' stageOperation' : ' endGame' }
7788 })
7889 },
90+ switchDivision (division ) {
91+ this .$socket .sendObj ({
92+ ' modify' : {' division' : division}
93+ })
94+ }
7995 },
8096 computed: {
8197 state () {
8298 return this .$store .state .refBoxState
8399 },
100+ isDivA () {
101+ return this .$store .state .refBoxState .division === ' Div A' ;
102+ },
84103 halted () {
85104 return this .state .command === ' halt' ;
86105 },
101120 </script >
102121
103122<style scoped>
104- button {
123+ button , .divisions {
105124 margin : 0.5em ;
106125 }
107126 </style >
You can’t perform that action at this time.
0 commit comments