Apps Home
|
Create an App
king_beta
Author:
sub_account
Description
Source Code
Launch App
Current Users
Created by:
Sub_Account
var royals = { peasant: { min: 1, color: "#d2cb7a", title: "Peasant", welcome: "it is better than nothing...", icon: ":peasanticon", bgColor: "#FFFFFF" }, servant: { min: 10, color: "#ff69b4", title: "Servant", welcome: "now do as you are told!", icon: ":servanticon", bgColor: "#FFFFFF" }, jester: { min: 20, color: "#00e170", title: "Royal Jester", welcome: "make me laugh!", icon: ":jestericon", bgColor: "#FFFFFF" }, baron: { min: 30, color: "#ffffe5", title: "Baron", welcome: "manage your new land well.", icon: ":baronicon", bgColor: "#854442" }, knight: { min: 40, color: "#2EAFC3", title: "Knight", welcome: "prepare to fight for your king!", icon: ":knighticon", bgColor: "#e5e5e5" }, duke: { min: 50, color: "#e5e500", title: "Duke", welcome: "enjoy your growing domain.", icon: ":dukeicon", bgColor: "#191b6b" }, vassal: { min: 60, color: "#a7c1b7", title: "Vassal", welcome: "you can now visit the royal court", icon: ":vassalicon", bgColor: "#b92a62" }, priest: { min: 80, color: "#800080", title: "High Priest", welcome: "pray for your king!", icon: ":priesticon", bgColor: "#d9b4d9" }, lord: { min: 100, color: "#cc0000", title: "Lord", welcome: "council your king with your best advice.", icon: ":lordicon", bgColor: "#b3ffff" } }; var specials = { randomlines: { type: 'wizard', color: "#8a2be2", title: "Wizard", welcome: "the hidden tower awaits!", icon: ":wizardicon", wizard: true } }; var sorted = Object.keys(royals).map(function (royal) { return { min: royals[royal].min, type: royal }; }).sort(function (a, b) { return b.min - a.min }); var tippers = {}; var kingdom = {}; var bestow = function (user) { if (specials[user]) { return; } if (!tippers[user].tips) { if (tippers[user].type) { delete kingdom[tippers[user].type][user]; } tippers[user].type = null; return; } for (var i = 0; i < sorted.length; ++i) { var level = sorted[i]; if (tippers[user].tips >= level.min) { if (tippers[user].type !== level.type) { kingdom[level.type] = kingdom[level.type] || {}; kingdom[level.type][user] = true; if (tippers[user].type) { delete kingdom[tippers[user].type][user]; } tippers[user].type = level.type; var props = royals[level.type]; cb.sendNotice("Welcome " + user + " The " + props.title + " to your new title, " + props.welcome + "\nYou have unlocked special gifs, simply type ':king" + level.type + "1-4'", user, '#ffffff', props.color); } return; } } }; var details = function (user) { cb.sendNotice('------ Behold, our glorious kingdom...', user); for (var i = 0; i < sorted.length; ++i) { var level = sorted[i]; var props = royals[level.type]; var peeps = kingdom[level.type]; if (peeps) { cb.sendNotice(props.icon + ' ' + props.title + 's: ' + Object.keys(peeps).join(', '), user, '#ffffff', props.color); } } }; cb.onEnter(function (user) { cb.sendNotice('Hello traveler, your king wants to invite you to his kingdom and give you the chance to rise to power. The amount you tip determines your rank in the kingdom, the choice is yours.', user.user, '#ffffff', '#ff0000'); }); cb.onTip(function (tip) { tippers[tip.from_user] = tippers[tip.from_user] || { tips: 0 }; tippers[tip.from_user].tips += parseInt(tip.amount); bestow(tip.from_user); }); var masterKeyReg = /^\~([^\:]+)\,(\+)?(\d+)$/; var gifReg = /\:((?:king(peasant|servant|jester|baron|knight|duke|vassal|priest|lord)\d+)|(?:(peasant|servant|jester|baron|knight|duke|vassal|priest|lord)icon))/g; cb.onMessage(function (message) { if (message.m === '/kingdom') { details(message.user); message['X-Spam'] = true; return message; } if (message.user == "__theking__") { var parts = message.m.match(masterKeyReg); if (parts) { var user = parts[1]; var relative = !!parts[2]; var amount = parseInt(parts[3]); tippers[user] = tippers[user] || { tips: 0 }; tippers[user].tips = (relative ? tippers[user].tips : 0) + amount; bestow(user); } } var royal = (specials[message.user] ? { type: specials[message.user].type } : tippers[message.user]); if (!specials[message.user] || !specials[message.user].super) { message.m = message.m.replace(gifReg, function ($0, gif, type1, type2) { var type = type1 || type2; if (!royal || royal.type !== type) { return ""; } return ":" + gif; }); } if (royal) { var props = (specials[message.user] ? specials[message.user] : royals[royal.type]); message.background = props.bgColor; message.c = props.color; message.m = " The " + props.title + " " + props.icon + " : " + message.m; } return message; });
© Copyright Chaturbate 2011- 2025. All Rights Reserved.