-
Notifications
You must be signed in to change notification settings - Fork 0
/
ms-vue.html
73 lines (66 loc) · 2.74 KB
/
ms-vue.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Minesweeper with vue</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/ms.css" rel="stylesheet">
</head>
<body>
<h1>Minesweeper with vue</h1>
<div id="vue-app" v-cloak>
<div class="ms-configuration">
<div>
<label>Rows:</label>
<input type="number" v-model="numberOfRows" :disabled="gameState === gameStates.play">
</div>
<div>
<label>Columns:</label>
<input type="number" v-model="numberOfColumns" :disabled="gameState === gameStates.play">
</div>
<div>
<label>Mines:</label>
<input type="number" v-model="numberOfMines" :disabled="gameState === gameStates.play">
</div>
</div>
<div class="ms-buttons">
<a class="button" @click="startGame" v-show="gameState !== gameStates.play">Generate Board</a>
<a class="button" @click="endGame" v-show="gameState === gameStates.play">End Game</a>
</div>
<div class="ms-information">
<div>
<label>Mines remaining:</label>
<span>{{ numberOfMinesRemaining }}</span>
</div>
<p class="ms-win-text" v-if="gameState === gameStates.win">You Won!</p>
<p class="ms-loss-text" v-if="gameState === gameStates.loss">You Lost!</p>
</div>
<div class="ms-board" :class="boardClasses[gameState]" v-if="cellMatrix.length">
<div class="ms-board__row" v-for="(row, rowIndex) in cellMatrix">
<div v-for="(cell, colIndex) in row" class="ms-board__cell"
:class="cellClasses[cell.state]"
@click="cellLeftClicked(rowIndex, colIndex)"
@contextmenu.prevent="cellRightClicked(rowIndex, colIndex)">
<template v-if="cell.state === cellStates.safe">
{{ cell.mineNeighbours === 0 ? '' : cell.mineNeighbours }}
</template>
<template v-else-if="cell.state === cellStates.flag">
F
</template>
<template v-else-if="cell.state === cellStates.mine">
X
</template>
<template v-else-if="cell.state === cellStates.displayMine">
X
</template>
</div>
</div>
</div>
</div>
<br>
<br>
<a href="/">Back to home</a>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="js/ms.js"></script>
</body>
</html>