Skip to content

Commit 2a156fc

Browse files
committed
[ui] Move card buttons from team view to control view
1 parent 26f0175 commit 2a156fc

File tree

6 files changed

+58
-63
lines changed

6 files changed

+58
-63
lines changed

internal/app/controller/engine.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,14 @@ func addCard(card *EventCard, teamState *TeamInfo, duration time.Duration) error
304304
func (e *Engine) processTrigger(t *EventTrigger) (*EventCommand, error) {
305305
if t.Type == TriggerResetMatch {
306306
e.ResetGame()
307-
308307
} else if t.Type == TriggerSwitchColor {
309308
yellow := e.State.TeamState[TeamYellow]
310309
e.State.TeamState[TeamYellow] = e.State.TeamState[TeamBlue]
311310
e.State.TeamState[TeamBlue] = yellow
311+
} else if t.Type == TriggerSwitchSides {
312+
yellowOnPositiveHalf := e.State.TeamState[TeamYellow].OnPositiveHalf
313+
e.State.TeamState[TeamYellow].OnPositiveHalf = !yellowOnPositiveHalf
314+
e.State.TeamState[TeamBlue].OnPositiveHalf = yellowOnPositiveHalf
312315
} else if t.Type == TriggerUndo {
313316
e.UndoLastAction()
314317
} else {

internal/app/controller/events.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ const (
7373
TriggerResetMatch TriggerType = "resetMatch"
7474
// TriggerSwitchColor switch color
7575
TriggerSwitchColor TriggerType = "switchColor"
76+
// TriggerSwitchSides switch sides/goals (onPositiveHalf)
77+
TriggerSwitchSides TriggerType = "switchSides"
7678
// TriggerUndo undo last action
7779
TriggerUndo TriggerType = "undo"
7880
)

ui/src/components/control/ControlMatch.vue

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div>
33
<b-button v-on:click="resetMatch">Reset Match</b-button>
44
<b-button v-on:click="switchColor">Switch colors</b-button>
5+
<b-button v-on:click="switchSides">Switch sides</b-button>
56
<b-button v-on:click="previousStage">Previous Stage</b-button>
67
<b-button v-on:click="nextStage">Next Stage</b-button>
78
<b-button v-on:click="undo">Undo Last Action</b-button>
@@ -13,20 +14,35 @@
1314
name: "ControlMatch",
1415
methods: {
1516
resetMatch: function () {
16-
this.$socket.sendObj({'trigger': {'triggerType': 'resetMatch'}})
17+
this.$socket.sendObj({
18+
'trigger': {'triggerType': 'resetMatch'}
19+
})
1720
},
1821
switchColor: function () {
19-
this.$socket.sendObj({'trigger': {'triggerType': 'switchColor'}})
22+
this.$socket.sendObj({
23+
'trigger': {'triggerType': 'switchColor'}
24+
})
25+
},
26+
switchSides: function () {
27+
this.$socket.sendObj({
28+
'trigger': {'triggerType': 'switchSides'}
29+
})
30+
},
31+
undo: function () {
32+
this.$socket.sendObj({
33+
'trigger': {'triggerType': 'undo'}
34+
})
2035
},
2136
previousStage: function () {
22-
this.$socket.sendObj({'stage': {'stageOperation': 'previous'}})
37+
this.$socket.sendObj({
38+
'stage': {'stageOperation': 'previous'}
39+
})
2340
},
2441
nextStage: function () {
25-
this.$socket.sendObj({'stage': {'stageOperation': 'next'}})
42+
this.$socket.sendObj({
43+
'stage': {'stageOperation': 'next'}
44+
})
2645
},
27-
undo: function () {
28-
this.$socket.sendObj({'trigger': {'triggerType': 'undo'}})
29-
}
3046
}
3147
}
3248
</script>

ui/src/components/control/ControlTeam.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
<b-button v-hotkey="keymapDirect" v-on:click="send('direct')">Direct</b-button>
66
<b-button v-hotkey="keymapIndirect" v-on:click="send('indirect')">Indirect</b-button>
77
<b-button v-on:click="send('penalty')">Penalty</b-button>
8+
9+
<br/>
10+
811
<b-button v-on:click="send('goal')">Goal</b-button>
12+
<b-button v-on:click="addYellowCard" v-hotkey="keymapYellowCard">Yellow Card</b-button>
13+
<b-button v-on:click="revokeYellowCard" v-if="teamState.yellowCardTimes.length>0">Revoke Yellow Card</b-button>
914
<ControlTeamTimeout :team-color="teamColor"/>
1015
</div>
1116
</template>
@@ -21,10 +26,21 @@
2126
},
2227
methods: {
2328
send: function (command) {
24-
this.$socket.sendObj({'command': {'forTeam': this.teamColor, 'commandType': command}})
25-
}
29+
this.$socket.sendObj({
30+
'command': {'forTeam': this.teamColor, 'commandType': command}
31+
})
32+
},
33+
addYellowCard: function () {
34+
this.$socket.sendObj({'card': {'forTeam': this.teamColor, 'cardType': 'yellow', 'operation': 'add'}})
35+
},
36+
revokeYellowCard: function () {
37+
this.$socket.sendObj({'card': {'forTeam': this.teamColor, 'cardType': 'yellow', 'operation': 'revoke'}})
38+
},
2639
},
2740
computed: {
41+
teamState: function () {
42+
return this.$store.state.refBoxState.teamState[this.teamColor]
43+
},
2844
keymapKickoff() {
2945
if (this.teamColor === 'Yellow') {
3046
return {'numpad 1': () => this.send('kickoff')};
@@ -46,6 +62,14 @@
4662
return {'numpad 6': () => this.send('indirect')};
4763
}
4864
},
65+
keymapYellowCard() {
66+
switch (this.teamColor) {
67+
case 'Yellow':
68+
return {'numpad 4': this.addYellowCard};
69+
case 'Blue':
70+
return {'numpad 6': this.addYellowCard};
71+
}
72+
}
4973
}
5074
}
5175
</script>

ui/src/components/team/TeamCards.vue

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
:callback="updateRedCards"
77
:min="0"
88
:max="99"/>
9-
<b-button class="revoke-card-button" v-hotkey="keymap" v-on:click="revokeRedCard">-</b-button>
10-
<b-button class="add-card-button" v-hotkey="keymap" v-on:click="addRedCard">+</b-button>
119

1210
<EditableLabelNumber
1311
label="Yellow cards: "
1412
:value="yellowCards"
1513
:callback="updateYellowCards"
1614
:min="0"
1715
:max="99"/>
18-
<b-button class="revoke-card-button" v-hotkey="keymap" v-on:click="revokeYellowCard">-</b-button>
19-
<b-button class="add-card-button" v-hotkey="keymap" v-on:click="addYellowCard">+</b-button>
2016

21-
<br>
22-
Yellow card times:
17+
Yellow card times: <span v-if="yellowCardTimes.length===0">None</span>
2318
<EditableLabelDuration
2419
v-bind:key="time"
2520
v-for="(time, index) in yellowCardTimes"
@@ -42,18 +37,6 @@
4237
teamColor: String
4338
},
4439
methods: {
45-
addYellowCard: function () {
46-
this.$socket.sendObj({'card': {'forTeam': this.teamColor, 'cardType': 'yellow', 'operation': 'add'}})
47-
},
48-
revokeYellowCard: function () {
49-
this.$socket.sendObj({'card': {'forTeam': this.teamColor, 'cardType': 'yellow', 'operation': 'revoke'}})
50-
},
51-
addRedCard: function () {
52-
this.$socket.sendObj({'card': {'forTeam': this.teamColor, 'cardType': 'red', 'operation': 'add'}})
53-
},
54-
revokeRedCard: function () {
55-
this.$socket.sendObj({'card': {'forTeam': this.teamColor, 'cardType': 'red', 'operation': 'revoke'}})
56-
},
5740
updateYellowCards: function (v) {
5841
this.$socket.sendObj({
5942
'modify': {
@@ -79,29 +62,8 @@
7962
})
8063
},
8164
},
82-
computed: {
83-
keymap() {
84-
switch (this.teamColor) {
85-
case 'Yellow':
86-
return {'numpad 4': this.addYellowCard};
87-
case 'Blue':
88-
return {'numpad 6': this.addYellowCard};
89-
}
90-
}
91-
}
9265
}
9366
</script>
9467

9568
<style scoped>
96-
button {
97-
margin: 0.5em;
98-
}
99-
100-
.add-card-button {
101-
width: 5em;
102-
}
103-
104-
.revoke-card-button {
105-
width: 2em;
106-
}
10769
</style>

ui/src/components/team/TeamHalf.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
22
<div>
3-
<label v-show="teamState.onPositiveHalf">On positive half</label>
4-
<label v-show="!teamState.onPositiveHalf">On negative half</label>
5-
<b-button v-on:click="switchHalf">Switch</b-button>
3+
<span v-show="teamState.onPositiveHalf">On positive half</span>
4+
<span v-show="!teamState.onPositiveHalf">On negative half</span>
65
</div>
76
</template>
87

@@ -12,17 +11,6 @@
1211
props: {
1312
teamColor: String
1413
},
15-
methods: {
16-
switchHalf: function () {
17-
let currentValue = this.teamState.onPositiveHalf;
18-
this.$socket.sendObj({
19-
'modify': {
20-
'forTeam': this.teamColor,
21-
'onPositiveHalf': !currentValue
22-
}
23-
})
24-
},
25-
},
2614
computed: {
2715
teamState: function () {
2816
return this.$store.state.refBoxState.teamState[this.teamColor]

0 commit comments

Comments
 (0)