Skip to content

Commit 3691237

Browse files
committed
Show next continue actions in disabled state during HALT
1 parent f35e00d commit 3691237

File tree

7 files changed

+130
-102
lines changed

7 files changed

+130
-102
lines changed

frontend/src/components/match/ContinueActionButton.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const color = computed(() => {
2929
return 'negative'
3030
case ContinueAction_State.WAITING:
3131
return 'warning'
32+
case ContinueAction_State.DISABLED:
33+
return 'negative'
3234
default:
3335
return 'secondary'
3436
}
@@ -94,6 +96,7 @@ const submitAction = () => {
9496
<template>
9597
<q-btn class="q-mx-md q-my-xs"
9698
:color="color"
99+
:disable="props.action.state === ContinueAction_State.DISABLED"
97100
@click="submitAction">
98101
<TeamBadge :team="team"/>
99102
{{ label }}

frontend/src/proto/ssl_gc_engine.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export enum ContinueAction_State {
282282
WAITING = "WAITING",
283283
READY_AUTO = "READY_AUTO",
284284
READY_MANUAL = "READY_MANUAL",
285+
DISABLED = "DISABLED",
285286
UNRECOGNIZED = "UNRECOGNIZED",
286287
}
287288

@@ -302,6 +303,9 @@ export function continueAction_StateFromJSON(object: any): ContinueAction_State
302303
case 4:
303304
case "READY_MANUAL":
304305
return ContinueAction_State.READY_MANUAL;
306+
case 5:
307+
case "DISABLED":
308+
return ContinueAction_State.DISABLED;
305309
case -1:
306310
case "UNRECOGNIZED":
307311
default:
@@ -321,6 +325,8 @@ export function continueAction_StateToJSON(object: ContinueAction_State): string
321325
return "READY_AUTO";
322326
case ContinueAction_State.READY_MANUAL:
323327
return "READY_MANUAL";
328+
case ContinueAction_State.DISABLED:
329+
return "DISABLED";
324330
case ContinueAction_State.UNRECOGNIZED:
325331
default:
326332
return "UNRECOGNIZED";

frontend/src/proto/ssl_gc_game_event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ export interface GameEvent_BotInterferedPlacement {
707707
location?: Vector2;
708708
}
709709

710-
/** a team collected multiple cards (yellow and red), which results in a penalty kick */
710+
/** a team collected multiple yellow cards */
711711
export interface GameEvent_MultipleCards {
712712
/** the team that received multiple yellow cards */
713713
byTeam?: Team;

internal/app/engine/process_continue_next_action.go

Lines changed: 105 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -71,120 +71,134 @@ 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-
for _, team := range state.BothTeams() {
75-
if e.currentState.HasGameEventByTeam(state.GameEvent_POSSIBLE_GOAL, team) &&
76-
!e.currentState.HasGameEventByTeam(state.GameEvent_GOAL, team) &&
77-
!e.currentState.HasGameEventByTeam(state.GameEvent_INVALID_GOAL, team) {
78-
actions = append(actions, createContinueAction(
79-
ContinueAction_ACCEPT_GOAL,
80-
team,
81-
ContinueAction_READY_MANUAL,
82-
))
83-
}
74+
newActions, newHints := e.actionsToContinueFromStop()
75+
actions = append(actions, newActions...)
76+
hints = append(hints, newHints...)
77+
} else {
78+
// reset random placing team
79+
e.randomPlacingTeam = state.Team_UNKNOWN
80+
}
8481

85-
challengeFlagsRaised := len(e.currentState.FindGameEventsByTeam(state.GameEvent_CHALLENGE_FLAG, team))
86-
challengeFlagsHandled := len(e.currentState.FindGameEventsByTeam(state.GameEvent_CHALLENGE_FLAG_HANDLED, team))
87-
88-
if challengeFlagsRaised > challengeFlagsHandled {
89-
actions = append(actions, createContinueAction(
90-
ContinueAction_CHALLENGE_ACCEPT,
91-
team,
92-
ContinueAction_READY_MANUAL,
93-
))
94-
actions = append(actions, createContinueAction(
95-
ContinueAction_CHALLENGE_REJECT,
96-
team,
97-
ContinueAction_READY_MANUAL,
98-
))
82+
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
9992
}
10093
}
101-
}
10294

103-
if *e.currentState.Command.Type == state.Command_STOP ||
104-
*e.currentState.Command.Type == state.Command_HALT {
105-
if (e.gameConfig.RecommendHalfTimes || e.currentState.Stage.IsPausedStage()) &&
106-
e.currentState.StageTimeLeft.AsDuration() < 0 &&
107-
*e.currentState.Stage != state.Referee_PENALTY_SHOOTOUT {
108-
actions = append(actions, createContinueAction(
109-
ContinueAction_NEXT_STAGE,
110-
state.Team_UNKNOWN,
111-
ContinueAction_READY_MANUAL,
112-
))
95+
continueFromHalt := createContinueAction(
96+
ContinueAction_RESUME_FROM_HALT,
97+
state.Team_UNKNOWN,
98+
ContinueAction_READY_MANUAL,
99+
)
100+
if e.teamDoingBotSubstitution() {
101+
continueFromHalt.ContinuationIssues = append(continueFromHalt.ContinuationIssues,
102+
"Robot substitution in progress")
113103
}
114-
if suggestEndOfMatch(e.currentState) {
104+
actions = append([]*ContinueAction{continueFromHalt}, actions...)
105+
}
106+
107+
return
108+
}
109+
110+
func (e *Engine) actionsToContinueFromStop() (actions []*ContinueAction, hints []*ContinueHint) {
111+
for _, team := range state.BothTeams() {
112+
if e.currentState.HasGameEventByTeam(state.GameEvent_POSSIBLE_GOAL, team) &&
113+
!e.currentState.HasGameEventByTeam(state.GameEvent_GOAL, team) &&
114+
!e.currentState.HasGameEventByTeam(state.GameEvent_INVALID_GOAL, team) {
115115
actions = append(actions, createContinueAction(
116-
ContinueAction_END_GAME,
117-
state.Team_UNKNOWN,
116+
ContinueAction_ACCEPT_GOAL,
117+
team,
118118
ContinueAction_READY_MANUAL,
119119
))
120120
}
121121

122-
var teamRequestingBotSubstitution = e.teamRequestingBotSubstitution()
123-
var teamRequestingTimeout = e.teamRequestingTimeout()
124-
if teamRequestingBotSubstitution != nil {
122+
challengeFlagsRaised := len(e.currentState.FindGameEventsByTeam(state.GameEvent_CHALLENGE_FLAG, team))
123+
challengeFlagsHandled := len(e.currentState.FindGameEventsByTeam(state.GameEvent_CHALLENGE_FLAG_HANDLED, team))
124+
125+
if challengeFlagsRaised > challengeFlagsHandled {
125126
actions = append(actions, createContinueAction(
126-
ContinueAction_BOT_SUBSTITUTION,
127-
*teamRequestingBotSubstitution,
128-
ContinueAction_READY_AUTO,
127+
ContinueAction_CHALLENGE_ACCEPT,
128+
team,
129+
ContinueAction_READY_MANUAL,
129130
))
130-
} else if teamRequestingTimeout != nil {
131131
actions = append(actions, createContinueAction(
132-
ContinueAction_TIMEOUT_START,
133-
*teamRequestingTimeout,
132+
ContinueAction_CHALLENGE_REJECT,
133+
team,
134134
ContinueAction_READY_MANUAL,
135135
))
136136
}
137137
}
138138

139-
if *e.currentState.Command.Type == state.Command_STOP {
140-
if e.ballPlacementRequired() {
141-
placingTeam := e.ballPlacementTeam()
142-
if placingTeam.Known() {
143-
actions = append(actions, createContinueAction(
144-
ContinueAction_BALL_PLACEMENT_START,
145-
placingTeam,
146-
ContinueAction_READY_AUTO,
147-
))
148-
} else {
149-
hint := fmt.Sprintf("Manually place the ball at x: %.2fm, y: %.2fm",
150-
*e.currentState.PlacementPos.X, *e.currentState.PlacementPos.Y)
151-
hints = append(hints, &ContinueHint{
152-
Message: &hint,
153-
})
154-
}
155-
}
156-
if e.currentState.NextCommand != nil {
157-
var forTeam state.Team
158-
if e.currentState.NextCommand != nil && e.currentState.NextCommand.ForTeam != nil {
159-
forTeam = *e.currentState.NextCommand.ForTeam
160-
} else {
161-
forTeam = state.Team_UNKNOWN
162-
}
163-
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_NEXT_COMMAND, forTeam))
164-
} else {
165-
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FORCE_START, state.Team_UNKNOWN))
166-
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FREE_KICK, state.Team_YELLOW))
167-
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FREE_KICK, state.Team_BLUE))
168-
}
169-
} else {
170-
// reset random placing team
171-
e.randomPlacingTeam = state.Team_UNKNOWN
139+
if (e.gameConfig.RecommendHalfTimes || e.currentState.Stage.IsPausedStage()) &&
140+
e.currentState.StageTimeLeft.AsDuration() < 0 &&
141+
*e.currentState.Stage != state.Referee_PENALTY_SHOOTOUT {
142+
actions = append(actions, createContinueAction(
143+
ContinueAction_NEXT_STAGE,
144+
state.Team_UNKNOWN,
145+
ContinueAction_READY_MANUAL,
146+
))
172147
}
173-
174-
if *e.currentState.Command.Type == state.Command_HALT {
175-
continueFromHalt := createContinueAction(
176-
ContinueAction_RESUME_FROM_HALT,
148+
if suggestEndOfMatch(e.currentState) {
149+
actions = append(actions, createContinueAction(
150+
ContinueAction_END_GAME,
177151
state.Team_UNKNOWN,
178152
ContinueAction_READY_MANUAL,
179-
)
180-
if e.teamDoingBotSubstitution() {
181-
continueFromHalt.ContinuationIssues = append(continueFromHalt.ContinuationIssues,
182-
"Robot substitution in progress")
183-
}
184-
actions = append(actions, continueFromHalt)
153+
))
185154
}
186155

187-
return
156+
var teamRequestingBotSubstitution = e.teamRequestingBotSubstitution()
157+
var teamRequestingTimeout = e.teamRequestingTimeout()
158+
if teamRequestingBotSubstitution != nil {
159+
actions = append(actions, createContinueAction(
160+
ContinueAction_BOT_SUBSTITUTION,
161+
*teamRequestingBotSubstitution,
162+
ContinueAction_READY_AUTO,
163+
))
164+
} else if teamRequestingTimeout != nil {
165+
actions = append(actions, createContinueAction(
166+
ContinueAction_TIMEOUT_START,
167+
*teamRequestingTimeout,
168+
ContinueAction_READY_MANUAL,
169+
))
170+
}
171+
172+
if e.ballPlacementRequired() {
173+
placingTeam := e.ballPlacementTeam()
174+
if placingTeam.Known() {
175+
actions = append(actions, createContinueAction(
176+
ContinueAction_BALL_PLACEMENT_START,
177+
placingTeam,
178+
ContinueAction_READY_AUTO,
179+
))
180+
} else {
181+
hint := fmt.Sprintf("Manually place the ball at x: %.2fm, y: %.2fm",
182+
*e.currentState.PlacementPos.X, *e.currentState.PlacementPos.Y)
183+
hints = append(hints, &ContinueHint{
184+
Message: &hint,
185+
})
186+
}
187+
}
188+
if e.currentState.NextCommand != nil {
189+
var forTeam state.Team
190+
if e.currentState.NextCommand != nil && e.currentState.NextCommand.ForTeam != nil {
191+
forTeam = *e.currentState.NextCommand.ForTeam
192+
} else {
193+
forTeam = state.Team_UNKNOWN
194+
}
195+
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_NEXT_COMMAND, forTeam))
196+
} else {
197+
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FORCE_START, state.Team_UNKNOWN))
198+
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FREE_KICK, state.Team_YELLOW))
199+
actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FREE_KICK, state.Team_BLUE))
200+
}
201+
return actions, hints
188202
}
189203

190204
func (e *Engine) teamRequestingBotSubstitution() *state.Team {

internal/app/engine/ssl_gc_engine.pb.go

Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/app/state/ssl_gc_game_event.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ssl_gc_engine.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ message ContinueAction {
141141
WAITING = 2;
142142
READY_AUTO = 3;
143143
READY_MANUAL = 4;
144+
DISABLED = 5;
144145
}
145146
}
146147

0 commit comments

Comments
 (0)