//character object // function Character(name= "name", hpMax, speed, coolness, energy, bgColor, immune, {passive = 1, shield = 0, fly = false, freeMove = 1, energize = 2, actions = 2, evade = 0, regen = 0} = {passive: 1, shield: 0, fly: false, freeMove: 1, energize: 2, actions: 2, evade: 0, regen: 0}) { function Character(c = {}) { this.name = c.name; this.health = parseInt(c.hpMax); this.hpMax = parseInt(c.hpMax); this.speed = parseInt(c.speed); this.cool = parseInt(c.coolness); this.energy = parseFloat(c.energy); this.bgColor = c.bgColor; this.passiveEnergy = c.passive; this.shield = parseFloat(c.shield); this.flight = c.flight; if (this.flight == 1) {this.flight = true} else {this.flight = false}; this.freeMove = parseInt(c.freeMove); this.freeMoveDefault = parseInt(c.freeMove); this.energize = parseFloat(c.energize); this.actionDefault = parseFloat(c.actions); this.alive = true; this.evade = parseInt(c.evade); this.regenerate = parseFloat(c.regen); this.onTile = 0; this.battleStats = {DamageGiven: 0, DamageTaken: 0, Kills: 0, Healing: 0, Movement: 0, Death: "none"} this.effects = []; this.immunities = c.immune; this.attacks = {}; this.tempShield = 0; this.tempEvade = 0; this.tempAcc = 0; this.meleeBonus = 0; this.rangeBonus = 0; this.faceDirection = "right"; } charSelect = []; charSelect['fire-og'] = new Character ({"id":"1","name":"fire-og","hpMax":"15","speed":"13","coolness":"10","energy":"5","bgColor":"#e17751","flight":"0","regen":"0.00","passive":"1.00","energize":"2.00","actions":"2.00","shield":"1","evade":"0","freeMove":"1","attacks":"Weak\/Fireball\/Delayed Punch\/Boom Boom Gun\/Super Fireball\/Heal Ray","immune":"burn"}); charSelect['Icicle'] = new Character ({"id":"3","name":"Icicle","hpMax":"15","speed":"11","coolness":"9","energy":"6","bgColor":"#ccfcff","flight":"0","regen":"0.00","passive":"1.00","energize":"3.00","actions":"2.00","shield":"1","evade":"-10","freeMove":"1","attacks":"Snowball\/Spin Attack\/Rain Attack\/Red Blaster\/Void Attack\/Healing Water","immune":"slowed"}); charSelect['Rock'] = new Character ({"id":"4","name":"Rock","hpMax":"32","speed":"5","coolness":"9","energy":"6","bgColor":"#565656","flight":"0","regen":"0.00","passive":"2.00","energize":"2.00","actions":"2.00","shield":"-1","evade":"0","freeMove":"1","attacks":"Pebble\/Rock\/Delayed Punch\/Boomerang\/Boulder Bomb\/Heal Ray","immune":"none"}); charSelect['Space'] = new Character ({"id":"5","name":"Space","hpMax":"6","speed":"16","coolness":"18","energy":"6","bgColor":"#140967","flight":"1","regen":"0.00","passive":"1.00","energize":"2.00","actions":"2.00","shield":"1","evade":"20","freeMove":"3","attacks":"Pebble\/Zap\/Super Arrow\/Phantom Slash\/Rainbow Blast\/Star Shower","immune":"poison"}); charSelect['Water'] = new Character ({"id":"6","name":"Water","hpMax":"11","speed":"17","coolness":"14","energy":"7","bgColor":"#7e6cf0","flight":"0","regen":"0.00","passive":"1.00","energize":"3.00","actions":"2.00","shield":"0","evade":"3","freeMove":"1","attacks":"Snowball\/Rain Attack\/Wobble Ray\/Acid Rain\/Tidal Wave\/Healing Water","immune":"burn"}); charSelect['Lava'] = new Character ({"id":"7","name":"Lava","hpMax":"10","speed":"14","coolness":"12","energy":"7","bgColor":"#541812","flight":"0","regen":"0.00","passive":"1.00","energize":"2.00","actions":"2.50","shield":"0","evade":"-5","freeMove":"1","attacks":"Weak\/Fireball\/Super Arrow\/Zap\/Bombs Away\/Hamburger","immune":"none"}); charSelect['Bob'] = new Character ({"id":"8","name":"Bob","hpMax":"7","speed":"30","coolness":"17","energy":"4","bgColor":"#677978","flight":"1","regen":"0.00","passive":"2.00","energize":"2.00","actions":"2.00","shield":"0","evade":"5","freeMove":"2","attacks":"Bees\/Wobble Ray\/Acid Breath\/Red Blaster\/Void Attack\/Heal Ray","immune":"blind"}); charSelect['Sheriff'] = new Character ({"id":"9","name":"Sheriff","hpMax":"13","speed":"23","coolness":"15","energy":"5","bgColor":"#deb887","flight":"0","regen":"0.00","passive":"1.00","energize":"3.00","actions":"2.00","shield":"-1","evade":"10","freeMove":"1","attacks":"Weak\/Quick Attack\/Spin Attack\/Heat Seeking\/Double Shot\/Bombs Away","immune":"none"}); charSelect['Lava-Pixi'] = new Character ({"id":"10","name":"Lava-Pixi","hpMax":"11","speed":"20","coolness":"14","energy":"2","bgColor":"#a45c5c","flight":"0","regen":"0.00","passive":"1.00","energize":"4.00","actions":"2.00","shield":"0","evade":"0","freeMove":"1","attacks":"Pebble\/Fireball\/Spin Attack\/Dark Pulse\/Super Fireball\/Boom Boom Gun","immune":"slowed"}); charSelect['Kitty'] = new Character ({"id":"11","name":"Kitty","hpMax":"14","speed":"17","coolness":"11","energy":"5","bgColor":"#8f6e91","flight":"0","regen":"1.00","passive":"1.00","energize":"2.00","actions":"2.00","shield":"0","evade":"0","freeMove":"4","attacks":"Snowball\/Spin Attack\/Boomerang\/Red Flower\/Brick\/Flying Cat","immune":"none"}); charSelect['Hamster'] = new Character ({"id":"12","name":"Hamster","hpMax":"13","speed":"16","coolness":"9","energy":"11","bgColor":"#36528e","flight":"0","regen":"0.00","passive":"1.00","energize":"3.00","actions":"2.50","shield":"0","evade":"-10","freeMove":"1","attacks":"Bees\/Wobble Ray\/Double Shot\/Boom Boom Gun\/Boulder Bomb\/Hamburger","immune":"none"}); charSelect['Heart-new'] = new Character ({"id":"13","name":"Heart-new","hpMax":"11","speed":"15","coolness":"10","energy":"6","bgColor":"#ae69cc","flight":"0","regen":"1.00","passive":"1.00","energize":"3.00","actions":"2.00","shield":"0","evade":"0","freeMove":"1","attacks":"Pebble\/Rain Attack\/Heat Seeking\/Blue Flower\/Mega Health\/Revival","immune":"burn"}); charSelect['Lightning'] = new Character ({"id":"14","name":"Lightning","hpMax":"9","speed":"24","coolness":"10","energy":"8","bgColor":"#f3fe5d","flight":"0","regen":"0.00","passive":"2.00","energize":"2.00","actions":"2.00","shield":"0","evade":"0","freeMove":"2","attacks":"Weak\/Quick Attack\/Zap\/Lightning Card\/Boom Boom Gun\/Super Shock","immune":"tired"}); charSelect['Droplet'] = new Character ({"id":"15","name":"Droplet","hpMax":"9","speed":"21","coolness":"10","energy":"6","bgColor":"#383f62","flight":"0","regen":"0.00","passive":"1.00","energize":"3.00","actions":"2.00","shield":"0","evade":"15","freeMove":"2","attacks":"Splash\/Rain Attack\/Acid Rain\/Phantom Slash\/Boomerang\/Healing Water","immune":"burn"}); charSelect['Bush'] = new Character ({"id":"16","name":"Bush","hpMax":"13","speed":"21","coolness":"10","energy":"6","bgColor":"#5b3101","flight":"0","regen":"0.00","passive":"3.00","energize":"2.00","actions":"2.00","shield":"0","evade":"-5","freeMove":"1","attacks":"Quick Attack\/Wobble Ray\/Brick\/Thorn Shot\/Boom Flower\/Hamburger","immune":"hypnotize"}); charSelect['Fire-new'] = new Character ({"id":"17","name":"Fire-new","hpMax":"13","speed":"19","coolness":"16","energy":"6","bgColor":"#c17c1a","flight":"1","regen":"0.00","passive":"1.00","energize":"2.00","actions":"2.00","shield":"0","evade":"0","freeMove":"2","attacks":"Quick Attack\/Fireball\/Brick\/Dark Pulse\/Super Fireball\/Easy Heal","immune":"burn"}); charSelect['Leaf'] = new Character ({"id":"18","name":"Leaf","hpMax":"9","speed":"13","coolness":"6","energy":"7","bgColor":"#2ca52c","flight":"0","regen":"2.00","passive":"0.00","energize":"2.00","actions":"2.00","shield":"0","evade":"0","freeMove":"2","attacks":"Bees\/Red Flower\/Spin Attack\/Thorn Shot\/Rainbow Cannon\/Blue Flower","immune":"poison"}); charSelect['Violet'] = new Character ({"id":"19","name":"Violet","hpMax":"11","speed":"15","coolness":"6","energy":"6","bgColor":"#986fc6","flight":"0","regen":"0.00","passive":"1.00","energize":"3.00","actions":"2.00","shield":"0","evade":"10","freeMove":"2","attacks":"Pebble\/Red Flower\/Rain Attack\/Thorn Shot\/Boom Flower\/Mega Health","immune":"none"}); charSelect['Daisy'] = new Character ({"id":"20","name":"Daisy","hpMax":"14","speed":"11","coolness":"13","energy":"7","bgColor":"#a0c832","flight":"0","regen":"0.00","passive":"2.00","energize":"2.00","actions":"2.00","shield":"0","evade":"0","freeMove":"2","attacks":"Weak\/Red Flower\/Rainbow Blast\/Thorn Shot\/Eclipse\/Mega Health","immune":"poison"}); charSelect['Heart'] = new Character ({"id":"21","name":"Heart","hpMax":"18","speed":"9","coolness":"10","energy":"6","bgColor":"#b22c78","flight":"0","regen":"1.00","passive":"2.00","energize":"1.50","actions":"2.00","shield":"0","evade":"0","freeMove":"1","attacks":"Snowball\/Rainbow Blast\/Red Flower\/Heal Ray\/Mega Health\/Revival","immune":"none"}); charSelect['Torpedo'] = new Character ({"id":"22","name":"Torpedo","hpMax":"15","speed":"19","coolness":"7","energy":"5","bgColor":"#d9d9d9","flight":"1","regen":"0.00","passive":"1.00","energize":"2.00","actions":"2.00","shield":"0","evade":"25","freeMove":"1","attacks":"Bees\/Spin Attack\/Boomerang\/Loud Wave\/Brick\/Flying Cat","immune":"burn"}); charSelect['Metal'] = new Character ({"id":"23","name":"Metal","hpMax":"17","speed":"8","coolness":"23","energy":"5","bgColor":"#708090","flight":"0","regen":"0.00","passive":"1.00","energize":"1.50","actions":"2.00","shield":"1","evade":"0","freeMove":"0","attacks":"Weak\/Rock\/Spin Attack\/Axe Toss\/Chaos Blast\/Easy Heal","immune":"poison"}); charSelect['Sunny'] = new Character ({"id":"24","name":"Sunny","hpMax":"17","speed":"13","coolness":"9","energy":"6","bgColor":"#48f3ff","flight":"1","regen":"0.00","passive":"2.00","energize":"2.00","actions":"2.00","shield":"0","evade":"5","freeMove":"1","attacks":"Weak\/Fireball\/Phantom Slash\/Earth Quake\/Eclipse\/Hamburger","immune":"blind"}); charSelect['Tomato'] = new Character ({"id":"25","name":"Tomato","hpMax":"18","speed":"12","coolness":"8","energy":"8","bgColor":"#f4a460","flight":"0","regen":"-1.00","passive":"3.00","energize":"2.00","actions":"2.00","shield":"0","evade":"0","freeMove":"1","attacks":"Splash\/Zap\/Spin Attack\/Boomerang\/Tidal Wave\/Hamburger","immune":"none"}); charSelect['Sound'] = new Character ({"id":"26","name":"Sound","hpMax":"20","speed":"7","coolness":"10","energy":"3","bgColor":"#3c659a","flight":"0","regen":"0.00","passive":"0.00","energize":"2.00","actions":"2.50","shield":"1","evade":"10","freeMove":"1","attacks":"Pebble\/Fireball\/Loud Wave\/Dark Pulse\/Chaos Blast\/Mega Health","immune":"none"}); charSelect['Copper'] = new Character ({"id":"27","name":"Copper","hpMax":"19","speed":"9","coolness":"12","energy":"6","bgColor":"#698052","flight":"0","regen":"0.00","passive":"2.00","energize":"3.00","actions":"1.50","shield":"1","evade":"-5","freeMove":"1","attacks":"Quick Attack\/Spin Attack\/Lightning Card\/Loud Wave\/Boom Boom Gun\/Heal Ray","immune":"burn"}); charSelect['Luna'] = new Character ({"id":"28","name":"Luna","hpMax":"15","speed":"10","coolness":"11","energy":"7","bgColor":"#0e3262","flight":"1","regen":"0.00","passive":"2.00","energize":"2.00","actions":"2.00","shield":"0","evade":"5","freeMove":"2","attacks":"Snowball\/Rain Attack\/Rainbow Blast\/Phantom Slash\/Star Shower\/Mega Health","immune":"blind"}); console.log(charSelect); let ghostCharacter = {attacks: characterAttacks("Ghost")}; const descriptions = []; descriptions["Fire-new"] = "Fly and Freemove"; descriptions["Fire-og"] = "Shield 1"; descriptions["Water"] = "+1 Energize"; descriptions["Space"] = "Evasive, Shield, Fly, Freemove"; descriptions["Lightning"] = "Freemove, +1 passive"; descriptions["Leaf"] = "Regen 2, but no passive Energy"; descriptions["Violet"] = "+1E from energize, Freemove"; descriptions["Lava"] = "+.5 actions"; descriptions["Lava-Pixi"] = "+2E from Energize"; descriptions["Rock"] = "-1 Shield, but +1 passive"; descriptions["Hamster"] = "+.5 action, +energize, -evade"; descriptions["Heart-new"] = "Regen 1, +energize"; descriptions["Icicle"] = "1 Shield, -evade, +energize"; descriptions["Sheriff"] = "Evasive, +energize, -1 Shield"; descriptions["Metal"] = "+1 Shield, but only 1.5 energize"; descriptions["Bush"] = "-evade, +2E/turn"; descriptions["Sound"] = "evasive, shield, +.5 actions, 0 passive"; descriptions["Sunny"] = "Evasive, Fly, +1 passive"; descriptions["Torpedo"] = "Fly and Evasive"; descriptions["Heart"] = "Regen 1"; descriptions["Tomato"] = "Hurt 1/turn, but +2 passive"; descriptions["Kitty"] = "Made By Evy"; descriptions["Daisy"] = "2 Freemove and 2 passive"; descriptions["Droplet"] = "+3E from energize and evasive"; descriptions["Bob"] = "Low health, but very fast and can fly"; let html = ""; let html2 = ""; for (var key in charSelect) { let c = charSelect[key]; let description = ''; if (descriptions[key]) { description = descriptions[key]; } html2 += `
${c.name}

Hp:
${c.hpMax}

Spd:
${c.speed}

Cool:
${c.cool}

E:
${c.energy}

Special: ${description}

` } $(".char-select-grid").html(html2); function randomReaction(p, type, extra = "") { let name = characters[p].name; let theseOptions = reactions["default"][type]; if (reactions[name] && reactions[name][type]) { theseOptions = theseOptions.concat(reactions[name][type]); } let randomIndex = Math.floor(Math.random() * theseOptions.length); console.log(theseOptions[randomIndex]); return theseOptions[randomIndex]; } // Dialog System const reactions = []; reactions["default"] = {hit: ["I hit", "Success", "I got you"], critical: ["Woah, critical hit", "Critical Hit"], miss: ["Aww, I missed", "It was so close", "Next time I'll get it"], dodge: ["You missed me"], shield: ["Now I'll be safe"], energize: ["I'm ready now", "So much energy"], heal: ["Let me heal you", "Teamwork"], healed: ["Thanks for the help", "I feel better now"], aim: ["Ready, Aim..."], item: ["I found something", "This looks useful", "Oh nice"], death: ["Goodbye world", "I guess this is the end", "I'll have my revenge"], win: ["Yay I win","Good Game","That was fun"] } reactions["Fire-new"] = {dodge: ["Haha, you missed", "Did you think you could hit me?"], miss: ["How could I miss?", "The sun was in my eyes"], aim: ["Now I can't miss"], item: ["Maybe this will help me win"], win:["Of course I won","I win, that means I'm the best"], } reactions["Leaf"] = {dodge: ["Phew, that was scary", "Yay it missed"], hit: ["I actually did it"], miss: ["Oh well, I just missed"], aim: ["I have to try my best"], shield: ["This should protect me"], win: ["Woah, I really won"] } reactions["Heart"] = {hit: ["Sorry but I have to", "Please forgive me"], dodge: ["Why would you even try to hit me?"], heal: ["This is what I'm good at","How do you feel now?","Life and Peace"], healed: ["That's so nice of you"], item: ["What's this doing on the ground?"], death: ["Goodbye, I didn't really want to fight anyway"], critical: ["I didn't know I could do that"], win: ["I win, but you did good too"] } reactions["Lightning"] = {energize: ["Oh yeah, I feel the power","I eat energy for breakfast"], dodge: ["I'm just too fast for you","I won't let you hit me"], healed: ["Thanks, now I'm ready to fight again"], death: ["I don't want it to be over yet"], item: ["This thing looks cool, I want it"], win: ["That was an awesome game"], } reactions["Space"] = {dodge: ["I can warp space to make you miss","Lalala"], death: ["Aww, I really wanted to win","WAaaa"], shield: ["Aha, now I'm invincible"], win: ["I win, I did it"], } reactions["Water"] = {hit: ["That was too easy", "You can't escape me"], critical: ["My power is strong","Don't underestimate me"], miss: ["I won't make this mistake again", "Maybe I wanted to miss"], dodge: ["I am swift like a river"], shield: ["Bubble Shield protect me"], energize: ["My energy is returning to me"], heal: ["You owe me one", "Yeah, you're welcome"], healed: ["I really needed that"], aim: ["I've got my eye on you"], item: ["I can't believe this was just lying on the ground", "I'll take that"], death: ["Nooooo", "I feel this is the end for me"], win: ["I knew I could make it, And now I won"], } reactions["Rock"] = {hit: ["I guess I hit"], critical: ["That was a big hit"], miss: ["Oh well, doesn't really matter", "I missed but that's fine"], dodge: ["I was just standing still and you missed"], shield: ["I have to keep it together"], heal: ["That should help you"], healed: ["Thanks I guess"], aim: ["It'd be nice if I didn't miss this next shot"], item: ["A perfectly good item", "I almost didn't see this"], death: ["I guess that means I'm out", "Oh well, at least I tried"], win: ["I guess I win, that's a suprise"], } reactions["Metal"] = {hit: ["And that's another hit","Oh man, it's just a regular hit"], critical: ["I'm not even suprised by critical hits anymore","Cool, it's a critical hit"], miss: ["Argg, I missed"], dodge: ["Missed me by that much"], shield: ["My armor will deflect your attacks","I'm always happy with more shield"], heal: ["We can work together"], healed: ["Thanks"], aim: ["Maybe I can see better without sunglasses","Oh yeah, this next one for sure"], item: ["Cool, an item","I wonder how I'd look with this"], death: ["But I'm too cool to die"], win: ["I win the game. Radical"], }