Skip to content

Commit 6adbff4

Browse files
committed
[feature] Add continue button
1 parent da819bd commit 6adbff4

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

internal/app/controller/engine.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ func (e *Engine) UndoLastAction() {
7272
}
7373
}
7474

75+
func (e *Engine) Continue() error {
76+
switch e.State.GameEvent {
77+
case GameEventBallLeftFieldTouchLine:
78+
e.SendCommand(CommandIndirect, e.State.GameEventFor.Opposite())
79+
case GameEventBallLeftFieldGoalLine:
80+
e.SendCommand(CommandDirect, e.State.GameEventFor.Opposite())
81+
default:
82+
return errors.New("No game event present")
83+
}
84+
return nil
85+
}
86+
7587
func (e *Engine) Process(event Event) error {
7688
err := e.processEvent(event)
7789
if err != nil {
@@ -326,7 +338,7 @@ func addCard(card *EventCard, teamState *TeamInfo, duration time.Duration) error
326338
return nil
327339
}
328340

329-
func (e *Engine) processTrigger(t *EventTrigger) error {
341+
func (e *Engine) processTrigger(t *EventTrigger) (err error) {
330342
if t.Type == TriggerResetMatch {
331343
e.ResetGame()
332344
} else if t.Type == TriggerSwitchColor {
@@ -339,11 +351,13 @@ func (e *Engine) processTrigger(t *EventTrigger) error {
339351
e.State.TeamState[TeamBlue].OnPositiveHalf = yellowOnPositiveHalf
340352
} else if t.Type == TriggerUndo {
341353
e.UndoLastAction()
354+
} else if t.Type == TriggerContinue {
355+
err = e.Continue()
342356
} else {
343357
return errors.Errorf("Unknown trigger: %v", t.Type)
344358
}
345359
log.Printf("Processed trigger %v", t.Type)
346-
return nil
360+
return err
347361
}
348362

349363
func (e *Engine) processGameEvent(t *EventGameEvent) error {

internal/app/controller/events.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const (
4949
TriggerSwitchSides TriggerType = "switchSides"
5050
// TriggerUndo undo last action
5151
TriggerUndo TriggerType = "undo"
52+
// TriggerContinue continues based on the current game event
53+
TriggerContinue TriggerType = "continue"
5254
)
5355

5456
// CardModification to apply to a card

src/components/control/ControlGeneral.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
Normal Start
3333
</b-button>
3434
</span>
35+
<span v-b-tooltip.hover
36+
:title="'Continue based on last game event (' + Object.keys(keymapContinue)[0] + ')'">
37+
<b-button v-hotkey="keymapContinue"
38+
v-on:click="triggerContinue"
39+
v-bind:disabled="!gameEventPresent">
40+
Continue
41+
</b-button>
42+
</span>
3543
</span>
3644
</template>
3745

@@ -42,7 +50,10 @@
4250
name: "ControlGeneral",
4351
methods: {
4452
send: function (command) {
45-
this.$socket.sendObj({'command': {'commandType': command}})
53+
this.$socket.sendObj({command: {commandType: command}})
54+
},
55+
triggerContinue() {
56+
this.$socket.sendObj({trigger: {triggerType: 'continue'}})
4657
}
4758
},
4859
computed: {
@@ -56,7 +67,10 @@
5667
return {'numpad 5': () => this.send('forceStart')}
5768
},
5869
keymapNormalStart() {
59-
return {'numpad +': () => this.send('normalStart')}
70+
return {'numpad -': () => this.send('normalStart')}
71+
},
72+
keymapContinue() {
73+
return {'numpad +': () => this.triggerContinue()}
6074
},
6175
state() {
6276
return this.$store.state.refBoxState
@@ -73,6 +87,9 @@
7387
inNormalHalf() {
7488
return isInNormalHalf(this.state);
7589
},
90+
gameEventPresent() {
91+
return this.state.gameEvent !== 'none';
92+
}
7693
}
7794
}
7895
</script>

0 commit comments

Comments
 (0)