public int HealPlayer(Player player) { int menuchoice = 0; while (menuchoice != 3) { Console.Clear(); Console.WriteLine("Which potion do you want to use?"); Console.WriteLine("If no potions show up, that means you are at full health."); if (player.HasObject("Strong Health Potion") == true && player.health < 100) { Console.WriteLine("1. Strong Health Potion (Heals 50 hitpoints)"); } if (player.HasObject("Weak Health Potion") == true && player.health < 100) { Console.WriteLine("2. Weak Health Potion (Heals 25 hitpoints)"); } Console.WriteLine("3. Exit"); try { menuchoice = int.Parse(Console.ReadLine()); } catch (Exception) { } switch (menuchoice) { case 1: if (player.HasObject("Strong Health Potion") == true && player.health < 100) { Console.WriteLine("You drink the health potion. You feel invigorated."); player.DropItem("Strong Health Potion"); return(player.health += 50); } break; case 2: if (player.HasObject("Weak Health Potion") == true && player.health < 100) { Console.WriteLine("You drink the health potion. You feel slightly invigorated."); player.DropItem("Weak Health Potion"); return(player.health += 25); } break; case 3: break; } } return(player.health += 0); }
public int HasBuff(Player player) { if (player.HasObject("Dagger") == true) { return(player.str = 2); } else { return(player.str = 1); } }
public int HasArmBuff(Player player) { if (player.HasObject("Steel Armour") == true) { if (player.HasObject("Iron Armour") == true) { Console.WriteLine("Steel armour is better than iron armour.\nYou decide to leave the iron armour behind"); player.DropItem("Iron Armour"); } if (player.HasObject("Leather Armour") == true) { Console.WriteLine("Steel armour is better than leather armour.\nYou decide to leave the leather armour behind"); player.DropItem("Leather Armour"); } return(player.armour = 6); } else if (player.HasObject("Iron Armour") == true) { if (player.HasObject("Leather Armour") == true) { Console.WriteLine("Iron armour is better than leather armour.\nYou decide to leave the leather armour behind"); player.DropItem("Leather Armour"); } return(player.armour = 4); } else if (player.HasObject("Leather Armour") == true) { return(player.armour = 2); } else { return(player.armour = 0); } }
public int HasStrBuff(Player player) { if (player.HasObject("Axe") == true) { if (player.HasObject("Sword") == true) { Console.WriteLine("The axe is better than your sword.\nYou decide to drop your sword."); player.DropItem("Sword"); } if (player.HasObject("Dagger") == true) { Console.WriteLine("The axe is better than your dagger.\nYou decide to drop your dagger."); player.DropItem("Dagger"); } return(player.str = 6); } else if (player.HasObject("Sword") == true) { if (player.HasObject("Dagger") == true) { Console.WriteLine("The sword is better than your dagger.\nYou decide to drop your dagger."); player.DropItem("Dagger"); } return(player.str = 4); } else if (player.HasObject("Dagger") == true) { return(player.str = 2); } else { return(player.str = 1); } }
public void AllowedDirections() { // if a direction has a value of 1, then the player can go there directions.north = 1; directions.east = 1; directions.south = 1; directions.west = 1; // Check boundries and if there is a level north in the array if (pos.Yposition + 1 >= height) { directions.north = -1; } else if (map[pos.Yposition + 1, pos.Xposition] == null) { directions.north = -1; } // Check boundries and if there is a level south in the array if (pos.Yposition - 1 < 0) { directions.south = -1; } else if (map[pos.Yposition - 1, pos.Xposition] == null) { directions.south = -1; } // Check boundries and if there is a level east in the array if (pos.Xposition + 1 >= width) { directions.east = -1; } else if (map[pos.Yposition, pos.Xposition + 1] == null) { directions.east = -1; } // Check boundries and if there is a level west in the array if (pos.Xposition - 1 < 0) { directions.west = -1; } else if (map[pos.Yposition, pos.Xposition - 1] == null) { directions.west = -1; } // tomb need key if (pos.Yposition == 4 && pos.Xposition == 3) { directions.north = -1; if (player.HasObject("Key") == true) { Console.WriteLine("You unlocked the tomb."); directions.north = +1; } else { Console.WriteLine("You need a key in order to enter the tomb."); } } //castle pickaxe need if (pos.Yposition == 1 && pos.Xposition == 0) { directions.south = -1; if (player.HasObject("Pickaxe") == true) { Console.WriteLine("You destroy the barricade with the pickaxe."); directions.south = +1; } else { Console.WriteLine("The entrance to the castle is barricaded."); Console.WriteLine("You need some kind of tool to destroy it."); } } // cliff needs rope if (pos.Yposition == 1 && pos.Xposition == 2) { directions.south = -1; if (player.HasObject("Rope") == true) { Console.WriteLine("You tie the rope to a rock. You can now climb down."); directions.south = +1; } else { Console.WriteLine("The cliff is too high to jump down."); Console.WriteLine("You need something in order to safely rappel down."); } } }
// This Method builds the menu static int ShowMenu(Map map, ref List <string> menu, ref Player player) { int choice; string input; menu.Clear(); if (!map.GetLocation().hasBossEnemy == false || map.GetLocation().hasEnemy == false) { ShowDirections(map, ref menu); if (map.GetLocation().CheckForItems()) { bool acquirableitems = false; Dictionary <string, Objects> list = map.GetLocation().GetItems(); Objects[] obj = list.Values.ToArray(); for (int i = 0; i < obj.Count(); i++) { if (obj[i].GetAcquirable()) { acquirableitems = true; } } if (acquirableitems) { menu.Add(ACTION_SEARCH); } } } if (map.GetLocation().HasEnemy()) { menu.Add(ACTION_FIGHT); menu.Add(ACTION_RUN); } if (map.GetLocation().HasBossEnemy()) { menu.Add(ACTION_BOSS); } if (map.GetLocation().HasInn()) { menu.Add(ACTION_INN); } if (map.GetLocation().HasTreasure()) { menu.Add(ACTION_TREASURE); } if (player.HasObject("Strong Health Potion") == true || player.HasObject("Weak Health Potion") == true) { menu.Add(ACTION_HEAL); } menu.Add(ACTION_STATS); menu.Add(ACTION_INV); menu.Add(ACTION_QUIT); do { for (int i = 0; i < menu.Count(); i++) { Console.WriteLine("{0} - {1}", i + 1, menu[i]); } Console.WriteLine("Please enter your choice: 1 - {0}", menu.Count()); input = Console.ReadLine(); } while (!int.TryParse(input, out choice) || (choice > menu.Count() || choice < 0)); //return choice return(choice - 1); }
// This Method builds the menu static int ShowMenu(Map map, ref List <string> menu, ref Player player, ref BloodDrake drake, ref AngryMan angryman) { int choice; string input; menu.Clear(); ShowDirections(map, ref menu); if (map.GetLocation().CheckForItems()) { bool acquirableitems = false; Dictionary <string, Objects> list = map.GetLocation().GetItems(); Objects[] obj = list.Values.ToArray(); for (int i = 0; i < obj.Count(); i++) { if (obj[i].GetAcquirable()) { acquirableitems = true; } } if (acquirableitems) { menu.Add(ACTION_SEARCH); } } if ((map.GetYPosition() == 5 && map.GetXPosition() == 1) && drake.IsAlive(drake.GetHealth())) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("On one of the pillars of the bridge is a smalle Blood Drake…"); Console.WriteLine("The Blood Drake growls at you…"); Console.WriteLine("It isn’t going to let you pass the bridge…"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; menu.Add("Fight the Blood Drake"); menu.Add("Go via the side of the bridge"); } if ((map.GetYPosition() == 3 && map.GetXPosition() == 2) && angryman.IsAlive(angryman.GetHealth())) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("When you knock on the door you hear heavy footsteps walking towards the door"); Console.WriteLine("An angry man opens the door, and screams:"); Console.WriteLine("If you don't stop bothering me I will kick your teeth in!"); Console.WriteLine("As you look inside the house you can see a bag of gold."); Console.WriteLine("Do you want to fight the man, and take his gold, or will you leave the man."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; menu.Add("Fight the man"); } if (map.GetYPosition() == 7 && map.GetXPosition() == 1) { menu.Add("Climb over the wall"); menu.Remove("Go North"); } if (map.GetYPosition() == 9 && map.GetXPosition() == 1) { menu.Add("Fight the Boss"); } menu.Add(ACTION_QUIT); menu.Add(ACTION_SHOP); menu.Add(ACTION_SHOWINVENTORY); if (player.HasObject("Health Potion")) { menu.Add(ACTION_USEHEALTHPOTION); } do { for (int i = 0; i < menu.Count(); i++) { Console.WriteLine("{0} - {1}", i + 1, menu[i]); } Console.WriteLine("Please enter your choice: 1 - {0}", menu.Count()); HealthUI(player.GetName(), player.GetHealth(), player.GetMaxHealth(), player.GetStamina(), player.GetMaxStamina(), player.GetGold()); input = Console.ReadLine(); Console.Clear(); map.GetLocation().Description(); } while (!int.TryParse(input, out choice) || (choice > menu.Count() || choice < 0)); //return choice; return(choice - 1); }