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 {
682682 e .LogIgnoredGameEvent (* event )
683683 return nil
684684 }
685- e . AddGameEvent ( * event )
685+ event . SetOccurred ( e . TimeProvider () )
686686
687- if event .IncrementsFoulCounter () {
687+ if ! e . State . MatchesRecentGameEvent ( event ) && event .IncrementsFoulCounter () {
688688 team := event .ByTeam ()
689689 if team .Unknown () {
690690 e .State .TeamState [TeamYellow ].FoulCounter ++
@@ -697,6 +697,8 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
697697 }
698698 }
699699
700+ e .AddGameEvent (* event )
701+
700702 if event .AddsYellowCard () {
701703 team := event .ByTeam ()
702704 if team .Unknown () {
Original file line number Diff line number Diff line change 66 "github.com/RoboCup-SSL/ssl-game-controller/pkg/refproto"
77 "log"
88 "reflect"
9+ "time"
910)
1011
1112type GameEventType string
@@ -113,9 +114,18 @@ func (g GameEventType) Valid() bool {
113114
114115// GameEvent combines the type of a game event with the corresponding detail structures
115116type 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
119129}
120130
121131// 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 {
571571 return nil
572572}
573573
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+
574584// Location is a two-dimensional coordinate
575585type Location struct {
576586 X float64 `json:"x" yaml:"x"`
You can’t perform that action at this time.
0 commit comments