From 6c6e4d32ed09f1528302db208466025bc0a7b344 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sat, 28 Jan 2023 18:51:10 +0100 Subject: [PATCH] prod: created function create randomized enemy --- src/c/encounter.c | 36 ++++++++++++++++++++++++++++++++++++ src/c/encounter.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/src/c/encounter.c b/src/c/encounter.c index aa8287d..2c25444 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -201,4 +201,40 @@ void setEnemyExp(enemy* enemy, int newExp){ int getEnemyGold(enemy* enemy){ return enemy->gold; +} +int setEnemyGold(enemy* enemy, int newGold){ + enemy->gold = newGold; +} + +int createRandomEnemy(enemy* enemy) +{ + int enemyType = randomIntRange(1, 3); + switch(enemyType) + { + case 1: + setEnemyHealth(enemy, 20); + setEnemyDamage(enemy, 5); + setEnemyArmor(enemy, 2); + setEnemyHealPotions(enemy, 1); + setEnemyExp(enemy, 10); + setEnemyGold(enemy, 10); + break; + case 2: + setEnemyHealth(enemy, 30); + setEnemyDamage(enemy, 10); + setEnemyArmor(enemy, 5); + setEnemyHealPotions(enemy, 2); + setEnemyExp(enemy, 20); + setEnemyGold(enemy, 20); + break; + case 3: + setEnemyHealth(enemy, 40); + setEnemyDamage(enemy, 15); + setEnemyArmor(enemy, 10); + setEnemyHealPotions(enemy, 3); + setEnemyExp(enemy, 30); + setEnemyGold(enemy, 30); + break; + } + return enemyType; } \ No newline at end of file diff --git a/src/c/encounter.h b/src/c/encounter.h index 071861f..796f555 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -46,4 +46,6 @@ void setEnemyHealPotions(enemy* enemy, int newPotions); int getEnemyExp(enemy* enemy); void setEnemyExp(enemy* enemy, int newExp); +int createRandomEnemy(enemy* enemy); + #endif \ No newline at end of file