Apps Home
|
Create an App
Inflated Tip Goal
Author:
lactose_intolerant
Description
Source Code
Launch App
Current Users
Created by:
Lactose_Intolerant
!function(){platform={};for(var r in cb)platform[r]=cb[r];var n,t=!!cb.cbUsers;platform.colors={fg:"#000000",bg:"#FFFFFF"},platform.users={};var e=function(){n=new platform.Events(["onMessage","onEnter","onLeave","onTip","onDrawPanel"]),cb.onMessage(l),cb.onDrawPanel(h),cb.onTip(p),t?platform.sendNotice=cb.chatNotice:(cb.onEnter(c),cb.onLeave(m))};platform.map=function(r,n){for(var t=[],e=0;e<r.length;++e)t.push(n(r[e]));return t},platform.fromCharCode=function(r){return r>65535?(r-=65536,String.fromCharCode(55296+(r>>10),56320+(1023&r))):String.fromCharCode(r)};var a=60,o=60*a,s=function(r){var n=0,t=0;return r>=o&&(n=Math.floor(r/o)),r-=n*o,r>=a&&(t=Math.floor(r/a)),r=Math.floor(r-t*a),{seconds:r,minutes:t,hours:n}};platform.createReadableDuration=function(r){parts=s(r);var n=[];return parts.hours>0&&n.push(parts.hours+":"),n.push(parts.minutes+":"),n.push(parts.seconds),n.join("")},platform.createReadableDuration2=function(r){parts=s(r);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(r){var n=/(?:(\d+)h)?\s*(?:(\d+)m)?\s*(?:(\d+)s)?/.exec(r);if(null===n)return null;if(!n[1]&&!n[2]&&!n[3])return null;var t=0;return n[1]&&(t+=parseInt(n[1])*o),n[2]&&(t+=parseInt(n[2])*a),n[3]&&(t+=parseInt(n[3])),t},platform.getTimeSinceEpochInSeconds=function(){return(new Date).valueOf()/1e3},platform.mergeObjects=function(r,n){var t={};for(var e in r)t[e]=r[e];for(e in n)t[e]=n[e];return t},platform.randomArrayItem=function(r){var n=Math.floor(Math.random()*r.length);return r[n]};var u=function(r){platform.users[r.user.toLowerCase()]=r},f=function(r){delete platform.users[r.toLowerCase()]};platform.isUserPresent=function(r){return r.toLowerCase()in platform.users},platform.getUserByName=function(r){return platform.users[r.toLowerCase()]},platform.onMessage=function(r){n.add("onMessage",r)},platform.onEnter=function(r){n.add("onEnter",r)},platform.onLeave=function(r){n.add("onLeave",r)},platform.onDrawPanel=function(r){n.add("onDrawPanel",r)},platform.onTip=function(r){n.add("onTip",r)},platform.fakeLeave=function(r){var n=r;"string"==typeof r&&(n=i(r)),m(n)},platform.fakeEnter=function(r){var n=r;"string"==typeof r&&(n=i(r)),c(n)},platform.setInterval=function(r,n){cb.setTimeout(function(){cb.setTimeout(arguments.callee,n);try{r()}catch(t){g("onTimeout",t)}},n)};var i=function(r){return{user:r,in_fanclub:!1,has_tokens:0,is_mod:!1,tipped_recently:!1,gender:"m"}},l=function(r){try{var t=platform.mergeObjects(r,{});delete t.c,delete t.m,delete t.f,d(t),n.raise("onMessage",r)}catch(e){g("onMessage",e)}return r},c=function(r){try{u(r),n.raise("onEnter",r)}catch(t){g("onEnter",t)}},m=function(r){try{f(r.user),n.raise("onLeave",r)}catch(t){g("onLeave",t)}},p=function(r){try{var t={user:r.from_user,in_fanclub:r.from_user_in_fanclub,has_tokens:r.from_user_has_tokens,is_mod:r.from_user_is_mod,tipped_recently:r.from_user_tipped_recently,gender:r.from_user_gender};d(t),n.raise("onTip",r)}catch(e){g("onTip",e)}},d=function(r){platform.isUserPresent(r.user)?u(r):platform.fakeEnter(r)},h=function(){try{return n.raise("onDrawPanel")}catch(r){g("onDrawPanel",r)}};platform.announce=function(r){platform.sendNotice(r,"",platform.colors.bg,platform.colors.fg,"bold")},platform.notify=function(r,n){platform.sendNotice(n,r,platform.colors.bg,platform.colors.fg,"bold")};var g=function(r,n){var t='<EXCEPTION>: "';t+="message"in n?n.message:n,t+='"',t+=" <EVENT>: "+r,"trace"in n&&(t+=" <TRACE>: "+n.stack),cb.log(t)};platform.Events=function(r){var n={},t=function(){for(var t=0;t<r.length;++t)n[r[t]]=[]};this.add=function(r,t){n[r].push(t)},this.raise=function(r){for(var t,e=Array.prototype.slice.call(arguments,1),a=0;a<n[r].length;++a)t=n[r][a].apply(null,e);return t},t()},platform.CommandParser=function(){var r=[],n=function(){platform.onMessage(t)};this.register=function(n,t,e){r.push({key:n,model:!!e,handler:t})};var t=function(r){var n=e(r.m),t=a(r.user,n);return t&&(r["X-Spam"]=!0,t.handler.apply(null,[r.user].concat(o(r.m)))),r},e=function(r){var n=/^\/(\S+)/.exec(r);return n?n[1]:void 0},a=function(n,t){for(var e=0;e<r.length;++e){var a=r[e];if(a.key==t&&(!a.model||n==platform.room_slug))return a}return null},o=function(r){var n=/^\/\S+\s+(.*)/.exec(r);return n?n[1].split(/\s+/):[]};n()},e()}();var main=function(){var r=128,n=25,t=60,e=n,a=0,o="",s=0,u=0,f={},i=function(){platform.colors.fg="#FF0000",platform.colors.bg="#FFA90A",E(),platform.onDrawPanel(y),platform.onEnter(b),platform.onLeave(M),platform.onTip(_),l(),e=n,a=0,platform.drawPanel()},l=function(){var r=new platform.CommandParser;r.register("setpop",p,!0),r.register("info",c,!0),r.register("goal",m,!0)},c=function(r){var n="Current inflation: "+h()+"\n"+"Current population: "+s;platform.notify(r,n)},m=function(r,a,s){return a=parseInt(a),isNaN(a)?(platform.notify(r,"Usage: /goal AMOUNT [message]"),void 0):(a>t&&(t=a),n>a&&(n=a),e=a,s&&(o=s),g(),platform.drawPanel(),void 0)},p=function(r,n){return n=parseInt(n),isNaN(n)?(platform.notify(r,"Usage: /setpop AMOUNT"),void 0):(s=n,d(),void 0)},d=function(){var r=a/e,o=h();e=Math.max(n,Math.min(t,Math.round(n+o*(t-n)))),a=Math.floor(e*r),platform.drawPanel()},h=function(){return Math.min(1,s/r)},g=function(){for(var r=!1;a>=e;)r=!0,v();r&&platform.drawPanel()},v=function(){++u,platform.announce("Goal reached! ("+P(u)+" time)"),a=Math.max(0,a-e)},_=function(r){var n=parseInt(r.amount);a+=n,r.from_user in f||(f[r.from_user]=0),f[r.from_user]+=n,g(),platform.drawPanel()},b=function(r){r.has_tokens&&(++s,d())},M=function(r){r.has_tokens&&(s=Math.max(0,s-1),d())},y=function(){return{template:"3_rows_12_21_31",row1_label:"Tips/Goal: ",row1_value:a+"/"+e,row2_value:o,row3_value:w()}},w=function(){return u>0?"Reached "+u+" times.":""},P=function(r){switch(r%10){default:return r+"th";case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}},E=function(){if(n=Math.max(1,platform.settings.minGoal),t=Math.max(1,platform.settings.maxGoal),n>t){var e=t;t=n,n=e}r=Math.max(1,platform.settings.maxPopulation),o=platform.settings.goalMessage};i()},initSettings=function(){cb.settings_choices=[{name:"goalMessage",label:"Goal message",type:"str",required:!1,defaultValue:"Do stuff at goal!"},{name:"minGoal",label:"Minimum Goal Amount",type:"int",required:!0,defaultValue:"25"},{name:"maxGoal",label:"Maximum Goal Amount",type:"int",required:!0,defaultValue:"75"},{name:"maxPopulation",label:"Max population",type:"int",required:!0,defaultValue:"128"}]};new function(){Object.keys(cb.settings).length>0?main():initSettings()};
© Copyright Freesexcam 2011- 2024. All Rights Reserved.