public TreasureItem DefeatDragon() { DragonsLair = 0; var treasure = TreasureItems[0]; TreasureItems.RemoveAt(0); return(treasure); }
public TreasureItem OpenChest() { // check if there are chests available to open if (!HasChest) { // no chests to open return(null); } // we have a chest, remove it from the list of dungeon dice var chest = DungeonDice.First(d => d.DungeonDieType == DungeonDieType.Chest); DungeonDice.Remove(chest); // now return a treasure item and remove from treasure items var treasure = TreasureItems[0]; TreasureItems.RemoveAt(0); return(treasure); }
public List <TreasureItem> OpenAllChests() { // opens all chests and returns multiple treasure items // if no chests return null if (!HasChest) { return(null); } List <TreasureItem> items = new List <TreasureItem>(); // remove all chests int numberOfChests = DungeonDice.RemoveAll(d => d.DungeonDieType == DungeonDieType.Chest); // now lets add the treasure items to the list we will return for (int i = 0; i < numberOfChests; i++) { items.Add(TreasureItems[0]); TreasureItems.RemoveAt(0); } return(items); }