Advertisement
Guest User

Untitled

a guest
Sep 5th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace new_new_new_new
  8. {
  9. class Program
  10. {
  11.  
  12. static void Main(string[] args)
  13. {
  14. Console.WriteLine("Welcome, traveler! Please, say your name.");
  15. string playerName = Console.ReadLine();
  16. string[] playerEquipment = Player.Equipment();
  17. int playerHealth = Player.Health();
  18. int playerDamage = Player.PlayerDamage();
  19. int playerDefense = Player.PlayerDefense();
  20. string[] enemiesName = Enemies.EnemiesName();
  21. int enemiesDamage = Enemies.EnemiesDamage();
  22. int enemiesHealth = Enemies.EnemiesHealth();
  23. int damagePlayer;
  24. int damageEnemy;
  25. bool endOfBattle;
  26. Random rng = new Random();
  27. int randomEnemy = rng.Next(0, 2);
  28. Console.WriteLine(playerName + " have: " + playerHealth + " health and: " + playerEquipment[0] + ", " + playerEquipment[1] + " and " + playerEquipment[2] + "!");
  29. Console.WriteLine("Stats: " + playerDamage + " damage and " + playerDefense + " defense.");
  30. Console.WriteLine("Choose path: left or right. Choose wisely!");
  31. string playerChoose1 = Console.ReadLine();
  32. string playerChoose2;
  33. if (playerChoose1 == "left" || playerChoose1 == "Left")
  34. {
  35. Console.WriteLine(playerName + " chosen left path. Time to your first adventure in forest.");
  36. Console.WriteLine("When " + playerName + " go into the forest - you see some good house. Maybe you want to go in? You chose to go in. When you came through the door - you saw a sleeping " + enemiesName[randomEnemy] + "!");
  37. Console.WriteLine("What do " + playerName + " choose? Run or fight?");
  38. playerChoose2 = Console.ReadLine();
  39. if (playerChoose2 == "Run" || playerChoose2 == "run")
  40. {
  41. Console.WriteLine(playerName + " chose to run as a rat. So pathetic. " + playerName + "'s journey ends here.");
  42. } else if (playerChoose2 == "Fight" || playerChoose2 == "fight")
  43. {
  44. Console.WriteLine(playerName + " chose a fight vs " + enemiesName[randomEnemy] + "!");
  45. endOfBattle = true;
  46. while (endOfBattle == true)
  47. {
  48. damageEnemy = enemiesHealth - playerDamage;
  49. Console.WriteLine(enemiesName[randomEnemy] + " HP: " + damageEnemy); //Battle code
  50. damagePlayer = playerHealth - (enemiesDamage - playerDefense);
  51. Console.WriteLine(playerName[randomEnemy] + " HP: " + damagePlayer);
  52. if (enemiesHealth <= 0)
  53. {
  54. endOfBattle = false;
  55. Console.WriteLine(playerName + " won the battle! Good job! " + playerName + "'s journey ends here.");
  56. } else if (playerHealth <= 0)
  57. {
  58. endOfBattle = false;
  59. Console.WriteLine(playerName + " died in battle! " + playerName + "'s journey ends here.");
  60. }
  61. }
  62. }
  63. }
  64.  
  65.  
  66. Console.ReadKey();
  67. }
  68.  
  69. }
  70.  
  71. class Player
  72. {
  73. public static int Health ()
  74. {
  75. int playerHealth = 100; //Player health
  76. return playerHealth;
  77. }
  78. public static string[] Equipment()
  79. {
  80. string[] equipment = new string[] {"Cloth armor", "Sword", "Health potion"}; //Player equipment
  81. return equipment;
  82. }
  83. public static int PlayerDamage()
  84. {
  85. string[] playerEquipment = Player.Equipment();
  86. int playerDamage;
  87. if (playerEquipment[1] == "Sword")
  88. {
  89. playerDamage = 10; //Player damage
  90. } else
  91. {
  92. playerDamage = 5;
  93. }
  94. return playerDamage;
  95. }
  96. public static int PlayerDefense()
  97. {
  98. string[] playerEquipment = Player.Equipment();
  99. int playerDefense;
  100. if (playerEquipment[0] == "Cloth armor")
  101. {
  102. playerDefense = 5;
  103. } else //Player defense
  104. {
  105. playerDefense = 0;
  106. }
  107. return playerDefense;
  108. }
  109. }
  110. class Enemies
  111. {
  112. public static string[] EnemiesName ()
  113. {
  114. string[] enemies = new string[] { "Slime", "Little ghoust", "Little wolf" };
  115. return enemies;
  116. }
  117. public static int EnemiesDamage ()
  118. {
  119. Random rngDamage = new Random();
  120. int damage = rngDamage.Next(5, 10); //Enemies info
  121. return damage;
  122. }
  123. public static int EnemiesHealth()
  124. {
  125. Random rngHealth = new Random();
  126. int health = rngHealth.Next(15, 150);
  127. return health;
  128. }
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement