Tavxela

Untitled

Nov 13th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 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.  
  17. int generalMove = 1;
  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 or H to heal" << 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. }
  42. else {
  43. int wolfDamage = 15 + RandomNumberGenerator();
  44. generalMove--;
  45. playerHealth = AttackDamage(playerHealth, wolfDamage);
  46. cout << "\nDamage Recieved: " << wolfDamage << endl;
  47. cout << "Your HP: " << playerHealth << endl;
  48. cout << "___________________________________________________________________" << endl;
  49. }
  50. }
  51. if (wolfHealth < 0) {
  52. cout << "You win!" << endl;
  53. }
  54. else if (playerHealth < 0 && wolfHealth < 0) {
  55. cout << "You both died" << endl;
  56. }
  57. else if (playerHealth < 0) {
  58. cout << "You lost!" << endl;
  59. }
  60. }
  61.  
  62. int AttackDamage(int hp, int dmg) {
  63. hp -= dmg;
  64. return hp;
  65. }
  66.  
  67. int Heal(int hp) {
  68. hp += (2 * RandomNumberGenerator());
  69. return hp;
  70. }
  71.  
  72. int RandomNumberGenerator() {
  73. int randomNumber = 0;
  74. default_random_engine generator(time(NULL));
  75. uniform_int_distribution<int> interval(1, 10);
  76. randomNumber = interval(generator);
  77. return randomNumber;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment