Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <random>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int AttackDamage(int, int);
  8. int Heal(int);
  9. int RandomNumberGenerator();
  10.  
  11. int main() {
  12. int playerHealth = 100;
  13. int playerDamage = 25;
  14. int Ultramove = playerDamage + 20 * RandomNumberGenerator();
  15. int wolfHealth = 100;
  16. int generalMove = 1;
  17. int energy = 0;
  18. char input1, playerMove;
  19. string game;
  20.  
  21. cout << "Wolf HP: " << wolfHealth << endl;
  22. cout << "Your HP: " << playerHealth << endl;
  23.  
  24. while (playerHealth > 0 || wolfHealth > 0) {
  25.  
  26. if (generalMove == 1) {
  27. cout << "\nType A to attack, H to heal or P to Pass and gain energy" << endl;
  28. cin >> playerMove;
  29. if (playerMove == 'a' || playerMove == 'A') {
  30. generalMove++;
  31. wolfHealth = AttackDamage(wolfHealth, playerDamage);
  32. cout << "Damage dealt: " << playerDamage << endl;
  33. cout << "Wolf HP: " << wolfHealth << endl;
  34. }
  35. else if (playerMove == 'h' || playerMove == 'H') {
  36. generalMove++;
  37. playerHealth = Heal(playerHealth);
  38. cout << "You regained: " << (2 * RandomNumberGenerator()) << " HP" << endl;
  39. cout << "Your Health: " << playerHealth << endl;
  40. }
  41. else if (playerMove == 'P' || playerMove == 'p') {
  42. generalMove++;
  43. energy++;
  44. cout << "Energy gained " << energy << endl;
  45. if (energy == 3) {
  46. cout << "Hurry! You have enough energy to use Ultra move! " << endl;
  47. cout << "Press X to use ultramove " << endl;
  48. }
  49. }
  50. else if (playerMove == 'X' || playerMove == 'x') {
  51. generalMove++;
  52. wolfHealth = AttackDamage(wolfHealth, Ultramove);
  53. cout << "Damage dealt: " << Ultramove << endl;
  54. cout << "Wolf HP: " << wolfHealth << endl;
  55. }
  56.  
  57. }
  58. else {
  59. int wolfDamage = 15 + RandomNumberGenerator();
  60. generalMove--;
  61. playerHealth = AttackDamage(playerHealth, wolfDamage);
  62. cout << "\nDamage Recieved: " << wolfDamage << endl;
  63. cout << "Your HP: " << playerHealth << endl;
  64. cout << "___________________________________________________________________" << endl;
  65. }
  66. }
  67. if (wolfHealth < 0) {
  68. cout << "You win!" << endl;
  69. }
  70. else if (playerHealth < 0 && wolfHealth < 0) {
  71. cout << "You both died" << endl;
  72. }
  73. else if (playerHealth < 0) {
  74. cout << "You lost!" << endl;
  75. }
  76. }
  77.  
  78. int AttackDamage(int hp, int dmg) {
  79. hp -= dmg;
  80. return hp;
  81. }
  82.  
  83. int Heal(int hp) {
  84. hp += (2 * RandomNumberGenerator());
  85. return hp;
  86. }
  87.  
  88. int RandomNumberGenerator() {
  89. int randomNumber = 0;
  90. default_random_engine generator(time(NULL));
  91. uniform_int_distribution<int> interval(1, 10);
  92. randomNumber = interval(generator);
  93. return randomNumber;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement