Apps Home
|
Create an App
jestapp
Author:
testnojest420
Description
Source Code
Launch App
Current Users
Created by:
Testnojest420
/* Version 1.0 */ /* A bot to greet people when they enter and optionally show a notice after they leave. You can choose your own messages when you start the bot. Separate each message with a backslash (\), and each message will be shown randomly when viewers enter and leave. You can choose where in the greeting the viewer's name appears using '<name>' in your message. If you don't use '<name>' it'll automatically be added to the end of the message. See the examples below to see how they work. If you enter nothing, these will be used as defaults Example entry messages... Welcome <name>, how's it going?\Hey there <name>.\Hi <name>. Come in and chat.\Come in and chat Example leaving messages.. Bye <name>.\Goodbye <name>, we'll miss you.\See ya <name>, come back soon. */ function findPlayerInScoreBoard(e) {"use strict";var t=0;if(e in score_board){t=score_board[e]}return t} function updatePlayerInScoreBoard(e,t) {"use strict";score_board[e]=t} function sendGameNotice(e) {"use strict";cb.chatNotice(MSG_GAME_HEADER+e)} function sendGameNoticeToPlayer(e,t) {"use strict";cb.chatNotice(MSG_GAME_HEADER+e,t)} function recordTip(e) {"use strict";var t=false;if(e.amount===cb.settings.cost_per_card) {card_tipped+=e.amount;drawn_cards+=1;cb.drawPanel();t=true} else{bonus_tipped+=e.amount}return t}function drawCard() {"use strict";var e=Math.floor(Math.random()*cards.length);return cards[e]} function evaluateBlank(e,t) {"use strict";sendGameNotice("Sorry "+t+", you draw a blank: "+e.name+" "+e.emote+" \nYour total score is still "+findPlayerInScoreBoard(t))} function evaluateJoker(e,t) {"use strict";if(cb.settings.joker==="no"){evaluateBlank(e,t)}else{sendGameNotice("Argh "+t+", you draw the evil "+e.name+" "+e.emote+" \nYour total score is reset to 0."); updatePlayerInScoreBoard(t,0)}} function evaluateAce(e,t) {"use strict";var n=findPlayerInScoreBoard(t),r=n+e.points;updatePlayerInScoreBoard(t,r);sendGameNotice(t+", you draw a "+e.name+" "+e.emote+" "+e.points+" are added to your score.\nYour total score now is "+r)} function evaluateKing(e,t) {"use strict";sendGameNotice("Congratulation "+t+", you draw a "+e.name+" "+e.emote+" The reward for this is: "+cb.settings.reward_king+"\nYour total score is unchanged at "+findPlayerInScoreBoard(t)+"\n"+cb.room_slug+", time to pay your debts ;)") } function evaluateQueen(e,t) {"use strict";sendGameNotice("Congratulation "+t+", you draw a "+e.name+" "+e.emote+" The reward for this is: "+cb.settings.reward_queen+"\nYour total score is unchanged at "+findPlayerInScoreBoard(t)+"\n"+cb.room_slug+", time to pay your debts ;)") } function evaluateJack(e,t) {"use strict";sendGameNotice("Congratulation "+t+", you draw a "+e.name+" "+e.emote+" The reward for this is: "+cb.settings.reward_queen+"\nYour total score is unchanged at "+findPlayerInScoreBoard(t)+"\n"+cb.room_slug+", time to pay your debts ;)") } function evaluateNumber(e,t) {"use strict";var n=findPlayerInScoreBoard(t),r=n+e.points;updatePlayerInScoreBoard(t,r);sendGameNotice(t+", you draw a "+e.name+" "+e.emote+" "+e.points+" are added to your score.\nYour total score now is "+r)} function evaluateCard(e,t) {"use strict";switch(e.type) {case CARD_TYPE_JOKER:evaluateJoker(e,t);case CARD_TYPE_ACE:evaluateAce(e,t);break;case CARD_TYPE_JACK:evaluateBlank(e,t);break;case CARD_TYPE_KING:evaluateKing(e,t);break;case CARD_TYPE_QUEEN:evaluateQueen(e,t);break;case CARD_TYPE_NUMBER:evaluateNumber(e,t);break;default:break}} function evaluateWinState(e){"use strict";if(findPlayerInScoreBoard(e)>=cb.settings.points_for_reward){sendGameNotice("Congratulation "+e+", you collected more than "+cb.settings.points_for_reward+" points. The reward for this is: "+cb.settings.reward_points+"\nYour score is reset to 0.\n"+cb.room_slug+", time to pay your debts ;)");cb.chatNotice(cb.room_slug+", in round "+round_number+" you earned "+card_tipped+" tokens by card drawings and "+bonus_tipped+" tokens by other tips.",cb.room_slug);card_total+=card_tipped;bonus_total+=bonus_tipped;cb.chatNotice(cb.room_slug+", in total you earned "+card_total+" tokens by card drawings and "+bonus_total+" tokens by other tips.",cb.room_slug);round_number+=1;updatePlayerInScoreBoard(e,0);card_tipped=0;bonus_tipped=0;drawn_cards=0;cb.drawPanel()}} function printRewards(e) {"use strict";sendGameNoticeToPlayer("Reward for a King: "+cb.settings.reward_king+"\n"+"Reward for a Queen: "+cb.settings.reward_queen+"\n"+"Reward for a Jack: "+cb.settings.reward_jack+"\n"+"Reward for "+cb.settings.points_for_reward+" points: "+cb.settings.reward_points,e)} function printScoreboard(e) {"use strict";var t=Object.getOwnPropertyNames(score_board).sort();var n="";t.forEach(function(e){n+=e+" ["+findPlayerInScoreBoard(e)+" points]\n"});sendGameNoticeToPlayer(n,e)} function advertise(){"use strict";var e="Draw a card for "+cb.settings.cost_per_card+" tokens in order to collect points or win a reward. Type /rewards "+" for a list of rewards, /scoreboard to see the actual points each player has collected so far. ";if(cb.settings.joker==="yes"){e+="But be aware of the Joker. You will loose all your points."} sendGameNotice(e);cb.setTimeout(advertise,5*6e4)} function init() {"use strict";cb.changeRoomSubject(cb.settings.room_description);cb.setTimeout(advertise,.5*6e4)} var CARD_TYPE_JOKER="joker";var CARD_TYPE_ACE="ace";var CARD_TYPE_KING="king";var CARD_TYPE_QUEEN="queen";var CARD_TYPE_JACK="jack";var CARD_TYPE_NUMBER="number";var MSG_GAME_HEADER="--== Jest420's Card Draw ==--\n";var LABEL_CARDS="Played cards:";var COST_PER_CARD="Draw a card:";var ROUNDS="Round:";var round_number=1;var drawn_cards=0;var card_tipped=0;var bonus_tipped=0;var card_total=0;var bonus_total=0;var cards=[ {name:"Red Joker",type:CARD_TYPE_JOKER,emote:":monkey_card_king",points:0}, {name:"Blue Joker",type:CARD_TYPE_JOKER,emote:":monkey_card_king",points:0}, {name:"Ace of Clubs",type:CARD_TYPE_ACE,emote:":monkey_card_ace",points:13}, {name:"King of Clubs",type:CARD_TYPE_KING,emote:":monkey_card_king",points:0}, {name:"Queen of Clubs",type:CARD_TYPE_QUEEN,emote:":monkey_card_queen",points:0}, {name:"Jack of Clubs",type:CARD_TYPE_JACK,emote:":monkey_card_jack",points:0}, {name:"10 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_10",points:10}, {name:"9 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_9",points:9}, {name:"8 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_8",points:8}, {name:"7 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_7",points:7}, {name:"6 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_6",points:6}, {name:"5 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_5",points:5}, {name:"4 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_4",points:4}, {name:"3 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_3",points:3}, {name:"2 of Clubs",type:CARD_TYPE_NUMBER,emote:":monkey_card_2",points:2}, {name:"Ace of Diamonds",type:CARD_TYPE_ACE,emote:":monkey_card_ace",points:13}, {name:"King of Diamonds",type:CARD_TYPE_KING,emote:":monkey_card_king",points:0}, {name:"Queen of Diamonds",type:CARD_TYPE_QUEEN,emote:":monkey_card_queen",points:0}, {name:"Jack of Diamonds",type:CARD_TYPE_JACK,emote:":monkey_card_jack",points:0}, {name:"10 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_10",points:10}, {name:"9 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_9",points:9}, {name:"8 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_8",points:8}, {name:"7 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_7",points:7}, {name:"6 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_6",points:6}, {name:"5 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_5",points:5}, {name:"4 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_4",points:4}, {name:"3 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_3",points:3}, {name:"2 of Diamonds",type:CARD_TYPE_NUMBER,emote:":monkey_card_2",points:2}, {name:"Ace of Hearts",type:CARD_TYPE_ACE,emote:":monkey_card_ace",points:13}, {name:"King of Hearts",type:CARD_TYPE_KING,emote:":monkey_card_king",points:0}, {name:"Queen of Hearts",type:CARD_TYPE_QUEEN,emote:":monkey_card_queen",points:0}, {name:"Jack of Hearts",type:CARD_TYPE_JACK,emote:":monkey_card_jack",points:0}, {name:"10 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_10",points:10}, {name:"9 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_9",points:9}, {name:"8 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_8",points:8}, {name:"7 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_7",points:7}, {name:"6 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_6",points:6}, {name:"5 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_5",points:5}, {name:"4 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_4",points:4}, {name:"3 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_3",points:3}, {name:"2 of Hearts",type:CARD_TYPE_NUMBER,emote:":monkey_card_2",points:2}, {name:"Ace of Spades",type:CARD_TYPE_ACE,emote:":monkey_card_ace",points:13}, {name:"King of Spades",type:CARD_TYPE_KING,emote:":monkey_card_king",points:0}, {name:"Queen of Spades",type:CARD_TYPE_QUEEN,emote:":monkey_card_queen",points:0}, {name:"Jack of Spades",type:CARD_TYPE_JACK,emote:":monkey_card_jack",points:0}, {name:"10 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_10",points:10}, {name:"9 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_9",points:9}, {name:"8 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_8",points:8}, {name:"7 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_7",points:7}, {name:"6 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_6",points:6}, {name:"5 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_5",points:5}, {name:"4 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_4",points:4}, {name:"3 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_3",points:3}, {name:"2 of Spades",type:CARD_TYPE_NUMBER,emote:":monkey_card_2",points:2}]; var score_board={}; /*//View Greeter//*/ if (!initialised) { var rawEntryMessages = ''; var rawLeavingMessages = ''; var entryMessages = new Array; var leavingMessages = new Array; // Put the messages into handy arrays if (cb.settings.messagesOnEntry != '' && cb.settings.messagesOnEntry != null) { rawEntryMessages = cb.settings.messagesOnEntry; } else { rawEntryMessages = "Welcome <name>, how's it going?\\Hey there <name>.\\Hi <name>. Come in and chat.\\Come in and chat"; } entryMessages = rawEntryMessages.split('\\'); if (cb.settings.messagesOnLeaving != '' && cb.settings.messagesOnLeaving != null) { rawLeavingMessages = cb.settings.messagesOnLeaving; } else { rawLeavingMessages = "Bye <name>.\\Goodbye <name>, we'll miss you.\\See ya <name>, come back soon." } leavingMessages = rawLeavingMessages.split('\\'); var eCount = entryMessages.length; var lCount = leavingMessages.length; } var initialised = true; cb.onEnter(function(user) { rawMessage = entryMessages[Math.floor(Math.random() * eCount)]; niceMessage = rawMessage.replace(/<name>/gi, user['user']); if (niceMessage == rawMessage) { niceMessage += ' ' + user['user']; } cb.chatNotice(niceMessage); }); cb.onLeave(function(user) { rawMessage = leavingMessages[Math.floor(Math.random() * lCount)]; niceMessage = rawMessage.replace(/<name>/gi, user['user']); if (niceMessage == rawMessage) { niceMessage += ' ' + user['user']; } cb.chatNotice(niceMessage); }); /*/ Set-up the user-supplied parameters/*/ cb.settings_choices=[{name:"room_description",type:"str",minLength:1,maxLength:255,label:"Room Description:"}, {name: 'messagesOnEntry',type: 'str',minLength: 1,maxLength: 4096,label: "Messages on entry - separate with backslashes (\\)."}, {name: 'messagesOnLeaving', type: 'str',minLength: 1,maxLength: 4096,label: "Messages on leaving - separate with backslashes (\\)."}, {name:"game_of_jest",type:"choice",choice1:"yes",choice2:"no",defaultValue:"yes",label:"jest:"},{name:"cost_per_card",type:"int",minValue:1,defaultValue:10,label:"Tokens for drawing a card:"}, {name:"reward_king",type:"str",minLength:1,maxLength:255,label:"Reward for drawing a king:"}, {name:"reward_queen",type:"str",minLength:1,maxLength:255,label:"Reward for drawing a queen:"}, {name:"reward_jack",type:"str",minLength:1,maxLength:255,label:"Reward for drawing a jack:"}, {name:"points_for_reward",type:"int",minValue:1,defaultValue:40,label:"Points needed for reward:"}, {name:"reward_points",type:"str",minLength:1,maxLength:255,label:"Reward for collecting enough points:"}, {name:"joker",type:"choice",choice1:"yes",choice2:"no",defaultValue:"yes",label:"Joker sets players point to 0?"}]; cb.onTip(function(e){"use strict";if(recordTip(e)){var t=drawCard();evaluateCard(t,e.from_user);evaluateWinState(e.from_user)}}); cb.onMessage(function(e){"use strict";if(e.m==="/rewards"){printRewards(e.user)}if(e.m==="/scoreboard"){printScoreboard(e.user)}}); cb.onDrawPanel(function() {"use strict";return{template:"3_rows_of_labels",row1_label:ROUNDS,row1_value:round_number,row2_label:COST_PER_CARD,row2_value:cb.settings.cost_per_card+" Tokens",row3_label:LABEL_CARDS,row3_value:drawn_cards}}); init()
© Copyright Chaturbate 2011- 2025. All Rights Reserved.