added reward checking
This commit is contained in:
parent
71665f6984
commit
f03997c4a4
6 changed files with 90 additions and 18 deletions
18
index.html
18
index.html
|
@ -1,11 +1,17 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>RollDice</title>
|
||||
<link rel="shortcut icon" href="media/logo.png" />
|
||||
<link rel="manifest" href="app.json">
|
||||
<link href="node_modules/@materializecss/materialize/dist/css/materialize.css" rel="stylesheet" />
|
||||
<link href="node_modules/@mdi/font/css/materialdesignicons.css" rel="stylesheet" />
|
||||
<link href="styles/dice.css" rel="stylesheet" />
|
||||
<script src="node_modules/jquery/dist/jquery.slim.js"></script>
|
||||
<script src="node_modules/@materializecss/materialize/dist/js/materialize.js"></script>
|
||||
<script src="scripts/app.js"></script>
|
||||
<script src="scripts/offline.js"></script>
|
||||
<script src="scripts/roll.js"></script>
|
||||
<script src="scripts/interface.js"></script>
|
||||
<script src="scripts/iRoll.js"></script>
|
||||
|
@ -17,15 +23,15 @@
|
|||
<li><a class="waves-effect waves-light"><i class="left mdi mdi-dice-4" id="app_nav_logo"></i><strong style="font-size: 150%;" id="app_nav_name">RollDice</strong></a></li>
|
||||
</ul>
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li class="hide-on-med-and-down"><a class="waves-effect waves-light" onclick="console.log(RollOnInterface())"><i class="left mdi mdi-format-rotate-90"></i><span class="right hide-on-med-and-down">Spin</span></a></li>
|
||||
<li><a class="waves-effect waves-light"><i class="left mdi mdi-information-outline"></i><span class="right hide-on-med-and-down">About</span></a></li>
|
||||
<li class="hide-on-med-and-down"><a class="waves-effect waves-light" onclick="console.log(RollOnInterface())" id="app_nav_button_spin"><i class="left mdi mdi-format-rotate-90"></i><span class="right hide-on-med-and-down">Spin</span></a></li>
|
||||
<li><a class="waves-effect waves-light" onclick="app_about_appearanceToggle()"><i class="left mdi mdi-information-outline"></i><span class="right hide-on-med-and-down">About</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<side id="interface_below_buttons">
|
||||
<div class="fixed-action-btn">
|
||||
<button class="btn-floating btn-large pulse waves-effect waves-light orange" title="Spin" onclick="console.log(RollOnInterface())"><i class="left mdi mdi-format-rotate-90"></i></button>
|
||||
<button class="btn-floating btn-large pulse waves-effect waves-light orange" title="Spin" id="app_nav_button_spin" onclick="console.log(RollOnInterface())"><i class="left mdi mdi-format-rotate-90"></i></button>
|
||||
</div>
|
||||
</side>
|
||||
<section>
|
||||
|
@ -65,12 +71,6 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="tap-target" data-target="menu">
|
||||
<div class="tap-target-content">
|
||||
<h5 id="result_title"></h5>
|
||||
<p id="result_data"></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
|
|
14
scripts/app.js
Normal file
14
scripts/app.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* app.js
|
||||
service workers
|
||||
*/
|
||||
|
||||
var app = {
|
||||
"name": "RollDice",
|
||||
"description": "Chinese Dice Game",
|
||||
"authors": ['buzz-lightsnack-2007'],
|
||||
"sourcecode": "https://gitdab.com/buzz-lightsnack-2007/RollDice"
|
||||
}
|
||||
|
||||
if('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('scripts/offline.js', { scope: '/' });
|
||||
}
|
|
@ -7,6 +7,7 @@ function RollOnInterface(muteSound = false, animation = true, times = 1) {
|
|||
|
||||
|
||||
if (animation) {
|
||||
if (muteSound == false) {soundEffects.hit.play();};
|
||||
app_dice_appearanceToggle(false);
|
||||
};
|
||||
|
||||
|
@ -19,8 +20,6 @@ function RollOnInterface(muteSound = false, animation = true, times = 1) {
|
|||
function playSound() {
|
||||
if (roll.result) {
|
||||
soundEffects.ding.play()
|
||||
} else {
|
||||
soundEffects.fallout.play()
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -43,7 +42,7 @@ function RollOnInterface(muteSound = false, animation = true, times = 1) {
|
|||
$(dice_identifier).addClass(dice_className);
|
||||
|
||||
if ((value_dices_current == 4) || (value_dices_current == 1)) {
|
||||
$(dice_identifier).addClass('orange-text');
|
||||
$(dice_identifier).addClass('red-text text-accent-1');
|
||||
} else {
|
||||
$(dice_identifier).addClass('white-text');
|
||||
}
|
||||
|
@ -51,6 +50,25 @@ function RollOnInterface(muteSound = false, animation = true, times = 1) {
|
|||
|
||||
};
|
||||
|
||||
function showReward() {
|
||||
let results = roll.result;
|
||||
|
||||
switch (results) {
|
||||
case 1: M.toast({text: '', html: '<h4>Six fours!</h4>'}); break;
|
||||
case 1.1: M.toast({text: '', html: '<h4>Six ones!</h4>'}); break;
|
||||
case 1.2: M.toast({text: '', html: '<h4>Six of a kind!</h4>'}); break;
|
||||
case 1.3: M.toast({text: '', html: '<h4>Five fours!</h4>'}); break;
|
||||
case 1.4: M.toast({text: '', html: '<h4>Five of a kind!</h4>'}); break;
|
||||
case 1.5: M.toast({text: '', html: '<h4>Four fours!</h4>'}); break;
|
||||
case 2: M.toast({text: '', html: '<h4>Straight!</h4>'}); break;
|
||||
case 2.1: M.toast({text: '', html: '<h4>Three of a kind!</h4>'}); break;
|
||||
case 3: M.toast({text: '', html: '<h4>Four of a kind!</h4>'}); break;
|
||||
case 4: M.toast({text: '', html: '<h4>Three fours!</h4>'}); break;
|
||||
case 5: M.toast({text: '', html: '<h4>Two fours!</h4>'}); break;
|
||||
case 6: M.toast({text: '', html: '<h4>One four!</h4>'}); break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function rollEffect() {
|
||||
$('.btn-floating').removeClass('pulse');
|
||||
|
@ -61,10 +79,8 @@ function RollOnInterface(muteSound = false, animation = true, times = 1) {
|
|||
};
|
||||
|
||||
setTimeout(function() {
|
||||
rollEffect();
|
||||
rollEffect(); showReward();
|
||||
}, 750);
|
||||
|
||||
instance.next();
|
||||
|
||||
return (roll);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
let soundEffects = {
|
||||
'ding': new Audio('media/ding.mp4'),
|
||||
'fallout': new Audio('media/Shells_falls-Marcel-829263474.mp3'),
|
||||
'hit': new Audio('media/Shells_falls-Marcel-829263474.mp3'),
|
||||
'tada': new Audio('media/tada.mp3')
|
||||
}
|
||||
|
||||
|
@ -14,3 +14,10 @@ function app_dice_appearanceToggle(setting = true) {
|
|||
$('.dice').addClass("scale-out");
|
||||
}
|
||||
};
|
||||
|
||||
function app_about_appearanceToggle() {
|
||||
let aboutMessage = (app.name.toUpperCase() + ': ' + app.description + '\n\n' + 'Maintained by ' + app.authors + '.\n' + 'Source code available at: ' + app.sourcecode);
|
||||
|
||||
console.log(aboutMessage);
|
||||
alert(aboutMessage);
|
||||
}
|
||||
|
|
35
scripts/offline.js
Normal file
35
scripts/offline.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* offline.js
|
||||
Make app available offline */
|
||||
|
||||
const CACHE_NAME = `RollDice`;
|
||||
|
||||
// Use the install event to pre-cache all initial resources.
|
||||
self.addEventListener('install', event => {
|
||||
event.waitUntil((async () => {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
cache.addAll(['/']);
|
||||
})());
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
event.respondWith((async () => {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
|
||||
try {
|
||||
// Try to fetch the resource from the network.
|
||||
const fetchResponse = await fetch(event.request);
|
||||
|
||||
// Save the resource in the cache.
|
||||
cache.put(event.request, fetchResponse.clone());
|
||||
|
||||
// And return it.
|
||||
return fetchResponse;
|
||||
} catch (e) {
|
||||
// Fetching didn't work get the resource from the cache.
|
||||
const cachedResponse = await cache.match(event.request);
|
||||
|
||||
// And return it.
|
||||
return cachedResponse;
|
||||
}
|
||||
})());
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
/* dice.css
|
||||
styles for the dice
|
||||
*/
|
||||
*/
|
||||
|
||||
#dice-1, #dice-2, #dice-3, #dice-4, #dice-5, #dice-6 {
|
||||
font-size: 750%;
|
||||
font-size: 625%;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue