Skip to content

Commit f9e9456

Browse files
committed
Do not apply proposal timeout to some game events
1 parent 9044df2 commit f9e9456

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/app/statemachine/change_proposedgameevent.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ func findGroup(proposal *state.Proposal, proposals []*state.ProposalGroup, timeo
2626
for i, group := range proposals {
2727
latestProposal := group.Proposals[len(group.Proposals)-1]
2828
if gameEventsSimilar(proposal.GameEvent, latestProposal.GameEvent) &&
29-
goTime(proposal.Timestamp).Sub(goTime(latestProposal.Timestamp)) < timeout {
29+
(isNonTimeoutEvent(proposal) || goTime(proposal.Timestamp).Sub(goTime(latestProposal.Timestamp)) < timeout) {
3030
return true, i
3131
}
3232
}
3333
return false, -1
3434
}
3535

36+
func isNonTimeoutEvent(proposal *state.Proposal) bool {
37+
switch *proposal.GameEvent.Type {
38+
case state.GameEvent_PLACEMENT_SUCCEEDED,
39+
state.GameEvent_PLACEMENT_FAILED,
40+
state.GameEvent_PENALTY_KICK_FAILED:
41+
// Do not apply timeout to those events, as they are valid for the whole game stage
42+
return true
43+
}
44+
return false
45+
}
46+
3647
func gameEventsSimilar(e1, e2 *state.GameEvent) bool {
3748
if *e1.Type != *e2.Type {
3849
return false

0 commit comments

Comments
 (0)