File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -682,9 +682,9 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
682
682
e .LogIgnoredGameEvent (* event )
683
683
return nil
684
684
}
685
- e . AddGameEvent ( * event )
685
+ event . SetOccurred ( e . TimeProvider () )
686
686
687
- if event .IncrementsFoulCounter () {
687
+ if ! e . State . MatchesRecentGameEvent ( event ) && event .IncrementsFoulCounter () {
688
688
team := event .ByTeam ()
689
689
if team .Unknown () {
690
690
e .State .TeamState [TeamYellow ].FoulCounter ++
@@ -697,6 +697,8 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
697
697
}
698
698
}
699
699
700
+ e .AddGameEvent (* event )
701
+
700
702
if event .AddsYellowCard () {
701
703
team := event .ByTeam ()
702
704
if team .Unknown () {
Original file line number Diff line number Diff line change 6
6
"github.com/RoboCup-SSL/ssl-game-controller/pkg/refproto"
7
7
"log"
8
8
"reflect"
9
+ "time"
9
10
)
10
11
11
12
type GameEventType string
@@ -113,9 +114,18 @@ func (g GameEventType) Valid() bool {
113
114
114
115
// GameEvent combines the type of a game event with the corresponding detail structures
115
116
type GameEvent struct {
116
- Type GameEventType `json:"type"`
117
- Details GameEventDetails `json:"details"`
118
- Origins []string `json:"origins"`
117
+ Type GameEventType `json:"type"`
118
+ Details GameEventDetails `json:"details"`
119
+ Origins []string `json:"origins"`
120
+ occurred time.Time `json:"-"`
121
+ }
122
+
123
+ func (e * GameEvent ) SetOccurred (occurred time.Time ) {
124
+ e .occurred = occurred
125
+ }
126
+
127
+ func (e GameEvent ) Occurred () time.Time {
128
+ return e .occurred
119
129
}
120
130
121
131
// String converts the game event into a string
Original file line number Diff line number Diff line change @@ -571,6 +571,16 @@ func (s *State) GetFirstGameEvent(gameEventType GameEventType) *GameEvent {
571
571
return nil
572
572
}
573
573
574
+ func (s * State ) MatchesRecentGameEvent (event * GameEvent ) bool {
575
+ for _ , gameEvent := range s .GameEvents {
576
+ if gameEvent .Type == event .Type &&
577
+ event .Occurred ().Sub (gameEvent .Occurred ()) < 5 * time .Second {
578
+ return true
579
+ }
580
+ }
581
+ return false
582
+ }
583
+
574
584
// Location is a two-dimensional coordinate
575
585
type Location struct {
576
586
X float64 `json:"x" yaml:"x"`
You can’t perform that action at this time.
0 commit comments