/** * Display information for the look command. displays player info, room info and enemies in room */ private void lookAround(Command command) { if (command.hasSecondWord()) { bool showDesc = true; if (player.CurrentRoom.getExit(command.getSecondWord()) != null) { if (player.CurrentRoom.getExit(command.getSecondWord()).IsBarred) { Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).BarredDescription); showDesc = false; } if (player.CurrentRoom.getExit(command.getSecondWord()).IsCutable) { Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).CutableDescription); showDesc = false; } if (player.CurrentRoom.getExit(command.getSecondWord()).IsLocked) { Console.WriteLine(GeneralDataLibrary.I() + "This room is locked!"); Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).KeyToUnlock); showDesc = false; } if (player.CurrentRoom.getExit(command.getSecondWord()).IsTutorialLocked) { Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).TutorialDescription); showDesc = false; } if (showDesc) { GeneralDataLibrary.Break(); Console.WriteLine(GeneralDataLibrary.I() + "There is nothing blocking the entrance to " + command.getSecondWord()); } } else { Console.WriteLine(GeneralDataLibrary.Note() + "Could not find exit!"); } } else { Console.WriteLine(player.CurrentRoom.getLongDescription()); GeneralDataLibrary.Break(); if (player.CurrentRoom.Inventory.Items.Count > 0) { Console.WriteLine(GeneralDataLibrary.I() + player.CurrentRoom.Inventory.Items.Count + " Item(s) in the room!"); GeneralDataLibrary.Break(); for (int i = 0; i < player.CurrentRoom.Inventory.Items.Count; i++) { Console.WriteLine(GeneralDataLibrary.I(2) + (i + 1) + " | " + player.CurrentRoom.Inventory.Items[i].Name + ": " + player.CurrentRoom.Inventory.Items[i].Description); } GeneralDataLibrary.Break(2); } Console.WriteLine(GeneralDataLibrary.I() + "health: " + player.Health.ToString()); Console.WriteLine(GeneralDataLibrary.I() + "room in bag: " + player.Inventory.SpaceLeft); } }
/** * Use an item can have a lto of different targets and a can take an item index or and equip slot for the item to use */ private void useItem(Command command) { Item i = null; switch (command.getSecondWord()) { case "hand": i = player.FirstHand; break; case "offhand": i = player.SecondHand; break; default: int num; if (int.TryParse(command.getSecondWord(), out num)) { if (num > 0 && num < player.Inventory.Items.Count - 1) { i = player.Inventory.Items[num]; } } else { for (int ii = player.Inventory.Items.Count - 1; ii >= 0; ii--) { if (player.Inventory.Items[ii].Name == command.getSecondWord()) { i = player.Inventory.Items[ii]; break; } } } break; } if (i == null) { Console.WriteLine("No item found on index, name or slot!"); return; } else { if (command.hasThirdWord()) { if (player.CurrentRoom.getExit(command.getThirdWord()) != null) { if (i.use(player.CurrentRoom.getExit(command.getThirdWord()))) { destroyItem(command.getSecondWord()); } } else { Console.WriteLine(GeneralDataLibrary.Note() + "That exit doesn't exist!"); } } else { if (i.use(player)) { destroyItem(command.getSecondWord()); } } } }
/** * Unequip an item from on of the player's equip slot */ private void unequipItem(Command command) { if (command.hasSecondWord()) { switch (command.getSecondWord()) { case "hand": if (player.FirstHand != null) { if (player.Inventory.addItem(player.FirstHand)) { Console.WriteLine("Unequiped: " + player.FirstHand.Name); player.FirstHand = null; } } else { Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!"); } break; case "offhand": if (player.SecondHand != null) { if (player.Inventory.addItem(player.SecondHand)) { Console.WriteLine("Unequiped: " + player.SecondHand.Name); player.SecondHand = null; } } else { Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!"); } break; case "armor": if (player.Armor != null) { if (player.Inventory.addItem(player.Armor)) { Console.WriteLine("Unequiped: " + player.Armor.Name); player.Armor = null; } } else { Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!"); } break; case "special": if (player.Special != null) { if (player.Inventory.addItem(player.Special)) { Console.WriteLine("Unequiped: " + player.Special.Name); player.Special = null; } } else { Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!"); } break; default: Console.WriteLine("Can't find item slot."); break; } } }