Skip to content

Commit

Permalink
Remove buttons when game is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Siegler committed Feb 21, 2021
1 parent 7ee19c8 commit 59380fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/components/SudokuGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
v-model="cell.num"
class="grid-cell-editor"
:class="cell.given? 'given-cell': 'empty-cell'"
:disabled="cell.given"
:disabled="cell.given || finished"
@click="hint(cell, rowIndex, cellIndex)"
type="number"/>
</div>
Expand All @@ -25,7 +25,10 @@ export default {
sudokuMatrix: Array
},
computed: {
...mapGetters({cellSolution: 'game/cellSolution'})
...mapGetters({cellSolution: 'game/cellSolution'}),
finished() {
return this.$store.getters['life/isGameOver'] || this.$store.state.game.gameFinished;
}
},
methods: {
hint(cell, rowIndex, cellIndex) {
Expand Down
13 changes: 9 additions & 4 deletions src/views/GamePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<div class="game-container">
<b-button class="b-btn"
@click="verifyGame"
v-if="!this.$store.getters['life/isGameOver'] && !this.$store.state.game.gameFinished">
v-if="!finished">
Verify
</b-button>
<b-button class="b-btn"
@click="solveGame"
v-if="this.$store.getters['life/isGameOver'] || this.$store.state.game.gameFinished">
v-if="finished">
Resolve
</b-button>
<life-display/>
<sudoku-grid class="sudoku-grid" :sudoku-matrix="this.$store.state.game.currentGame"/>
<b-button class="b-btn" @click="cancelGame">New</b-button>
<b-button class="b-btn" @click="$store.commit('game/clearUserInput')">Clear</b-button>
<hint-display class="hint"/>
<b-button class="b-btn" @click="$store.commit('game/clearUserInput')" v-if="!this.finished">Clear</b-button>
<hint-display class="hint" v-if="!this.finished"/>

</div>
</template>
Expand All @@ -28,6 +28,11 @@ import HintDisplay from "@/components/HintDisplay";
export default {
name: "GamePage",
components: {HintDisplay, LifeDisplay, BButton, SudokuGrid},
computed: {
finished() {
return this.$store.getters['life/isGameOver'] || this.$store.state.game.gameFinished;
}
},
methods: {
cancelGame() {
this.$router.push({name: 'StartPage'})
Expand Down

0 comments on commit 59380fe

Please sign in to comment.