Browse Source

refactoring: changed enemyHeal function

remotes/origin/thirdcycle
Kai Kehres 2 years ago
parent
commit
c00b79a1f1
  1. 8
      src/c/encounter.c

8
src/c/encounter.c

@ -51,13 +51,11 @@ int playerDamaged(enemy* enemy, Character* character)
void enemyHeal(enemy *enemy, int healAmount)
{
int currentHealth = getEnemyHealth(enemy);
int maxHealth = getEnemyMaxHealth(enemy);
if (currentHealth + healAmount > maxHealth)
if (getEnemyHealth(enemy) + healAmount > getEnemyMaxHealth(enemy))
{
healAmount = maxHealth - currentHealth;
healAmount = getEnemyMaxHealth(enemy) - getEnemyHealth(enemy);
}
setEnemyHealth(enemy, currentHealth + healAmount);
setEnemyHealth(enemy, getEnemyHealth(enemy) + healAmount);
}
void enemyDamaged(enemy *enemy, int damage)

Loading…
Cancel
Save