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.

main002.cpp 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #include "src/class/player.hpp"
  2. #include "src/class/monster.hpp"
  3. #include "src/interface/battle.hpp"
  4. #include "src/interface/creation.hpp"
  5. #include "src/interface/info.hpp"
  6. #include "src/system/betatest.hpp"
  7. #include "src/system/memory.hpp"
  8. #include "src/system/flag.hpp"
  9. #include <iostream>
  10. void printMenu();
  11. void printMenu()
  12. {
  13. printf("===== HackTheGame v0.0.1 (Beta) =====\n");
  14. printf("[1] Create new Character\n");
  15. printf("[2] Character Info\n");
  16. printf("[9] Credits\n");
  17. printf("[0] Exit\n");
  18. printf(">");
  19. }
  20. int main(int argc, char const *argv[])
  21. {
  22. Player *player;
  23. Monster *enemy;
  24. std::cout << "This game is still in closed beta\n"
  25. << "Please input your beta test code\n"
  26. << ">" << std::flush;
  27. std::string betaCode;
  28. std::cin >> betaCode;
  29. if (BetaTest::check(betaCode))
  30. {
  31. std::cout << "Welcome back tester!\n"
  32. << "do you have your character backup code?\n"
  33. << "[y/N] " << std::flush;
  34. char choice = 'n';
  35. std::cin >> choice;
  36. if (choice == 'Y' || choice == 'y')
  37. {
  38. std::cout << "Please input your backup code\n"
  39. << "> " << std::flush;
  40. std::string code;
  41. std::cin >> code;
  42. player = Memory::loadFromCode(code);
  43. if (player == nullptr)
  44. {
  45. std::cout << "Your backup code is invalid, please try again..." << std::endl;
  46. return 1;
  47. }
  48. }
  49. else
  50. {
  51. player = Creation::ofPlayer();
  52. }
  53. do
  54. {
  55. std::cout << "====== HackTheGame v0.0.2 (Closed Beta) =====\n"
  56. << "[1] Character Info\n"
  57. << "[2] Hunt Monster\n"
  58. << "[3] Fight Boss\n"
  59. << "[4] Rest\n"
  60. << "[9] Credits\n"
  61. << "[0] Exit\n"
  62. << ">" << std::flush;
  63. choice = '0';
  64. std::cin >> choice;
  65. switch (choice)
  66. {
  67. case '1':
  68. Info::ofPlayer(player);
  69. break;
  70. case '2':
  71. enemy = Creation::ofMonster();
  72. if (enemy != nullptr)
  73. {
  74. Battle::Start(player, enemy);
  75. if (Battle::Lose())
  76. {
  77. std::cout << "GAME OVER !!!!" << std::endl;
  78. return 0;
  79. }
  80. }
  81. break;
  82. case '3':
  83. enemy = Creation::ofBoss();
  84. if (enemy != nullptr)
  85. {
  86. Battle::Start(player, enemy);
  87. if (Battle::Won())
  88. {
  89. Flag::Print();
  90. }
  91. else
  92. {
  93. std::cout << "GAME OVER !!!!" << std::endl;
  94. return 0;
  95. }
  96. }
  97. break;
  98. case '4':
  99. std::cout << "You take a rest at nearby Inn...\n"
  100. << "You wrote your journey to a diary in some cryptic language...\n"
  101. << Memory::saveToCode(player) << "\n"
  102. << "You woke up feeling resfreshed...\n"
  103. << std::flush;
  104. player->restoreHP();
  105. break;
  106. case '9':
  107. Info::ofApplication();
  108. break;
  109. case '0':
  110. return 0;
  111. break;
  112. default:
  113. printf("Not Implemented...\n");
  114. }
  115. } while (choice != 0);
  116. }
  117. else
  118. {
  119. std::cout << "Invalid code, exiting..." << std::endl;
  120. return 0;
  121. }
  122. }