Apps Home
|
Create an App
Roll The Fate
Author:
greyhardy93live
Description
Source Code
Launch App
Current Users
Created by:
Greyhardy93live
//messages var help = "Press r to roll the dice."; var lastRolled = {}; var prearrangedCount = 0; //settings cb.settings_choices = [ {name: 'roomSubject', type: 'str', minLength: 1, maxLength: 255, label: 'Room subject', default: 'Roll the fate! Type "roll" to roll the dice.'}, {name: 'prize1', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 1', default: 'Sorry, no prize :( '}, {name: 'prize2', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 2', default: 'Pour water '}, {name: 'prize3', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 3', default: 'Pour flour mix '}, {name: 'prize4', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 4', default: 'Cream pie on face '}, {name: 'prize5', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 5', default: 'Cut off clothes '}, {name: 'prize6', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 6', default: 'Anything you want '}, {name: 'initial_sequence', type: 'str', minLength: 1, maxLength: 255, label: 'Pre-output sequence', default: '4,4,3,5,3'}, ]; var prearranged = []; if(cb.settings["initial_sequence"]){ prearranged = cb.settings["initial_sequence"].split(","); } function info(text, userName){ cb.sendNotice(text, userName, "black", "yellow", "bolder"); } function init(){ cb.changeRoomSubject(cb.settings["roomSubject"]); info('Welcome to the "Roll The Fate" game!'); howTo(); } function howTo(userName){ info('You have 1 chance to roll a dice, that will determine the fate of me.', userName); info('HOW TO PLAY? Just type "roll" to roll the dice.', userName); drawprizes(); } function initializeUser(userName){ info('Welcome ' + userName + '! We are playing "Roll The Fate" game.', userName); howTo(userName); } function updateUserStatus(userName){ lastRolled[userName] = true; } drawings = { 1: ":tdr1", 2: ":tdr2", 3: ":tdr3", 4: ":tdr4", 5: ":tdr5", 6: ":tdr6" }; function drawDice(diceValue){ cb.chatNotice(drawings[diceValue]); } function rollDice(userName){ if(userName == cb.room_slug){ cb.chatNotice('Rolling Dice by broadcaster...','','','','bold'); var diceValue = Math.floor(Math.random() * 6 + 1); if(prearrangedCount < prearranged.length){ diceValue = prearranged[prearrangedCount]; prearrangedCount++; } drawDice(diceValue); var prize_won = cb.settings["prize" + diceValue]; stateChange(userName, prize_won); }else{ if(!lastRolled[userName]){ cb.chatNotice('Rolling Dice for '+ userName,'','','','bold'); var diceValue = Math.floor(Math.random() * 6 + 1); if(prearrangedCount < prearranged.length){ diceValue = prearranged[prearrangedCount]; prearrangedCount++; } drawDice(diceValue); var prize_won = cb.settings["prize" + diceValue]; stateChange(userName, prize_won); updateUserStatus(userName); }else{ info("Sorry "+userName+", you can't roll twice.") } } } function stateChange(player, prize_won) { setTimeout(function(){ if(player){ cb.chatNotice(' \u2605 ' + 'Prize: ' + prize_won + ' \u2605','','#666699','#FFFFFF'); cb.drawPanel(); } }, 3500); } var lines = '\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501'; function drawprizes(user) { var out = ''; for (i=1; i <= 6; i++) { out += i + ': ' + cb.settings["prize" + i] + '\n'; } out += lines; cb.chatNotice(' Prizes: ', user, '#B00000','#FFFFFF','bold'); cb.chatNotice(out, user); } init(); cb.onMessage(function (msg) { if (msg['m'].indexOf('roll') === 0) { msg['X-Spam'] = true; rollDice(msg['user']); } }) cb.onEnter(function(user) { initializeUser(user['user']); });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.