@@ -40,8 +40,14 @@ func (s *StateMachine) processChangeAddGameEvent(newState *state.State, change *
40
40
if byTeam == state .Team_UNKNOWN || byTeam == team {
41
41
log .Printf ("Team %v got a foul for %v" , byTeam , gameEvent )
42
42
newState .TeamInfo (team ).AddFoul (gameEvent )
43
- if len (newState .TeamInfo (team ).Fouls )% 3 == 0 {
44
- changes = append (changes , s .multipleFoulsChange (team ))
43
+ numFouls := len (newState .TeamInfo (team ).Fouls )
44
+ if numFouls % 3 == 0 {
45
+ var causedGameEvents []* state.GameEvent
46
+ for i := numFouls - 3 ; i < numFouls ; i ++ {
47
+ causedGameEvents = append (causedGameEvents , newState .TeamInfo (team ).Fouls [i ].CausedByGameEvent )
48
+ }
49
+
50
+ changes = append (changes , s .multipleFoulsChange (team , causedGameEvents ))
45
51
}
46
52
}
47
53
}
@@ -284,11 +290,12 @@ func (s *StateMachine) isGoalValid(newState *state.State, gameEvent *state.GameE
284
290
}
285
291
286
292
// multipleFoulsChange creates a multiple fouls event change
287
- func (s * StateMachine ) multipleFoulsChange (byTeam state.Team ) * Change {
293
+ func (s * StateMachine ) multipleFoulsChange (byTeam state.Team , events [] * state. GameEvent ) * Change {
288
294
return createGameEventChange (state .GameEvent_MULTIPLE_FOULS , state.GameEvent {
289
295
Event : & state.GameEvent_MultipleFouls_ {
290
296
MultipleFouls : & state.GameEvent_MultipleFouls {
291
- ByTeam : & byTeam ,
297
+ ByTeam : & byTeam ,
298
+ CausedGameEvents : events ,
292
299
},
293
300
},
294
301
},
0 commit comments