Advertisement
Guest User

Program

a guest
Mar 14th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.33 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 Pokemon
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<Pokemon> roster = new List<Pokemon>();
  14. List<Pokemon> matchUp = new List<Pokemon>();
  15.  
  16. // INITIALIZE YOUR THREE POKEMONS HERE
  17.  
  18. List<Move> charMoves = new List<Move>();
  19. charMoves.Add(new Move("\nEmber [0]"));
  20. charMoves.Add(new Move("Fire Blast [1]"));
  21.  
  22. List<Move> bulbaMoves = new List<Move>();
  23. bulbaMoves.Add(new Move("\nCut [0]"));
  24. bulbaMoves.Add(new Move("Mega Drain [1]"));
  25. bulbaMoves.Add(new Move("Razor Leafes [2]"));
  26.  
  27. List<Move> squirMoves = new List<Move>();
  28. squirMoves.Add(new Move("\nBubble [0]"));
  29. squirMoves.Add(new Move("Bite [1]"));
  30.  
  31. Pokemon Charmander = new Pokemon("Charmander", 3, 52, 43, 39, Elements.Fire, charMoves);
  32. Pokemon Bulbasaur = new Pokemon("Bulbasaur", 3, 49, 49, 45, Elements.Grass, bulbaMoves);
  33. Pokemon Squirtle = new Pokemon("Squirtle", 2, 48, 65, 44, Elements.Water, squirMoves);
  34.  
  35. roster.Add(Charmander);
  36. roster.Add(Bulbasaur);
  37. roster.Add(Squirtle);
  38.  
  39.  
  40.  
  41.  
  42. Console.WriteLine("Welcome to the world of Pokemon!\nThe available commands are list/fight/heal/quit");
  43.  
  44. while (true)
  45. {
  46. Console.WriteLine("\nPlease enter a command");
  47. switch (Console.ReadLine())
  48. {
  49. case "list":
  50. // PRINT THE POKEMONS IN THE ROSTER HERE
  51. Console.WriteLine("Squirtle " + "Bulbasaur " + "Charmander ");
  52. break;
  53.  
  54. case "fight":
  55. //PRINT INSTRUCTIONS AND POSSIBLE POKEMONS (SEE SLIDES FOR EXAMPLE OF EXECUTION)
  56. Console.Write("CHOOSE WHO SHOULD FIGHT!\n" +
  57. "Pick two of the following: Charmander, Bulbasaur and Squirtle\n");
  58.  
  59. //READ INPUT, REMEMBER IT SHOULD BE TWO POKEMON NAMES
  60. string input = Console.ReadLine();
  61. string[] chosen = input.Split(' ');
  62.  
  63. Pokemon player = null;
  64. Pokemon enemy = null;
  65.  
  66. if (chosen[0] == "Bulbasaur")
  67. {
  68. matchUp.Insert(0, Bulbasaur);
  69. }
  70. if (chosen[0] == "Charmander")
  71. {
  72. matchUp.Insert(0, Charmander);
  73. }
  74. if (chosen[0] == "Squirtle")
  75. {
  76. matchUp.Insert(0, Squirtle);
  77. }
  78.  
  79. if (chosen[1] == "Bulbasaur")
  80. {
  81. matchUp.Insert(1, Bulbasaur);
  82. }
  83. if (chosen[1] == "Charmander")
  84. {
  85. matchUp.Insert(1, Charmander);
  86. }
  87. if (chosen[1] == "Squirtle")
  88. {
  89. matchUp.Insert(1, Squirtle);
  90. }
  91.  
  92. player = matchUp.First();
  93. enemy = matchUp.Last();
  94.  
  95. //BE SURE TO CHECK THE POKEMON NAMES THE USER WROTE ARE VALID (IN THE ROSTER) AND IF THEY ARE IN FACT 2!
  96.  
  97.  
  98. //if everything is fine and we have 2 pokemons let's make them fight
  99. if (player != null && enemy != null && player != enemy)
  100. {
  101. Console.WriteLine("A wild " + enemy.Name + " appears!");
  102. Console.Write(player.Name + " I choose you! ");
  103.  
  104. //BEGIN FIGHT LOOP
  105. while (player.Hp > 0 && enemy.Hp > 0)
  106. {
  107. //PRINT POSSIBLE MOVES
  108. Console.Write("What move should we use?");
  109. if (player == Bulbasaur)
  110. {
  111. foreach (Move pokemon in bulbaMoves)
  112. {
  113. Console.WriteLine(pokemon.Name);
  114. }
  115. }
  116. if (player == Charmander)
  117. {
  118. foreach (Move pokemon in charMoves)
  119. {
  120. Console.WriteLine(pokemon.Name);
  121. }
  122. }
  123. if (player == Squirtle)
  124. {
  125. foreach (Move pokemon in squirMoves)
  126. {
  127. Console.WriteLine(pokemon.Name);
  128. }
  129. }
  130.  
  131.  
  132. if (chosen == "0")
  133. {
  134.  
  135. }
  136.  
  137.  
  138. //GET USER ANSWER, BE SURE TO CHECK IF IT'S A VALID MOVE, OTHERWISE ASK AGAIN
  139. int move = -1;
  140.  
  141.  
  142. //CALCULATE AND APPLY DAMAGE
  143. int damage = -1;
  144.  
  145. //print the move and damage
  146. Console.WriteLine(player.Name + " uses " + player.Moves[move].Name + ". " + enemy.Name + " loses " + damage + " HP");
  147.  
  148. //if the enemy is not dead yet, it attacks
  149. if (enemy.Hp > 0)
  150. {
  151. //CHOOSE A RANDOM MOVE BETWEEN THE ENEMY MOVES AND USE IT TO ATTACK THE PLAYER
  152. Random rand = new Random();
  153. /*the C# random is a bit different than the Unity random
  154. * you can ask for a number between [0,X) (X not included) by writing
  155. * rand.Next(X)
  156. * where X is a number
  157. */
  158. int enemyMove = -1;
  159. int enemyDamage = -1;
  160.  
  161. //print the move and damage
  162. Console.WriteLine(enemy.Name + " uses " + enemy.Moves[enemyMove].Name + ". " + player.Name + " loses " + enemyDamage + " HP");
  163. }
  164. }
  165. //The loop is over, so either we won or lost
  166. if (enemy.Hp <= 0)
  167. {
  168. Console.WriteLine(enemy.Name + " faints, you won!");
  169. }
  170. else
  171. {
  172. Console.WriteLine(player.Name + " faints, you lost...");
  173. }
  174. }
  175. //otherwise let's print an error message
  176. else
  177. {
  178. Console.WriteLine("Invalid pokemons!");
  179. }
  180. break;
  181.  
  182. case "heal":
  183. //RESTORE ALL POKEMONS IN THE ROSTER
  184.  
  185. Console.WriteLine("All pokemons have been healed");
  186. break;
  187.  
  188. case "quit":
  189. Environment.Exit(0);
  190. break;
  191.  
  192. default:
  193. Console.WriteLine("Unknown command");
  194. break;
  195. }
  196. }
  197. }
  198. }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement