Skip to content

Commit 530721e

Browse files
committed
Suggest timeout, substitution, etc. during HALT before resume
1 parent 55c05f5 commit 530721e

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

internal/app/engine/process_continue_next_action.go

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,12 @@ func (e *Engine) nextActions() (actions []*ContinueAction, hints []*ContinueHint
7171
}
7272

7373
if *e.currentState.Command.Type == state.Command_STOP || *e.currentState.Command.Type == state.Command_HALT {
74-
newActions, newHints := e.actionsToContinueFromStop()
74+
newActions, newHints := e.actionsDuringHaltAndStop()
7575
actions = append(actions, newActions...)
7676
hints = append(hints, newHints...)
77-
} else {
78-
// reset random placing team
79-
e.randomPlacingTeam = state.Team_UNKNOWN
8077
}
8178

8279
if *e.currentState.Command.Type == state.Command_HALT {
83-
// disable continue actions that can't be used after halt
84-
for _, action := range actions {
85-
switch *action.Type {
86-
case
87-
ContinueAction_FORCE_START,
88-
ContinueAction_FREE_KICK,
89-
ContinueAction_NEXT_COMMAND,
90-
ContinueAction_BALL_PLACEMENT_START:
91-
*action.State = ContinueAction_DISABLED
92-
}
93-
}
94-
9580
continueFromHalt := createContinueAction(
9681
ContinueAction_RESUME_FROM_HALT,
9782
state.Team_UNKNOWN,
@@ -107,13 +92,36 @@ func (e *Engine) nextActions() (actions []*ContinueAction, hints []*ContinueHint
10792
*continueFromHalt.State = ContinueAction_DISABLED
10893
}
10994

110-
actions = append([]*ContinueAction{continueFromHalt}, actions...)
95+
actions = append(actions, continueFromHalt)
96+
}
97+
98+
if *e.currentState.Command.Type == state.Command_STOP || *e.currentState.Command.Type == state.Command_HALT {
99+
newActions, newHints := e.actionsToContinueFromStop()
100+
actions = append(actions, newActions...)
101+
hints = append(hints, newHints...)
102+
} else {
103+
// reset random placing team
104+
e.randomPlacingTeam = state.Team_UNKNOWN
105+
}
106+
107+
if *e.currentState.Command.Type == state.Command_HALT {
108+
// disable continue actions that can't be used after halt
109+
for _, action := range actions {
110+
switch *action.Type {
111+
case
112+
ContinueAction_FORCE_START,
113+
ContinueAction_FREE_KICK,
114+
ContinueAction_NEXT_COMMAND,
115+
ContinueAction_BALL_PLACEMENT_START:
116+
*action.State = ContinueAction_DISABLED
117+
}
118+
}
111119
}
112120

113121
return
114122
}
115123

116-
func (e *Engine) actionsToContinueFromStop() (actions []*ContinueAction, hints []*ContinueHint) {
124+
func (e *Engine) actionsDuringHaltAndStop() (actions []*ContinueAction, hints []*ContinueHint) {
117125
for _, team := range state.BothTeams() {
118126
if e.currentState.GameState.IsHalted() &&
119127
e.currentState.HasGameEventByTeam(state.GameEvent_POSSIBLE_GOAL, team) &&
@@ -191,7 +199,10 @@ func (e *Engine) actionsToContinueFromStop() (actions []*ContinueAction, hints [
191199
ContinueAction_READY_MANUAL,
192200
))
193201
}
202+
return actions, hints
203+
}
194204

205+
func (e *Engine) actionsToContinueFromStop() (actions []*ContinueAction, hints []*ContinueHint) {
195206
if e.ballPlacementRequired() {
196207
placingTeam := e.ballPlacementTeam()
197208
if placingTeam.Known() {

0 commit comments

Comments
 (0)