Skip to content

Commit 60a4690

Browse files
committed
[feature] Send game events with advantage choice request
1 parent 251871d commit 60a4690

File tree

3 files changed

+69
-37
lines changed

3 files changed

+69
-37
lines changed

internal/app/controller/teamConnection.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,23 @@ func (c *GameController) askForTeamDecisionIfRequired(event Event) (handled bool
9393
handled = false
9494
if c.outstandingTeamChoice == nil && c.Engine.State.GameState() == GameStateRunning {
9595
var byTeamProto refproto.Team
96-
var choiceType refproto.AdvantageChoice_Foul
96+
var choice refproto.AdvantageChoice
97+
choice.Foul = new(refproto.AdvantageChoice_Foul)
9798
if event.GameEvent.Details.BotCrashUnique != nil {
9899
byTeamProto = *event.GameEvent.Details.BotCrashUnique.ByTeam
99-
choiceType = refproto.AdvantageChoice_COLLISION
100+
*choice.Foul = refproto.AdvantageChoice_COLLISION
101+
choice.BotCrashUnique = new(refproto.GameEvent_BotCrashUnique)
102+
*choice.BotCrashUnique = *event.GameEvent.Details.BotCrashUnique
100103
} else if event.GameEvent.Details.BotPushedBot != nil {
101104
byTeamProto = *event.GameEvent.Details.BotPushedBot.ByTeam
102-
choiceType = refproto.AdvantageChoice_PUSHING
105+
*choice.Foul = refproto.AdvantageChoice_PUSHING
106+
choice.BotPushedBot = new(refproto.GameEvent_BotPushedBot)
107+
*choice.BotPushedBot = *event.GameEvent.Details.BotPushedBot
103108
}
104109

105110
forTeam := NewTeam(byTeamProto).Opposite()
106111
if forTeam != "" {
107112
teamName := c.Engine.State.TeamState[forTeam].Name
108-
choice := refproto.AdvantageChoice{Foul: &choiceType}
109113
requestPayload := refproto.ControllerToTeam_AdvantageChoice{AdvantageChoice: &choice}
110114
request := refproto.ControllerToTeam{Msg: &requestPayload}
111115
err := c.TeamServer.SendRequest(teamName, request)

pkg/refproto/ssl_game_controller_team.pb.go

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

pkg/refproto/ssl_game_controller_team.proto

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto2";
22

3+
import "ssl_game_event_2019.proto";
34
import "ssl_game_controller_common.proto";
45

56
// a registration that must be send by teams and autoRefs to the controller as the very first message
@@ -50,6 +51,10 @@ message ControllerToTeam {
5051
message AdvantageChoice {
5152
// the type of foul that occurred
5253
required Foul foul = 1;
54+
// the bot crash event that was the source for this advantage choice
55+
optional GameEvent.BotCrashUnique bot_crash_unique = 2;
56+
// the bot push event that was the source for this advantage choice
57+
optional GameEvent.BotPushedBot bot_pushed_bot = 3;
5358

5459
enum Foul {
5560
// default value when not set
@@ -59,4 +64,4 @@ message AdvantageChoice {
5964
// an opponent bot has pushed one of your bots
6065
PUSHING = 2;
6166
}
62-
}
67+
}

0 commit comments

Comments
 (0)