Esempio n. 1
0
        public string DefeatMonsters(string monster, List <DungeonDieType> targetList)
        {
            // player attacked a monster, remove all monsters of that type if it is in the target list, otherwise remove single monster
            var  monsterDie = DungeonDice.First(d => d.Name == monster);
            bool removeAllMonstersOfThisType = targetList.Any(m => m == monsterDie.DungeonDieType);

            if (!removeAllMonstersOfThisType)
            {
                // we do not need to kill all monsters, just  remove a single one
                DungeonDice.Remove(monsterDie);
                return($"one {monsterDie.Name}");
            }
            int monstersKilled = 0;

            for (int i = DungeonDice.Count - 1; i >= 0; i--)
            {
                if (DungeonDice[i].DungeonDieType == monsterDie.DungeonDieType)
                {
                    monstersKilled++;
                    DungeonDice.RemoveAt(i);
                }
            }

            return(monstersKilled > 1 ?  $"{monstersKilled} {monsterDie.Name} monsters" : $"{monstersKilled} {monsterDie.Name}");;
        }
Esempio n. 2
0
        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);
        }