public void AddIrons(Iron iron) { irons.Add(iron); if (iron == null) { irons.Remove(iron); } }
protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item) { switch (itemTypeString) { case "weapon": item = new Weapon(itemNameString, itemLocation); break; case "iron": item = new Iron(itemNameString, itemLocation); break; case "wood": item = new Wood(itemNameString, itemLocation); break; default: return base.CreateItem(itemTypeString, itemNameString, itemLocation, item); } return item; }
private void HandleGatherInteraction(string[] commandWords, Person actor) { string gatherItemName = commandWords[2]; Item newItem = null; if (actor.Location.LocationType == LocationType.Forest) { bool hasWeapon = false; foreach (var item in actor.ListInventory()) { if (item.ItemType == ItemType.Weapon) { hasWeapon = true; break; } } if (hasWeapon) { newItem = new Wood(gatherItemName); this.AddToPerson(actor, newItem); newItem.UpdateWithInteraction("gather"); } } else if (actor.Location.LocationType == LocationType.Mine) { bool hasArmor = false; foreach (var item in actor.ListInventory()) { if (item.ItemType == ItemType.Armor) { hasArmor = true; break; } } if (hasArmor) { newItem = new Iron(gatherItemName); this.AddToPerson(actor, newItem); newItem.UpdateWithInteraction("gather"); } } }