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.

122 lines
3.0 KiB

  1. #include "src/interface/creation.hpp"
  2. #include "src/interface/info.hpp"
  3. #include <iostream>
  4. Player *Creation::ofPlayer()
  5. {
  6. std::cout << "=== Welcome to Character Creation ===\n"
  7. << std::flush;
  8. while (true)
  9. {
  10. std::cout << "Please enter your character name below\n"
  11. << ">" << std::flush;
  12. std::string name;
  13. std::cin >> name;
  14. if (name.size() > 15)
  15. {
  16. std::cout << "Your character name is too long!\n"
  17. << std::flush;
  18. continue;
  19. }
  20. else
  21. {
  22. std::cout << "Creating your character...\n"
  23. << std::flush;
  24. Player *newPlayer = new Player(name);
  25. Info::ofPlayer(newPlayer);
  26. std::cout << "Accept? [Y/n] \n"
  27. << ">" << std::flush;
  28. char choice = 'Y';
  29. std::cin >> choice;
  30. if (choice == 'Y' || choice == 'y')
  31. {
  32. return newPlayer;
  33. }
  34. }
  35. }
  36. }
  37. Monster *Creation::ofMonster()
  38. {
  39. const Monster monsterDen[] = {
  40. Monster("Slime", 10, 1, 0, 1),
  41. Monster("Goblin", 30, 2, 1, 2),
  42. Monster("Wolf", 50, 3, 1, 3),
  43. Monster("Zombie", 100, 4, 0, 4),
  44. Monster("Zombie Knight", 200, 10, 7, 5),
  45. Monster("Baby Dragon", 500, 20, 15, 10),
  46. Monster("Dragon", 1000, 50, 20, 20)};
  47. while (true)
  48. {
  49. int count = 0;
  50. std::cout << "=== Welcome to Hunting Ground ===\n"
  51. << std::flush;
  52. for (Monster monster : monsterDen)
  53. {
  54. std::cout << "[" << ++count << "] " << monster.getName() << std::endl;
  55. }
  56. std::cout << "[0] Exit\n"
  57. << ">" << std::flush;
  58. char input;
  59. std::cin >> input;
  60. if (input <= ('0' + count) && input > '0')
  61. {
  62. char decision = 'Y';
  63. Monster *summoned = new Monster(monsterDen[input - '1']);
  64. Info::ofMonster(summoned);
  65. std::cout << "Fight this monster? [Y/n]" << std::endl;
  66. std::cout << ">" << std::flush;
  67. std::cin >> decision;
  68. if (decision == 'y' || decision == 'Y')
  69. {
  70. return summoned;
  71. }
  72. else
  73. {
  74. continue;
  75. }
  76. }
  77. else if (input == '0')
  78. {
  79. return nullptr;
  80. }
  81. else
  82. {
  83. std::cout << "Monster not found!" << std::endl;
  84. continue;
  85. }
  86. }
  87. }
  88. Monster *Creation::ofBoss()
  89. {
  90. Monster *boss = new Monster("Flag Guardian", 987654321, 123456789, 123456789, 0);
  91. std::cout << "You are gonna fight the final boss:\n" << std::flush;
  92. Info::ofMonster(boss);
  93. std::cout << "Are you sure? [Y/n]\n"
  94. << "> " << std::flush;
  95. char choice = 'Y';
  96. std::cin >> choice;
  97. if (choice == 'Y' || choice == 'y')
  98. {
  99. return boss;
  100. }
  101. else
  102. {
  103. return nullptr;
  104. }
  105. }