Apps Home
|
Create an App
Bianca's Tip War
Author:
lactose_intolerant
Description
Source Code
Launch App
Current Users
Created by:
Lactose_Intolerant
!function(){platform={};for(var t in cb)platform[t]=cb[t];var n,e=!!cb.cbUsers;platform.colors={fg:"#000000",bg:"#FFFFFF"},platform.users={};var o=function(){n=new platform.Events(["onMessage","onEnter","onLeave","onTip","onDrawPanel"]),cb.onMessage(f),cb.onDrawPanel(g),cb.onTip(m),e?platform.sendNotice=cb.chatNotice:(cb.onEnter(c),cb.onLeave(p))};platform.map=function(t,n){for(var e=[],o=0;o<t.length;++o)e.push(n(t[o]));return e},platform.fromCharCode=function(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):String.fromCharCode(t)};var r=60,a=60*r,l=function(t){var n=0,e=0;return t>=a&&(n=Math.floor(t/a)),t-=n*a,t>=r&&(e=Math.floor(t/r)),t=Math.floor(t-e*r),{seconds:t,minutes:e,hours:n}};platform.createReadableDuration=function(t){parts=l(t);var n=[];return parts.hours>0&&n.push(parts.hours+":"),n.push(parts.minutes+":"),n.push(parts.seconds),n.join("")},platform.createReadableDuration2=function(t){parts=l(t);var n=[];return parts.hours>0&&n.push(parts.hours+" hours"),parts.minutes>0&&n.push(parts.minutes+" minutes"),(0===n.length||parts.seconds>0)&&n.push(parts.seconds+" seconds"),n.join(", ")},platform.parseDurationString=function(t){var n=/(?:(\d+)h)?\s*(?:(\d+)m)?\s*(?:(\d+)s)?/.exec(t);if(null===n)return null;if(!n[1]&&!n[2]&&!n[3])return null;var e=0;return n[1]&&(e+=parseInt(n[1])*a),n[2]&&(e+=parseInt(n[2])*r),n[3]&&(e+=parseInt(n[3])),e},platform.getTimeSinceEpochInSeconds=function(){return(new Date).valueOf()/1e3},platform.mergeObjects=function(t,n){var e={};for(var o in t)e[o]=t[o];for(o in n)e[o]=n[o];return e},platform.randomArrayItem=function(t){var n=Math.floor(Math.random()*t.length);return t[n]};var s=function(t){platform.users[t.user.toLowerCase()]=t},i=function(t){delete platform.users[t.toLowerCase()]};platform.isUserPresent=function(t){return t.toLowerCase()in platform.users},platform.getUserByName=function(t){return platform.users[t.toLowerCase()]},platform.onMessage=function(t){n.add("onMessage",t)},platform.onEnter=function(t){n.add("onEnter",t)},platform.onLeave=function(t){n.add("onLeave",t)},platform.onDrawPanel=function(t){n.add("onDrawPanel",t)},platform.onTip=function(t){n.add("onTip",t)},platform.fakeLeave=function(t){var n=t;"string"==typeof t&&(n=u(t)),p(n)},platform.fakeEnter=function(t){var n=t;"string"==typeof t&&(n=u(t)),c(n)},platform.setInterval=function(t,n){cb.setTimeout(function(){cb.setTimeout(arguments.callee,n);try{t()}catch(e){h("onTimeout",e)}},n)};var u=function(t){return{user:t,in_fanclub:!1,has_tokens:0,is_mod:!1,tipped_recently:!1,gender:"m"}},f=function(t){try{var e=platform.mergeObjects(t,{});delete e.c,delete e.m,delete e.f,d(e),n.raise("onMessage",t)}catch(o){h("onMessage",o)}return t},c=function(t){try{s(t),n.raise("onEnter",t)}catch(e){h("onEnter",e)}},p=function(t){try{i(t.user),n.raise("onLeave",t)}catch(e){h("onLeave",e)}},m=function(t){try{var e={user:t.from_user,in_fanclub:t.from_user_in_fanclub,has_tokens:t.from_user_has_tokens,is_mod:t.from_user_is_mod,tipped_recently:t.from_user_tipped_recently,gender:t.from_user_gender};d(e),n.raise("onTip",t)}catch(o){h("onTip",o)}},d=function(t){platform.isUserPresent(t.user)?s(t):platform.fakeEnter(t)},g=function(){try{return n.raise("onDrawPanel")}catch(t){h("onDrawPanel",t)}};platform.announce=function(t){platform.sendNotice(t,"",platform.colors.bg,platform.colors.fg,"bold")},platform.notify=function(t,n){platform.sendNotice(n,t,platform.colors.bg,platform.colors.fg,"bold")};var h=function(t,n){var e='<EXCEPTION>: "';e+="message"in n?n.message:n,e+='"',e+=" <EVENT>: "+t,"trace"in n&&(e+=" <TRACE>: "+n.stack),cb.log(e)};platform.Events=function(t){var n={},e=function(){for(var e=0;e<t.length;++e)n[t[e]]=[]};this.add=function(t,e){n[t].push(e)},this.raise=function(t){for(var e,o=Array.prototype.slice.call(arguments,1),r=0;r<n[t].length;++r)e=n[t][r].apply(null,o);return e},e()},platform.CommandParser=function(){var t=[],n=function(){platform.onMessage(e)};this.register=function(n,e,o){t.push({key:n,model:!!o,handler:e})};var e=function(t){var n=o(t.m),e=r(t.user,n);return e&&(t["X-Spam"]=!0,e.handler.apply(null,[t.user].concat(a(t.m)))),t},o=function(t){var n=/^\/(\S+)/.exec(t);return n?n[1]:void 0},r=function(n,e){for(var o=0;o<t.length;++o){var r=t[o];if(r.key==e&&(!r.model||n==platform.room_slug))return r}return null},a=function(t){var n=/^\/\S+\s+(.*)/.exec(t);return n?n[1].split(/\s+/):[]};n()},o()}();var Goal=function(t){this.description="",this.amount=0,this.ballot="",t&&(this.description=t)},main=function(){var t,n=[new Goal,new Goal],e=[0,0],o={},r=!1,a=function(){platform.colors.fg="#6D5D2F",platform.colors.bg="#00FF52",i(),platform.onDrawPanel(y),platform.onEnter(f),platform.onLeave(c),platform.onTip(g),platform.tipOptions(d),platform.onMessage(p),l(),platform.drawPanel(),u()},l=function(){var t=new platform.CommandParser;t.register("stats",s,!0)},s=function(t){platform.notify(t,"Ballot: initial tips + tips received = ending tips");for(var o=0;o<n.length;++o)platform.notify(t,n[o].ballot+": "+e[o]+" + "+(n[o].amount-e[o])+" = "+n[o].amount)},i=function(){n[0].description=platform.settings.goalDescription0,n[1].description=platform.settings.goalDescription1,n[0].amount=e[0]=platform.settings.goalAmount0,n[1].amount=e[1]=platform.settings.goalAmount1,n[0].ballot=platform.settings.goalBallot0,n[1].ballot=platform.settings.goalBallot1,r="yes"==platform.settings.restrictTipOptions},u=function(t){var e="We're having a tip war. Whichever has more tips at the end wins.\nTip \""+n[0].ballot+'" for: '+n[0].description+"\n"+'Tip "'+n[1].ballot+'" for: '+n[1].description;t?platform.notify(t,e):platform.announce(e)},f=function(t){u(t.user),m(t.user)},c=function(t){m(t.user)},p=function(n){return t&&t==n.user&&(n.c="#000000",n.background="#E0E0FF"),n},m=function(n){if(n in o){t=null;for(var e in o)platform.isUserPresent(e)&&(t?o[t]<o[e]&&(t=e):t=e)}},d=function(){return r?{options:[{label:n[0].ballot},{label:n[1].ballot}],label:"Choose a ballot:"}:void 0},g=function(t){var n=parseInt(t.amount),e=v(t.message);-1!=e&&b(e,n),h(t.from_user,n)},h=function(t,n){t in o?o[t]+=n:o[t]=0,m(t)},v=function(t){t=t.toLowerCase();for(var e=0;e<n.length;++e)if(n[e].ballot.toLowerCase()==t)return e;return-1},b=function(t,e){var o=n[t];o.amount+=e,platform.drawPanel()},y=function(){return _()},_=function(){return{template:"3_rows_12_22_31",row1_label:n[0].ballot+":",row1_value:n[0].amount,row2_label:n[1].ballot+":",row2_value:n[1].amount,row3_value:"Cast your vote!"}};a()},initSettings=function(){cb.settings_choices=[{name:"goalBallot0",label:"First goal ballot",type:"str",required:!0,defaultValue:"FOOT"},{name:"goalBallot1",label:"Second goal ballot",type:"str",required:!0,defaultValue:"CAT"},{name:"goalDescription0",label:"First goal description",type:"str",required:!0,defaultValue:"I eat my foot."},{name:"goalDescription1",label:"Second goal description",type:"str",required:!0,defaultValue:"I eat my cat."},{name:"goalAmount0",label:"First goal amount",type:"int",required:!0,defaultValue:"0"},{name:"goalAmount1",label:"Second goal amount",type:"int",required:!0,defaultValue:"0"},{name:"restrictTipOptions",label:"Restrict tip options to ballot names.",type:"choice",choice1:"yes",choice2:"no",defaultValue:"yes"}]};new function(){Object.keys(cb.settings).length>0?main():initSettings()};
© Copyright Freesexcam 2011- 2024. All Rights Reserved.