public Monster ToMonster() { var monster = new Monster(Id, Name, HP, XP, Image, Gold); if (Loot?.Any() ?? false) { foreach (var loot in Loot) { monster.AddToLootTable(new IdPercentage() { Id = loot.Id, Percentage = loot.Chance }); } } ; if (Weapon > 0) { //TODO: Should defer this var weapon = ItemFactory.NewItem(Weapon); if (weapon != null) { monster.CurrentWeapon = weapon; } else { Trace.TraceWarning($"Monster {Id}: Weapon {Weapon} not found"); } } ; return(monster); }
public IItem LootTheLoot() { IItem item = null; if (!Loot.Any()) { Console.WriteLine("Enemy doesn't have any items."); Console.WriteLine(""); } else { ListLoot(); Console.WriteLine("You can (take 'item') or go (back)."); string userInput = Console.ReadLine().ToLower(); string[] words = userInput.Split(' '); string command = words[0]; string option = ""; if (words.Length > 1) { option = words[1]; } switch (command) { case "take": IItem targetItem = Loot.Find(l => l.Name.ToLower() == option); Console.Clear(); if (targetItem is null) { Console.WriteLine("They don't have whatever it is you're wanting, buddy."); } else { Loot.Remove(targetItem); item = targetItem; } break; case "back": // Console.Clear(); return(null); default: Console.WriteLine("What's wrong with you?! Hurry up! Everyone's waiting!"); break; } } // NOTE Take enemy items and add to inventory (How to get it into Fighter inventory from here...) // NOTE Remove items from enemy Loot // NOTE Display what the Fighter took return(item); }
public Tile GetClosestEmpty(Tile baseTile, bool incDiagonals, bool excludeLootPositions) { var emptyTiles = GetEmptyNeighborhoodTiles(baseTile, incDiagonals, excludeLootPositions); if (emptyTiles.Any()) { return(emptyTiles.First()); } Func <Tile, bool> canBeUsed = (Tile tile) => { if (excludeLootPositions) { if (Loot.Any(j => j.Value.point == tile.point)) { return(false); } } return(true); }; return(base.GetClosestEmpty(baseTile, false, null, incDiagonals, canBeUsed)); }
bool IsLootTile(Tile tile) { return(Loot.Any(j => j.Value.point == tile.point)); }