Skip to content

Commit 8f33a9d

Browse files
committed
[feature] Add bot interchange intend to UI
1 parent e579b40 commit 8f33a9d

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

internal/app/controller/engine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ func (e *Engine) processTeamModify(m *EventModifyValue) error {
454454
}
455455
} else if m.CanPlaceBall != nil {
456456
teamState.CanPlaceBall = *m.CanPlaceBall
457+
} else if m.BotInterchangeIntend != nil {
458+
teamState.BotInterchangeIntend = *m.BotInterchangeIntend
457459
} else {
458460
return errors.Errorf("Unknown modify: %v", m)
459461
}

internal/app/controller/events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type EventModifyValue struct {
114114
Division *Division `json:"division,omitempty"`
115115
AutoContinue *bool `json:"autoContinue,omitempty"`
116116
GameEventBehavior *EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty"`
117+
BotInterchangeIntend *bool `json:"botInterchangeIntend,omitempty"`
117118
}
118119

119120
func (m EventModifyValue) String() string {

internal/app/controller/state.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ type TeamInfo struct {
245245
CanPlaceBall bool `json:"canPlaceBall"`
246246
MaxAllowedBots int `json:"maxAllowedBots"`
247247
Connected bool `json:"connected"`
248+
BotInterchangeIntend bool `json:"botInterchangeIntend"`
248249
}
249250

250251
type GameEventBehavior string
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<div>
3+
<label>Intends to interchange a bot: </label>
4+
<a class="btn-edit" v-on:click="edit()">
5+
<font-awesome-icon icon="toggle-on" v-if="botInterchangeIntend"/>
6+
<font-awesome-icon icon="toggle-off" v-if="!botInterchangeIntend"/>
7+
</a>
8+
</div>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: "TeamBotInterchange",
14+
props: {
15+
teamColor: String
16+
},
17+
methods: {
18+
edit: function () {
19+
this.$socket.sendObj({
20+
'modify': {
21+
'forTeam': this.teamColor,
22+
'botInterchangeIntend': !this.botInterchangeIntend
23+
}
24+
})
25+
}
26+
},
27+
computed: {
28+
teamState: function () {
29+
return this.$store.state.refBoxState.teamState[this.teamColor]
30+
},
31+
botInterchangeIntend() {
32+
return this.teamState.botInterchangeIntend;
33+
},
34+
}
35+
}
36+
</script>
37+
38+
<style scoped>
39+
.btn-edit {
40+
margin-left: 0.3em;
41+
margin-right: 0.3em;
42+
}
43+
</style>

src/components/team/TeamOverview.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
<TeamBallPlacement
5454
:team-color="teamColor"/>
5555
</div>
56+
<div>
57+
<TeamBotInterchange
58+
:team-color="teamColor"/>
59+
</div>
5660
<div>
5761
Max <b>{{maxAllowedBots}}</b> bots allowed on the field
5862
</div>
@@ -71,10 +75,12 @@
7175
import TeamRedCards from "./TeamRedCards";
7276
import TeamCounters from "./TeamCounters";
7377
import TeamBallPlacement from "./TeamBallPlacement";
78+
import TeamBotInterchange from "./TeamBotInterchange";
7479
7580
export default {
7681
name: "TeamOverview",
7782
components: {
83+
TeamBotInterchange,
7884
TeamBallPlacement,
7985
TeamCounters,
8086
TeamRedCards,

0 commit comments

Comments
 (0)