Commit 78603129 by krkane

Update gameBase.c

parent 11460f8a
Showing with 15 additions and 16 deletions
...@@ -37,10 +37,10 @@ int Move(int defeated_enemies) ...@@ -37,10 +37,10 @@ int Move(int defeated_enemies)
" süngem kui teine.\n" " süngem kui teine.\n"
"Süda puperdades mõtled sa, millisesse neist suunduda.\n\n"); "Süda puperdades mõtled sa, millisesse neist suunduda.\n\n");
// Genereerime juhusliku arvu, et määrata, milline käik on õige // 50/50 coinflip
int correctChoice = rand() % 2 + 1; int correctChoice = rand() % 2 + 1;
// Kui see on esimene vaenlane, siis pole mõtet lisada õiget ja vale valikut // Not on the first turn
if (defeated_enemies == 0) if (defeated_enemies == 0)
{ {
printf("1. Vasakule\n" printf("1. Vasakule\n"
...@@ -49,7 +49,7 @@ int Move(int defeated_enemies) ...@@ -49,7 +49,7 @@ int Move(int defeated_enemies)
} }
else else
{ {
// Kui see pole esimene vaenlane, siis määrame vasaku ja parema käigu vastavalt juhuslikult // Used on the second turn
printf("1. %s\n", (correctChoice == 1) ? "Mine vasakule" : printf("1. %s\n", (correctChoice == 1) ? "Mine vasakule" :
"Mine paremale"); "Mine paremale");
printf("2. %s\n", (correctChoice == 2) ? "Mine vasakule" printf("2. %s\n", (correctChoice == 2) ? "Mine vasakule"
...@@ -111,7 +111,7 @@ int Move(int defeated_enemies) ...@@ -111,7 +111,7 @@ int Move(int defeated_enemies)
else else
{ {
printf("Vale valik. Palun vali uuesti.\n"); printf("Vale valik. Palun vali uuesti.\n");
return Move(defeated_enemies); // Rekursiivselt kutsu Move funktsiooni uuesti, et saaksid uue valiku teha return Move(defeated_enemies); // Reinitiate cycle
} }
} }
...@@ -120,7 +120,7 @@ int fight(Player *p, Enemy *e) ...@@ -120,7 +120,7 @@ int fight(Player *p, Enemy *e)
int playerHp = p->health; int playerHp = p->health;
int enemyHp = e->health; int enemyHp = e->health;
int playerAttack, enemyAttack; int playerAttack, enemyAttack;
int escaped = 0; // Flag variable to track if player escaped int escaped = 0; // To track if player escaped
int initialHealth = p->health; // Store initial health int initialHealth = p->health; // Store initial health
while (playerHp > 0 && enemyHp > 0 && !escaped) while (playerHp > 0 && enemyHp > 0 && !escaped)
...@@ -174,7 +174,7 @@ int fight(Player *p, Enemy *e) ...@@ -174,7 +174,7 @@ int fight(Player *p, Enemy *e)
if (playerHp <= 0) if (playerHp <= 0)
{ {
printf("Kahjuks, sa kaotasid.\n"); printf("Kahjuks, sa kaotasid.\n");
return 0; // Mängija kaotas return 0; // Player lost
} }
else if (enemyHp <= 0) else if (enemyHp <= 0)
{ {
...@@ -190,7 +190,7 @@ int bossFight(Player *p, FinalBoss *boss) ...@@ -190,7 +190,7 @@ int bossFight(Player *p, FinalBoss *boss)
int playerHp = p->health; int playerHp = p->health;
int bossHp = boss->health; int bossHp = boss->health;
int playerAttack, bossAttack; int playerAttack, bossAttack;
int escaped = 0; // Flag variable to track if player escaped int escaped = 0; // track if player escaped
int initialHealth = p->health; // Store initial health int initialHealth = p->health; // Store initial health
int specialAttack = 0; int specialAttack = 0;
...@@ -274,7 +274,7 @@ int bossFight(Player *p, FinalBoss *boss) ...@@ -274,7 +274,7 @@ int bossFight(Player *p, FinalBoss *boss)
{ {
printf("\nSu keha ei pidanud löögile vastu ning jooksid nii energiast kui ka verest tühjaks." printf("\nSu keha ei pidanud löögile vastu ning jooksid nii energiast kui ka verest tühjaks."
"\nKahjuks, sa kaotasid.\n"); "\nKahjuks, sa kaotasid.\n");
return 0; // Mängija kaotas return 0; // Player lost
} }
} }
specialAttack++; specialAttack++;
...@@ -283,7 +283,7 @@ int bossFight(Player *p, FinalBoss *boss) ...@@ -283,7 +283,7 @@ int bossFight(Player *p, FinalBoss *boss)
if (playerHp <= 0) if (playerHp <= 0)
{ {
printf("\nKahjuks, sa kaotasid.\n"); printf("\nKahjuks, sa kaotasid.\n");
return 0; // Mängija kaotas return 0; // Player lost
} }
else if (bossHp <= 0) else if (bossHp <= 0)
{ {
...@@ -348,8 +348,8 @@ int usePotion(Player *p, int initialHealth, int currentHealth) ...@@ -348,8 +348,8 @@ int usePotion(Player *p, int initialHealth, int currentHealth)
void levelUp(Player *p) void levelUp(Player *p)
{ {
p->health += LEVEL_UP_HP; // Lisame mängijale 20 HP-d p->health += LEVEL_UP_HP; // add 20 HP to base
p->attack += LEVEL_UP_ATTACK; // Lisame mängijale 5 rünnakuvõimet p->attack += LEVEL_UP_ATTACK; // add 5 attack to base
printf("Mängija taseme tõus! Sa said 20 lisa HP-d ja 5 lisa rünnakuvõimet" printf("Mängija taseme tõus! Sa said 20 lisa HP-d ja 5 lisa rünnakuvõimet"
"!\n"); "!\n");
printf("Mängija andmed: HP - %d, rünnakuvõime - %d\n\n", p->health, printf("Mängija andmed: HP - %d, rünnakuvõime - %d\n\n", p->health,
...@@ -359,10 +359,10 @@ void levelUp(Player *p) ...@@ -359,10 +359,10 @@ void levelUp(Player *p)
Enemy CreateEnemy(int defeated_enemies) Enemy CreateEnemy(int defeated_enemies)
{ {
Enemy enemy; Enemy enemy;
// Genereeri vaenlase elude arv, kasutades alistatud vastaste arvu // Generate enemy hp based on defeated enemies
enemy.health = 50 + defeated_enemies * 10; // Näiteks 50 + (10 * alistatud vastaste arv) enemy.health = 50 + defeated_enemies * 10;
// Määra vaenlase rünnaku tugevus vastavalt tüübile // generate enemy type and attack damage
switch (defeated_enemies) switch (defeated_enemies)
{ {
case 0: case 0:
...@@ -392,8 +392,7 @@ Enemy CreateEnemy(int defeated_enemies) ...@@ -392,8 +392,7 @@ Enemy CreateEnemy(int defeated_enemies)
FinalBoss CreateFinalBoss(int defeated_enemies) FinalBoss CreateFinalBoss(int defeated_enemies)
{ {
FinalBoss boss; FinalBoss boss;
// Adjust boss stats based on the number of defeated enemies //Boss stats based on the number of defeated enemies
// You can customize the boss's stats and type based on the game's design
boss.health = BOSS_HEALTH + defeated_enemies * 20; boss.health = BOSS_HEALTH + defeated_enemies * 20;
boss.attack = BOSS_DAMAGE + defeated_enemies * 5; boss.attack = BOSS_DAMAGE + defeated_enemies * 5;
strcpy(boss.type, "Final Boss"); strcpy(boss.type, "Final Boss");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment