Skip to content

Commit

Permalink
[feature] Add a button to end the game immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Aug 25, 2018
1 parent e7dd7fc commit 082e294
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/app/controller/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ func (e *Engine) processStage(s *EventStage) error {
e.updateStage(e.State.Stage.Next())
} else if s.StageOperation == StagePrevious {
e.updateStage(e.State.Stage.Previous())
} else if s.StageOperation == StageEndGame {
e.updateStage(StagePostGame)
} else {
return errors.Errorf("Unknown stage operation: %v", s.StageOperation)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/app/controller/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
StageNext StageOperation = "next"
// StagePrevious previous stage
StagePrevious StageOperation = "previous"
// StageEndGame ends the game
StageEndGame StageOperation = "endGame"
)

// TriggerType is something that can be triggered
Expand Down
10 changes: 10 additions & 0 deletions src/components/control/ControlMatch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
:disabled="forbidMatchControls || noNextStage">
Next Stage
</b-button>
<b-button v-b-tooltip.hover title="Finish the game"
v-on:click="endGame"
:disabled="forbidMatchControls || noNextStage">
End of Game
</b-button>
</div>
</template>

Expand Down Expand Up @@ -66,6 +71,11 @@
'stage': {'stageOperation': 'next'}
})
},
endGame: function () {
this.$socket.sendObj({
'stage': {'stageOperation': 'endGame'}
})
},
},
computed: {
state() {
Expand Down

0 comments on commit 082e294

Please sign in to comment.