dice function now on the website
- jQuery was added to make this work. - Cards were removed.
This commit is contained in:
parent
1d16cfc44b
commit
ab638b152c
158 changed files with 69420 additions and 47 deletions
70
scripts/iRoll.js
Normal file
70
scripts/iRoll.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* iRoll.js
|
||||
put roll results onscreen */
|
||||
|
||||
function RollOnInterface(muteSound = false, animation = true, times = 1) {
|
||||
|
||||
let roll = {};
|
||||
|
||||
|
||||
if (animation) {
|
||||
app_dice_appearanceToggle(false);
|
||||
};
|
||||
|
||||
function rollTheDice() {
|
||||
for (rolls = 0; rolls < times; rolls++) {
|
||||
roll = rollDiceWithResults();
|
||||
}
|
||||
}
|
||||
|
||||
function playSound() {
|
||||
if (roll.result) {
|
||||
soundEffects.ding.play()
|
||||
} else {
|
||||
soundEffects.fallout.play()
|
||||
};
|
||||
};
|
||||
|
||||
rollTheDice();
|
||||
|
||||
function replaceDice() {
|
||||
let diceNumber = 0;
|
||||
let value_dices = roll.dice;
|
||||
let value_dices_current = 0;
|
||||
|
||||
|
||||
for (diceNumber = 0; diceNumber < value_dices.length; diceNumber++) {
|
||||
value_dices_current = value_dices[diceNumber];
|
||||
|
||||
let dice_identifier = ('#dice-' + (diceNumber + 1));
|
||||
$(dice_identifier).removeClass();
|
||||
$(dice_identifier).addClass('dice scale-transition center mdi');
|
||||
|
||||
let dice_className = ('mdi-dice-' + value_dices_current);
|
||||
$(dice_identifier).addClass(dice_className);
|
||||
|
||||
if ((value_dices_current == 4) || (value_dices_current == 1)) {
|
||||
$(dice_identifier).addClass('orange-text');
|
||||
} else {
|
||||
$(dice_identifier).addClass('white-text');
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
function rollEffect() {
|
||||
$('.btn-floating').removeClass('pulse');
|
||||
replaceDice();
|
||||
|
||||
if (animation) {app_dice_appearanceToggle(true);}
|
||||
if (muteSound == false) {playSound();};
|
||||
};
|
||||
|
||||
setTimeout(function() {
|
||||
rollEffect();
|
||||
}, 750);
|
||||
|
||||
instance.next();
|
||||
|
||||
return (roll);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue