Apps Home
|
Create an App
JonnyClothesBattle by Luissen
Author:
luissendev1
Description
Source Code
Launch App
Current Users
Created by:
Luissendev1
total_tips = 0; cb.settings_choices = []; /* cb.settings_choices.push ( {name:'rule1', type:'str', minLength:1, maxLength:255, label:'Rule #1'}, {name:'rule2', type:'str', minLength:1, maxLength:255, label:'Rule #2 (optional)', required:false}, {name:'rule3', type:'str', minLength:1, maxLength:255, label:'Rule #3 (optional)', required:false}, {name:'rule4', type:'str', minLength:1, maxLength:255, label:'Rule #4 (optional)', required:false}, {name:'rule5', type:'str', minLength:1, maxLength:255, label:'Rule #5 (optional)', required:false}, {name:'rule6', type:'str', minLength:1, maxLength:255, label:'Rule #6 (optional)', required:false}, {name:'rule7', type:'str', minLength:1, maxLength:255, label:'Rule #7 (optional)', required:false}, {name:'rule8', type:'str', minLength:1, maxLength:255, label:'Rule #8 (optional)', required:false}, {name:'rule9', type:'str', minLength:1, maxLength:255, label:'Rule #9 (optional)', required:false}, {name:'rule10', type:'str', minLength:1, maxLength:255, label:'Rule #10 (optional)', required:false}, {name:'advertisement_wait_time', type:'choice', label:'Notification Time (in minutes)', choice1:5, choice2:10, choice3:15, choice4:20, choice5:25, choice6:30, choice7:45, choice8:60, defaultValue:15} );*/ cb.settings_choices.push ( {name: "clothing1Name", type: "str", minLength: 1, maxLength: 21, label: "Item 1 name", defaultValue: "Pants", required: false}, {name: "clothing1HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 300, required: false}, {name: "clothing1MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing1TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 20, required: false} ); cb.settings_choices.push ( {name: "clothing2Name", type: "str", minLength: 1, maxLength: 21, label: "Item 2 name", defaultValue: "Shirt", required: false}, {name: "clothing2HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 200, required: false}, {name: "clothing2MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing2TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 15, required: false} ); cb.settings_choices.push ( {name: "clothing3Name", type: "str", minLength: 1, maxLength: 21, label: "Item 3 name", defaultValue: "Socks", required: false}, {name: "clothing3HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 100, required: false}, {name: "clothing3MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing3TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 10, required: false} ); /* for (i=1; i<4; i++) { cb.settings_choices.push ( {name: "clothing"+i+"Name", type: "str", minLength: 1, maxLength: 21, label: "Item "+i+" name", defaultValue: "", required: false}, {name: "clothing"+i+"HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 100, required: false}, {name: "clothing"+i+"MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing"+i+"TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 30, required: false} ); }*/ // vars var clothing = new Array(); for (item = 0; item < 3; item ++) { clothing[item] = [ cb.settings["clothing"+(item+1)+"Name"] ,cb.settings["clothing"+(item+1)+"HitPoints"] ,cb.settings["clothing"+(item+1)+"MaxDamage"] ,cb.settings["clothing"+(item+1)+"TipValue"] ]; } // draw panel cb.onDrawPanel(function(user) { var defeatedText = "*** DEFEATED! ***"; var rowLabels = new Array(); var rowValues = new Array(); for (item = 0; item < 3; item ++) { rowLabels[item] = clothing[item][0].length > 0 ? clothing[item][0] + " (tip " + clothing[item][3] + ")" : " "; rowValues[item] = clothing[item][1]>0 ? "points remaining: " + clothing[item][1] : defeatedText ; rowValues[item] = clothing[item][0].length > 0 ? rowValues[item] : " "; // clear it if there is no item name } var fields = { template: '3_rows_of_labels', row1_label: rowLabels[0], row1_value: rowValues[0], row2_label: rowLabels[1], row2_value: rowValues[1], row3_label: rowLabels[2], row3_value: rowValues[2] }; return fields; }); // game logic cb.onTip(function (data) { // work out which item is being tipped for var tipValue = parseInt(data["amount"]); total_tips += tipValue; var tippedItem = -1; if (tipValue == clothing[0][3] && clothing[0][0]) { tippedItem = 0 } if (tipValue == clothing[1][3] && clothing[1][0]) { tippedItem = 1 } if (tipValue == clothing[2][3] && clothing[2][0]) { tippedItem = 2 } if (tippedItem > -1) { // check for already defeated if (clothing[tippedItem][1] < 1) { cb.sendNotice("That item is no longer being worn", "", "", "#ff8900", "bold"); } else { // valid item has been tipped for, get a random damage number var attackStrength = Math.floor((Math.random() * (clothing[tippedItem][2]+2)) -1); var damageTaken = 0; var damageMessage = ""; // if 0, the clothing defends and takes no damage if (attackStrength == 0) { damageMessage = clothing[tippedItem][0] + " defended itself and took no damage at all!"; } // if negative, the clothing defends and gains health if (attackStrength < 0) { var gainedPoints = Math.floor(Math.random() * clothing[tippedItem][2]); damageMessage = clothing[tippedItem][0] + " blocked your attack and feels rather good about it, healing by " + gainedPoints + " points as a result!"; } // positive damage if (attackStrength > 0) { var pluralVerb = "was"; if (clothing[tippedItem][0].slice(-1).toLowerCase() == "s") { pluralVerb = "were"; } damageMessage = clothing[tippedItem][0] + " " + pluralVerb + " attacked and took " + attackStrength + " points of damage."; } cb.sendNotice(damageMessage, "", "", "#740000", "bold"); clothing[tippedItem][1] = clothing[tippedItem][1] - attackStrength; // check for defeated if (clothing[tippedItem][1] < 1) { // defeated var pluralVerb = "has"; if (clothing[tippedItem][0].slice(-1).toLowerCase() == "s") { pluralVerb = "have"; } var itemDefeatedMessage = clothing[tippedItem][0] + " " + pluralVerb + " been defeated!"; cb.sendNotice(itemDefeatedMessage, "", "", "#ff0000", "bold"); } // check for naked! if (clothing[0][1] < 1 && clothing[1][1] < 1 && clothing[2][1] < 1) { cb.sendNotice("Game completed! All clothing gone, congratulations!", "", "", "#ff00ce", "bold"); } cb.drawPanel(); } } }); // display help when requested cb.onMessage(function (data) { if (data["m"] == "!help") { data['X-Spam'] = true; var helpText = "Items of clothing are shown in the panel below the video. Each item has a number of 'hitpoints' and when they're gone, the item of clothing is defeated and must be removed.\nTip to 'attack' the clothes! Tip the number printed next to the item to choose your target. Have fun!!"; if (data['user'] == cb.room_slug || data['is_mod']) { cb.sendNotice(helpText, "", "", "#417900", "normal"); } else { cb.sendNotice(helpText, data["user"], "", "#417900", "normal"); } } if (data["m"] == "!t") { if (data['user'] == cb.room_slug || data['is_mod']) { cb.sendNotice("Total tips so far: " + total_tips, data["user"], "", "#417900", "normal"); data["m"] = ""; } else { cb.sendNotice("You do not have permission to execute this command.", data["user"], "", "#417900", "normal"); data["m"] = ""; } } return data; }); // inform user on join cb.onEnter(function(data) { cb.sendNotice('Welcome to my room, ' + data['user'] + '. Please take a moment to read my room rules before chatting. Thank you!', data['user'], '#CCF5EB', '', 'bold'); /* displayRules(data['user']); if (data["user"] != cb.room_slug) { cb.sendNotice("Clothing Battle app is running, type !help for details.", data["user"], "", "#67c200", "bold"); cb.drawPanel(); }*/ }); // repeated info message function repeatingMessage() { cb.sendNotice("Luissen's Clothing Battle app running, type !help for instructions.", "", "", "#3072ff", "bold"); cb.setTimeout(repeatingMessage, 180000) } function displayRules(user) { var username = ''; if(user) username = user['user']; var notices = '## MY RULES ##'; for(var i=1; i<=10;i++) { if(cb.settings['rule' + i]) notices += '\nRule #'+ i +': ' + cb.settings['rule'+i]; } cb.sendNotice(notices, username, '', '#7FFF00', 'bold'); if(!user || user == null) cb.setTimeout(displayRules, cb.settings.advertisement_wait_time * 60000); } function init() { //displayRules(); cb.sendNotice("Luissen's Clothing Battle is now running. Type !help for instructions.", "", "", "#67c200", "bold"); cb.drawPanel(); cb.setTimeout(repeatingMessage, 180000); } init();total_tips = 0; cb.settings_choices = []; /* cb.settings_choices.push ( {name:'rule1', type:'str', minLength:1, maxLength:255, label:'Rule #1'}, {name:'rule2', type:'str', minLength:1, maxLength:255, label:'Rule #2 (optional)', required:false}, {name:'rule3', type:'str', minLength:1, maxLength:255, label:'Rule #3 (optional)', required:false}, {name:'rule4', type:'str', minLength:1, maxLength:255, label:'Rule #4 (optional)', required:false}, {name:'rule5', type:'str', minLength:1, maxLength:255, label:'Rule #5 (optional)', required:false}, {name:'rule6', type:'str', minLength:1, maxLength:255, label:'Rule #6 (optional)', required:false}, {name:'rule7', type:'str', minLength:1, maxLength:255, label:'Rule #7 (optional)', required:false}, {name:'rule8', type:'str', minLength:1, maxLength:255, label:'Rule #8 (optional)', required:false}, {name:'rule9', type:'str', minLength:1, maxLength:255, label:'Rule #9 (optional)', required:false}, {name:'rule10', type:'str', minLength:1, maxLength:255, label:'Rule #10 (optional)', required:false}, {name:'advertisement_wait_time', type:'choice', label:'Notification Time (in minutes)', choice1:5, choice2:10, choice3:15, choice4:20, choice5:25, choice6:30, choice7:45, choice8:60, defaultValue:15} );*/ cb.settings_choices.push ( {name: "clothing1Name", type: "str", minLength: 1, maxLength: 21, label: "Item 1 name", defaultValue: "Pants", required: false}, {name: "clothing1HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 300, required: false}, {name: "clothing1MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing1TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 20, required: false} ); cb.settings_choices.push ( {name: "clothing2Name", type: "str", minLength: 1, maxLength: 21, label: "Item 2 name", defaultValue: "Shirt", required: false}, {name: "clothing2HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 200, required: false}, {name: "clothing2MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing2TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 15, required: false} ); cb.settings_choices.push ( {name: "clothing3Name", type: "str", minLength: 1, maxLength: 21, label: "Item 3 name", defaultValue: "Socks", required: false}, {name: "clothing3HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 100, required: false}, {name: "clothing3MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing3TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 10, required: false} ); /* for (i=1; i<4; i++) { cb.settings_choices.push ( {name: "clothing"+i+"Name", type: "str", minLength: 1, maxLength: 21, label: "Item "+i+" name", defaultValue: "", required: false}, {name: "clothing"+i+"HitPoints", type: "int", minValue: 1, maxValue: 1000, label: "Starting hit points", defaultValue: 100, required: false}, {name: "clothing"+i+"MaxDamage", type: "int", minValue: 1, maxValue: 1000, label: "Max damage each hit", defaultValue: 25, required: false}, {name: "clothing"+i+"TipValue", type: "int", minValue: 1, maxValue: 1000, label: "Tip value for this item", defaultValue: 30, required: false} ); }*/ // vars var clothing = new Array(); for (item = 0; item < 3; item ++) { clothing[item] = [ cb.settings["clothing"+(item+1)+"Name"] ,cb.settings["clothing"+(item+1)+"HitPoints"] ,cb.settings["clothing"+(item+1)+"MaxDamage"] ,cb.settings["clothing"+(item+1)+"TipValue"] ]; } // draw panel cb.onDrawPanel(function(user) { var defeatedText = "*** DEFEATED! ***"; var rowLabels = new Array(); var rowValues = new Array(); for (item = 0; item < 3; item ++) { rowLabels[item] = clothing[item][0].length > 0 ? clothing[item][0] + " (tip " + clothing[item][3] + ")" : " "; rowValues[item] = clothing[item][1]>0 ? "points remaining: " + clothing[item][1] : defeatedText ; rowValues[item] = clothing[item][0].length > 0 ? rowValues[item] : " "; // clear it if there is no item name } var fields = { template: '3_rows_of_labels', row1_label: rowLabels[0], row1_value: rowValues[0], row2_label: rowLabels[1], row2_value: rowValues[1], row3_label: rowLabels[2], row3_value: rowValues[2] }; return fields; }); // game logic cb.onTip(function (data) { // work out which item is being tipped for var tipValue = parseInt(data["amount"]); total_tips += tipValue; var tippedItem = -1; if (tipValue == clothing[0][3] && clothing[0][0]) { tippedItem = 0 } if (tipValue == clothing[1][3] && clothing[1][0]) { tippedItem = 1 } if (tipValue == clothing[2][3] && clothing[2][0]) { tippedItem = 2 } if (tippedItem > -1) { // check for already defeated if (clothing[tippedItem][1] < 1) { cb.sendNotice("That item is no longer being worn", "", "", "#ff8900", "bold"); } else { // valid item has been tipped for, get a random damage number var attackStrength = Math.floor((Math.random() * (clothing[tippedItem][2]+2)) -1); var damageTaken = 0; var damageMessage = ""; // if 0, the clothing defends and takes no damage if (attackStrength == 0) { damageMessage = clothing[tippedItem][0] + " defended itself and took no damage at all!"; } // if negative, the clothing defends and gains health if (attackStrength < 0) { var gainedPoints = Math.floor(Math.random() * clothing[tippedItem][2]); damageMessage = clothing[tippedItem][0] + " blocked your attack and feels rather good about it, healing by " + gainedPoints + " points as a result!"; } // positive damage if (attackStrength > 0) { var pluralVerb = "was"; if (clothing[tippedItem][0].slice(-1).toLowerCase() == "s") { pluralVerb = "were"; } damageMessage = clothing[tippedItem][0] + " " + pluralVerb + " attacked and took " + attackStrength + " points of damage."; } cb.sendNotice(damageMessage, "", "", "#740000", "bold"); clothing[tippedItem][1] = clothing[tippedItem][1] - attackStrength; // check for defeated if (clothing[tippedItem][1] < 1) { // defeated var pluralVerb = "has"; if (clothing[tippedItem][0].slice(-1).toLowerCase() == "s") { pluralVerb = "have"; } var itemDefeatedMessage = clothing[tippedItem][0] + " " + pluralVerb + " been defeated!"; cb.sendNotice(itemDefeatedMessage, "", "", "#ff0000", "bold"); } // check for naked! if (clothing[0][1] < 1 && clothing[1][1] < 1 && clothing[2][1] < 1) { cb.sendNotice("Game completed! All clothing gone, congratulations!", "", "", "#ff00ce", "bold"); } cb.drawPanel(); } } }); // display help when requested cb.onMessage(function (data) { if (data["m"] == "!help") { data['X-Spam'] = true; var helpText = "Items of clothing are shown in the panel below the video. Each item has a number of 'hitpoints' and when they're gone, the item of clothing is defeated and must be removed.\nTip to 'attack' the clothes! Tip the number printed next to the item to choose your target. Have fun!!"; if (data['user'] == cb.room_slug || data['is_mod']) { cb.sendNotice(helpText, "", "", "#417900", "normal"); } else { cb.sendNotice(helpText, data["user"], "", "#417900", "normal"); } } if (data["m"] == "!t") { if (data['user'] == cb.room_slug || data['is_mod']) { cb.sendNotice("Total tips so far: " + total_tips, data["user"], "", "#417900", "normal"); data["m"] = ""; } else { cb.sendNotice("You do not have permission to execute this command.", data["user"], "", "#417900", "normal"); data["m"] = ""; } } return data; }); // inform user on join cb.onEnter(function(data) { cb.sendNotice('Welcome to my room, ' + data['user'] + '. Please take a moment to read my room rules before chatting. Thank you!', data['user'], '#CCF5EB', '', 'bold'); /* displayRules(data['user']); if (data["user"] != cb.room_slug) { cb.sendNotice("Clothing Battle app is running, type !help for details.", data["user"], "", "#67c200", "bold"); cb.drawPanel(); }*/ }); // repeated info message function repeatingMessage() { cb.sendNotice("Luissen's Clothing Battle app running, type !help for instructions.", "", "", "#3072ff", "bold"); cb.setTimeout(repeatingMessage, 180000) } function displayRules(user) { var username = ''; if(user) username = user['user']; var notices = '## MY RULES ##'; for(var i=1; i<=10;i++) { if(cb.settings['rule' + i]) notices += '\nRule #'+ i +': ' + cb.settings['rule'+i]; } cb.sendNotice(notices, username, '', '#7FFF00', 'bold'); if(!user || user == null) cb.setTimeout(displayRules, cb.settings.advertisement_wait_time * 60000); } function init() { //displayRules(); cb.sendNotice("Luissen's Clothing Battle is now running. Type !help for instructions.", "", "", "#67c200", "bold"); cb.drawPanel(); cb.setTimeout(repeatingMessage, 180000); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.