Skip to content

Commit ffc25b6

Browse files
committed
[feature] Allow to revoke game events
1 parent 7d35019 commit ffc25b6

File tree

6 files changed

+106
-2
lines changed

6 files changed

+106
-2
lines changed

internal/app/controller/engine.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ func (e *Engine) processModify(m *EventModifyValue) error {
395395
}
396396
} else if m.GameEventBehavior != nil {
397397
e.State.GameEventBehavior[m.GameEventBehavior.GameEventType] = m.GameEventBehavior.GameEventBehavior
398+
} else if m.RemoveGameEvent != nil {
399+
i := *m.RemoveGameEvent
400+
if i >= len(e.State.GameEvents) {
401+
return errors.Errorf("Game event id %d is too large.", i)
402+
}
403+
e.State.GameEvents = append(e.State.GameEvents[:i], e.State.GameEvents[i+1:]...)
398404
} else if err := e.processTeamModify(m); err != nil {
399405
return err
400406
}

internal/app/controller/events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ type EventModifyValue struct {
122122
AutoContinue *bool `json:"autoContinue,omitempty" yaml:"autoContinue"`
123123
GameEventBehavior *EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty" yaml:"gameEventBehavior"`
124124
BotSubstitutionIntend *bool `json:"botSubstitutionIntend,omitempty" yaml:"botSubstitutionIntend"`
125+
RemoveGameEvent *int `json:"removeGameEvent,omitempty" yaml:"removeGameEvent"`
125126
}
126127

127128
func (m EventModifyValue) String() string {

src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<div class="team-container">
99
<TeamOverview class="team-views" team-color="Yellow"/>
1010
<ControlTeam class="team-views" team-color="Yellow"/>
11+
<CurrentEvents class="team-views"/>
1112
</div>
1213
<div class="main-middle-container">
1314
<Events/>
@@ -26,7 +27,7 @@
2627
<div class="team-container">
2728
<TeamOverview class="team-views" team-color="Blue"/>
2829
<ControlTeam class="team-views" team-color="Blue"/>
29-
<EventProposals class="team-views event-proposals"/>
30+
<EventProposals class="team-views"/>
3031
</div>
3132
</div>
3233
<ControlMatch id="match-controls"/>
@@ -41,10 +42,12 @@
4142
import ControlMatch from "./components/control/ControlMatch";
4243
import Events from "./components/events/Events";
4344
import EventProposals from "./components/events/EventProposals";
45+
import CurrentEvents from "./components/events/CurrentEvents";
4446
4547
export default {
4648
name: 'app',
4749
components: {
50+
CurrentEvents,
4851
EventProposals,
4952
Events,
5053
ControlMatch,
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<template>
2+
<div>
3+
<h2>Current Game Events</h2>
4+
<div class="content">
5+
<span v-if="!gameEventsPresent">None</span>
6+
<div class="game-event-item"
7+
v-if="gameEventsPresent"
8+
v-for="(gameEvent, index) in gameEvents"
9+
:key="index">
10+
<span :class="{'team-blue': byTeam(gameEvent) === 2, 'team-yellow': byTeam(gameEvent) === 1}">
11+
{{gameEvent.type}}
12+
</span>
13+
<p>
14+
<span v-for="detail in detailsList(gameEvent)"
15+
:key="detail.key">{{detail.key}}: {{detail.value}}<br/></span>
16+
</p>
17+
<div class="btn-revoke"
18+
v-b-tooltip.hover.righttop="'Revoke this game event'">
19+
<a @click="revoke(index)">
20+
<font-awesome-icon icon="times-circle" class="fa-lg"></font-awesome-icon>
21+
</a>
22+
</div>
23+
</div>
24+
</div>
25+
</div>
26+
</template>
27+
28+
<script>
29+
export default {
30+
name: "CurrentEvents",
31+
computed: {
32+
state() {
33+
return this.$store.state.refBoxState
34+
},
35+
gameEvents() {
36+
return this.state.gameEvents;
37+
},
38+
gameEventsPresent() {
39+
return this.gameEvents != null && this.gameEvents.length > 0;
40+
}
41+
},
42+
methods: {
43+
details(gameEvent) {
44+
let key = Object.keys(gameEvent.details)[0];
45+
return gameEvent.details[key];
46+
},
47+
detailsList(gameEvent) {
48+
let list = [];
49+
let details = this.details(gameEvent);
50+
let i = 0;
51+
Object.keys(details).forEach(function (key) {
52+
if (key !== 'by_team') {
53+
list[i++] = {key: key, value: details[key]};
54+
}
55+
});
56+
return list;
57+
},
58+
byTeam(gameEvent) {
59+
let details = this.details(gameEvent);
60+
if (details.hasOwnProperty('by_team')) {
61+
return details.by_team;
62+
}
63+
return '';
64+
},
65+
revoke(index) {
66+
this.$socket.sendObj({
67+
"modify": {"removeGameEvent": index}
68+
});
69+
},
70+
}
71+
}
72+
</script>
73+
74+
<style scoped>
75+
.content {
76+
text-align: left;
77+
overflow-y: auto;
78+
max-height: 15em;
79+
}
80+
81+
.game-event-item {
82+
position: relative;
83+
min-height: 2em;
84+
}
85+
86+
.btn-revoke {
87+
position: absolute;
88+
right: 0;
89+
bottom: 0;
90+
margin: 0.3em;
91+
}
92+
</style>

src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
faCaretSquareDown,
1616
faCaretSquareUp,
1717
faCheckCircle,
18+
faTimesCircle,
1819
faEdit,
1920
faSignal,
2021
faToggleOff,
@@ -40,6 +41,7 @@ library.add(faToggleOn);
4041
library.add(faToggleOff);
4142
library.add(faSignal);
4243
library.add(faCheckCircle);
44+
library.add(faTimesCircle);
4345
library.add(faShieldAlt);
4446
Vue.component('font-awesome-icon', FontAwesomeIcon);
4547

src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class RefBoxState {
2323
stage = 'unknown';
2424
command = '';
2525
commandForTeam = '';
26-
gameEvents = [{type: '', details: {}}];
26+
gameEvents = [];
2727
stageTimeElapsed = 0;
2828
stageTimeLeft = 0;
2929
matchDuration = 0;

0 commit comments

Comments
 (0)