/* iRoll.js put roll results onscreen */ function RollOnInterface(muteSound = false, animation = true, times = 1) { let roll = {}; if (animation) { if (muteSound == false) {soundEffects.hit.play();}; app_dice_appearanceToggle(false); }; function rollTheDice() { for (rolls = 0; rolls < times; rolls++) { roll = rollDiceWithResults(); } } function playSound() { if (roll.result) { soundEffects.ding.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('red-text text-accent-1'); } else { $(dice_identifier).addClass('white-text'); } }; }; function showReward() { let results = roll.result; switch (results) { case 1: M.toast({text: '', html: '

Six fours!

'}); break; case 1.1: M.toast({text: '', html: '

Six ones!

'}); break; case 1.2: M.toast({text: '', html: '

Six of a kind!

'}); break; case 1.3: M.toast({text: '', html: '

Five fours!

'}); break; case 1.4: M.toast({text: '', html: '

Five of a kind!

'}); break; case 1.5: M.toast({text: '', html: '

Four fours!

'}); break; case 2: M.toast({text: '', html: '

Straight!

'}); break; case 2.1: M.toast({text: '', html: '

Three of a kind!

'}); break; case 3: M.toast({text: '', html: '

Four of a kind!

'}); break; case 4: M.toast({text: '', html: '

Three fours!

'}); break; case 5: M.toast({text: '', html: '

Two fours!

'}); break; case 6: M.toast({text: '', html: '

One four!

'}); break; } }; function rollEffect() { $('.btn-floating').removeClass('pulse'); replaceDice(); if (animation) {app_dice_appearanceToggle(true);} if (muteSound == false) {playSound();}; }; setTimeout(function() { rollEffect(); showReward(); }, 750); return (roll); }