Advertisement
Tavxela

Untitled

Nov 13th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 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.  
  15. int wolfHealth = 100;
  16. int wolfDamage = 15 + RandomNumberGenerator();
  17.  
  18. int generalMove = 1;
  19. char input1,playerMove;
  20. string game;
  21.  
  22. //cout << "Type A to deal damage" << endl;
  23. //cout << "Type H to heal" << endl;
  24. //cout << "Type QQQ to stop the game" << endl;
  25.  
  26. //while (game != "qqq" || game != "QQQ") {
  27. // cin >> input1;
  28. // if (input1 == 'a' || input1 == 'A') {
  29. // health = AttackDamage(health, damage);
  30. // cout << "Health: " << health << endl;
  31. // }
  32. // else if (input1 == 'h' || input1 == 'H') {
  33. // health = Heal(health);
  34. // cout << "You regained: " << RandomNumberGenerator() << " HP \n Your Health: " << health << endl;
  35. // }
  36. //}
  37. cout << "Wolf HP: " << wolfHealth << endl;
  38. cout << "Your HP: " << playerHealth << endl;
  39.  
  40. while (playerHealth > 0 || wolfHealth > 0) {
  41.  
  42. if (generalMove == 1) {
  43. cout << "\nType A to attack or H to heal" << endl;
  44. cin >> playerMove;
  45. if (playerMove == 'a' || playerMove == 'A') {
  46. generalMove++;
  47. wolfHealth = AttackDamage(wolfHealth, playerDamage);
  48. cout << "Damage dealt: " << playerDamage << endl;
  49. cout << "Wolf HP: " << wolfHealth << endl;
  50. }
  51. else if (playerMove == 'h' || playerMove == 'H') {
  52. generalMove++;
  53. playerHealth = Heal(playerHealth);
  54. cout << "You regained: " << RandomNumberGenerator() << " HP" << endl;
  55. cout << "Your Health: " << playerHealth << endl;
  56. }
  57. }
  58. else {
  59. generalMove--;
  60. playerHealth = AttackDamage(playerHealth, wolfDamage);
  61. cout << "\nDamage Recieved: " << wolfDamage << endl;
  62. cout << "Your HP: " << playerHealth << endl;
  63. }
  64. }
  65. if (wolfHealth < 0) {
  66. cout << "You win!" << endl;
  67. }
  68. else if (playerHealth < 0 && wolfHealth < 0) {
  69. cout << "You both died" << endl;
  70. }
  71. else if (playerHealth < 0) {
  72. cout << "You lost!" << endl;
  73. }
  74. }
  75. int AttackDamage(int hp, int dmg) {
  76. hp -= dmg;
  77. return hp;
  78. }
  79.  
  80. int Heal(int hp) {
  81. hp += RandomNumberGenerator();
  82. return hp;
  83. }
  84.  
  85. int RandomNumberGenerator() {
  86. int randomNumber = 0;
  87. default_random_engine generator(time(NULL));
  88. uniform_int_distribution<int> interval(1, 10);
  89. randomNumber = interval(generator);
  90. return randomNumber;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement