Skip to content

Commit

Permalink
Long touch flag deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
virgs committed Dec 20, 2023
1 parent 265aafe commit 15211d2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ npm run format

## Bibliography

- [Algorithmic Approaches to Playing Minesweeper](https://cs50.harvard.edu/ai/2023/projects/1/minesweeper/)
- [Minesweeper.online](https://minesweeper.online/statistics)
- [Becerra, David J. 2015. Algorithmic Approaches to Playing Minesweeper](https://dash.harvard.edu/bitstream/handle/1/14398552/BECERRA-SENIORTHESIS-2015.pdf)
- [Unknown author](http://honors.cs.umd.edu/reports/minesweeper.pdf)
1. [Algorithmic Approaches to Playing Minesweeper](https://cs50.harvard.edu/ai/2023/projects/1/minesweeper/)
1. [Algorithms for Minesweeper Game Grid Generation](https://dspace.cvut.cz/bitstream/handle/10467/61624/F3-BP-2016-Cicvarek-Jan-Algorithms%20for%20Minesweeper%20Game%20Grid%20Generation.pdf)
1. [Becerra, David J. 2015. Algorithmic Approaches to Playing Minesweeper](https://dash.harvard.edu/bitstream/handle/1/14398552/BECERRA-SENIORTHESIS-2015.pdf)
1. [A solver of single-agent stochastic puzzle: A case study with Minesweeper](https://www.sciencedirect.com/science/article/pii/S0950705122002842)
1. [Unknown author](http://honors.cs.umd.edu/reports/minesweeper.pdf)
1. [nothings.org](https://minesweeper.online/statistics)
1. [minesweeper.online](https://nothings.org/games/minesweeper/)
1. [minesweepergame.com](https://minesweepergame.com/strategy/guessing.php)
2 changes: 1 addition & 1 deletion docs/index-d6a74c47.css → docs/index-6f3a8123.css

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/index-0a99ed3f.js → docs/index-99bc14b8.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Exo&display=swap" rel="stylesheet">
<link href="https://db.onlinewebfonts.com/c/61b4eaee5625d47bb7215f205e44f580?family=F7-Segment" rel="stylesheet">
<script type="module" crossorigin src="/minesweeper-ai/index-0a99ed3f.js"></script>
<link rel="stylesheet" href="/minesweeper-ai/index-d6a74c47.css">
<script type="module" crossorigin src="/minesweeper-ai/index-99bc14b8.js"></script>
<link rel="stylesheet" href="/minesweeper-ai/index-6f3a8123.css">
</head>

<body>
Expand Down
1 change: 0 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ export default {
border-width: 4px;
border-style: solid;
border-color: white;
touch-action: none;
}
</style>
25 changes: 15 additions & 10 deletions src/components/Cell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
@mousedown="mouseDownEvent"
@mouseup="mouseUpEvent"
:class="classStyle"
@touchstart="touchStartEvent"
@touchend="touchEndEvent"
@touchstart="startLongPressDetection"
@touchmove="cancelLongPressDetection"
@touchend="cancelLongPressDetection"
>
<div v-if="isRevealed">
<span v-if="cell.hasMine" :style="bombStyle" :class="{ exploded: exploded }">
Expand Down Expand Up @@ -52,7 +53,7 @@ export default {
data() {
return {
mouseButtonDown: 0,
touchStartInstant: 0,
touchStartTimer: 0,
}
},
computed: {
Expand Down Expand Up @@ -136,25 +137,29 @@ export default {
}
this.mouseButtonDown = event.buttons
},
touchStartEvent(event: TouchEvent) {
if (!this.minesweeperStore.gameOver) {
this.touchStartInstant = Date.now()
}
cancelLongPressDetection(event: TouchEvent) {
clearTimeout(this.touchStartTimer)
},
startLongPressDetection(event: TouchEvent) {
setTimeout(() => {
this.touchStartTimer = 0
this.onLongTouch()
}, LONG_TOUCH_THRESHOLD_IN_MS)
},
touchEndEvent(event: TouchEvent) {
if (!this.minesweeperStore.gameOver) {
const touchDuration = Date.now() - this.touchStartInstant
if (!this.cell.flagged) {
if (this.cell.isRevealed()) {
this.minesweeperStore.cellChorded(this.cell)
} else {
this.minesweeperStore.cellClick(this.cell)
}
} else if (touchDuration > LONG_TOUCH_THRESHOLD_IN_MS) {
this.minesweeperStore.flagCell(this.cell.id)
}
}
},
onLongTouch() {
this.minesweeperStore.flagCell(this.cell.id)
},
},
}
</script>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default {
)
},
timer(): string {
return (this.minesweeperStore.timer / 10).toString().padEnd(3, '.0')
const intPart = Math.floor(this.minesweeperStore.timer / 10)
const fractPart = this.minesweeperStore.timer % 10
return `${intPart}.${fractPart}`
},
},
}
Expand Down
1 change: 0 additions & 1 deletion src/components/NewGameButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export default {
#newGameButton {
font-size: x-large;
background-color: yellow;
}
button {
Expand Down

0 comments on commit 15211d2

Please sign in to comment.