Apps Home
|
Create an App
War goal teste
Author:
maga
Description
Source Code
Launch App
Current Users
Created by:
Maga
!function(){platform={};for(var t in cb)platform[t]=cb[t];var e,r=!!cb.cbUsers;platform.colors={fg:"#000000",bg:"#FFFFFF"},platform.users={};var n=function(){e=new platform.Events(["onMessage","onEnter","onLeave","onTip","onDrawPanel"]),cb.onMessage(f),cb.onDrawPanel(g),cb.onTip(m),r?platform.sendNotice=cb.chatNotice:(cb.onEnter(c),cb.onLeave(p))};platform.map=function(t,e){for(var r=[],n=0;n<t.length;++n)r.push(e(t[n]));return r},platform.fromCharCode=function(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):String.fromCharCode(t)};var o=60,a=60*o,l=function(t){var e=0,r=0;return t>=a&&(e=Math.floor(t/a)),t-=e*a,t>=o&&(r=Math.floor(t/o)),t=Math.floor(t-r*o),{seconds:t,minutes:r,hours:e}};platform.createReadableDuration=function(t){parts=l(t);var e=[];return parts.hours>0&&e.push(parts.hours+":"),e.push(parts.minutes+":"),e.push(parts.seconds),e.join("")},platform.createReadableDuration2=function(t){parts=l(t);var e=[];return parts.hours>0&&e.push(parts.hours+" hours"),parts.minutes>0&&e.push(parts.minutes+" minutes"),(0===e.length||parts.seconds>0)&&e.push(parts.seconds+" seconds"),e.join(", ")},platform.parseDurationString=function(t){var e=/(?:(\d+)h)?\s*(?:(\d+)m)?\s*(?:(\d+)s)?/.exec(t);if(null===e)return null;if(!e[1]&&!e[2]&&!e[3])return null;var r=0;return e[1]&&(r+=parseInt(e[1])*a),e[2]&&(r+=parseInt(e[2])*o),e[3]&&(r+=parseInt(e[3])),r},platform.getTimeSinceEpochInSeconds=function(){return(new Date).valueOf()/1e3},platform.mergeObjects=function(t,e){var r={};for(var n in t)r[n]=t[n];for(n in e)r[n]=e[n];return r},platform.randomArrayItem=function(t){var e=Math.floor(Math.random()*t.length);return t[e]};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){e.add("onMessage",t)},platform.onEnter=function(t){e.add("onEnter",t)},platform.onLeave=function(t){e.add("onLeave",t)},platform.onDrawPanel=function(t){e.add("onDrawPanel",t)},platform.onTip=function(t){e.add("onTip",t)},platform.fakeLeave=function(t){var e=t;"string"==typeof t&&(e=u(t)),p(e)},platform.fakeEnter=function(t){var e=t;"string"==typeof t&&(e=u(t)),c(e)},platform.setInterval=function(t,e){cb.setTimeout(function(){cb.setTimeout(arguments.callee,e);try{t()}catch(r){v("onTimeout",r)}},e)};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 r=platform.mergeObjects(t,{});delete r.c,delete r.m,delete r.f,d(r),e.raise("onMessage",t)}catch(n){v("onMessage",n)}return t},c=function(t){try{s(t),e.raise("onEnter",t)}catch(r){v("onEnter",r)}},p=function(t){try{i(t.user),e.raise("onLeave",t)}catch(r){v("onLeave",r)}},m=function(t){try{var r={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(r),e.raise("onTip",t)}catch(n){v("onTip",n)}},d=function(t){platform.isUserPresent(t.user)?s(t):platform.fakeEnter(t)},g=function(){try{return e.raise("onDrawPanel")}catch(t){v("onDrawPanel",t)}};platform.announce=function(t){platform.sendNotice(t,"",platform.colors.bg,platform.colors.fg,"bold")},platform.notify=function(t,e){platform.sendNotice(e,t,platform.colors.bg,platform.colors.fg,"bold")};var v=function(t,e){var r='<EXCEPTION>: "';r+="message"in e?e.message:e,r+='"',r+=" <EVENT>: "+t,"trace"in e&&(r+=" <TRACE>: "+e.stack),cb.log(r)};platform.Events=function(t){var e={},r=function(){for(var r=0;r<t.length;++r)e[t[r]]=[]};this.add=function(t,r){e[t].push(r)},this.raise=function(t){for(var r,n=Array.prototype.slice.call(arguments,1),o=0;o<e[t].length;++o)r=e[t][o].apply(null,n);return r},r()},platform.CommandParser=function(){var t=[],e=function(){platform.onMessage(r)};this.register=function(e,r,n){t.push({key:e,model:!!n,handler:r})};var r=function(t){var e=n(t.m),r=o(t.user,e);return r&&(t["X-Spam"]=!0,r.handler.apply(null,[t.user].concat(a(t.m)))),t},n=function(t){var e=/^\/(\S+)/.exec(t);return e?e[1]:void 0},o=function(e,r){for(var n=0;n<t.length;++n){var o=t[n];if(o.key==r&&(!o.model||e==platform.room_slug))return o}return null},a=function(t){var e=/^\/\S+\s+(.*)/.exec(t);return e?e[1].split(/\s+/):[]};e()},n()}();var Goal=function(t){this.description="",this.received=0,this.amount=0,this.ballot="",t&&(this.description=t)},main=function(){var t,e=[new Goal,new Goal],r=-1,n={},o=function(){platform.colors.fg="#6D5D2F",platform.colors.bg="#00FF52",l(),platform.onDrawPanel(w),platform.onEnter(u),platform.onLeave(f),platform.onTip(d),platform.tipOptions(m),platform.onMessage(c),a(),platform.drawPanel(),s()},a=function(){var t=new platform.CommandParser;t.register("reset",i,!0)},l=function(){e[0].description=platform.settings.goalDescription0,e[1].description=platform.settings.goalDescription1,e[0].amount=platform.settings.goalAmount0,e[1].amount=platform.settings.goalAmount1,e[0].ballot=platform.settings.goalBallot0,e[1].ballot=platform.settings.goalBallot1},s=function(t){var r="We're having a goal war. Vote with tokens towards which goal you want to happen!\nTip \""+e[0].ballot+'" for: '+e[0].description+"\n"+'Tip "'+e[1].ballot+'" for: '+e[1].description;t?platform.notify(t,r):platform.announce(r)},i=function(){r=-1;for(var t=0;t<e.length;++t)e[t].received=0;platform.announce("Goals reset."),platform.drawPanel(),s()},u=function(t){s(t.user),p(t.user)},f=function(t){p(t.user)},c=function(e){return t&&t==e.user&&(e.c="#000000",e.background="#E0E0FF"),e},p=function(e){if(e in n){t=null;for(var r in n)platform.isUserPresent(r)&&(t?n[t]<n[r]&&(t=r):t=r)}},m=function(){return _()?void 0:{options:[{label:e[0].ballot},{label:e[1].ballot}],label:"Choose a ballot:"}},d=function(t){var e=parseInt(t.amount),r=v(t.message);-1!=r&&h(r,e),g(t.from_user,e)},g=function(t,e){t in n?n[t]+=e:n[t]=0,p(t)},v=function(t){t=t.toLowerCase();for(var r=0;r<e.length;++r)if(e[r].ballot.toLowerCase()==t)return r;return-1},h=function(t,r){var n=e[t];n.received+=r,!_()&&n.received>=n.amount&&b(t),platform.drawPanel()},b=function(t){var n=e[t];r=t,platform.announce("We have a winner! [[ "+n.ballot+": "+n.description+" ]]")},_=function(){return-1!=r},w=function(){return _()?E():y()},y=function(){return{template:"3_rows_12_22_31",row1_label:e[0].ballot+":",row1_value:e[0].received+"/"+e[0].amount,row2_label:e[1].ballot+":",row2_value:e[1].received+"/"+e[1].amount,row3_value:"Vote for your goal!"}},E=function(){var t=e[r];return{template:"3_rows_12_21_31",row1_label:"Winner:",row1_value:t.ballot,row2_value:t.description,row3_value:""}};o()},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:"1000"},{name:"goalAmount1",label:"Second goal amount",type:"int",required:!0,defaultValue:"1000"}]};new function(){Object.keys(cb.settings).length>0?main():initSettings()};
© Copyright Chaturbate 2011- 2024. All Rights Reserved.