Skip to content

Commit fcb5e3a

Browse files
committed
Require explicit rejection of possible goals
1 parent c1285ce commit fcb5e3a

File tree

7 files changed

+63
-21
lines changed

7 files changed

+63
-21
lines changed

frontend/src/helpers/texts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ export function continueActionLabel(type: ContinueAction_Type, nextCommand?: Com
176176
return 'End match'
177177
case ContinueAction_Type.ACCEPT_GOAL:
178178
return 'Accept Goal'
179+
case ContinueAction_Type.REJECT_GOAL:
180+
return 'Reject Goal'
179181
case ContinueAction_Type.NORMAL_START:
180182
return 'Normal Start'
181183
case ContinueAction_Type.CHALLENGE_ACCEPT:

frontend/src/proto/ssl_gc_engine.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export enum ContinueAction_Type {
153153
NEXT_STAGE = "NEXT_STAGE",
154154
END_GAME = "END_GAME",
155155
ACCEPT_GOAL = "ACCEPT_GOAL",
156+
REJECT_GOAL = "REJECT_GOAL",
156157
NORMAL_START = "NORMAL_START",
157158
CHALLENGE_ACCEPT = "CHALLENGE_ACCEPT",
158159
CHALLENGE_REJECT = "CHALLENGE_REJECT",
@@ -212,6 +213,9 @@ export function continueAction_TypeFromJSON(object: any): ContinueAction_Type {
212213
case 12:
213214
case "ACCEPT_GOAL":
214215
return ContinueAction_Type.ACCEPT_GOAL;
216+
case 20:
217+
case "REJECT_GOAL":
218+
return ContinueAction_Type.REJECT_GOAL;
215219
case 13:
216220
case "NORMAL_START":
217221
return ContinueAction_Type.NORMAL_START;
@@ -264,6 +268,8 @@ export function continueAction_TypeToJSON(object: ContinueAction_Type): string {
264268
return "END_GAME";
265269
case ContinueAction_Type.ACCEPT_GOAL:
266270
return "ACCEPT_GOAL";
271+
case ContinueAction_Type.REJECT_GOAL:
272+
return "REJECT_GOAL";
267273
case ContinueAction_Type.NORMAL_START:
268274
return "NORMAL_START";
269275
case ContinueAction_Type.CHALLENGE_ACCEPT:

internal/app/engine/process_continue_next_action.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ func (e *Engine) actionsToContinueFromStop() (actions []*ContinueAction, hints [
126126
actions = append(actions, continueActionAcceptGoal)
127127
}
128128

129+
if e.currentState.HasGameEventByTeam(state.GameEvent_POSSIBLE_GOAL, team) &&
130+
!e.currentState.HasGameEventByTeam(state.GameEvent_INVALID_GOAL, team) {
131+
continueActionRejectGoal := createContinueAction(
132+
ContinueAction_REJECT_GOAL,
133+
team,
134+
ContinueAction_READY_MANUAL,
135+
)
136+
actions = append(actions, continueActionRejectGoal)
137+
}
138+
129139
challengeFlagsRaised := len(e.currentState.FindGameEventsByTeam(state.GameEvent_CHALLENGE_FLAG, team))
130140
challengeFlagsHandled := len(e.currentState.FindGameEventsByTeam(state.GameEvent_CHALLENGE_FLAG_HANDLED, team))
131141

internal/app/engine/process_continue_perform.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ func (e *Engine) performContinueAction(action *ContinueAction) {
7272
} else {
7373
log.Println("No possible goal event present to accept")
7474
}
75+
case ContinueAction_REJECT_GOAL:
76+
possibleGoals := e.currentState.FindGameEventsByTeam(state.GameEvent_POSSIBLE_GOAL, *action.ForTeam)
77+
if len(possibleGoals) == 1 {
78+
possibleGoal := possibleGoals[0]
79+
goal := state.GameEvent_Goal{}
80+
proto.Merge(&goal, possibleGoal.GetPossibleGoal())
81+
goal.Message = new(string)
82+
*goal.Message = "Rejected by GC operator"
83+
goalEvent := &state.GameEvent{
84+
Event: &state.GameEvent_InvalidGoal{
85+
InvalidGoal: &goal,
86+
},
87+
}
88+
e.Enqueue(createGameEventChange(state.GameEvent_INVALID_GOAL, goalEvent))
89+
} else {
90+
log.Println("No possible goal event present to reject")
91+
}
7592
case ContinueAction_NORMAL_START:
7693
e.Enqueue(createCommandChange(state.NewCommandNeutral(state.Command_NORMAL_START)))
7794
case ContinueAction_CHALLENGE_ACCEPT:

internal/app/engine/ssl_gc_engine.pb.go

Lines changed: 24 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/app/statemachine/change_gameevent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ func (s *StateMachine) nextCommandForEvent(newState *state.State, gameEvent *sta
349349
state.GameEvent_BOT_DRIBBLED_BALL_TOO_FAR,
350350
state.GameEvent_ATTACKER_DOUBLE_TOUCHED_BALL,
351351
state.GameEvent_PENALTY_KICK_FAILED,
352-
state.GameEvent_POSSIBLE_GOAL,
353352
state.GameEvent_INVALID_GOAL:
354353
return lastCommandOnUnknownTeam(
355354
newState.NextCommand,
@@ -392,6 +391,9 @@ func (s *StateMachine) nextCommandForEvent(newState *state.State, gameEvent *sta
392391
newState.NextCommand,
393392
state.NewCommand(state.Command_DIRECT, gameEvent.ByTeam().Opposite()),
394393
)
394+
case state.GameEvent_POSSIBLE_GOAL:
395+
// explicitly no next command. GCO has to accept or reject the goal.
396+
return nil
395397
default:
396398
return newState.NextCommand
397399
}

proto/ssl_gc_engine.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ message ContinueAction {
130130
NEXT_STAGE = 8;
131131
END_GAME = 16;
132132
ACCEPT_GOAL = 12;
133+
REJECT_GOAL = 20;
133134
NORMAL_START = 13;
134135
CHALLENGE_ACCEPT = 18;
135136
CHALLENGE_REJECT = 19;

0 commit comments

Comments
 (0)