Skip to content

Commit 61153cc

Browse files
committed
[feature] Halt game when bot substitution is intended
1 parent 8f33a9d commit 61153cc

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

internal/app/controller/engine.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ func (e *Engine) UndoLastAction() {
8686
}
8787

8888
func (e *Engine) Continue() {
89-
if e.State.NextCommand != CommandUnknown {
89+
if e.State.BotSubstitutionIntend() {
90+
e.State.TeamState[TeamBlue].BotSubstitutionIntend = false
91+
e.State.TeamState[TeamYellow].BotSubstitutionIntend = false
92+
e.SendCommand(CommandHalt, "")
93+
} else if e.State.NextCommand != CommandUnknown {
9094
e.SendCommand(e.State.NextCommand, e.State.NextCommandFor)
9195
}
9296
}
@@ -454,8 +458,8 @@ func (e *Engine) processTeamModify(m *EventModifyValue) error {
454458
}
455459
} else if m.CanPlaceBall != nil {
456460
teamState.CanPlaceBall = *m.CanPlaceBall
457-
} else if m.BotInterchangeIntend != nil {
458-
teamState.BotInterchangeIntend = *m.BotInterchangeIntend
461+
} else if m.BotSubstitutionIntend != nil {
462+
teamState.BotSubstitutionIntend = *m.BotSubstitutionIntend
459463
} else {
460464
return errors.Errorf("Unknown modify: %v", m)
461465
}

internal/app/controller/events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type EventModifyValue struct {
114114
Division *Division `json:"division,omitempty"`
115115
AutoContinue *bool `json:"autoContinue,omitempty"`
116116
GameEventBehavior *EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty"`
117-
BotInterchangeIntend *bool `json:"botInterchangeIntend,omitempty"`
117+
BotSubstitutionIntend *bool `json:"botSubstitutionIntend,omitempty"`
118118
}
119119

120120
func (m EventModifyValue) String() string {

internal/app/controller/state.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ type TeamInfo struct {
245245
CanPlaceBall bool `json:"canPlaceBall"`
246246
MaxAllowedBots int `json:"maxAllowedBots"`
247247
Connected bool `json:"connected"`
248-
BotInterchangeIntend bool `json:"botInterchangeIntend"`
248+
BotSubstitutionIntend bool `json:"botSubstitutionIntend"`
249249
}
250250

251251
type GameEventBehavior string
@@ -334,6 +334,10 @@ func (s State) GameState() GameState {
334334
return ""
335335
}
336336

337+
func (s State) BotSubstitutionIntend() bool {
338+
return s.TeamState[TeamYellow].BotSubstitutionIntend || s.TeamState[TeamBlue].BotSubstitutionIntend
339+
}
340+
337341
func newTeamInfo() (t TeamInfo) {
338342
t.Name = ""
339343
t.Goals = 0

src/components/team/TeamBotInterchange.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<div>
33
<label>Intends to interchange a bot: </label>
44
<a class="btn-edit" v-on:click="edit()">
5-
<font-awesome-icon icon="toggle-on" v-if="botInterchangeIntend"/>
6-
<font-awesome-icon icon="toggle-off" v-if="!botInterchangeIntend"/>
5+
<font-awesome-icon icon="toggle-on" v-if="botSubstitutionIntend"/>
6+
<font-awesome-icon icon="toggle-off" v-if="!botSubstitutionIntend"/>
77
</a>
88
</div>
99
</template>
@@ -19,7 +19,7 @@
1919
this.$socket.sendObj({
2020
'modify': {
2121
'forTeam': this.teamColor,
22-
'botInterchangeIntend': !this.botInterchangeIntend
22+
'botSubstitutionIntend': !this.botSubstitutionIntend
2323
}
2424
})
2525
}
@@ -28,8 +28,8 @@
2828
teamState: function () {
2929
return this.$store.state.refBoxState.teamState[this.teamColor]
3030
},
31-
botInterchangeIntend() {
32-
return this.teamState.botInterchangeIntend;
31+
botSubstitutionIntend() {
32+
return this.teamState.botSubstitutionIntend;
3333
},
3434
}
3535
}

0 commit comments

Comments
 (0)