Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. public void Commands()
  2. {
  3. List<string> command = new List<string>();
  4. command.AddRange(Console.ReadLine().Split(' '));
  5. Console.WriteLine("\n");
  6.  
  7. if (command.Count == 0)
  8. {
  9. Console.WriteLine("Please enter a valid command");
  10. }
  11.  
  12. if (command.Count >= 1)
  13. {
  14. switch (command[0])
  15. {
  16. case "move":
  17. if(command.Count ==1 )
  18. {
  19. Console.WriteLine("Command: Move (direction)");
  20. }
  21.  
  22. if(command.Count == 2)
  23. {
  24. if(command[1] == "n" && player.currentLocation.locToNorth != null)
  25. {
  26. moveNorth();
  27. command.Clear();
  28.  
  29. }
  30.  
  31. else if (command[1] == "s" && player.currentLocation.locToSouth != null)
  32. {
  33. moveSouth();
  34. command.Clear();
  35. }
  36.  
  37. else if (command[1] == "w" && player.currentLocation.locToWest != null)
  38. {
  39. moveWest();
  40. command.Clear();
  41. }
  42.  
  43. else if (command[1] == "e" && player.currentLocation.locToEast != null)
  44. {
  45. moveEast();
  46. command.Clear();
  47. }
  48. else
  49. {
  50. Console.WriteLine("Invalid direction. The valid directions are: ");
  51. GetDirections(player.currentLocation);
  52. }
  53. }
  54.  
  55. break;
  56. case "attack":
  57. if (command.Count == 1)
  58. {
  59. Console.WriteLine("Invalid target");
  60. }
  61. else
  62. {
  63. Console.WriteLine("You attack.");
  64. }
  65. break;
  66. case "quaff":
  67. if (command.Count == 1)
  68. {
  69. Console.WriteLine("Which potion?");
  70. }
  71. else
  72. {
  73. Console.WriteLine("You potion.");
  74. }
  75. break;
  76. case "quit":
  77. {
  78. Console.WriteLine("You have quit.");
  79. Environment.Exit(0);
  80. break;
  81. }
  82. case "stats":
  83. Console.WriteLine("Health {0}/{1} Gold: {2} XP: {3} level: {4}", player.currentHp, player.maxHp, player.gold, player.xp, player.level);
  84. break;
  85. case "inventory":
  86. Console.WriteLine("Player Inventory\n****************");
  87. foreach (Item item in player.inventory)
  88. {
  89. Console.WriteLine(item.name + "\n");
  90. }
  91. break;
  92. case "quests":
  93. Console.WriteLine("Player Quests\n*************");
  94. break;
  95. case "givexp":
  96. if (command.Count == 1)
  97. {
  98. Console.WriteLine("givexp PLAYER XPVALUE");
  99. }
  100. else if (command.Count == 2)
  101. {
  102. Console.WriteLine("enter a valid xp ammount");
  103. }
  104. else
  105. {
  106. player.xp = Int32.Parse(command[2]);
  107. }
  108. break;
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement