選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

145 行
5.2 KiB

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