Apps Home
|
Create an App
spaceslots
Author:
daisy_marz_test
Description
Source Code
Launch App
Current Users
Created by:
Daisy_Marz_Test
/** * app: spaceslots * modified by: daisy_marz * original author: zingknaat */ cb.settings_choices = [ {name: 'tokens', type: 'int', label: 'cost per spin (in tokens)', defaultValue: 25}, {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:1000}, {name: 'prize_1', type: 'str', label: 'jackpot prize (3 rockets)', defaultValue:'cum'}, {name: 'prize_2', type: 'str', label: '2nd place prize (3 ufos)'}, {name: 'prize_3', type: 'str', label: '3rd place prize (3 earths)'}, {name: 'prize_4', type: 'str', label: '4th place prize (3 moons)'}, {name: 'prize_5', type: 'str', label: '5th place prize (any object and 2 comets)'}, {name: 'prize_6', type: 'str', label: '6th place prize (any combination of marz/rocket)'}, {name: 'prize_7', type: 'str', label: '7th place prize (any combination and 1 comet)'} ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var lastPlayer = '--'; var lastPrizeWon = '--'; var spinCounter = 0; var tipCounter = 0; var prizesWon = Array(); var rocket = ':daisy_marz-rocketslot'; var moon = ':daisy_marz-moonslot'; var ufo = ':daisy_marz-ufoslot'; var earth = ':daisy_marz-earthslot'; var comet = ':daisy_marz-cometslot'; var marz = ':daisy_marz-marzslot'; var slotPieces = Array(rocket, moon, ufo, earth, comet, marz); 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 = "hey, " + user['user'] + ". we're playing spaceslots.\n"; notices += 'tip ' + cb.settings.tokens + ' ' + langTokens + ' to spin the reels.\n'; notices += 'type "/p" to see the 7 possible prizes.\n'; notices += 'type "/w" to see a list of the last 20 prizes won.'; cb.sendNotice(notices, user['user'], '', '#B3D2FF', '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)]; if((piece == rocket) && (spinCounter%2 != 0)) { return comet; } return piece; } function getRow() { var row = getSlotPiece() + ' ' + getSlotPiece() + ' ' + getSlotPiece(); var rocketMatches = row.match(/rocket/g); if(rocketMatches != null) { var numberOfrockets = rocketMatches.length; if((numberOfrocketss == 3) && (parseInt(tipCounter) >= parseInt(cb.settings.jackpot_minimum))) { return row; } else { getRow(); } } return row; } function spin(username) { spinCounter++; var prize = '--'; var row1 = getRow(); var row2 = getRow(); var row3 = getRow(); var rocketMatches = row2.match(/rocket/g); if(rocketMatches != null) { var numberOfrockets = rocketMatches.length; } var moonMatches = row2.match(/moon/g); if(moonMatches != null) { var numberOfmoons = moonMatches.length; } var earthMatches = row2.match(/earth/g); if (earthMatches != null) { var numberOfearths = earthMatches.length; } var marzMatches = row2.match(/marz/g); if (marzMatches != null) { var numberOfmarzs = marzMatches.length; } var ufoMatches = row2.match(/ufo/g); if (ufoMatches != null) { var numberOfufos = ufoMatches.length; } var cometMatches = row2.match(/comet/g); if (cometMatches != null) { var numberOfcomets = cometMatches.length; } var notices = row1 + "\n"; notices += row2 + " <-- pay line \n"; notices += row3; cb.sendNotice(notices); if (numberOfrockets == 3) { prize = cb.settings.prize_1; } else if (numberOfufos == 3) { prize = cb.settings.prize_2; } else if (numberOfearths == 3) { prize = cb.settings.prize_3; } else if (numberOfmoons == 3) { prize = cb.settings.prize_4; } else if (numberOfcomets == 2) { prize = cb.settings.prize_5; } else if ((numberOfmarzs == 1 && numberOfrockets == 2) || (numberOfmarzs == 2 && numberOfrockets == 1)) { prize = cb.settings.prize_6; } else if ((numberOfcomets == 1) || (numberOfcomets == 3)) { prize = cb.settings.prize_7; } lastPlayer = username; if(prize != '--') { lastPlayer = username; lastPrizeWon = prize; prizesWon.push(prize + ' - ' + username); cb.sendNotice(username + ' won a prize! Prize: ' + prize, '', '#66FFEB', '', 'bold'); } else { cb.sendNotice(username + ' did not win anything. :cry', '', '', '#66FFEB', 'bold'); } cb.drawPanel(); return prize; } function showPrizes(username) { var notices = ' :daisy_marz-yellowstaricon possible prizes :daisy_marz-yellowstaricon \n'; notices += '1st) 3 rockets (jackpot) = ' + cb.settings.prize_1 + '\n'; notices += '2nd) 3 ufos = ' + cb.settings.prize_2 + '\n'; notices += '3rd) 3 earths = ' + cb.settings.prize_3 + '\n'; notices += '4th) 3 moons = ' + cb.settings.prize_4 + '\n'; notices += '5th) any piece + 2 comets = ' + cb.settings.prize_5 + '\n'; notices += '6th) any combination of marz/rocket = ' + cb.settings.prize_6 + '\n'; notices += '7th) any combination + 1 comet = ' + cb.settings.prize_7; cb.sendNotice(notices, username, '#B3D2FF', '', 'bold'); } function showPrizesWon(username) { prizesWon.reverse(); if(prizesWon.length == 0) { cb.sendNotice('no one has won anything yet. play some spaceslots to win an out of this world prize!', username, '', '#B3D2FF', '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, '#B3E8FF', '', 'bold'); } } function advertise() { var notices = "spaceslots by daisy_marz\n"; notices += 'Tip ' + cb.settings.tokens + ' ' + langTokens + ' to spin the reels.\n'; notices += 'Type "/p" to see the 7 possible prizes.\n'; notices += 'Type "/w" to see a list of the last 20 winners.'; cb.sendNotice(notices, '', '', '#B3D2FF', 'bold'); cb.setTimeout(advertise, cb.settings.notice_wait_time * 60000); } function init() { advertise(); cb.changeRoomSubject("lets play some spaceslots!"); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.