Adds random level selector
This commit is contained in:
@@ -23,7 +23,10 @@ function numsToCard(arr) {
|
||||
{ color: colors[Math.floor(c / 6)], number: (c % 6) + 1 },
|
||||
];
|
||||
}
|
||||
let curr_seed = Math.floor(Date.now() / 1000 / 3600 / 24);
|
||||
const daily = !new URLSearchParams(window.location.search).get("random");
|
||||
let curr_seed = daily
|
||||
? Math.floor(Date.now() / 1000 / 3600 / 24)
|
||||
: Math.floor(Math.random() * 1000000);
|
||||
function prand(str) {
|
||||
let h1 = 1779033703,
|
||||
h2 = 3144134277,
|
||||
@@ -169,5 +172,13 @@ $("document").ready(() => {
|
||||
state.picked_board_card = null;
|
||||
render_game(state);
|
||||
});
|
||||
$("#random").button();
|
||||
$("#random").click(() => {
|
||||
window.location = "/klumpy?random=true";
|
||||
});
|
||||
$("#daily").button();
|
||||
$("#daily").click(() => {
|
||||
window.location = "/klumpy";
|
||||
});
|
||||
render_game(state);
|
||||
});
|
||||
|
||||
@@ -43,6 +43,13 @@
|
||||
</ol>
|
||||
<p><a href='/klumpy/leaderboard.php'>Click here for the leaderboard.</a></p>
|
||||
<?php
|
||||
if (array_key_exists("random", $_GET)) {
|
||||
echo "<h1>Playing Random Game</h1>";
|
||||
echo "<button id='daily'>Switch to Daily Game</button>";
|
||||
} else {
|
||||
echo "<h1>Playing Daily Game</h1>";
|
||||
echo "<button id='random'>Switch to Random Game</button>";
|
||||
}
|
||||
if (!$USERNAME) {
|
||||
echo "<h2>You must be logged in to submit your score to the leaderboard and share your games. <a href='/login.php?redirect=klumpy'>Login here</a></h2>";
|
||||
}
|
||||
@@ -104,7 +111,7 @@
|
||||
</div>
|
||||
<script src="render.js?v=1.1.0"></script>
|
||||
<script src="score.js?v=1.1.0"></script>
|
||||
<script src="index.js?v=1.3.2"></script>
|
||||
<script src="index.js?v=1.4.0"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user