Apps Home
|
Create an App
testgrghsebearg
Author:
kittycats
Description
Source Code
Launch App
Current Users
Created by:
Kittycats
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 evaluateAce(e,t){"use strict";if(cb.settings.evil_ace==="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 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 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_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 "+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.evil_ace==="yes"){e+="But be aware of the evil ace. 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_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="--== Monkey 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:"Ace of Clubs",type:CARD_TYPE_ACE,emote:":monkey_card_ace",points:0},{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:0},{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:0},{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:0},{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={};cb.settings_choices=[{name:"room_description",type:"str",minLength:1,maxLength:255,label:"Room Description:"},{name:"Cost_to_Play",type:"int",minValue:1,defaultValue:20,label:"Tokens to Play:"},{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:"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:"evil_ace",type:"choice",choice1:"yes",choice2:"no",defaultValue:"yes",label:"Evil Ace 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.