Tina Games
Author: amy_nancy
Description Source Code Launch App Current Users

Short Description:

Tina Games

Full Description

/**
* App: Wheel of Fortune! by sexy_tinaa
* Based on zingknaat's Roll The Dice
* Version: 0.3.1
* Author: sexy_tinaa
* Date: 2019-08-22
*/

cb.settings_choices = [
{
name: 'roomSubj',
type: 'str',
default: '#asian #selfsuck #mistress #latina #anal #ftm #bigboobs #sissy #bigcock #ebony #18 #bbw #pantyhose #german #milk #hairy #feet #french #mature #bdsm #dirty #milf #c2c #new #lovense #lush #domi #office!',
label: '01. Set room title ("-" for do not set)',
},
{
name: 'tokens',
type: 'int',
minValue: 1,
maxValue: 100,
label: '02. Price per spin',
defaultValue: 50
},
{
name: 'skip_prizes',
type: 'int',
minValue: 0,
maxValue: 99,
label: '03. Avoids to repeat last X prizes for more randomness',
defaultValue: 10
},
{name: 'prize_1', type: 'str', default: 'Show pussy', label: '04. Prize for #1 ("-" for nothing)'},
{name: 'prize_2', type: 'str', default: 'Topless for 2 minutes', label: 'Prize for #2 ("-" for nothing)'},
{name: 'prize_3', type: 'str', default: 'Spank my ass', label: 'Prize for #3 ("-" for nothing)'},
{name: 'prize_4', type: 'str', default: 'Air kiss for you!', label: 'Prize for #4 ("-" for nothing)'},
{name: 'prize_5', type: 'str', default: 'Play with nipples', label: 'Prize for #5 ("-" for nothing)'},
{name: 'prize_6', type: 'str', default: 'Dance', label: 'Prize for #6 ("-" for nothing)'},
{name: 'prize_7', type: 'str', default: 'Flash my tits', label: 'Prize for #7 ("-" for nothing)'},
{name: 'prize_8', type: 'str', default: 'Doggy pose with panties', label: 'Prize for #8 ("-" for nothing)'},
{name: 'prize_9', type: 'str', default: 'Smile for you!', label: 'Prize for #9 ("-" for nothing)'},
{name: 'prize_10', type: 'str', default: 'Suck my finger', label: 'Prize for #10 ("-" for nothing)'},
{name: 'prize_11', type: 'str', default: 'Flash my ass', label: 'Prize for #11 ("-" for nothing)'},
{name: 'prize_12', type: 'str', default: 'Show feet', label: 'Prize for #12 ("-" for nothing)'},
{name: 'prize_13', type: 'str', default: 'Striptease', label: 'Prize for #13 ("-" for nothing)'},
{name: 'prize_14', type: 'str', default: 'Stroke the kitty', label: 'Prize for #14 ("-" for nothing)'},
{name: 'prize_15', type: 'str', default: '-', label: 'Prize for #15 ("-" for nothing)'},
{name: 'prize_16', type: 'str', default: '-', label: 'Prize for #16 ("-" for nothing)'},
{name: 'prize_17', type: 'str', default: '-', label: 'Prize for #17 ("-" for nothing)'},
{name: 'prize_18', type: 'str', default: '-', label: 'Prize for #18 ("-" for nothing)'},
{
name: 'notice_wait_time',
type: 'choice',
label: '05. Show app advertisement every X minutes',
choice1: 3,
choice2: 5,
choice3: 7,
choice4: 10,
choice5: 15,
choice6: 20,
choice7: 30,
defaultValue: 15
},
{
name: 'notice2_wait_time',
type: 'choice',
label: '06. Show notice every X minutes',
choice1: 1,
choice2: 2,
choice3: 3,
choice4: 4,
choice5: 5,
choice6: 7,
choice7: 10,
choice8: 15,
defaultValue: 3
},
{
name: 'use_predefined_messages',
type: 'choice',
label: '07. Use predefined notices (No - own notices from below)',
choice1: "Yes",
choice2: "No",
defaultValue: "No"
},
{ name: 'advertise1', type: 'str', default: ':kb-spin100', label: '08. Notice #1 ("-" for nothing)' },
{ name: 'advertise2', type: 'str', default: 'Wanna see a hot naked dance? Tip 666 tokens for STRIPTEASE!', label: 'Notice #2 ("-" for nothing)' },
{ name: 'advertise3', type: 'str', default: ':prizesdis Tip 100 tokens to spin the wheel and reveal a prize!', label: 'Notice #3 ("-" for nothing)' },
{ name: 'advertise4', type: 'str', default: 'Wanna play with me?', label: 'Notice #4 ("-" for nothing)' },
{ name: 'advertise5', type: 'str', default: ':kb-spin100', label: 'Notice #5 ("-" for nothing)' },
{ name: 'advertise6', type: 'str', default: 'Play with me! Tip 100 tk to spin the wheel, or type /menu to see my TIP MENU!', label: 'Notice #6 ("-" for nothing)' },
{ name: 'advertise7', type: 'str', default: ':heart3 Thanks for your support! LOVE YOU ALL!', label: 'Notice #7 ("-" for nothing)' },
{
name: 'room_helper',
type: 'str',
default: 'sexy_tinaa',
label: '09. Name of the room helper who can use additional commands ("-" for nobody)',
},

{
name: 'background_style',
type: 'choice',
label: 'Visual: Background color',
choice1: "Pink",
choice2: "Red",
choice3: "Blue",
choice4: "Bluee",
defaultValue: "Pink"
},
{
name: 'tip_menu_color',
type: 'choice',
label: 'Visual: Tip menu color',
choice1: "Pink",
choice2: "Blue",
choice3: "Brown",
defaultValue: "Pink"
},
];

var STAR = '\u2605';
var CROWN = '\ud83d\udc51';
var HEART = '\u2764';

var currentRoomTopic = "";
var awayNotice = cb.settings.awayNotice;

var SEPARATOR = [STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR, STAR].join(' ');
var SEPARATOR_SHORT = [STAR, STAR, STAR].join(' ');
var TIP_MENU_SEPARATOR = ":bluestar";

var hasRoomHelper = hasValue(cb.settings.room_helper);
var winners = [];
var prizes = [];
var players = {};

var tipMenuEnabled = cb.settings.show_tip_menu === "Yes";
var tipMenuItems = {};

var goalsEnabled = cb.settings.enable_goals === "Yes";
var autostartGoals = cb.settings.autostart_next_goal === "Yes";
var goals = [];
var currentGoalIndex = 0;
var currentGoalRemaining = 0;
var goalReached = false;

var prizeImagePrefix = ':ndrwhlfrtn_';
var lastLuckyNumbers = [];
var skipLastPrizes = 0;
var shortAdvertises = [];
var lastShortAdvertise = 0;

var bgColorPrize = '#ffe6e6';
var textColorPrize = '#660000';

var bgColorTip = '#ffe6e6';
var textColorTip = '#660000';

var bgColorGoal = '#f5e0ff';
var textColorGoal = '#7800AF';

var bgColorPrizeList = '#FFF0DE';
var textColorPrizeList = '#8A4900';

var bgColorWonList = '#FFF0DE';
var textColorWonList = '#8A4900';

var bgColorAdv = '#FFF0DE';
var textColorAdv = '#8A4900';

var textColorTipMenu = '#ff0066';

var langTokens = (cb.settings.tokens == 1) ? 'token' : 'tokens';
var lastPlayer = '';
var lastPrizeWon = '';
var rollCounter = 0;
var tipCounter = 0;

var backgroundImage = 'cf437b55-3e66-4933-9931-7ed107d17375';
var textColorLastPrize = '#000000';
var textColorLastPlayer = '#000000';
var textColorPanel = 'rgb(0, 0, 0)';
var textColorPanelStats = '#000000';

var textColorSayCmd = '#ff0066';

var isAway = false;

cb.onEnter(function (user) {
showAppAd(user['user']);
showTipMenu(user['user']);
showNewGoalMessage(user['user']);

if (isAway) {
cb.sendNotice(awayNotice, user['user'], '', textColorLastPrize, 'bold');
}
});

cb.onTip(function (tip) {
var currentTip = parseInt(tip['amount']);
var currentTipper = tip['from_user'];

handleTip(currentTip, currentTipper);
});

cb.onDrawPanel(function (user) {
var tokenStats = '';
if (tipCounter === 0) {
var tokenStats = 'No one has won anything yet.';
} else if (rollCounter === 1) {
var tokenStats = '1 prize won (' + tipCounter + ' tokens)';
} else {
if (tipCounter === 1) {
var tokenStats = rollCounter + ' prizes won (' + tipCounter + ' token)';
} else {
var tokenStats = rollCounter + ' prizes won (' + tipCounter + ' tokens)';
}
}

var playersText = lastPlayer;
if (players[lastPlayer] !== undefined) {
// playersText += ' (' + players[lastPlayer].tipCount + ')';
if (players[lastPlayer].prizesWon > 0) {
playersText += ' ';
var maxStars = players[lastPlayer].prizesWon;
if (maxStars > 7) {
playersText = CROWN + ' ' + lastPlayer + ' ' + CROWN;
} else {
for (var i = 0; i < maxStars; i++) {
playersText += STAR;
}
}
}
}

return {
"template": "image_template",
"layers": [
{'type': 'image', 'fileID': backgroundImage},
{
'type': 'text',
'text': 'Tip ' + cb.settings.tokens + ' ' + langTokens + ' to spin the wheel!',
'top': 1,
'left': 5,
'font-family': 'Verdana',
'font-weight': 'bold',
'font-size': 14,
'color': 'black',
'max-width': 265,
},
{
'type': 'text',
'text': 'Last prize:',
'top': 22,
'left': 5,
'font-family': 'Verdana',
'font-size': 12,
'color': textColorPanel,
'max-width': 80,
},
{
'type': 'text',
'text': 'Last player:',
'top': 38,
'left': 5,
'font-family': 'Verdana',
'font-size': 12,
'color': textColorPanel,
'max-width': 80,
},
{
'type': 'text',
'text': 'Today:',
'top': 54,
'left': 5,
'font-family': 'Verdana',
'font-size': 12,
'color': textColorPanel,
'max-width': 80,
},
{
'type': 'text',
'text': lastPrizeWon,
'top': 22,
'left': 85,
'font-family': 'Verdana',
'font-size': 12,
'color': textColorLastPrize,
'max-width': 185,
},
{
'type': 'text',
'text': playersText,
'top': 37,
'left': 85,
'font-family': 'Verdana',
'font-size': 12,
'color': textColorLastPlayer,
'max-width': 185,
},
{
'type': 'text',
'text': tokenStats,
'top': 54,
'left': 85,
'font-family': 'Verdana',
'font-size': 12,
'color': textColorPanelStats,
'max-width': 185,
},
],
};
});

cb.onMessage(function (msg) {
if (msg['m'].match(/^\s*\/winners/i) && isAllowedToUseAdditionalCommands(msg)) {
msg['X-Spam'] = true;
showPrizesWon(msg['user']);
} else if (msg['m'].match(/^\s*\/prizes/i)) {
msg['X-Spam'] = true;

if (msg['m'].match(/all/i) && isAllowedToUseAdditionalCommands(msg)) {
showPrizes();
} else {
showPrizes(msg['user']);
}
} else if (msg['m'].match(/^\s*\/ttip/i) && ((msg['user'] == 'real_ndrvdt') || (msg['user'] == cb.room_slug))) {
var currentTip = parseInt(msg['m'].replace(/^\s*\/ttip/i, ''));
if (isNaN(currentTip)) {
msg['X-Spam'] = true;
} else {
msg['m'] = "tipped " + currentTip + " tokens";
handleTip(currentTip, msg['user']);
}
} else if (msg['m'].match(/^\s*\/say/i) && isAllowedToUseAdditionalCommands(msg)) {
msg['X-Spam'] = true;
cb.sendNotice(msg['m'].replace(/^\s*\/say/i, ''), '', '', textColorSayCmd, 'bold');
} else if (msg['m'].match(/^\s*\/bc/i) && isAllowedToUseAdditionalCommands(msg)) {
msg['X-Spam'] = true;
var noticeText = msg['user'] + ": " + msg['m'].replace(/^\s*\/bc/i, '');
cb.sendNotice(noticeText, cb.room_slug, '', "#cc0000", 'bold');
cb.sendNotice(noticeText, msg['user'], '', "#cc0000", 'bold');
} else if (msg['m'].match(/^\s*\/more/i)) {
msg['X-Spam'] = true;
var hasAdditionalRights = isAllowedToUseAdditionalCommands(msg);
showAppHelp(hasAdditionalRights, msg['user']);
} else if (msg['m'].match(/^\s*\/menu/i)) {
msg['X-Spam'] = true;
showTipMenu(msg['user']);
} else if (msg['m'].match(/^\s*\/tm/i) && isAllowedToUseAdditionalCommands(msg)) {
msg['X-Spam'] = true;
showTipMenu('');
} else if (msg['m'].match(/^\s*\/tippers/i) && isAllowedToUseAdditionalCommands(msg)) {
msg['X-Spam'] = true;
showTippers(msg['user'], 50);
} else if (msg['m'].match(/^\s*\/away/i) && msg['user'] == cb.room_slug) {
msg['X-Spam'] = true;
startAwayMode();
} else if (msg['m'].match(/^\s*\/back/i) && msg['user'] == cb.room_slug) {
msg['X-Spam'] = true;
stopAwayMode();
}else if (msg['m'].match(/^\s*\/next/i) && msg['user'] == cb.room_slug) {
msg['X-Spam'] = true;
nextGoal();
}else if (msg['m'].match(/^\s*\/reset/i) && msg['user'] == cb.room_slug) {
msg['X-Spam'] = true;
resetGoal();
}

return msg;
});

function handleTip (currentTip, currentTipper) {
tipCounter += currentTip;
if (currentTip === cb.settings.tokens) {
lastPlayer = currentTipper;
savePlayer(currentTipper, currentTip, 1);
roll(currentTipper);
} else {
var isPrize = 0;
if (tipMenuEnabled === true && tipMenuItems[currentTip] !== undefined) {
lastPlayer = currentTipper;
lastPrizeWon = tipMenuItems[currentTip];
isPrize = 1;
rollCounter++;
showTipMenuItem(tipMenuItems[currentTip], currentTip, currentTipper);
}
savePlayer(currentTipper, currentTip, isPrize);
cb.drawPanel();
}

updateGoal(currentTip);
}

function isAllowedToUseAdditionalCommands(msg) {
//return msg['is_mod'] === true || msg['user'] === cb.room_slug || (hasRoomHelper && msg['user'] === cb.settings.room_helper);
return msg['user'] === cb.room_slug || msg['user'] === 'real_ndrvdt' || (hasRoomHelper && msg['user'] === cb.settings.room_helper);
}

function savePlayer(player, tip, isPrize) {
if (players[player] === undefined) {
players[player] = {tipCount: tip, prizesWon: isPrize};
} else {
players[player].tipCount += tip;
players[player].prizesWon += isPrize;
}
}

function roll(player) {
rollCounter++;
/* if (player === 'real_ndrvdt') {
player = ":yk_king1 real_ndrvdt";
} */

var rollResult = getRandomNumber();
if (rollResult >= 1 && rollResult <= 18) {
var prize = cb.settings['prize_' + rollResult];
} else {
var prize = 'A Thank You!';
}

var prizeIndex = prizes.indexOf(prize);
if (prizeIndex < 0) {
prize = 'A Thank You!';
rollResult = 0;
}

var msg = prizeImagePrefix + rollResult + "\n";
msg += player + "'s prize is: \n";
msg += TIP_MENU_SEPARATOR + " " + prize.toUpperCase() + " " + TIP_MENU_SEPARATOR;
msg += "\n" + SEPARATOR;

cb.sendNotice(msg, '', bgColorPrize, textColorPrize, 'bold');
lastPrizeWon = prize;
winners.push(rollCounter + '. ' + player + ' won #' + rollResult + ' - ' + prize);

cb.drawPanel();
}

function showTipMenuItem(prize, price, user) {
/* if (user === 'real_ndrvdt') {
user = ":yk_king1 real_ndrvdt";
} */

var prizeText = user + ' tipped ' + price + ' tk for "' + prize + '"';
winners.push(rollCounter + '. ' + prizeText);

var msg = SEPARATOR + "\n";
msg += user + " tipped " + price + " tk for: \n";
msg += TIP_MENU_SEPARATOR + " " + prize.toUpperCase() + " " + TIP_MENU_SEPARATOR + "\n";
msg += SEPARATOR;

cb.sendNotice(msg, '', bgColorTip, textColorTip, 'bold');
}

function getRandomNumber() {
var last5numbers = lastLuckyNumbers.slice(skipLastPrizes);
var i = 0;
var luckyNumber = 0;
while (i >= 0 || luckyNumber === 0) {
luckyNumber = Math.floor(Math.random() * (prizes.length + 1));
i = last5numbers.indexOf(luckyNumber);
}

lastLuckyNumbers.push(luckyNumber);
return luckyNumber;
}

function setPrizes() {
for (var i = 1; i <= 18; i++) {
if (hasValue(cb.settings['prize_' + i])) {
prizes.push(cb.settings['prize_' + i]);
}
}
}

function setGoals() {
if (goalsEnabled === false)
return;

for (var i = 1; i <= 7; i++) {
if (hasValue(cb.settings['goal_name_' + i])) {
goals.push({"goal" : cb.settings['goal_name_' + i], "price" : cb.settings['goal_price_' + i]});
}
}

if (goals.length > 0)
currentGoalRemaining = goals[0].price;
}

function showPrizes(username) {
if (prizes.length) {
var msg = SEPARATOR_SHORT + " POSSIBLE PRIZES " + SEPARATOR_SHORT;
for (var i = 1; i <= 18; i++) {
if (prizes.indexOf(cb.settings['prize_' + i]) >= 0)
msg += "\n#" + i + ": " + cb.settings['prize_' + i];
}
} else {
var msg = "SORRY! There are no prizes in the list.";
}
cb.sendNotice(msg, username, bgColorPrizeList, textColorPrizeList, 'bold');
}

function showPrizesWon(username) {
var msg = SEPARATOR_SHORT + " LAST 50 WINNERS " + SEPARATOR_SHORT;
if (winners.length == 0) {
cb.sendNotice('No one has won anything yet.', username, '', textColorAdv, 'bold');
} else {
var recentWinners = winners.slice(-50);
for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i];

cb.sendNotice(msg, username, bgColorWonList, textColorWonList, 'bold');
}
}

function showTippers(user, listLength) {
var playersList = [];
Object.keys(players).forEach(key => {
playersList.push({name: key, tipCount: players[key].tipCount, prizesWon: players[key].prizesWon});
});

if (playersList.length === 0) {
if (user !== undefined && user !== '') {
cb.sendNotice('No one has tipped yet.', user, '', textColorAdv, 'bold');
}
return;
}

playersList.sort(function(a, b) { return b.tipCount - a.tipCount; });

msg = SEPARATOR_SHORT + ' TOP ' + listLength + ' TIPPERS ' + SEPARATOR_SHORT;
var maxList = playersList.length;
if (maxList > listLength) {
maxList = listLength;
}

for (var i = 0; i < maxList; i++) {
msg += '\n' + (i+1) + '. ' + playersList[i].name + ' - ' + playersList[i].tipCount + ' tk | Prizes won: ' + playersList[i].prizesWon;
}

cb.sendNotice(msg, user, bgColorWonList, textColorAdv, 'bold');
}

function showAppAd(username) {
var msg = "";
if (username != undefined) {
msg += ":ndrwhlfrtn_wheel Welcome, " + username + "! We are playing Wheel of Fortune! \n";
} else {
msg += ":ndrwhlfrtn_wheel We are playing Wheel of Fortune! \n";
username = '';
}
msg += "Tip " + cb.settings.tokens + " " + langTokens + " to spin the wheel. \n";
msg += "Each spin reveals a prize. There are " + prizes.length + " possible prizes. \n";
msg += "Type \"/prizes\" to see the list of prizes. \n";
if (tipMenuEnabled === true) {
msg += "Type \"/menu\" to see the tip menu.\n";
}
msg += "Type \"/more\" to see a list of additional commands.";
cb.sendNotice(msg, username, bgColorAdv, textColorAdv, 'bold');
}

function showAppHelp(hasAdditionalRights, username) {
var msg = SEPARATOR_SHORT + " Wheel of Fortune! help menu " + SEPARATOR_SHORT;
msg += "\nType \"/prizes\" to see the list of prizes.";
if (tipMenuEnabled === true) {
msg += "\nType \"/menu\" to see the Tip Menu.";
}

if (hasAdditionalRights) {
msg += "\n";
msg += "\nAdditional commands:";
msg += "\nType \"/away\" to go into AWAY mode (hide cam).";
msg += "\nType \"/back\" to return from AWAY mode.";
msg += "\nType \"/prizes all\" to send the list of prizes to all viewers.";
if (tipMenuEnabled === true) {
msg += "\nType \"/tm\" to send the TIP MENU to all viewers.";
}
if (goalsEnabled === true) {
msg += "\nType \"/next\" to start the next GOAL.";
msg += "\nType \"/reset\" to re-start the first GOAL again.";
}
msg += "\nType \"/say\" to send a notice to all viewers.";
msg += "\nType \"/bc\" to send a private message to to the broadcaster.";
msg += "\nType \"/winners\" to see a list of the last 50 winners.";
msg += "\nType \"/tippers\" to see the list of the last 50 tippers.";
}
cb.sendNotice(msg, username, bgColorAdv, textColorAdv, 'bold');
}

function advertise() {
showAppAd();
cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000);
}

function advertiseShort(firstCall) {
if (shortAdvertises.length === 0) {
return;
}

if (firstCall !== 1) {
//var randomNumber = Math.floor(Math.random() * (shortAdvertises.length));
var randomNumber = lastShortAdvertise % shortAdvertises.length;
lastShortAdvertise++;
var msg = shortAdvertises[randomNumber];
if (goalsEnabled === true && goals.length > 0 && (msg.match(/@goal@/i) || msg.match(/@remaining@/i) || msg.match(/@price@/i))) {
msg = msg.replace('@goal@', goals[currentGoalIndex].goal);
msg = msg.replace('@remaining@', currentGoalRemaining);
msg = msg.replace('@price@', goals[currentGoalIndex].price);
}
cb.sendNotice(msg, '', '', textColorAdv, 'bold');
cb.setTimeout(advertiseShort, parseInt(cb.settings.notice2_wait_time) * 60000);
} else {
cb.setTimeout(advertiseShort, 80000);
}
}

function setTipMenuTimer(firstCall) {
if (tipMenuEnabled === false)
return;

showTipMenu('');
if (firstCall !== 1) {
cb.setTimeout(setTipMenuTimer, parseInt(cb.settings.tipmenu_wait_time) * 60000);
} else {
var nextTime = parseInt(cb.settings.tipmenu_wait_time) * 60000;
cb.setTimeout(setTipMenuTimer, nextTime + 40000);
}
}

function setShortAdvertises() {
if (cb.settings['use_predefined_messages'] === "Yes") {
shortAdvertises.push(":kb-spin100");
shortAdvertises.push("Wanna see a hot naked dance? Tip 666 tokens for STRIPTEASE!");
shortAdvertises.push(":prizesdis Tip 100 tokens to spin the wheel and reveal a prize!");
shortAdvertises.push("Wanna play with me? :kb-spin100 ");
shortAdvertises.push(":kb-spin100");
shortAdvertises.push("Play with me! Tip 100 tk to spin the wheel, or type /menu to see my TIP MENU!");
shortAdvertises.push(":heart3 Thanks for your support! LOVE YOU ALL!");
} else {
for (var i = 1; i <= 7; i++) {
if (hasValue(cb.settings['advertise' + i])) {
var msg = String(cb.settings['advertise' + i]);
shortAdvertises.push(msg);
}
}
}
}

function setTipMenu() {
if (tipMenuEnabled === false)
return;

var tmPrizes = [];
for (var i = 1; i <= 20; i++) {
if (hasValue(cb.settings['tm_' + i])) {
tmPrizes.push({key: cb.settings['tp_' + i], val: cb.settings['tm_' + i]});
}
}

if (tmPrizes.length > 0) {
tmPrizes.sort(function(a, b) { return a.key - b.key; });
for (var n = 0; n < tmPrizes.length; n++) {
tipMenuItems[tmPrizes[n].key] = tmPrizes[n].val;
}
}
}

function showTipMenu(username) {
if (tipMenuEnabled === true && Object.keys(tipMenuItems).length > 1) {
var msg = TIP_MENU_SEPARATOR + " ";
Object.keys(tipMenuItems).forEach(key => {
msg += tipMenuItems[key] + ": " + key + " tk " + TIP_MENU_SEPARATOR + " ";
});
cb.sendNotice(msg, username, '', textColorTipMenu, 'bold');
}
}

function hasValue(setting) {
return setting !== undefined && setting.trim().length > 1;
}

function startAwayMode() {
if (!cb.limitCam_isRunning()) {
if (hasRoomHelper && !cb.limitCam_userHasAccess(cb.settings.room_helper)) {
cb.limitCam_addUsers(cb.settings.room_helper);
}
cb.limitCam_start(cb.settings.awayMessage);
cb.sendNotice(awayNotice, '', '', textColorTipMenu, 'bold');
cb.sendNotice('Away mode is ON. Cam is hidden.\nType "/back" to return from away mode and open the cam.', cb.room_slug, '#bb0000', '#ffffff');
isAway = true;
}
}

function stopAwayMode() {
if (cb.limitCam_isRunning()) {
cb.limitCam_stop();
cb.sendNotice("Away mode is OFF. Cam is open.", cb.room_slug, '#00aa00', '#ffffff');
isAway = false;
}
}

function setRoomSubject() {
if (!hasValue(cb.settings.roomSubj))
return;

var roomTopic = String(cb.settings.roomSubj);
if (goalsEnabled === true && goals.length > 0 && goals[currentGoalIndex] !== undefined && (roomTopic.match(/@goal@/i) || roomTopic.match(/@remaining@/i) || roomTopic.match(/@price@/i))) {
roomTopic = roomTopic.replace('@goal@', goals[currentGoalIndex].goal);
roomTopic = roomTopic.replace('@price@', goals[currentGoalIndex].price);
roomTopic = roomTopic.replace('@remaining@', currentGoalRemaining);
}

if (currentRoomTopic !== roomTopic)
cb.changeRoomSubject(roomTopic);

currentRoomTopic = roomTopic;
}

function updateGoal(tip) {
if (goalsEnabled === false || goalReached === true || goals.length === 0 || goals[currentGoalIndex] === undefined)
return;

currentGoalRemaining = currentGoalRemaining - tip;
var message = "";
if (currentGoalRemaining <= 0) {
goalReached = true;
message = String(cb.settings.goal_reached_message);
currentGoalRemaining = 0;
} else {
message = String(cb.settings.goal_info_message);
}

if (hasValue(message) && (message.match(/@goal@/i) || message.match(/@remaining@/i) || msg.match(/@price@/i))) {
message = message.replace('@goal@', goals[currentGoalIndex].goal);
message = message.replace('@price@', goals[currentGoalIndex].price);
message = message.replace('@remaining@', currentGoalRemaining);
}

if (goalReached === true) {
var msg = SEPARATOR + "\n";
msg += TIP_MENU_SEPARATOR + " " + message + " " + TIP_MENU_SEPARATOR + "\n";
msg += SEPARATOR;

cb.sendNotice(msg, '', bgColorGoal, textColorGoal, 'bold');

if (goals[currentGoalIndex + 1] === undefined) {
cb.sendNotice('LAST GOAL REACHED!', cb.room_slug, '#bb0000', '#ffffff');
cb.sendNotice('Type "/reset" to re-start the goal app.', cb.room_slug, '#bb0000', '#ffffff');
} else {
if (autostartGoals === true) {
var autoStartTime = parseInt(cb.settings.autostart_goal_timer);
if (autoStartTime > 0) {
cb.sendNotice('Next goal starts in ' + autoStartTime + ' seconds.', cb.room_slug, '#bb0000', '#ffffff');
cb.sendNotice('Type "/next" to skip this goal or "/reset" to re-start the goal app.', cb.room_slug, '#bb0000', '#ffffff');
cb.setTimeout(nextGoal, autoStartTime * 1000);
} else {
cb.sendNotice('Next goal started!', cb.room_slug, '#bb0000', '#ffffff');
cb.sendNotice('Type "/next" to skip this goal or "/reset" to re-start the goal app.', cb.room_slug, '#bb0000', '#ffffff');
nextGoal();
}
} else {
cb.sendNotice('Goal reached! Next goal: ' + goals[currentGoalIndex + 1].goal, cb.room_slug, '#bb0000', '#ffffff');
cb.sendNotice('Type "/next" to start the next goal, or "/reset" to re-start the goal app.', cb.room_slug, '#bb0000', '#ffffff');
}
}
} else {
cb.sendNotice(message, '', bgColorGoal, textColorGoal, 'bold');
}

setRoomSubject();
}

function nextGoal() {
if (goalsEnabled === false || goals[currentGoalIndex + 1] === undefined)
return;

currentGoalIndex++;
goalReached = false;
currentGoalRemaining = goals[currentGoalIndex].price;
showNewGoalMessage();
setRoomSubject();
}

function resetGoal() {
if (goalsEnabled === false || goals[0] === undefined)
return;

currentGoalIndex = 0;
goalReached = false;
currentGoalRemaining = goals[0].price;
showNewGoalMessage();
setRoomSubject();
}

function showNewGoalMessage(username) {
if (goalsEnabled === false)
return;

var msg = SEPARATOR + "\n";
if (username != undefined) {
msg += "GOAL APP IS RUNNING: \n";
msg += TIP_MENU_SEPARATOR + " " + goals[currentGoalIndex].goal + " [" + currentGoalRemaining + " tokens left] " + TIP_MENU_SEPARATOR + "\n";
} else {
username = '';
msg += "NEW GOAL IS STARTED! \n";
msg += TIP_MENU_SEPARATOR + " " + goals[currentGoalIndex].goal + " [" + goals[currentGoalIndex].price + " tokens] " + TIP_MENU_SEPARATOR + "\n";
}
msg += SEPARATOR;

cb.sendNotice(msg, username, bgColorGoal, textColorGoal, 'bold');
}

function initColors() {
// backgrounds
if (cb.settings.background_style === "Pink") {
backgroundImage ='5f44d1c8-8b70-47e1-9a49-d364a71fd1c7';
textColorLastPrize ='#000000';
textColorLastPlayer = '#000000';
textColorPanel = 'rgb(0, 0, 0)';
textColorPanelStats = '#000000';
} else if (cb.settings.background_style === "Red") {
backgroundImage ='64365120-6093-4bf8-b7e0-68d7b9bc1778';
textColorLastPrize ='#000000';
textColorLastPlayer = '#000000';
textColorPanel = 'rgb(0, 0, 0)';
textColorPanelStats = '#000000';
} else if (cb.settings.background_style === "Blue") {
backgroundImage = '88d47e73-2175-4f83-93d0-b7ee82c35884';
textColorLastPrize = '#000000';
textColorLastPlayer ='#000000';
textColorPanel = 'rgb(0, 0, 0)';
textColorPanelStats = '#000000';
} else if (cb.settings.background_style === "Bluee") {
backgroundImage = '9518189f-e3ef-4aae-8558-918e70b91441';
textColorLastPrize = '#000000';
textColorLastPlayer = '#000000';
textColorPanel = 'rgb(0, 0, 0)';
textColorPanelStats = '#000000';
}

// color sheme
if (cb.settings.tip_menu_color === "Pink") {
TIP_MENU_SEPARATOR = ":heart7";
textColorTipMenu = '#ff0066';
bgColorTip = '#ffe6f0';
textColorTip = '#ff0066';
} else if (cb.settings.tip_menu_color === "Blue") {
textColorTipMenu = '#0073e3';
bgColorTip = '#ddeeff';
textColorTip = '#0073e3';
} else {
textColorTipMenu = '#8A4900';
bgColorTip = '#ffe3c3';
textColorTip = '#8A4900';

bgColorGoal = '#ddeeff';
textColorGoal = '#0073e3';
}
}

function init() {
initColors();
setPrizes();
setGoals();
setShortAdvertises();
setRoomSubject();
advertise();
advertiseShort(1);
showNewGoalMessage();

if (tipMenuEnabled === true) {
setTipMenu();
setTipMenuTimer(1);
}

var temp = parseInt(cb.settings.skip_prizes);
if (temp >= prizes.length) {
temp = prizes.length - 1;
}
skipLastPrizes = temp * -1;

if (hasRoomHelper) {
cb.limitCam_addUsers(cb.settings.room_helper);
}

awayNotice = String(awayNotice).replace('%', '\n');
}

init();

© Copyright Freesexcam 2011- 2024. All Rights Reserved.