Apps Home
|
Create an App
Roll The Dice Flesh - 1
Author:
loulouw
Description
Source Code
Launch App
Current Users
Created by:
Loulouw
/** * App: Roll The Dice * Version: 1.5 * Author: Hexting (Derrived from zingknaat) * Date: 2014-12-07 */ cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'Cost per Roll (in tokens)', defaultValue: 69}, {name:'remove_winning_prize', type:'choice', label:'Remove prize from list after each roll?', choice1:'Yes', choice2:'No', defaultValue:'No'}, {name: 'goalRoll_1', type: 'int', minValue: 0, maxValue: 200, label: 'goal 1 @ roll#', defaultValue: 16}, {name: 'goalRollShow_1', type: 'str', label: 'If goal 1, what will you do?' }, {name: 'goalRoll_2', type: 'int', minValue: 0, maxValue: 200, label: 'goal 2 @ roll#', defaultValue: 34, required: false}, {name: 'goalRollShow_2', type: 'str', label: 'If goal 2, what will you do?', required: false}, {name: 'goalRoll_3', type: 'int', minValue: 0, maxValue: 200, label: 'goal 3 @ roll#', defaultValue: 54, required: false}, {name: 'goalRollShow_3', type: 'str', label: 'If goal 3, what will you do?', required: false}, {name: 'notice_wait_time', type: 'choice', label: 'Notification Time (in minutes)', choice1: 1, choice2: 2, choice3: 3, choice4: 4, choice5: 5, choice6: 10, choice7: 15, choice8: 20, choice9: 25, choice10: 30, choice11: 45, choice12: 60, defaultValue: 10}, {name: 'prize_2', type: 'str', label: 'If the outcome is 2, what will you do?'}, {name: 'prize_3', type: 'str', label: 'If the outcome is 3, what will you do?'}, {name: 'prize_4', type: 'str', label: 'If the outcome is 4, what will you do?'}, {name: 'prize_5', type: 'str', label: 'If the outcome is 5, what will you do?'}, {name: 'prize_6', type: 'str', label: 'If the outcome is 6, what will you do?'}, //{name: 'prizeDd_6', type: 'str', label: 'If the outcome is 6 : 3+3 , what will you do?'}, {name: 'prize_7', type: 'str', label: 'If the outcome is 7, what will you do?'}, {name: 'prize_8', type: 'str', label: 'If the outcome is 8, what will you do?'}, {name: 'prize_9', type: 'str', label: 'If the outcome is 9, what will you do?'}, {name: 'prize_10', type: 'str', label: 'If the outcome is 10, what will you do?'}, {name: 'prize_11', type: 'str', label: 'If the outcome is 11, what will you do?'}, {name: 'prize_12', type: 'str', label: 'If the outcome is 12, what will you do?'}, {name: 'prize_13', type: 'str', label: 'If the outcome is 13 (very rare), what will you do?'}, //{name: 'separator', type: 'str', label: '*********************************', defaultValue: '**********************', required: false}, {name: 'force13', type: 'int', minValue: 0, maxValue: 300, label: 'Force a 13 every x rolls (Set to 0 for none)', defaultValue: 80}, {name: 'show13', type:'choice', label:'Show 13 in prizes list ?', choice1:'Yes', choice2:'No', defaultValue:'Yes'}, // lou add {name: 'allow0', type:'choice', label:'Allow a zero (Thank you)', choice1:'Yes', choice2:'No', defaultValue:'Yes'} ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var dice = Array(0, 1, 2, 3, 4, 5, 6); var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winnersList = []; var prizesList = []; var goalRoll = [cb.settings.goalRoll_1, cb.settings.goalRoll_2]; var outcomePrize13 = [] ; // lou add var virtualForce13 = []; // lou add var prizesDd = []; // lou add var test = '' ; // lou add cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); /* ORI if (parseInt(tip['amount']) >= cb.settings.tokens) { var numberOfRolls = Math.floor(parseInt(tip['amount'])/cb.settings.tokens); for(var i = 0 ; i < numberOfRolls ; i++) { cb.setTimeout(function() { roll(tip['from_user']); lastRoller = tip['from_user']; }, 1000); } } */ /* LOU ADD 1 if (parseInt(tip['amount']) >= cb.settings.tokens){ var limitNumberOfRolls = 2 ; numberOfRolls = Math.floor(parseInt(tip['amount'])/cb.settings.tokens); if (limitNumberOfRolls !== "No") { if (numberOfRolls >= limitNumberOfRolls) { numberOfRolls = limitNumberOfRolls ; } } for(var i = 0 ; i < numberOfRolls ; i++) { cb.setTimeout(function() { roll(tip['from_user']); lastRoller = tip['from_user']; }, 1000); } } */ /* if (parseInt(tip['amount']) == cb.settings.tokens || parseInt(tip['amount']) == cb.settings.tokens *2){ // lou add var numberOfRolls = Math.floor(parseInt(tip['amount'])/cb.settings.tokens); for(var i = 0 ; i < numberOfRolls ; i++) { cb.setTimeout(function() { roll(tip['from_user']); lastRoller = tip['from_user']; }, 1000); } } */ if (parseInt(tip['amount']) == cb.settings.tokens){ // lou add var numberOfRolls = 1 ; } /*else if (parseInt(tip['amount']) == 256){ // Option valable uniquement pour le tarif normal. Les rolls promotionels ne sont pas concernés var numberOfRolls = 4 ; }*/ for(var i = 0 ; i < numberOfRolls ; i++) { cb.setTimeout(function() { roll(tip['from_user']); lastRoller = tip['from_user']; }, 1000); } }); cb.onDrawPanel(function (user) { return { 'template': '3_rows_12_22_31', 'row1_label': 'Last prize / player:', 'row1_value': lastPrizeWon+' / '+lastRoller, 'row2_label': 'Last player:', 'row2_value': lastRoller, 'row3_value': tipCounter + ' ' + langTokens + ' received / roll #' + rollCounter }; }); cb.onEnter(function (user) { var notices = ""; notices += "Welcome, " + user['user'] + "! We are playing Roll The Dice. \n"; notices += "Each roll reveals a prize. There are 12 possible prizes. \n"; notices += "Tip " + cb.settings.tokens + " " + langTokens + " to roll the dice. \n"; //notices += "Tip " + cb.settings.tokens + " " + langTokens + " to roll the dice once. Tip " + cb.settings.tokens *2 + " " + langTokens + " or more to roll the dice twice. \n"; notices += "Type /p to see the list of prizes. \n"; notices += "Type /w to see a list of the last 20 winners."; cb.sendNotice(notices, user['user'], '', '#FF6600', 'bold'); }); cb.onMessage(function(msg) { if(msg['m'].match(/\/w/i)) { msg['X-Spam'] = true; showPrizesWon(msg['user']); } else if(msg['m'].match(/\/p/i)) { msg['X-Spam'] = true; showPrizes(msg['user']); } return msg; }); function roll(username) { rollCounter++; var goalNotices = ""; var notices = ""; if (cb.settings['allow0'] == 'No') { //dices = 2; var dice1 = Math.floor(Math.random() * 6 + 1); var dice2 = Math.floor(Math.random() * 6 + 1); } else { var dice1 = dice[Math.floor(Math.random() * dice.length)]; var dice2 = dice[Math.floor(Math.random() * dice.length)]; } /*if (rollCounter%10 == 0) { if((dice1 == 1) && (dice2 != 1)) { dice1 = 7; } if((dice2 == 1) && (dice1 != 1)) { dice2 = 7; } }*/ /** Option pour tout Roll sauf roll promotionnel **/ /* if (outcomePrize13.length >= 0) { // >2 if (rollCounter%10 == 0) { if((dice1 == 1) && (dice2 != 1)) { dice1 = dice2; test = "X 2 !!" ; } else if((dice2 == 1) && (dice1 != 1)) { dice2 = dice1; test = "X 3 !!" ; } }else { test = "" ; } } */ var dices = dice1 + dice2; /* ori - if (cb.settings['allow0'] == 'No' && dices == 0) { if (cb.settings['allow0'] == 'No' && dices == 0) { dices = 2; dice1 = 1; dice2 = 1; }*/ /* ori - if (cb.settings['force13'] > 0) { if (cb.settings['force13'] > 0) { if (rollCounter%cb.settings['force13'] == 0) { dices = 13; dice1 = 6; dice2 = 7; } } */ { // lou add - if (cb.settings['force13'] > 0) { if (cb.settings['force13'] > 0 ) { if (virtualForce13.length == 0) { if (rollCounter%cb.settings['force13'] == 0) { dices = 13; dice1 = 6; dice2 = 7; } } else { if (rollCounter%virtualForce13 == 0) { dices = 13; dice1 = 6; dice2 = 7; } } } } if (dices > 1) { var prize = cb.settings['prize_' + dices]; } else { var prize = 'A Thank You!'; } var rareText=''; if(dices == 13) rareText = " (VERY RARE)"; var prizeIndex = prizesList.indexOf(prize+rareText); if (prizeIndex >= 0) { if (cb.settings.remove_winning_prize == 'Yes') { prizesList.splice(prizeIndex,1); } } else { prize = 'A Thank You!'; } { // lou add if(dices == 13) { notices += "\u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \n" ; notices += "\u2618 \u2618 :diceresult" + dice1 + " :diceresult" + dice2 + " : [" + dices + "] \n"; notices += "\u2618 \u2618 " + username + "'s prize : " + prize + " \n "; notices += "\u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \u2618 \n" ; cb.sendNotice(notices, '', '#CCFFCC', '#000000', 'bold'); var y = Math.floor(Math.random() * ((23 - 13) + 1)) + 13 ; // Math.floor(Math.random() * ((max - min) + 1)) + min var nextForce13 = rollCounter + y ; //var nextForce13 = rollCounter + Math.floor(Math.random() * ((23 - 13) + 1)) + 13 ; // Math.floor(Math.random() * ((max - min) + 1)) + min var totalWonPrize13 = outcomePrize13.length+1 ; outcomePrize13.push(1); virtualForce13.splice(0,1,nextForce13); cb.sendNotice('nextForce13 : roll#'+nextForce13+ '['+rollCounter+'+'+y+'] and sumprize13 : '+totalWonPrize13+'\n ', cb.room_slug, '#CCFFCC', '#000000', 'bold'); // temps control } else { notices += ":diceresult" + dice1 + " :diceresult" + dice2 + " : [" + dices + "] \n"; notices += username + "'s prize : " +prize+ "\n"; //notices += username + "'s prize: " + prize+ ' test : ' +test ; cb.sendNotice(notices, '', '#d7ebf4', '#000000', 'bold'); } } if (rollCounter == cb.settings.goalRoll_1) { goalNotices += "-- -- -- ---- -- -- -- -- ---- -- -- -- -- \n"; goalNotices += "-- GOAL 1/3 ! reached @Roll" +cb.settings.goalRoll_1+ " \n"; goalNotices += "-- " +cb.settings.goalRollShow_1+ " \n"; goalNotices += "-- -- -- ---- -- -- -- -- ---- -- -- -- -- \n"; cb.sendNotice(goalNotices, '', '#CCFFCC', '#e50000', 'bold'); cb.changeRoomSubject("#"+cb.settings.goalRollShow_1+ " time! Next Goal : #"+cb.settings.goalRollShow_2+ " @roll"+cb.settings.goalRoll_2+". Tip "+cb.settings.tokens +" to #RollTheDices.") ; } if (rollCounter == cb.settings.goalRoll_2) { goalNotices += "-- -- -- ---- -- -- -- -- ---- -- -- -- -- \n"; goalNotices += "-- GOAL 2/3 ! reached @Roll" +cb.settings.goalRoll_2+ " \n"; goalNotices += "-- " +cb.settings.goalRollShow_2+ " \n"; goalNotices += "-- -- -- ---- -- -- -- -- ---- -- -- -- -- \n"; cb.sendNotice(goalNotices, '', '#CCFFCC', '#e50000', 'bold'); cb.changeRoomSubject("#"+cb.settings.goalRollShow_2+" & #"+cb.settings.goalRollShow_1+ " time! Next Goal : #"+cb.settings.goalRollShow_3+ " @roll"+cb.settings.goalRoll_3+". Tip "+cb.settings.tokens +" to #RollTheDices.") ; } if (rollCounter == cb.settings.goalRoll_3) { goalNotices += "-- -- -- ---- -- -- -- -- ---- -- -- -- -- \n"; goalNotices += "-- FINAL GOAL !! reached @Roll" +cb.settings.goalRoll_3+ " \n"; goalNotices += "-- " +cb.settings.goalRollShow_3+ " \n"; goalNotices += "-- Thank you all tipers !! --\n"; goalNotices += "-- -- -- ---- -- -- -- -- ---- -- -- -- -- \n"; cb.sendNotice(goalNotices, '', '#CCFFCC', '#e50000', 'bold'); cb.changeRoomSubject("#"+cb.settings.goalRollShow_3+" #"+cb.settings.goalRollShow_2+" & #"+cb.settings.goalRollShow_1+ " time!") ; } //cb.sendNotice(notices, '', '#F0FAFF', '#000000', 'bold'); // ori lou sup lastPrizeWon = prize; winnersList.push(username + ' won: ' + prize); cb.drawPanel(); } function setPrizes() { var rareText = ''; for(var i = 2; i <= 13; i++) { if(i == 13) rareText = " (VERY RARE)"; prizesList.push(cb.settings['prize_' + i] + rareText); } } function showPrizes(username) { var limit = 12; // lou add var notices = ""; var rareText = ""; notices += "***** POSSIBLE PRIZES *****"; { // lou add if (cb.settings.show13 == 'Yes') { limit = 13 ; } } if (prizesList.length) { notices += "\n [Dice outcome] : Prize" ; for(var i = 2; i <= limit; i++){ // lou modif if(i == 13) rareText = " (VERY RARE)"; if (prizesList.indexOf(cb.settings['prize_' + i] + rareText) >= 0) { // notices += "\nDice outcome is " + i + ": " + cb.settings['prize_' + i] + rareText; notices += "\n [" + i + "] : " + cb.settings['prize_' + i] + rareText; } } } else { notices += "No prizes left. Please tell the broadcaster to restart the game."; } cb.sendNotice(notices, username, '#F0FAFF'); } function showPrizesWon(username) { winnersList.reverse(); var notices = "***** LAST 20 WINNERS *****"; if(winnersList.length == 0) { cb.sendNotice('No one has won anything yet. Roll the dice to win a prize!', username, '', '', 'bold'); } else { var last20Winners = winnersList.slice(0,20); var prizeNum = 1; for(var i=0; i<last20Winners.length;i++) { notices += "\n" + prizeNum + ") " + last20Winners[i]; prizeNum++; } cb.sendNotice(notices, username, '#CCFF99', '', 'bold'); } } function advertise() { var notices = ""; //notices += "Roll The Dice by zingknaat " +goalRoll.length+ "\n"; notices += "Roll The Dice "+goalRoll.length+" : each roll reveals a prize. There are 12 possible prizes. \n"; //notices += "Tip " + cb.settings.tokens + " " + langTokens + " to roll the dice once. Tip " + cb.settings.tokens *2 + " " + langTokens + " or more to roll the dice twice. \n \n"; notices += "Tip " + cb.settings.tokens + " " + langTokens + " to roll the dice. \n \n"; notices += "Type /p to see the list of prizes. \n"; notices += "Type /w to see a list of the last 20 winners. \n"; cb.sendNotice(notices, '', '', '#FF6600', 'bold'); cb.setTimeout(advertise, cb.settings.notice_wait_time * 60000); } function init() { setPrizes(); advertise(); cb.changeRoomSubject('#RollTheDice : Tip ' + cb.settings.tokens + ' to reveal a prize!'); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.