Commit eeb8e691 by grlabu

Replace main.c

parent 89ae5fee
Showing with 22 additions and 158 deletions
#include "Header.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "bossdefeated.h"
#include "ui_bossdefeated.h"
int main(void)
{
srand(time(NULL));
PrintWelcomeMessage();
int selection;
char *saveFile = "GameSave.txt";
while (1)
{
selection = Menu();
switch(selection)
{
case 1:
{
int gameState = 1;
Player player = CreatePlayer();
int defeatedEnemies = 0;
#include <QApplication>
#include <QDebug>
while (gameState == 1)
{
int moveResult = Move(defeatedEnemies);
if (moveResult == LOSE_HP)
{ // Player encountered a trap
handleTrap(&player);
continue; // Restart the loop, allowing the player to choose the path again
}
if (moveResult == SAVE_GAME)
{
SaveGame(saveFile, &player, defeatedEnemies);
return EXIT_SUCCESS;
}
else if (moveResult == 0)
{
gameState = 0;
}
else if (moveResult == 1)
{
if (defeatedEnemies < NUM_HENCHMEN)
{
Enemy enemy = CreateEnemy(defeatedEnemies);
printf("\nKohtasid vastast tüübiga %s, %dHP ja rünnaku tugevusega"
" %d.\n", enemy.type, enemy.health,
enemy.attack);
gameState = fight(&player, &enemy);
}
else
{
// Generate the final boss
FinalBoss boss = CreateFinalBoss(defeatedEnemies);
printf("\nOled jõudmas koopa lõppu ning "
"äkitselt märkasid pealikku %s, %dHP ja"
" rünnaku tugevusega"
" %d.\n", boss.type, boss.health,
boss.attack);
gameState = bossFight(&player, &boss);
}
if (gameState == 0)
{
return EXIT_SUCCESS;
}
if (gameState == SAVE_GAME)
{
SaveGame(saveFile, &player, defeatedEnemies);
return EXIT_SUCCESS;
}
BossDefeated::BossDefeated(QWidget *parent)
: QDialog(parent)
, ui(new Ui::BossDefeated)
{
qDebug() << "boss defeated";
ui->setupUi(this);
}
defeatedEnemies++;
levelUp(&player);
}
}
break;
}
case 2:
DisplayGameRules();
break;
case 3:
{
int gameState = 1;
Player player;
int defeatedEnemies;
LoadGame(saveFile, &player, &defeatedEnemies);
while (gameState == 1)
{
int moveResult = Move(defeatedEnemies);
if (moveResult == LOSE_HP)
{ // Player encountered a trap
handleTrap(&player);
continue; // Restart the loop, allowing the player to choose the path again
}
if (moveResult == SAVE_GAME)
{
SaveGame(saveFile, &player, defeatedEnemies);
return EXIT_SUCCESS;
}
else if (moveResult == 0)
{
gameState = 0;
}
else if (moveResult == 1)
{
if (defeatedEnemies < NUM_HENCHMEN)
{
Enemy enemy = CreateEnemy(defeatedEnemies);
printf("\nKohtasid vastast tüübiga %s, %dHP ja rünnaku tugevusega"
" %d.\n", enemy.type, enemy.health,
enemy.attack);
gameState = fight(&player, &enemy);
}
else
{
// Generate the final boss
FinalBoss boss = CreateFinalBoss(defeatedEnemies);
printf("\nOled jõudmas koopa lõppu ning "
"äkitselt märkasid pealikku %s, %dHP ja"
" rünnaku tugevusega"
" %d.\n", boss.type, boss.health,
boss.attack);
gameState = bossFight(&player, &boss);
}
if (gameState == 0)
{
return EXIT_SUCCESS;
}
if (gameState == SAVE_GAME)
{
SaveGame(saveFile, &player, defeatedEnemies);
return EXIT_SUCCESS;
}
BossDefeated::~BossDefeated()
{
delete ui;
}
defeatedEnemies++;
levelUp(&player);
}
}
break;
}
case 0:
printf("VÄLJUN...\n\n");
return EXIT_SUCCESS;
}
}
return 0;
void BossDefeated::on_pushButton_2_clicked()
{
qApp->exit(0);
}
void BossDefeated::on_pushButton_clicked()
{
qApp->exit(0);
}
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