Fix Minesweeper

This commit is contained in:
octospacc 2023-03-26 21:11:20 +02:00
parent eac8317d50
commit 2b6de66a38
1 changed files with 6 additions and 3 deletions

View File

@ -8,9 +8,10 @@ var Notices = {
AlertLockedWon: "Hai vinto! Goditi il contenuto sbloccato. 💖️", AlertLockedWon: "Hai vinto! Goditi il contenuto sbloccato. 💖️",
AlertLockedLost: "Ops! Hai perso! Ritenta. 🙃️", AlertLockedLost: "Ops! Hai perso! Ritenta. 🙃️",
AlertLockedEgg: "Hai scoperto l'easter egg e hai saltato la partita. Mah. 🙄️", AlertLockedEgg: "Hai scoperto l'easter egg e hai saltato la partita. Mah. 🙄️",
AlertLockedResize: "Non si imbroglia ridimensionando la finestra!!! Il gioco verrà resettato. Non riceverai ulteriori avvisi. 😈️", AlertLockedResize: "Non si imbroglia ridimensionando la finestra!!! Il gioco verrà ora resettato. Non riceverai ulteriori avvisi. 😈️",
}; };
var WindowWidth;
var ResizeAlerted = false; var ResizeAlerted = false;
// Add styles to current page // Add styles to current page
@ -51,6 +52,7 @@ document.querySelectorAll('.Minesweeper').forEach(function(Container){
}; };
window.onload = function(){ window.onload = function(){
WindowWidth = window.innerWidth;
Container.style.display = ''; Container.style.display = '';
Game = GameWindow.vuesweeper; Game = GameWindow.vuesweeper;
var [Width, Height, Bombs] = [15, 15, 36]; var [Width, Height, Bombs] = [15, 15, 36];
@ -141,7 +143,7 @@ document.querySelectorAll('.Minesweeper').forEach(function(Container){
Bombs = ~~(2 * Math.sqrt(Width * Height)); Bombs = ~~(2 * Math.sqrt(Width * Height));
// No cheating! (And no breaking my fragile CSS :c) // No cheating! (And no breaking my fragile CSS :c)
window.onresize = function(){ window.onresize = function(){if(window.innerWidth != WindowWidth){
if (!ResizeAlerted) { if (!ResizeAlerted) {
setTimeout(function(){ setTimeout(function(){
LockedEl.style.visibility = 'hidden'; LockedEl.style.visibility = 'hidden';
@ -153,7 +155,8 @@ document.querySelectorAll('.Minesweeper').forEach(function(Container){
LockedEl.style['padding-right'] = ''; LockedEl.style['padding-right'] = '';
NoticeEl.remove(); NoticeEl.remove();
SetupLockGame(); SetupLockGame();
}; WindowWidth = window.innerWidth;
}};
Game.reset(Width, Height, Bombs); Game.reset(Width, Height, Bombs);
}; };