File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package controller
2
2
3
3
import (
4
4
"fmt"
5
+ "github.com/RoboCup-SSL/ssl-game-controller/pkg/refproto"
5
6
"github.com/pkg/errors"
6
7
"log"
7
8
"strconv"
@@ -547,7 +548,7 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
547
548
e .AddGameEvent (* event )
548
549
e .State .PlacementPos = e .BallPlacementPos ()
549
550
550
- if e .State .GameState () != GameStateHalted && ! event .IsContinued () {
551
+ if e .State .GameState () != GameStateHalted && ! event .IsContinued () && ! event . IsSecondary () {
551
552
teamInFavor := event .ByTeam ().Opposite ()
552
553
if e .State .PlacementPos != nil {
553
554
if e .State .TeamState [teamInFavor ].CanPlaceBall {
@@ -563,6 +564,18 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
563
564
}
564
565
565
566
log .Printf ("Processed game event %v" , event )
567
+
568
+ for _ , team := range []Team {TeamBlue , TeamYellow } {
569
+ counter := e .State .TeamState [team ].FoulCounter
570
+ counterPunished := e .State .TeamState [team ].FoulCounterPunished
571
+ if counter > 0 && counter % 3 == 0 && counter != counterPunished {
572
+ e .State .TeamState [team ].FoulCounterPunished = counter
573
+ teamProto := team .toProto ()
574
+ return e .processGameEvent (& GameEvent {Type : GameEventMultipleFouls ,
575
+ Details : GameEventDetails {MultipleFouls : & refproto.GameEvent_MultipleFouls {ByTeam : & teamProto }}})
576
+ }
577
+ }
578
+
566
579
return nil
567
580
}
568
581
Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ func (t Team) Known() bool {
40
40
return ! t .Unknown ()
41
41
}
42
42
43
+ func (t Team ) toProto () refproto.Team {
44
+ if t == TeamYellow {
45
+ return refproto .Team_YELLOW
46
+ } else if t == TeamBlue {
47
+ return refproto .Team_BLUE
48
+ }
49
+ return refproto .Team_UNKNOWN
50
+ }
51
+
43
52
// NewTeam creates a team from a protobuf team
44
53
func NewTeam (team refproto.Team ) Team {
45
54
if team == refproto .Team_YELLOW {
@@ -225,6 +234,7 @@ type TeamInfo struct {
225
234
TimeoutTimeLeft time.Duration `json:"timeoutTimeLeft"`
226
235
OnPositiveHalf bool `json:"onPositiveHalf"`
227
236
FoulCounter int `json:"foulCounter"`
237
+ FoulCounterPunished int `json:"foulCounterPunished"`
228
238
BallPlacementFailures int `json:"ballPlacementFailures"`
229
239
CanPlaceBall bool `json:"canPlaceBall"`
230
240
}
You can’t perform that action at this time.
0 commit comments