Apps Home
|
Create an App
brazilianxnuts Party
Author:
kirarenard
Description
Source Code
Launch App
Current Users
Created by:
Kirarenard
cb.settings_choices = [ {name: 'goal1description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 1 description", required: false}, {name:'goal1value', type:'int', minValue:1, maxValue:9999, label: "Goal 1 value", required: false}, {name: 'goal2description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 2 description", required: false}, {name:'goal2value', type:'int', minValue:1, maxValue:9999, label: "Goal 2 value", required: false}, {name: 'goal3description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 3 description", required: false}, {name:'goal3value', type:'int', minValue:1, maxValue:9999, label: "Goal 3 value", required: false}, {name: 'goal4description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 4 description", required: false}, {name:'goal4value', type:'int', minValue:1, maxValue:9999, label: "Goal 4 value", required: false}, {name: 'goal5description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 5 description", required: false}, {name:'goal5value', type:'int', minValue:1, maxValue:9999, label: "Goal 5 value", required: false}, {name: 'goal6description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 6 description", required: false}, {name:'goal6value', type:'int', minValue:1, maxValue:9999, label: "Goal 6 value", required: false}, {name: 'goal7description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 7 description", required: false}, {name:'goal7value', type:'int', minValue:1, maxValue:9999, label: "Goal 7 value", required: false}, {name: 'goal8description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 8 description", required: false}, {name:'goal8value', type:'int', minValue:1, maxValue:9999, label: "Goal 8 value", required: false}, {name: 'goal9description', type: 'str', minLength: 1, maxLength: 255, label: "Goal 9 description", required: false}, {name:'goal9value', type:'int', minValue:1, maxValue:9999, label: "Goal 9 value", required: false}, {name: 'goalrepeatdescription', type: 'str', minLength: 1, maxLength: 255, label: "Goal to repeat description"}, {name:'goalrepeatvalue', type:'int', minValue:1, maxValue:9999, label: "Goal to repeat value"}, {name: 'ticket_price', type: 'int', minValue: 1, maxValue: 1000, defaultValue: 50, label: "Ticket show price"}, {name: 'hide_message', label: 'Hidden Cam Message', type: 'str', minLength: 1, maxLength: 256, defaultValue: 'Ticket Show in progress! Tip for the ticket to join us.' }, {name: 'dice_price', type: 'int', minValue: 1, maxValue: 1000, defaultValue: 6, label: "Price for rolling the dice", required: false}, {name: 'six_price', type: 'int', minValue: 1, maxValue: 1000, defaultValue: 33, label: "Price for get 6 on the dice", required: false}, {name: 'app_key', type: 'str', minLength: 5, maxLength: 20, label: "App key", required: false} ]; var goals = []; var goal_tipped = 0; var actual_goal = 0; var last_goal = 0; var times_repeated = 0; var total_tipped = 0; var highest = []; var last_tip = []; var display_message = ""; var action = 0; var players = []; var players_place = []; var players_lucky_number = []; var prizes_place = [ 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, 0,1,2,3,4,5,6,7,8,9, 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, 0,1,2,3,4,5,6,7,8,9 ]; var app_key = cb.settings.app_key; if(app_key == "") app_key = "no_key"; function rollDice(tip) { var dice; var date = new Date(); var time = date.getTime(); var user = tip['from_user']; var amount = parseInt(tip['amount']); if (amount == cb.settings.dice_price || amount == cb.settings.six_price) { if (amount == cb.settings.dice_price) dice = Math.floor((Math.random() * 6) + 1); else if (amount == cb.settings.six_price) dice = 6; action++; boardNotice(":::"+action+":::dice:::"+user+":::"+dice); if(cbjs.arrayContains(players, user)) { movePlayer(user,dice); } else { players.push(user); players_place.push(0); players_lucky_number.push(dice); action++; boardNotice(":::"+action+":::added:::"+user); action++; boardNotice(":::"+action+":::place:::"+user+":::"+0); } if (dice == 6) rollAgain(user); } } function movePlayer(user,dice) { var index = players.indexOf(user); players_place[index] += dice; action++; boardNotice(":::"+action+":::move:::"+user+":::"+dice); action++; boardNotice(":::"+action+":::place:::"+user+":::"+players_place[index]); if (prizes_place[players_place[index]] > 0) { action++; boardNotice(":::"+action+":::prize:::"+user+":::"+prizes_place[players_place[index]]); } } function rollAgain(user) { action++; boardNotice(":::"+action+":::again:::"+user); var dice = Math.floor((Math.random() * 6) + 1); action++; boardNotice(":::"+action+":::dice:::"+user+":::"+dice); movePlayer(user,dice); } function boardNotice(m) { cb.sendNotice("BOARD_APP:::"+app_key+m, cb.room_slug); } function broadcasterOnlyNotice(m) { cb.sendNotice("*** BROADCASTER ONLY ***", cb.room_slug); cb.sendNotice(m, cb.room_slug); cb.sendNotice("*** BROADCASTER ONLY ***", cb.room_slug); } function highestTip() { if ((last_tip[0] == undefined) && (last_tip[1] == undefined)) { highest[0] = 0; highest[1] = ""; return "highest tip"; } else { if (last_tip[0] > highest[0]) { highest[0] = last_tip[0]; highest[1] = last_tip[1]; } return highest[1] + " (" + highest[0] + ")"; } } function goalTimes() { if (actual_goal > 0) { cb.sendNotice("atingiu goal " + actual_goal); if (actual_goal == 9) actual_goal = 0; else actual_goal++; } else if (actual_goal == 0) { times_repeated++; cb.sendNotice("atingiu goal repetitivo pela " + times_repeated + "a vez"); } } function checkGoal(tip) { var to_reach_goal = goals[actual_goal][0] - goal_tipped; total_tipped += tip['amount']; if (actual_goal <= last_goal) { if (tip['amount'] < to_reach_goal) { goal_tipped += tip['amount']; //cb.sendNotice("nao atingiu goal"); } else { //atingiu pelo menos uma goal goal_tipped += tip['amount'] - goals[actual_goal][0]; goalTimes(); while (goal_tipped >= goals[actual_goal][0]) { goal_tipped -= goals[actual_goal][0]; goalTimes(); } } to_reach_goal = goals[actual_goal][0] - goal_tipped; if (actual_goal > 1) cb.changeRoomSubject(goals[actual_goal-1][1]+" now! "+to_reach_goal+" tokens to "+goals[actual_goal][1]); else cb.changeRoomSubject(to_reach_goal+" tokens to "+goals[actual_goal][1]); } } function checkTicket(tip) { if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), tip['from_user']) && (parseInt(tip['amount']) == cb.settings.ticket_price)) { output('Added '+ tip['from_user'] + ' to ticket show!'); cb.limitCam_addUsers([tip['from_user']]); } } function startShow() { output(cb.room_slug + ' has started the show!'); cb.limitCam_start(cb.settings.hide_message); } function stopShow() { output(cb.room_slug + ' has stopped the show!'); cb.limitCam_stop(); } function addUser(username) { if (!cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), username)) { cb.limitCam_addUsers([username]); output(cb.room_slug + ' has add ' + username + ' to the show!'); } } function checkUser(username) { if (cb.limitCam_userHasAccess(username)) { output(username + " is in the show!"); } else { output(username + " is not in the show!"); } } function removeUser(username) { if (cbjs.arrayContains(cb.limitCam_allUsersWithAccess(), username)) { cb.limitCam_removeUsers([username]); output(cb.room_slug + ' has removed ' + username + ' from the show!'); } } function listUsers() { var userlist = cb.limitCam_allUsersWithAccess(); if (userlist.length > 0) { output("" + userlist.length + (userlist.length > 1 ? " users" : " user") + " in show: " + cbjs.arrayJoin(userlist, ", ")); } else { output("No users in show."); } } function updateLastTip(tip) { last_tip[0] = tip['amount']; last_tip[1] = tip['from_user']; } function output(message) { cb.sendNotice(message); } cb.onTip(function (tip) { updateLastTip(tip); checkGoal(tip); rollDice(tip); cb.drawPanel(); }); cb.onMessage(function (msg) { var message = msg['m']; var user = msg['user']; var username = ""; var ludo_icon = ""; if (cb.room_slug == user) { if (message == '/start_show' && !cb.limitCam_isRunning()) { startShow(); } if (message == '/stop_show' && cb.limitCam_isRunning()) { stopShow(); } if (message.substring(0, 9) == '/add_user') { username = message.substring(10, message.length); addUser(username); } if (message.substring(0, 11) == '/check_user') { username = message.substring(12, message.length); checkUser(username); } if (message.substring(0, 12) == '/remove_user' && cb.limitCam_allUsersWithAccess().length > 0) { username = message.substring(13, message.length); removeUser(username); } if (message == '/list_users') { listUsers(); } } if (!cbjs.arrayContains(ludo_players, user)) { if (message.substring(0, 5) == '/move') { //move pino existente ludo_icon = message.substring(6, message.length); } if (message == '/new') { addLudoPlayerIcon(user); } } if (message[0] == '/') { msg['X-Spam'] = true; } return msg; }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_11_21_31', 'row1_value': goals[actual_goal][0] - goal_tipped + ' tokens left to ' + goals[actual_goal][1], 'row2_value': highestTip(), 'row3_value': display_message }; }); function init() { cb.changeRoomSubject('Hi! I\'m Kira and this is Luky, don\'t be shy and say hi :-)'); goals[0] = [cb.settings.goalrepeatvalue,cb.settings.goalrepeatdescription]; goals[1] = [cb.settings.goal1value,cb.settings.goal1description]; goals[2] = [cb.settings.goal2value,cb.settings.goal2description]; goals[3] = [cb.settings.goal3value,cb.settings.goal3description]; goals[4] = [cb.settings.goal4value,cb.settings.goal4description]; goals[5] = [cb.settings.goal5value,cb.settings.goal5description]; goals[6] = [cb.settings.goal6value,cb.settings.goal6description]; goals[7] = [cb.settings.goal7value,cb.settings.goal7description]; goals[8] = [cb.settings.goal8value,cb.settings.goal8description]; goals[9] = [cb.settings.goal9value,cb.settings.goal9description]; for (i = 9; i > 0; i--) { if ((goals[i][0] != undefined) && (goals[i][1] != undefined)) actual_goal = i; } for (i = 1; i <= 9; i++) { if ((goals[i][0] != undefined) && (goals[i][1] != undefined)) { last_goal = i; } else { i = 10; } } display_message = "display some message"; cb.drawPanel(); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.