|
|
@ -37,7 +37,7 @@ int playerHealth(int health, int damage, int armor) |
|
|
|
|
|
|
|
int enemyDamaged(enemy enemy, int damage) |
|
|
|
{ |
|
|
|
int armor = getEnemyInt(&enemy.armor); |
|
|
|
int armor = getEnemyArmor(&enemy); |
|
|
|
int damagedealt = damage - armor; |
|
|
|
if (damagedealt < 1) |
|
|
|
{ |
|
|
@ -47,27 +47,7 @@ int enemyDamaged(enemy enemy, int damage) |
|
|
|
return enemy.health; |
|
|
|
} |
|
|
|
|
|
|
|
// Getter/Setter Funktionen |
|
|
|
void *setEnemyHealth(int *num, int health) |
|
|
|
{ |
|
|
|
*num = health; |
|
|
|
// return health; |
|
|
|
} |
|
|
|
|
|
|
|
void *setEnemyDamage(int *num, int damage) |
|
|
|
{ |
|
|
|
*num = damage; |
|
|
|
} |
|
|
|
|
|
|
|
void *setEnemyArmor(int *num, int armor) |
|
|
|
{ |
|
|
|
*num = armor; |
|
|
|
} |
|
|
|
|
|
|
|
int getEnemyInt(int *structParam) |
|
|
|
{ |
|
|
|
return *structParam; |
|
|
|
} |
|
|
|
|
|
|
|
int switchTurns(int currentTurn) |
|
|
|
{ |
|
|
@ -78,7 +58,7 @@ int switchTurns(int currentTurn) |
|
|
|
int fight(int playerH, int playerDamage, int playerArmor, int playerAttack, enemy enemy) |
|
|
|
{ |
|
|
|
int currentTurn = 0; |
|
|
|
while (playerAlive(playerH) && getEnemyInt(&enemy.health) > 0) |
|
|
|
while (playerAlive(playerH) && getEnemyHealth(&enemy) > 0) |
|
|
|
{ |
|
|
|
if (currentTurn == 0) |
|
|
|
{ |
|
|
@ -86,7 +66,7 @@ int fight(int playerH, int playerDamage, int playerArmor, int playerAttack, enem |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
playerH = playerHealth(playerH, getEnemyInt(&enemy.damage), playerArmor); |
|
|
|
playerH = playerHealth(playerH, getEnemyDamage(&enemy), playerArmor); |
|
|
|
} |
|
|
|
currentTurn = switchTurns(currentTurn); |
|
|
|
} |
|
|
@ -99,3 +79,41 @@ int fight(int playerH, int playerDamage, int playerArmor, int playerAttack, enem |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Getter/Setter Funktionen |
|
|
|
void *setEnemyHealth(int *num, int health) |
|
|
|
{ |
|
|
|
*num = health; |
|
|
|
// return health; |
|
|
|
} |
|
|
|
|
|
|
|
void *setEnemyDamage(int *num, int damage) |
|
|
|
{ |
|
|
|
*num = damage; |
|
|
|
} |
|
|
|
|
|
|
|
void *setEnemyArmor(int *num, int armor) |
|
|
|
{ |
|
|
|
*num = armor; |
|
|
|
} |
|
|
|
|
|
|
|
int getEnemyHealth(enemy* enemy) |
|
|
|
{ |
|
|
|
return enemy->health; |
|
|
|
} |
|
|
|
|
|
|
|
int getEnemyArmor(enemy* enemy) |
|
|
|
{ |
|
|
|
return enemy->armor; |
|
|
|
} |
|
|
|
|
|
|
|
int getEnemyDamage(enemy* enemy) |
|
|
|
{ |
|
|
|
return enemy->damage; |
|
|
|
} |
|
|
|
|
|
|
|
int getEnemyAttack(enemy* enemy) |
|
|
|
{ |
|
|
|
return enemy->attack; |
|
|
|
} |