Skip to content

Commit ec505b7

Browse files
committed
[bugfix] Reset bot substitution trigger after first continuation
botSubstitution will be called after a tooManyRobots event, when trying to continue the game. The GC does not know if the robots have been substituted, so on the second continue trigger, it should go on with the game.
1 parent 7c67ba0 commit ec505b7

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

internal/app/controller/state.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (t Team) Known() bool {
4444
return !t.Unknown()
4545
}
4646

47+
// toProto converts the Team to a protobuf Team
4748
func (t Team) toProto() refproto.Team {
4849
if t == TeamYellow {
4950
return refproto.Team_YELLOW
@@ -53,6 +54,17 @@ func (t Team) toProto() refproto.Team {
5354
return refproto.Team_UNKNOWN
5455
}
5556

57+
// Is returns true, if the team is equal to given team, respecting unknown and both accordingly
58+
func (t Team) Is(team Team) bool {
59+
if team == TeamUnknown {
60+
return false
61+
}
62+
if t == TeamBoth {
63+
return true
64+
}
65+
return t == team
66+
}
67+
5668
// NewTeam creates a team from a protobuf team. Its either a single team or unknown. Not both.
5769
func NewTeam(team refproto.Team) Team {
5870
if team == refproto.Team_YELLOW {
@@ -464,7 +476,10 @@ func (s State) BotSubstitutionIntend() Team {
464476
if event.Type == GameEventTooManyRobots {
465477
blue = blue || event.ByTeam() == TeamBlue
466478
yellow = yellow || event.ByTeam() == TeamYellow
467-
break
479+
} else if event.Type == GameEventBotSubstitution {
480+
// reset after a sub substitution event
481+
blue = false
482+
yellow = false
468483
}
469484
}
470485

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
initialState:
2+
stage: First Half
3+
command: stop
4+
division: DivA
5+
gameEvents:
6+
- type: ballLeftFieldGoalLine
7+
details:
8+
ballleftfieldgoalline:
9+
byteam: 1 # Yellow
10+
bybot: 0
11+
location:
12+
x: 6.0
13+
y: 4.0
14+
transitions:
15+
- event:
16+
gameEvent:
17+
type: tooManyRobots
18+
details:
19+
toomanyrobots:
20+
byteam: 1 # Yellow
21+
expectedStateDiff:
22+
command: stop
23+
nextCommand: direct
24+
nextCommandFor: Blue
25+
placementPos:
26+
x: 5.8
27+
y: 4.3
28+
gameEvents:
29+
- type: ballLeftFieldGoalLine
30+
details:
31+
ballleftfieldgoalline:
32+
byteam: 1 # Yellow
33+
bybot: 0
34+
location:
35+
x: 6.0
36+
y: 4.0
37+
- type: tooManyRobots
38+
details:
39+
toomanyrobots:
40+
byteam: 1 # Yellow
41+
- event:
42+
trigger:
43+
type: continue
44+
expectedStateDiff:
45+
command: halt
46+
placementPos:
47+
x: 5.8
48+
y: 4.3
49+
gameEvents:
50+
- type: ballLeftFieldGoalLine
51+
details:
52+
ballleftfieldgoalline:
53+
byteam: 1 # Yellow
54+
bybot: 0
55+
location:
56+
x: 6.0
57+
y: 4.0
58+
- type: tooManyRobots
59+
details:
60+
toomanyrobots:
61+
byteam: 1 # Yellow
62+
- type: botSubstitution
63+
details:
64+
botsubstitution:
65+
byteam: 1 # Yellow
66+
- event:
67+
trigger:
68+
type: continue
69+
expectedStateDiff:
70+
command: direct
71+
commandFor: Blue
72+
nextCommand: ""
73+
nextCommandFor: ""
74+
gameEvents: []
75+
currentActionDeadline: "2010-01-01T00:00:05Z"
76+
currentActionTimeRemaining: 5s

0 commit comments

Comments
 (0)