Apps Home
|
Create an App
Cheshire Slots
Author:
mikesmodelstest
Description
Source Code
Launch App
Current Users
Created by:
Mikesmodelstest
/** * App: Bunny Slots * Version: 1.00 * Author: MikesModels * Date: 11.25.17 */ cb.settings_choices = [ {name: 'tokens', type: 'int', label: 'Cost per spin (in tokens)', defaultValue: 10}, {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: 'jackpot_minimum', type:'int', label:'Minimum number tokens before jackpot', defaultValue:10}, {name: 'lose_0', type: 'str', label: 'Message when lose', defaultValue:'Sorry babe, Try again'}, {name: 'prize_1', type: 'str', label: 'Jackpot prize (3 Cheshire Cats)', defaultValue:'Cum Show ^_^'}, {name: 'prize_2', type: 'str', label: '2nd place prize (3 Mad Hatters)'}, {name: 'prize_3', type: 'str', label: '3rd place prize (3 White Rabbits)'}, {name: 'prize_4', type: 'str', label: '4th place prize (2 Cheshire Cats)'}, {name: 'prize_5', type: 'str', label: '5th place prize (2 Mad Hatters)'}, {name: 'prize_6', type: 'str', label: '6th place prize (2 White Rabbits)'}, {name: 'prize_7', type: 'str', label: '7th place prize (2 March Hares)'}, {name: 'prize_8', type: 'str', label: '8th place prize (2 Alices)'}, {name: 'prize_9', type: 'str', label: '9th place prize (2 door mice)'}, {name: 'prize_10', type: 'str', label: '10th place prize (1 Cheshire Cat)'}, {name: 'prize_11', type: 'str', label: '11th place prize (1 Mad Hatter)'}, {name: 'prize_12', type: 'str', label: '12th place prize (1 White Rabbit)'} ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var lastPlayer = '--'; var lastPrizeWon = '--'; var spinCounter = 0; var tipCounter = 0; var prizesWon = Array(); var loser = 'Blank' var cat = ':cheshire_jackpot1'; var doormouse = ':cheshire_doormouse'; var madhatter = ':cheshire_madhatter'; var rabbit = ':cheshire_rabbit'; var march = ':cheshire_march'; var alice = ':cheshire_alice'; var slotPieces = Array (loser, cat, doormouse, madhatter, rabbit, march, alice); cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); if (parseInt(tip['amount']) >= cb.settings.tokens) { var numberOfSpins = Math.floor(parseInt(tip['amount'])/cb.settings.tokens); for(var i=1;i<=numberOfSpins;i++) { cb.setTimeout(function() { spin(tip['from_user']); }, 2000*i); } } }); cb.onDrawPanel(function (user) { return { 'template': '3_rows_12_22_31', 'row1_label': 'Last prize won:', 'row1_value': lastPrizeWon, 'row2_label': 'Last player:', 'row2_value': lastPlayer, 'row3_value': tipCounter + ' ' + langTokens + ' received / spun ' + spinCounter + ' time(s)' }; }); cb.onEnter(function (user) { var notices = "Welcome, " + user['user'] + ". Please enjoy Cheshire Slots.\n"; notices += 'Tip ' + cb.settings.tokens + ' ' + langTokens + ' to spin the reels.\n'; notices += 'Type "/p" to see the 13 possible prizes.\n'; notices += 'Type "/w" to see a list of the last 20 prizes won.'; 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 getSlotPiece() { var piece = slotPieces[Math.floor(Math.random() * slotPieces.length)]; return piece; } function getRow() { var row = getSlotPiece() + ' ' + getSlotPiece() + ' ' + getSlotPiece(); var loserMatches = row.match(/loser/g); if(loserMatches != null) { var numberOfloss = loserMatches.length; if(numberOfloss == 3) { return row; } else { getRow(); } } return row; } function spin(username) { spinCounter++; var prize = '--'; var row1 = getRow(); var row2 = getRow(); var row3 = getRow(); var loserMatches = row2.match(/loser/g); if(loserMatches != null) { var numberOfloss = loserMatches.length; } var catMatches = row2.match(/cat/g); if(catMatches != null) { var numberOfcat = catMatches.length; } var doormouseMatches = row2.match(/doormouse/g); if(doormouseMatches != null) { var numberOfdoormouses = doormouseMatches.length; } var rabbitMatches = row2.match(/rabbit/g); if (rabbitMatches != null) { var numberOfrabbits = rabbitMatches.length; } var aliceMatches = row2.match(/alice/g); if (aliceMatches != null) { var numberOfalices = aliceMatches.length; } var madhatterMatches = row2.match(/madhatter/g); if (madhatterMatches != null) { var numberOfmadhatters = madhatterMatches.length; } var marchMatches = row2.match(/march/g); if (marchMatches != null) { var numberOfmarches = marchMatches.length; } var notices = row1 + "\n"; notices += row2 + " <-- pay line \n"; notices += row3; cb.sendNotice(notices); if (numberOfloss == 3) { prize = cb.settings.prize_0; } else if (numberOfcat == 3) { prize = cb.settings.prize_1; } else if (numberOfmadhatters == 3) { prize = cb.settings.prize_2; } else if (numberOfrabbits == 3) { prize = cb.settings.prize_3; } else if (numberOfcat == 2) { prize = cb.settings.prize_4; } else if (numberOfmadhatters == 2) { prize = cb.settings.prize_5; } else if (numberOfrabbits == 2) { prize = cb.settings.prize_6; } else if (numberOfmarches == 2) { prize = cb.settings.prize_7; }else if (numberOfalices == 2) { prize = cb.settings.prize_8; } else if (numberOfdoormouses == 2) { prize = cb.settings.prize_9; } else if (numberOfcat == 1) { prize = cb.settings.prize_10; } else if (numberOfmadhatters == 1) { prize = cb.settings.prize_11; } else if (numberOfrabbits == 1) { prize = cb.settings.prize_12; } lastPlayer = username; if(prize != '--') { lastPlayer = username; lastPrizeWon = prize; prizesWon.push(prize + ' - ' + username); cb.sendNotice(username + ' WINNER WINNER, BUNNY DINNER! Prize: ' + prize, '', '#99FF99', '', 'bold'); } else { cb.sendNotice(username + ' Sorry Babe, Try again. :cry', '', '', '#996633', 'bold'); } cb.drawPanel(); return prize; } function showPrizes(username) { var notices = '**** Possible Prizes ****\n'; notices += '1st) 3 Cheshire Cats (jackpot) = ' + cb.settings.prize_1 + '\n'; notices += '2nd) 3 madhatters = ' + cb.settings.prize_2 + '\n'; notices += '3rd) 3 White Rabbits = ' + cb.settings.prize_3 + '\n'; notices += '4th) 2 Cheshire Cats + Any Piece = ' + cb.settings.prize_4 + '\n'; notices += '5th) 2 Mad Hatters + Any Piece = ' + cb.settings.prize_5 + '\n'; notices += '6th) 2 White Rabbits + Any Piece = ' + cb.settings.prize_6 + '\n'; notices += '7th) 2 March Hares + Any Piece = ' + cb.settings.prize_7 + '\n'; notices += '8th) 2 Alices + Any Piece = ' + cb.settings.prize_8 + '\n'; notices += '9th) 2 Door Mice + Any Piece = ' + cb.settings.prize_9 + '\n'; notices += '10th) 1 Cheshire Cat + Any Piece = ' + cb.settings.prize_10 + '\n'; notices += '11th) 1 Mad Hatter + Any Piece = ' + cb.settings.prize_11 + '\n'; notices += '12th) 1 White Rabbit + Any Piece = ' + cb.settings.prize_12 + '\n'; cb.sendNotice(notices, username, '#D1F0FF', '', 'bold'); } function showPrizesWon(username) { prizesWon.reverse(); if(prizesWon.length == 0) { cb.sendNotice('No one has won anything yet. Play the slot machine to win a prize!', username, '', '#CC0000', 'bold'); } else { prizesWon.slice(0,20); var notices = "**** Last 20 Winners ****"; var prizeNum = 1; var totalWon = prizesWon.length; if(prizesWon.length >= 20) totalWon = 20; for(var i=0; i<totalWon;i++) { notices += "\n" + prizeNum + ") " + prizesWon[i]; prizeNum++; } cb.sendNotice(notices, username, '#EBFFEB', '', 'bold'); } } function advertise() { var notices = "Cheshy Slots by MikesModels\n"; notices += 'Tip ' + cb.settings.tokens + ' ' + langTokens + ' to spin the reels.\n'; notices += 'Type "/p" to see the 12 possible prizes.\n'; notices += 'Type "/w" to see a list of the last 20 winners.'; cb.sendNotice(notices, '', '', '#FF6600', 'bold'); cb.setTimeout(advertise, cb.settings.notice_wait_time * 60000); } function init() { advertise(); cb.changeRoomSubject("Loosest Slots on CB ;)"); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.