diff --git a/client/src/scenes/combat.cryps.js b/client/src/scenes/combat.cryps.js index d33c490d..ad64ca21 100644 --- a/client/src/scenes/combat.cryps.js +++ b/client/src/scenes/combat.cryps.js @@ -84,7 +84,7 @@ class CrypImage extends Phaser.GameObjects.Image { // Add cryp name scene.add.text(nameX, nameY, cryp.name, TEXT.NORMAL).setOrigin(team, 0); // Add cryp stat bars - this.healthBar = scene.add.existing(new StatBar(scene, this, 'HP')); + this.health = scene.add.existing(new StatBar(scene, this, 'HP')); this.armour = scene.add.existing(new StatBar(scene, this, 'Armour')); this.evasion = scene.add.existing(new StatBar(scene, this, 'Evasion')); this.spellShield = scene.add.existing(new StatBar(scene, this, 'Spell Shield')); @@ -114,10 +114,27 @@ class CrypImage extends Phaser.GameObjects.Image { this.statusText.text = ''; } - takeDamage(damage) { - if (damage > 0) this.setTint(0xff0000); - else this.setTint(0x00bb00); - this.healthBar.takeDamage(damage); + reduceDefense(amount, type) { + if (type === 'PhysDmg') { + this.armour.takeDamage(amount); + } else if (type === 'SpellDmg') { + this.spellShield.takeDamage(amount); + } + } + + takeDamage(props) { + const { amount, mitigation, category } = props; + if (mitigation) this.reduceDefense(mitigation, category); + this.setTint(0xff0000); + this.health.takeDamage(amount); + this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => { + if (this.state !== 'ko') this.clearTint(); + }); + } + + takeHealing(amount) { + this.setTint(0x00bb00); + this.health.takeDamage(amount * -1); this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => { if (this.state !== 'ko') this.clearTint(); }); @@ -171,8 +188,8 @@ class CombatCryps extends Phaser.Scene { const crypObj = this.cryps.children.entries .find(c => c.cryp.id === cryp.id) || renderCryp(cryp, iter, team); - crypObj.healthBar.hp = cryp.hp.base; - crypObj.healthBar.drawStatBar(); + crypObj.health.hp = cryp.hp.base; + crypObj.health.drawStatBar(); crypObj.effects.update(cryp.effects); }; diff --git a/client/src/scenes/combat.render.resolutions.js b/client/src/scenes/combat.render.resolutions.js index 11c5fbb2..29eeeb61 100644 --- a/client/src/scenes/combat.render.resolutions.js +++ b/client/src/scenes/combat.render.resolutions.js @@ -88,12 +88,12 @@ function animatePhase(scene, game, resolution, cb) { const [resultType, values] = result; if (resultType === 'Damage') { - targetSpawn.takeDamage(values.amount); + targetSpawn.takeDamage(values); scene.registry.set('gameLog', scene.registry.get('gameLog') + 1); return setTimeout(tickCb, DAMAGE_TICK); } if (resultType === 'Healing') { - targetSpawn.takeDamage(values.amount * -1); + targetSpawn.takeHealing(values.amount); scene.registry.set('gameLog', scene.registry.get('gameLog') + 1); return setTimeout(tickCb, DAMAGE_TICK); } diff --git a/client/src/scenes/elements/combat.statbar.js b/client/src/scenes/elements/combat.statbar.js index ead70ccb..8b6e234f 100644 --- a/client/src/scenes/elements/combat.statbar.js +++ b/client/src/scenes/elements/combat.statbar.js @@ -78,7 +78,7 @@ class StatBar extends Phaser.GameObjects.Graphics { } else { this.val = (this.val - value > this.max) ? this.max : this.val -= value; } - if (this.val === 0) this.crypObj.setKo(); + if (this.val === 0 && this.type === 'HP') this.crypObj.setKo(); this.drawStatBar(); } } diff --git a/client/src/scenes/item.list.js b/client/src/scenes/item.list.js index b58c863e..39797917 100644 --- a/client/src/scenes/item.list.js +++ b/client/src/scenes/item.list.js @@ -12,7 +12,7 @@ const Y = ITEM_LIST.y(); const WIDTH = ITEM_LIST.width(); const HEIGHT = ITEM_LIST.height(); const ITEM_WIDTH = WIDTH * 0.4; -const ITEM_HEIGHT = HEIGHT * 0.1; +const ITEM_HEIGHT = HEIGHT * 0.08; const itemCheckHitbox = (scenePlugin, pointer) => { const { list } = scenePlugin.get('MenuCrypList').children;