Skip to content

Commit d0df699

Browse files
committed
Show end of match button when a team has 10 goals
1 parent 5294213 commit d0df699

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

internal/app/engine/process_continue_next_action.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import (
1010
)
1111

1212
func (e *Engine) nextActions() (actions []*ContinueAction, hints []*ContinueHint) {
13+
if *e.currentState.Stage == state.Referee_POST_GAME {
14+
// match is over
15+
return
16+
}
17+
1318
if e.currentState.Stage.IsPausedStage() {
14-
if *e.currentState.Stage.Next() != *e.currentState.Stage {
15-
actions = append(actions, createContinueAction(
16-
ContinueAction_NEXT_STAGE,
17-
state.Team_UNKNOWN,
18-
ContinueAction_READY_MANUAL,
19-
))
20-
}
19+
actions = append(actions, createContinueAction(
20+
ContinueAction_NEXT_STAGE,
21+
state.Team_UNKNOWN,
22+
ContinueAction_READY_MANUAL,
23+
))
2124
// only possible action is to proceed to non-paused stage
2225
return
2326
}
@@ -326,15 +329,23 @@ func (e *Engine) randomTeam() state.Team {
326329
}
327330

328331
func suggestEndOfMatch(currentState *state.State) bool {
332+
goalsY := int(*currentState.TeamInfo(state.Team_YELLOW).Goals)
333+
goalsB := int(*currentState.TeamInfo(state.Team_BLUE).Goals)
334+
if *currentState.Stage != state.Referee_POST_GAME &&
335+
(goalsY >= 10 || goalsB >= 10) && math.Abs(float64(goalsY-goalsB)) > 1 {
336+
return true
337+
}
338+
329339
if *currentState.Stage == state.Referee_NORMAL_SECOND_HALF ||
330340
*currentState.Stage == state.Referee_EXTRA_SECOND_HALF {
331341
return currentState.StageTimeLeft.AsDuration() < 0
332-
} else if *currentState.Stage == state.Referee_EXTRA_TIME_BREAK ||
342+
}
343+
344+
if *currentState.Stage == state.Referee_EXTRA_TIME_BREAK ||
333345
*currentState.Stage == state.Referee_PENALTY_SHOOTOUT_BREAK ||
334346
*currentState.Stage == state.Referee_PENALTY_SHOOTOUT {
335347
return true
336348
}
337-
goalsY := int(*currentState.TeamInfo(state.Team_YELLOW).Goals)
338-
goalsB := int(*currentState.TeamInfo(state.Team_BLUE).Goals)
339-
return (goalsY >= 10 || goalsB >= 10) && math.Abs(float64(goalsY-goalsB)) > 1
349+
350+
return false
340351
}

0 commit comments

Comments
 (0)