You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

134 lines
4.9 KiB

#include <fstream>
#include <map>
#include <unistd.h>
#include "lib/Character.hpp"
#include "lib/Spell.hpp"
#include "lib/Element.hpp"
#include "lib/UserInterface.hpp"
#include "lib/BattleInterface.hpp"
#include "lib/Game.hpp"
std::string loadFlag()
{
std::string flagString;
std::ifstream flagFile("flag.txt");
flagFile >> flagString;
flagFile.close();
return flagString;
}
int main()
{
alarm(600);
srand(time(0));
std::string flag = loadFlag();
Game::init();
UserInterface::welcomeMessage();
UserInterface::epilogue();
Game::PlayerParty.push_back(UserInterface::characterCreation());
while (player->isAlive() && !UserInterface::isGameOver())
{
int choiceInt = -1;
char choiceChar = -1;
UserInterface::menu();
choiceInt = UserInterface::getNumber(
"What are you gonna do today?\n>",
0, 6);
switch (choiceInt)
{
case 0:
UserInterface::print("You commit sudoku...\n");
UserInterface::print("Was it supposed to be seppuku?\n");
UserInterface::print("Nevermind, you killed yourself.\n");
player->kill();
break;
case 1:
UserInterface::print("You spend the whole day sleeping...\n");
UserInterface::print("HP and MP restored.\n");
player->rest();
break;
case 2:
UserInterface::print("You practice your magic in the yard...\n");
UserInterface::print("You gained some experience.\n");
player->increaseExperience((random() % player->getLevel()) + 1);
break;
case 3:
UserInterface::print("List of your classmates:\n");
UserInterface::enemiesInfo(enemies);
choiceInt = UserInterface::getNumber("Who would you prefer to train with?\n>", 0, enemies.size());
UserInterface::print("You are going to spar with:\n");
UserInterface::characterInfo(enemies.at(choiceInt));
UserInterface::print("Are you sure? (y/N)\n>");
std::cin >> choiceChar;
if (choiceChar == 'y' || choiceChar == 'Y')
{
enemy = new Character(*enemies.at(choiceInt));
battle = BattleInterface(player, enemy);
battle.start();
if (battle.getWinner() == player)
{
UserInterface::print("You win, you get more experience...\n");
player->increaseExperience(enemies.at(choiceInt)->getLevel());
}
else
{
UserInterface::print("You lose, but you still get some experience...\n");
player->revive();
player->increaseExperience(enemies.at(choiceInt)->getLevel() / 2);
}
delete enemy;
}
else
{
UserInterface::print("On second thought, you decide to sleep in your room instead...\n");
player->rest();
}
break;
case 4:
UserInterface::print("You are going to challenge the Arch-Mage...\n");
UserInterface::print("Are you sure? (y/N)\n>");
std::cin >> choiceChar;
if (choiceChar == 'y' || choiceChar == 'Y')
{
battle = BattleInterface(player, archMage);
battle.start();
if (battle.getWinner() == player)
{
UserInterface::print("You win, you get more experience...\n");
player->increaseExperience(enemies.at(choiceInt)->getLevel());
UserInterface::print("You win against the Arch-Mage!\n");
UserInterface::print("He let you take a glimpse to the scroll that you always wanted...\n");
UserInterface::print("Turns out the content is just some meaningless word...\n");
UserInterface::print("Here is the content:\n");
UserInterface::print(flag + "\n");
}
else
{
UserInterface::print("You lose...\n");
UserInterface::print("Sadly his spell was to powerful,\n");
UserInterface::print("You got killed by the arch-mage...\n");
}
}
else
{
UserInterface::print("On second thought, you decide to sleep in your room instead...\n");
player->rest();
}
break;
case 5:
UserInterface::print("You found some info about the arch-mage:\n");
UserInterface::characterInfo(archMage);
break;
case 6:
UserInterface::print("You meditate and got some insight to your ability:\n");
UserInterface::characterInfo(player);
break;
}
UserInterface::nextDay();
}
}