Skip to content

Commit

Permalink
23words: Limit attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
1tgr committed Jul 27, 2024
1 parent 002cf61 commit 2f2b1bb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions 23words/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h1>23 Words</h1>
<div class="playing hidden">
<!-- Save the daily words in HTML -->
<div class="dailywords hidden"></div>
<div class="mb-20"><span class="score">0</span> survived</div>
<div class="mb-20"><span class="attempts"></span> attempts remaining | <span class="score">0</span> survived</div>
<div class="slots flex"></div>
<p class="message"></p>
<div class="letters flex mb-20"></div>
Expand Down Expand Up @@ -116,7 +116,7 @@ <h2 class="mb-10">Average</h2>
<div class="modalinner">
<div id="instructions" class="togglemodal close">x</div>
<h2 class="mb-20">How to play</h2>
<p class="mb-20">Find the hidden word.</p>
<p class="mb-20">Find the hidden word before.</p>
<p class="mb-20">Can you survive all 23 words?</p>
<div id="instructions" class="togglemodal button">Close</div>
</div>
Expand All @@ -140,12 +140,15 @@ <h2 class="mb-20">Game paused</h2>
<script type="text/javascript">
var day = Math.floor((new Date() - new Date('2024-07-27')) / 86400000);

var attempts;

// Load game
function loadgame(){
// Check if user has started todays puzzle
if(localStorage.getItem('23words') == day){
// Get load from localStorage
$('.container').html(localStorage.getItem('23wordsload'));
attempts = $('.attempts').html();
}
// Else load todays puzzle
else {
Expand Down Expand Up @@ -212,6 +215,10 @@ <h2 class="mb-20">Game paused</h2>

// Shuffle
shuffle();

// Reset attempts
attempts = 3;
$('.attempts').html(attempts);
}


Expand Down Expand Up @@ -260,6 +267,12 @@ <h2 class="mb-20">Game paused</h2>
}
} else {
$('.message').html('Not in wordlist').show().delay(1000).fadeOut(0);
savegame();
attempts--;
$('.attempts').html(attempts);
if(attempts < 1){
finish();
}
}
}
}
Expand Down

0 comments on commit 2f2b1bb

Please sign in to comment.