Bots Home
|
Create an App
Yahtzee
Author:
erik91383
Description
Source Code
Launch Bot
Current Users
Created by:
Erik91383
var rolledDice = [],savedDice = [] var rolls = 0 var scorecard = [{value:'aces',score:false},{value:'twos',score:false},{value:'threes',score:false},{value:'fours',score:false},{value:'fives',score:false},{value:'sixes',score:false},{value:'bonus',score:0},{value:'upperTotal',score:0},{value:'threeOfKind',score:false},{value:'fourOfKind',score:false},{value:'fullHouse',score:false},{value:'smStraight',score:false},{value:'lgStraight',score:false},{value:'yahtzee',score:false},{value:'chance',score:false},{value:'yahtzeeBonus',score:0},{value:'lowerTotal',score:0},{value:'grandTotal',score:0},] //var scorecard = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] var aces,twos,threes,fours,fives,sixes,bonus,threeOfKind,fourOfKind,fullHouse,smStraight,lgStraight,yahtzee,chance,yahtzeeBonus,upperTotal,lowerTotal,grandTotal cb.onMessage(function(msg){ if((msg['m'].substring(0,1)=='/')){ msg['X-Spam'] = true var words = msg['m'].split(" ") if(words[0].toLowerCase()=='/keep'){ var saved = '' if(words[1].toLowerCase()=='all'){ for(var i=0;i<rolledDice.length;i++){ savedDice.push(rolledDice[i]) } for(var i=0;i<savedDice.length;i++){ saved += ':reddie'+savedDice[i]+" " } } else{ for(var i=1;i<words.length;i++){ savedDice.push(parseInt(rolledDice[words[i]-1])) } for(var i=0;i<savedDice.length;i++){ saved += ':reddie'+savedDice[i]+" " } } cb.setTimeout(function(){cb.chatNotice("You kept: "+saved)},1000) cb.setTimeout(rollDice,1025) } else if(words[0].toLowerCase()=='/roll'){rollDice()} else if(words[0].toLowerCase()=='/pass'){rollDice()} else if(words[0].toLowerCase()=='/aces'){updateScore('aces',1)} else if(words[0].toLowerCase()=='/twos'){updateScore('twos',2)} else if(words[0].toLowerCase()=='/threes'){updateScore('threes',3)} else if(words[0].toLowerCase()=='/fours'){updateScore('fours',4)} else if(words[0].toLowerCase()=='/fives'){updateScore('fives',5)} else if(words[0].toLowerCase()=='/sixes'){updateScore('sixes',6)} else if(words[0].toLowerCase()=='/3kind'){} else if(words[0].toLowerCase()=='/4kind'){} else if(words[0].toLowerCase()=='/full'){} else if(words[0].toLowerCase()=='/small'){} else if(words[0].toLowerCase()=='/large'){} else if(words[0].toLowerCase()=='/yahtzee'){} else if(words[0].toLowerCase()=='/chance'){} } }); function rollDice(){ rolls++ rolledDice = [] var msg='' for(var i=0;i<(5-savedDice.length);i++){ rolledDice.push((Math.floor(Math.random()*6))+1) } for(var i=0;i<rolledDice.length;i++){ msg += ':reddie'+rolledDice[i]+" " } cb.chatNotice("Rolling the "+(rolledDice.length==1?"die!":"dice!"),'','','','bold') if(rolls<3){ cb.setTimeout(function(){cb.chatNotice(msg)},1100) } else{ saved='' for(var i=0;i<rolledDice.length;i++){ savedDice.push(rolledDice[i]) } for(var i=0;i<savedDice.length;i++){ saved += ':reddie'+savedDice[i]+" " } cb.setTimeout(function(){cb.chatNotice("Save your score to which category?\n"+saved)},1100) } }; function updateScore(position,value){ for(var i=0;i<scorecard.length;i++){ if(scorecard[i].value==position && scorecard[i].score==false){ scorecard[i].score=0 for(var j=0;j<savedDice.length;j++){ if(savedDice[j]==value){ scorecard[i].score+=value if(i<7){scorecard[7].score+=value} else{scorecard[16].score+=value} scorecard[17].score+=value } } savedDice = [] createScore() showScorecard() } else if(scorecard[i].value==position && scorecard[i].score==true){ cb.chatNotice("You have already used this category. Please choose another.",'','','','bold') } } }; function createScore(){ aces=(scorecard[0].score=='x'?'xx':(scorecard[0].score>0?(scorecard[0].score<10?"\u2007"+scorecard[0].score:scorecard[0].score):'\u2003')) twos=(scorecard[1].score=='x'?'xx':(scorecard[1].score>0?(scorecard[1].score<10?"\u2007"+scorecard[1].score:scorecard[1].score):'\u2003')) threes=(scorecard[2].score=='x'?'xx':(scorecard[2].score>0?(scorecard[2].score<10?"\u2007"+scorecard[2].score:scorecard[2].score):'\u2003')) fours=(scorecard[3].score=='x'?'xx':(scorecard[3].score>0?(scorecard[3].score<10?"\u2007"+scorecard[3].score:scorecard[3].score):'\u2003')) fives=(scorecard[4].score=='x'?'xx':(scorecard[4].score>0?(scorecard[4].score<10?"\u2007"+scorecard[4].score:scorecard[4].score):'\u2003')) sixes=(scorecard[5].score=='x'?'xx':(scorecard[5].score>0?(scorecard[5].score<10?"\u2007"+scorecard[5].score:scorecard[5].score):'\u2003')) bonus=(scorecard[6].score=='x'?'xx':(scorecard[6].score>0?(scorecard[6].score<10?"\u2007"+scorecard[6].score:scorecard[6].score):'\u2003')) upperTotal = scorecard[7].score=='x'?'xx':scorecard[7].score>0?scorecard[7].score<10?"\u2007\u2007"+scorecard[7].score:scorecard[7].score>=100?scorecard[7].score:'\u2007'+scorecard[7].score:'\u2007\u2003' //grandTotal=(scorecard[7].score=='x'?'xx':(scorecard[7].score>0?(scorecard[7].score<10?"\u2007"+scorecard[7].score:scorecard[7].score>=100?scorecard[7].score:'\u2007'+scorecard[7].score):'\u2007\u2003')) threeOfKind=(scorecard[8].score=='x'?'xx':(scorecard[8].score>0?(scorecard[8].score<10?"\u2007"+scorecard[8].score:scorecard[8].score):'\u2003')) fourOfKind=(scorecard[9].score=='x'?'xx':(scorecard[9].score>0?(scorecard[9].score<10?"\u2007"+scorecard[9].score:scorecard[9].score):'\u2003')) fullHouse=(scorecard[10].score=='x'?'xx':(scorecard[10].score>0?(scorecard[10].score<10?"\u2007"+scorecard[10].score:scorecard[10].score):'\u2003')) smStraight=(scorecard[11].score=='x'?'xx':(scorecard[11].score>0?(scorecard[11].score<10?"\u2007"+scorecard[11].score:scorecard[11].score):'\u2003')) lgStraight=(scorecard[12].score=='x'?'xx':(scorecard[12].score>0?(scorecard[12].score<10?"\u2007"+scorecard[12].score:scorecard[12].score):'\u2003')) yahtzee=(scorecard[13].score=='x'?'xx':(scorecard[13].score>0?(scorecard[13].score<10?"\u2007"+scorecard[13].score:scorecard[13].score):'\u2003')) chance=(scorecard[14].score=='x'?'xx':(scorecard[14].score>0?(scorecard[14].score<10?"\u2007"+scorecard[14].score:scorecard[14].score):'\u2003')) yahtzeeBonus=(scorecard[15].score=='x'?'xx':(scorecard[15].score>0?(scorecard[15].score<10?"\u2007"+scorecard[15].score:scorecard[15].score>=100?scorecard[15].score:'\u2007'+scorecard[15].score):'\u2007\u2003')) lowerTotal=(scorecard[16].score=='x'?'xx':(scorecard[16].score>0?(scorecard[16].score<10?"\u2007"+scorecard[16].score:scorecard[16].score>=100?scorecard[16].score:'\u2007'+scorecard[16].score):'\u2007\u2003')) grandTotal=(scorecard[17].score=='x'?'xx':(scorecard[17].score>0?(scorecard[17].score<10?"\u2007"+scorecard[17].score:scorecard[17].score>=100?scorecard[17].score:'\u2007'+scorecard[17].score):'\u2007\u2003')) }; function showScorecard(){ cb.chatNotice("\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\u005F\n"+ "|\u2007Aces\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u2007\u2007\u00A0\u00A0|\u2007\u2007"+aces+"\u2007\u00A0|\u20074 of a kind\u2003\u2003\u2007\u2007\u2007\u2006|\u2007\u2007"+fourOfKind+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Twos\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u2007\u2007\u00A0|\u2007\u2007"+twos+"\u2007\u00A0|\u2007Full House\u2003\u2003\u2007\u2007\u2007\u2006|\u2007\u2007"+fullHouse+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Threes\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u00A0\u00A0\u2006|\u2007\u2007"+threes+"\u2007\u00A0|\u2007Sm Straight\u2003\u2003\u2007\u2007\u2006|\u2007\u2007"+smStraight+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Fours\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u2007\u00A0\u00A0\u2006|\u2007\u2007"+fours+"\u2007\u00A0|\u2007Lg Straight\u2003\u2003\u2003\u2007|\u2007\u2007"+lgStraight+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Fives\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u2007\u00A0\u00A0\u00A0|\u2007\u2007"+fives+"\u2007\u00A0|\u2007YAHTZEE\u2003\u2003\u2007\u2007\u2007\u2007\u2006|\u2007\u2007"+yahtzee+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Sixes\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u2007\u00A0\u00A0\u00A0|\u2007\u2007"+sixes+"\u2007\u00A0|\u2007Chance\u2003\u2003\u2003\u2003\u2003\u2006|\u2007\u2007"+chance+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Bonus\u2003\u2003\u2007\u2007\u2007\u2007\u2007\u2007\u00A0\u2006|\u2007\u2007"+bonus+"\u2007\u00A0|\u2007YAHTZEE Bonus\u2003\u00A0|\u2007"+yahtzeeBonus+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u2007Upper Total\u2003\u2003\u2007\u2007\u2006|\u2007"+upperTotal+"\u2007\u00A0|\u2007Lower Total\u2003\u2003\u2007\u2007\u2006|\u2007"+lowerTotal+"\u2007\u00A0|\n"+ "|\u2E3B\u2E3B\u2E3B|\u2E3B|\u2E3B\u2E3B\u2E3B|\u2E3B|\n"+ "|\u20073 of a kind\u2003\u2003\u2007\u2007\u2007\u2006|\u2007\u2007"+threeOfKind+"\u2007\u00A0|\u2007Grand Total\u2003\u2003\u2007\u2007\u2006|\u2007"+grandTotal+"\u2007\u00A0|\n"+ "\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF\u00AF" ) }; function init(){ //createScore() //showScorecard() //rollDice() //cb.chatNotice(scorecard[0]) }; init()
© Copyright Chaturbate 2011- 2024. All Rights Reserved.