private void HandleSellInteraction(string[] commandWords, Person actor) { Item saleItem = null; string saleItemName = commandWords[2]; foreach (var item in actor.ListInventory()) { if (this.ownerByItem[item] == actor && saleItemName == item.Name) { saleItem = item; } } var buyer = this.personByName[commandWords[3]] as Shopkeeper; if (buyer != null && this.peopleByLocation[actor.Location].Contains(buyer)) { var price = buyer.CalculateBuyingPrice(saleItem); this.moneyByPerson[buyer] -= price; this.moneyByPerson[actor] += price; this.RemoveFromPerson(actor, saleItem); this.AddToPerson(buyer, saleItem); saleItem.UpdateWithInteraction("sell"); } }
private void HandleGatherInteraction(string[] commandWords, Person actor) { GatheringLocation actorLocationAsGathering = actor.Location as GatheringLocation; if (actorLocationAsGathering != null) { if (actor.ListInventory().Any(item => item.ItemType == actorLocationAsGathering.RequiredItem)) { Item gatheredItem = actorLocationAsGathering.ProduceItem(commandWords[2]); this.AddToPerson(actor, gatheredItem); gatheredItem.UpdateWithInteraction("gather"); } } }