Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // NExt Gen Pokemon
  4. //
  5. // Created by Robin Michaelson on 26/6/17.
  6. // Copyright © 2017 Robin Michaelson. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <time.h>
  11.  
  12. #include "Monster.h"
  13.  
  14. //Functions
  15. Monster starter();
  16. Monster beginning();
  17. void attack(Monster&, Monster&);
  18. void defend(Monster&, Monster&);
  19. void fight(Monster&, Monster&, int);
  20. void firstbattle(Monster&, Monster&);
  21.  
  22. int main()
  23. {
  24. srand(time(NULL));
  25.  
  26. Monster player = beginning(),
  27. enemy("Reginald", 20, 3);
  28.  
  29. firstbattle(player, enemy);
  30.  
  31. system("PAUSE");
  32. return 0;
  33. }
  34.  
  35. //The start of the epic journey, runs the starter function and names your Monster as well as sets the stats for your starter
  36. Monster beginning()
  37. {
  38. Monster temp;
  39.  
  40. std::cout << "Welcome to the real world jackass!" << std::endl;
  41.  
  42. temp = starter();
  43.  
  44. std::cout << std::endl << "Really? You chose " << temp.getName() << ", lame but okay..." << std::endl;
  45. std::cout << "Your HP is " << temp.getHP() << std::endl;
  46. std::cout << "Your Attack stat is " << temp.getAtt() << std::endl;
  47.  
  48. return temp;
  49. }
  50.  
  51. //Sets the pointer for mymon to the starter you choose
  52. Monster starter()
  53. {
  54. int select,
  55. hp = rand() % 10 + 1,
  56. att = rand() % 5 + 1;
  57.  
  58. std::cout << "Pick a fighter:" << std::endl;
  59. std::cout << "[1] Aggressive\n[2] Balanced\n[3] Defensive\n>";
  60. std::cin >> select;
  61.  
  62. switch (select)
  63. {
  64. case 1:
  65. std::cout << "You've chosen 'Aggressive', now name it:" << std::endl;
  66. hp += 15;
  67. att += 5;
  68. break;
  69. case 2:
  70. std::cout << "You've chosen 'Balanced', now name it:" << std::endl;
  71. hp += 20;
  72. att += 3;
  73. break;
  74. case 3:
  75. std::cout << "You've chosen 'Defensive', now name it:" << std::endl;
  76. hp += 25;
  77. att += 1;
  78. break;
  79. default:
  80. std::cout << "Go fuck yourself!" << std::endl;
  81. return starter();
  82. }
  83.  
  84. std::string name;
  85. std::cin >> name;
  86.  
  87. return Monster(name, hp, att);
  88. }
  89.  
  90. void attack(Monster& attacker, Monster& defender)
  91. {
  92. int attack;
  93. std::cout << "Choose your attack this turn " << std::endl;
  94. std::cout << " 1) Powerful 2) Accurate 3) Defensive " << std::endl;
  95. std::cin >> attack;
  96. fight(attacker, defender, attack);
  97. }
  98.  
  99. void defend(Monster& attacker, Monster& defender)
  100. {
  101. int rando = rand() % 3 + 1;
  102. fight(attacker, defender, rando);
  103. }
  104.  
  105. //Monster y is the one doing the attacking to x
  106. void fight(Monster& attacker, Monster& defender, int choice)
  107. {
  108. switch (choice)
  109. {
  110. case 1:
  111. std::cout << attacker.getName() << " uses a powerful attack!" << std::endl;
  112.  
  113. if (rand() % 2)
  114. defender.subHp(2 * attacker.getAtt());
  115. else
  116. std::cout << "The attack missed!" << std::endl;
  117. break;
  118. case 2:
  119. std::cout << attacker.getName() << " uses an accurate attack!" << std::endl;
  120. defender.subHp(attacker.getAtt());
  121. break;
  122. case 3:
  123. std::cout << attacker.getName() << " uses a defensive attack and heals for half the damage done!" << std::endl;
  124.  
  125. defender.subHp(attacker.getAtt() / 2);
  126. attacker.heal(attacker.getAtt() / 2);
  127. break;
  128. }
  129.  
  130. std::cout << "HP of " << attacker.getName() << " is now " << attacker.getHP() << std::endl;
  131. std::cout << "HP of " << defender.getName() << " is now " << defender.getHP() << std::endl;
  132. std::cout << std::endl;
  133. }
  134.  
  135. //Runs the first fight simulation
  136. void firstbattle(Monster& player, Monster& enemy)
  137. {
  138. std::cout << std::endl << "It's time for your first fight, cause that's just what we do in this world." << std::endl;
  139. do {
  140. attack(player, enemy);
  141. defend(enemy, player);
  142. } while (player.getHP() && enemy.getHP());
  143.  
  144. if (player.getHP())
  145. std::cout << "Congratulations on your first victory..." << std::endl;
  146. else
  147. std::cout << "Go fuck yourself!" << std::endl;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement