From 6b9ae24cbfbc680833d40195bdcaaf7b8bd0d60d Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 19 Aug 2018 14:31:08 -0300 Subject: Curasa --- index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index a57f8af..a0cda18 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const randomIndex = arr => Math.floor(Math.random() * arr.length) const chainDatabase = { fire: ['fire', 'fira', 'firaga'], cure: ['cure'], + curasa: ['curasa'], blizz: ['blizz', 'blizzara', 'blizzaga'], aqua: ['aqua', 'aquara', 'aquaga'] } @@ -20,6 +21,8 @@ const actionDatabase = { cure: {id: 'cure', chain: 'cure', label: 'Cure', size: 1, target: 'ally', color: '#AFA', heal: 80}, + curasa: {id: 'curasa', chain: 'curasa', label: 'Curasa', size: 1, target: 'ally', color: '#AFA', healRelativeToDamageTaken: 0.25}, + blizz: {id: 'blizz', chain: 'blizz', label: 'Blizz', size: 1, target: 'enemy', color: '#AAF', damage: 15, stun: 0.2}, blizzara: {id: 'blizzara', chain: 'blizz', label: 'Blizzara', size: 2, target: 'enemy', color: '#AAF', damage: 30, stun: 0.35}, blizzaga: {id: 'blizzaga', chain: 'blizz', label: 'Blizzaga', size: 3, target: 'enemy', color: '#AAF', damage: 45, stun: 0.5}, @@ -562,9 +565,8 @@ class TargetMenu extends BaseBattleMenu { .map(char => ({label: char.name, battleCharacter: char})) // If the top action is a 'cure' action, pick the character with the least health by default. - // TODO: Some property like "healsAlive" on the action itself, so things like potions (which target one) are also affected by this const lastAction = last(this.battle.playerCharacter.atbBar.queuedActions) - if (lastAction && lastAction.chain === 'cure') { + if (lastAction && (lastAction.heal || lastAction.healRelativeToDamageTaken)) { const allies = this.battle.playerCharacter.team.characters const aliveCharacter = allies.find(c => !c.dead) const mostHurtCharacter = allies.reduce((a, b) => (b.hp < a.hp && !b.dead ? b : a), aliveCharacter) @@ -779,7 +781,7 @@ class BattleCharacter extends Sprite { takeDamage(damage) { if (!this.dead) { - this.hp -= damage + this.hp -= Math.round(damage) if (this.hp <= 0) { this.died() } @@ -788,7 +790,7 @@ class BattleCharacter extends Sprite { recoverHP(amount) { if (!this.dead) { - this.hp = Math.min(this.maxHP, this.hp + amount) + this.hp = Math.min(this.maxHP, this.hp + Math.round(amount)) } } @@ -1075,6 +1077,7 @@ class Battle { showTargetTypeMenu() { this.changeMenuAnim = {old: this.currentMenu, direction: -1, time: 1} this.currentMenu = this.targetTypeMenu + this.targetTypeMenu.currentOptionIndex = this.targetTypeMenu.options.findIndex(opt => opt.targetType === this.playerCharacter.targetType) } showActionMenu({direction}) { @@ -1210,6 +1213,8 @@ class MagicProjectile { if (this.action.stun) this.target.addStunTime(this.action.stun || 0) } else if (this.action.target === 'ally') { if (this.action.heal) this.target.recoverHP(this.action.heal) + const { healRelativeToDamageTaken: rel } = this.action + if (rel) this.target.recoverHP(rel * (this.target.maxHP - this.target.hp)) } this.discarded = true } @@ -1273,7 +1278,7 @@ const battle = new Battle({ teamData: [ {characterData: [ {x: -55, y: 190, name: 'Ren', hp: 600, maxHP: 600, knownActions: ['fire', 'fira', 'firaga', 'blizz', 'blizzara', 'cure']}, - {x: -75, y: 225, name: 'Fie', hp: 475, maxHP: 475, knownActions: ['fire', 'blizz', 'blizzara', 'blizzaga', 'aqua', 'aquara']} + {x: -75, y: 225, name: 'Fie', hp: 475, maxHP: 475, knownActions: ['fire', 'blizz', 'blizzara', 'blizzaga', 'aqua', 'aquara', 'curasa']} ]}, {characterData: [ {x: 80, y: 200, aiID: 'manasvinWarmech', name: 'Manasvin Warmech', hp: 1600, maxHP: 1600, knownActions: ['aqua', 'aquaga', 'manasvinSwipe', 'manasvinRecover']} -- cgit 1.3.0-6-gf8a5