Skip to content

Commit 9b116a7

Browse files
committed
[bugfix] Set next command to last command on defenderTooCloseToKickPoint
1 parent a98d59f commit 9b116a7

File tree

3 files changed

+62
-8
lines changed

3 files changed

+62
-8
lines changed

internal/app/controller/engine.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,29 @@ func (e *Engine) updateNextCommand() {
357357
if primaryEvent == nil {
358358
return
359359
}
360-
command, forTeam, err := e.CommandForEvent(primaryEvent)
361-
if err != nil {
362-
log.Print("Warn: ", err)
363-
return
360+
if primaryEvent.Type == GameEventDefenderTooCloseToKickPoint {
361+
e.State.NextCommand, e.State.NextCommandFor =
362+
e.lastCommand([]RefCommand{CommandIndirect, CommandDirect, CommandKickoff, CommandPenalty})
363+
} else {
364+
command, forTeam, err := e.CommandForEvent(primaryEvent)
365+
if err != nil {
366+
log.Print("Warn: ", err)
367+
return
368+
}
369+
e.State.NextCommand = command
370+
e.State.NextCommandFor = forTeam
371+
}
372+
}
373+
374+
func (e *Engine) lastCommand(commands []RefCommand) (RefCommand, Team) {
375+
for i := len(e.History) - 1; i >= 0; i-- {
376+
for _, cmd := range commands {
377+
if e.History[i].State.Command == cmd {
378+
return e.History[i].State.Command, e.History[i].State.CommandFor
379+
}
380+
}
364381
}
365-
e.State.NextCommand = command
366-
e.State.NextCommandFor = forTeam
382+
return CommandUnknown, TeamUnknown
367383
}
368384

369385
func (e *Engine) processEvent(event Event) error {

internal/app/controller/gameEvent.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ func (e GameEvent) IsSecondary() bool {
236236
GameEventPrepared,
237237
GameEventBotSubstitution,
238238
GameEventTooManyRobots,
239-
GameEventBotInterferedPlacement,
240-
GameEventDefenderTooCloseToKickPoint:
239+
GameEventBotInterferedPlacement:
241240
return true
242241
}
243242
return false
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
initialState:
2+
stage: First Half
3+
command: stop
4+
division: DivA
5+
transitions:
6+
- event:
7+
command:
8+
type: indirect
9+
forTeam: Blue
10+
expectedStateDiff:
11+
command: indirect
12+
commandFor: Blue
13+
currentActionDeadline: "2010-01-01T00:00:05Z"
14+
currentActionTimeRemaining: 5s
15+
- event:
16+
gameEvent:
17+
type: defenderTooCloseToKickPoint
18+
details:
19+
defendertooclosetokickpoint:
20+
byteam: 1 # Yellow
21+
location:
22+
x: 1.0
23+
y: 2.0
24+
expectedStateDiff:
25+
command: stop
26+
commandFor: ""
27+
nextCommand: indirect
28+
nextCommandFor: Blue
29+
teamState:
30+
Yellow:
31+
foulCounter: 1
32+
gameEvents:
33+
- type: defenderTooCloseToKickPoint
34+
details:
35+
defendertooclosetokickpoint:
36+
byteam: 1 # Yellow
37+
location:
38+
x: 1.0
39+
y: 2.0

0 commit comments

Comments
 (0)