From d4e69bb3ff201066dfb40d9e4fa781720e2b70c9 Mon Sep 17 00:00:00 2001 From: OfficialCHenry Date: Fri, 22 Apr 2022 12:35:36 -0400 Subject: [PATCH] fixed shield generation, fixed addhealth --- src/shattered_sword/GameSystems/BattleManager.ts | 8 ++++---- src/shattered_sword/Player/PlayerController.ts | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/shattered_sword/GameSystems/BattleManager.ts b/src/shattered_sword/GameSystems/BattleManager.ts index a2b27ce..5157a17 100644 --- a/src/shattered_sword/GameSystems/BattleManager.ts +++ b/src/shattered_sword/GameSystems/BattleManager.ts @@ -22,11 +22,9 @@ export default class BattleManager { enemy.damage(Math.round(weapon.type.damage * (this.players[0]).CURRENT_ATK/100)); //console.log("enemy took dmg"); - //TODO - test shield, //add checking for each onhit buff here let player = (this.players[0]); - - player.addShield(1); + //DOTS if(player.hasBleed){ (enemy).bleedCounter +=3; @@ -52,7 +50,9 @@ export default class BattleManager { for (let player of this.players) { if (weapon.hits(player.owner)) { (player).damage(weapon.type.damage, user); - + if((player).hasShield){ + (player).addShield(weapon.type.damage * .5); //half of dmg taken is converted to shield + } } } } diff --git a/src/shattered_sword/Player/PlayerController.ts b/src/shattered_sword/Player/PlayerController.ts index 29466ce..36d029e 100644 --- a/src/shattered_sword/Player/PlayerController.ts +++ b/src/shattered_sword/Player/PlayerController.ts @@ -300,7 +300,10 @@ export default class PlayerController extends StateMachineAI implements BattlerA * @param health health to give player */ addHealth(health : number){ - this.CURRENT_HP = (this.CURRENT_HP + health) %this.MAX_HP + this.CURRENT_BUFFS.hp; + this.CURRENT_HP += health; + if(this.CURRENT_HP > this.MAX_HP + this.CURRENT_BUFFS.hp){ + this.CURRENT_HP = this.MAX_HP + this.CURRENT_BUFFS.hp; + } } /**