File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,15 @@ import (
55 "github.com/RoboCup-SSL/ssl-game-controller/internal/app/statemachine"
66 "log"
77 "math"
8- "time"
98)
109
1110const maxProposals = 5
1211
1312func (e * Engine ) processProposals () {
14-
15- now := e .timeProvider ()
16- proposalTimeout := e .gameConfig .AutoRefProposalTimeout
17- minTime := now .Add (- proposalTimeout )
18-
1913 for i , group := range e .currentState .ProposalGroups {
2014 latestGameEvent := group .Proposals [len (group .Proposals )- 1 ].GameEvent
21- if * group .Accepted || groupHasRecentProposal (group , minTime ) ||
15+ if * group .Accepted ||
16+ e .groupIsStillAcceptingProposals (group ) ||
2217 e .config .GameEventBehavior [latestGameEvent .Type .String ()] == Config_BEHAVIOR_PROPOSE_ONLY {
2318 continue
2419 }
@@ -58,9 +53,13 @@ func uniqueOrigins(group *state.ProposalGroup) int {
5853 return len (origins )
5954}
6055
61- func groupHasRecentProposal (group * state.ProposalGroup , minTime time.Time ) bool {
62- latestProposal := group .Proposals [len (group .Proposals )- 1 ]
63- return goTime (latestProposal .Timestamp ).Before (minTime )
56+ func (e * Engine ) groupIsStillAcceptingProposals (group * state.ProposalGroup ) bool {
57+ firstProposal := group .Proposals [0 ]
58+
59+ now := e .timeProvider ()
60+ proposalTimeout := e .gameConfig .AutoRefProposalTimeout
61+
62+ return now .Sub (firstProposal .Timestamp .AsTime ()) < proposalTimeout
6463}
6564
6665func (e * Engine ) numAutoRefs (gameEvent * state.GameEvent ) (n int ) {
You can’t perform that action at this time.
0 commit comments