Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

150 rindas
5.4 KiB

pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
  1. #include <iostream>
  2. #include <fstream>
  3. #include <thread>
  4. #include <chrono>
  5. #include <random>
  6. #include <fstream>
  7. #include <unistd.h>
  8. #include "lib/Character.hpp"
  9. #include "lib/Spell.hpp"
  10. #include "lib/UserInterface.hpp"
  11. #include "lib/BattleInterface.hpp"
  12. std::string loadFlag()
  13. {
  14. std::string flagString;
  15. std::ifstream flagFile("flag.txt");
  16. flagFile >> flagString;
  17. flagFile.close();
  18. return flagString;
  19. }
  20. int main()
  21. {
  22. std::string flag;
  23. Character *player;
  24. Character *archMage;
  25. Character *enemy;
  26. BattleInterface battle;
  27. std::vector<Character *> enemies;
  28. flag = loadFlag();
  29. srand(time(0));
  30. alarm(600);
  31. UserInterface::welcomeMessage();
  32. UserInterface::epilogue();
  33. player = UserInterface::characterCreation();
  34. archMage = new Character("Arch-Mage", 500, 0, 5000, 5000, 1, 1);
  35. enemies = {
  36. new Character("Abby", 1, 1, 10, 5, 1, 1),
  37. new Character("John", 2, 3, 20, 10, 1, 1),
  38. new Character("Adam", 3, 7, 40, 25, 1, 1),
  39. new Character("Christo", 4, 11, 80, 40, 1, 1),
  40. new Character("Greg", 5, 16, 160, 80, 1, 1),
  41. };
  42. while (player->isAlive() && !UserInterface::isGameOver())
  43. {
  44. int choiceInt = -1;
  45. char choiceChar = -1;
  46. UserInterface::menu();
  47. choiceInt = UserInterface::getNumber(
  48. "What are you gonna do today?\n>",
  49. 0, 6);
  50. switch (choiceInt)
  51. {
  52. case 0:
  53. UserInterface::print("You commit sudoku...\n");
  54. UserInterface::print("Was it supposed to be seppuku?\n");
  55. UserInterface::print("Nevermind, you killed yourself.\n");
  56. player->kill();
  57. break;
  58. case 1:
  59. UserInterface::print("You spend the whole day sleeping...\n");
  60. UserInterface::print("HP and MP restored.\n");
  61. player->rest();
  62. break;
  63. case 2:
  64. UserInterface::print("You practice your magic in the yard...\n");
  65. UserInterface::print("You gained some experience.\n");
  66. player->increaseExperience((random() % player->getLevel()) + 1);
  67. break;
  68. case 3:
  69. UserInterface::print("List of your classmates:\n");
  70. UserInterface::enemiesInfo(enemies);
  71. choiceInt = UserInterface::getNumber("Who would you prefer to train with?\n>", 0, enemies.size());
  72. UserInterface::print("You are going to spar with:\n");
  73. UserInterface::characterInfo(enemies.at(choiceInt));
  74. UserInterface::print("Are you sure? (y/N)\n>");
  75. std::cin >> choiceChar;
  76. if (choiceChar == 'y' || choiceChar == 'Y')
  77. {
  78. enemy = new Character(*enemies.at(choiceInt));
  79. battle = BattleInterface(player, enemy);
  80. battle.start();
  81. if (battle.getWinner() == player)
  82. {
  83. UserInterface::print("You win, you get more experience...\n");
  84. player->increaseExperience(enemies.at(choiceInt)->getLevel());
  85. }
  86. else
  87. {
  88. UserInterface::print("You lose, but you still get some experience...\n");
  89. player->revive();
  90. player->increaseExperience(enemies.at(choiceInt)->getLevel() / 2);
  91. }
  92. delete enemy;
  93. }
  94. else
  95. {
  96. UserInterface::print("On second thought, you decide to sleep in your room instead...\n");
  97. player->rest();
  98. }
  99. break;
  100. case 4:
  101. UserInterface::print("You are going to challenge the Arch-Mage...\n");
  102. UserInterface::print("Are you sure? (y/N)\n>");
  103. std::cin >> choiceChar;
  104. if (choiceChar == 'y' || choiceChar == 'Y')
  105. {
  106. battle = BattleInterface(player, archMage);
  107. battle.start();
  108. if (battle.getWinner() == player)
  109. {
  110. UserInterface::print("You win, you get more experience...\n");
  111. player->increaseExperience(enemies.at(choiceInt)->getLevel());
  112. UserInterface::print("You win against the Arch-Mage!\n");
  113. UserInterface::print("He let you take a glimpse to the scroll that you always wanted...\n");
  114. UserInterface::print("Turns out the content is just some meaningless word...\n");
  115. UserInterface::print("Here is the content:\n");
  116. UserInterface::print(flag + "\n");
  117. }
  118. else
  119. {
  120. UserInterface::print("You lose...\n");
  121. UserInterface::print("Sadly his spell was to powerful,\n");
  122. UserInterface::print("You got killed by the arch-mage...\n");
  123. }
  124. }
  125. else
  126. {
  127. UserInterface::print("On second thought, you decide to sleep in your room instead...\n");
  128. player->rest();
  129. }
  130. break;
  131. case 5:
  132. UserInterface::print("You found some info about the arch-mage:\n");
  133. UserInterface::characterInfo(archMage);
  134. break;
  135. case 6:
  136. UserInterface::print("You meditate and got some insight to your ability:\n");
  137. UserInterface::characterInfo(player);
  138. break;
  139. }
  140. UserInterface::nextDay();
  141. }
  142. }