Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
krkane
/
Rüütli Vaev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
78603129
authored
Mar 21, 2024
by
krkane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update gameBase.c
parent
11460f8a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
Source/gameBase.c
Source/gameBase.c
View file @
78603129
...
@@ -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
);
// Re
kursiivselt kutsu Move funktsiooni uuesti, et saaksid uue valiku teha
return
Move
(
defeated_enemies
);
// Re
initiate 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 t
o track if player escaped
int
escaped
=
0
;
//
T
o 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
(
"
\n
Su keha ei pidanud löögile vastu ning jooksid nii energiast kui ka verest tühjaks."
printf
(
"
\n
Su keha ei pidanud löögile vastu ning jooksid nii energiast kui ka verest tühjaks."
"
\n
Kahjuks, sa kaotasid.
\n
"
);
"
\n
Kahjuks, 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
(
"
\n
Kahjuks, sa kaotasid.
\n
"
);
printf
(
"
\n
Kahjuks, 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
;
// Gener
eeri vaenlase elude arv, kasutades alistatud vastaste arvu
// Gener
ate 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üübil
e
//
generate enemy type and attack damag
e
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"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment