public Location ToLocation() { var location = new Location(X, Y, Name, Description, FilePaths.NormalizePath(Image)); if (Monsters?.Any() ?? false) { foreach (var encounter in Monsters) { var availableMonster = MonsterFactory.Get(encounter.Id); if (availableMonster != null) { location.AddEncounter(encounter.Id, encounter.Chance); } else { Trace.TraceWarning($"Location({Name}) has monster {encounter.Id} that could not be found"); } } ; } ; if (Quests?.Any() ?? false) { foreach (var quest in Quests) { var availableQuest = QuestFactory.FindQuest(quest.Id); if (availableQuest != null) { location.AddQuest(availableQuest); } else { Trace.TraceWarning($"Location({Name}) has quest {quest.Id} that could not be found"); } } ; } ; if (Trader > 0) { var availableTader = TraderFactory.GetTrader(Trader); if (availableTader != null) { location.TraderHere = availableTader; } else { Trace.TraceWarning($"Location({Name}) has tracer '{Trader}' that could not be found"); } } ; return(location); }
public MethodResult CanBuy(MarketOffer offer, Entity buyer, Entity seller) { if (buyer.EntityID == seller.EntityID) { return(new MethodResult("You cannot buy from yourself!")); } var traderFactory = new TraderFactory(equipmentService); var buyerTrader = traderFactory.GetTrader(buyer); var sellerTrader = traderFactory.GetTrader(seller); return(buyerTrader.CanBuy(offer, sellerTrader)); }