Пример #1
0
        public string ValidateNumberOfPotions(int requestedNumberOfPotions, int numberOfCompanionsInGraveyard)
        {
            // return empty string if number is valid, otherwise returns the error message
            int availablePotions = DungeonDice.Count(d => d.DungeonDieType == DungeonDieType.Potion);

            if (availablePotions < 1)
            {
                return("There are no potions available. ");
            }
            else if (requestedNumberOfPotions < 1)
            {
                return($"You provided an invalid number of potions. The number of potions that are currently available is {availablePotions}. ");
            }
            else if (availablePotions < requestedNumberOfPotions)
            {
                return($"The number of potions currently available is {availablePotions}. Try the quaff potion command again. ");
            }
            else if (requestedNumberOfPotions > numberOfCompanionsInGraveyard)
            {
                return($"The number of potions you can quaff can't be higher than the companions in your graveyard. ");
            }

            // no errors found proceed
            return(string.Empty);
        }
Пример #2
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}");;
        }
Пример #3
0
        public virtual string CreateNextDungeonLevel()
        {
            // creates the next dungeon level

            Level++;
            // get the number of dice we can roll
            int dungeonDiceToRoll = Math.Min(Level, TOTAL_DUNGEON_DICE - DragonsLair);

            for (int i = 0; i < dungeonDiceToRoll; i++)
            {
                var die = new DungeonDie();
                // if dragon add it to dragon's lair and continue
                if (die.DungeonDieType == DungeonDieType.Dragon)
                {
                    DragonsLair++;
                    // we got a dragon continue with a new die
                    continue;
                }
                // not a dragon, at it to dungeon dice
                DungeonDice.Add(die);
            }
            string dragons = DragonsLair > 0 ? $"The number of dragon dice in the Dragon's lair is {DragonsLair}. " : "";
            string message = $"{SoundManager.DiceRollSound(true)} {dragons}";

            return(message);
        }
Пример #4
0
 public void DrinkPotions(int numberOfPotions)
 {
     // remove potions from the dungeon dice
     for (int i = 0; i < numberOfPotions; i++)
     {
         DungeonDice.RemoveFirst(d => d.DungeonDieType == DungeonDieType.Potion);
     }
 }
Пример #5
0
        public string GetDungeonDiceAsString()
        {
            // formatted string to describe the dungeon
            string message = "";

            var    groups   = DungeonDice.GroupBy(g => g.Name).OrderByDescending(g => g.Count()).Select(g => new { Key = (g.Count() > 1) ? g.Key + "s" : g.Key, Count = g.Count() });
            int    dieCount = 0;
            string dieName  = "";

            if (groups.Count() == 1)
            {
                dieCount = groups.First().Count;
                dieName  = groups.First().Key;
                if (dieCount > 1)
                {
                    //dieName += "s"; ;
                }
                message = $"{dieCount} {dieName}";
            }
            else if (groups.Count() == 2)
            {
                List <string> formattedGroups = new List <string>();
                foreach (var item in groups)
                {
                    dieCount = item.Count;
                    dieName  = item.Key;
                    if (dieCount > 1)
                    {
                        //dieName += "s"; ;
                    }
                    formattedGroups.Add($"{dieCount} {dieName}");
                }
                message = $"{formattedGroups[0]} and {formattedGroups[1]}";
            }
            else if (groups.Count() > 2)
            {
                for (int i = 0; i < groups.Count(); i++)
                {
                    dieCount = groups.ElementAt(i).Count;
                    dieName  = groups.ElementAt(i).Key;
                    if (dieCount > 1)
                    {
                        //dieName += "s"; ;
                    }
                    message += (i == groups.Count() - 1) ? $"and {dieCount} {dieName}" : $"{dieCount} {dieName}, ";
                }
            }
            else
            {
                message = "no monsters or loot";
            }

            return(message);
        }
Пример #6
0
 public void CheckForDragons()
 {
     // Checks if there are dragons in the dungeon dice and increments the lair size
     for (int i = DungeonDice.Count - 1; i >= 0; i--)
     {
         if (DungeonDice[i].DungeonDieType == DungeonDieType.Dragon)
         {
             DragonsLair++;
             DungeonDice.RemoveAt(i);
         }
     }
 }
Пример #7
0
        public override string CreateNextDungeonLevel()
        {
            // use default level creation if we dont need to transform  yet
            if (!SkeletonsToPotions)
            {
                return(base.CreateNextDungeonLevel());
            }

            Level++;
            // get the number of dice we can roll
            int dungeonDiceToRoll    = Math.Min(Level, TOTAL_DUNGEON_DICE - DragonsLair);
            int transformedSkeletons = 0;

            for (int i = 0; i < dungeonDiceToRoll; i++)
            {
                var die = new DungeonDie();
                // if dragon add it to dragon's lair and continue
                if (die.DungeonDieType == DungeonDieType.Dragon)
                {
                    DragonsLair++;
                    // we got a dragon continue with a new die
                    continue;
                }
                // transform skeleton into potion if die is a skeleton
                if (die.DungeonDieType == DungeonDieType.Skeleton)
                {
                    die.DungeonDieType = DungeonDieType.Potion;
                    transformedSkeletons++;
                }
                // at it to dungeon dice
                DungeonDice.Add(die);
            }
            string dragons = DragonsLair > 0 ? $"The number of dragon dice in the Dragon's lair is {DragonsLair}. " : "";
            string skeletonsToPotionsMessage = "";

            if (transformedSkeletons == 1)
            {
                skeletonsToPotionsMessage = "One skeleton was transformed to a potion. ";
            }
            if (transformedSkeletons > 1)
            {
                skeletonsToPotionsMessage = $"{transformedSkeletons} skeletons were transformed to potions. ";
            }
            string message = $"{SoundManager.DiceRollSound(true)} {dragons}{skeletonsToPotionsMessage}";

            return(message);
        }
Пример #8
0
        public override string CreateNextDungeonLevel()
        {
            // creates the next dungeon level

            Level++;
            // get the number of dice we can roll
            int dungeonDiceToRoll = Math.Min(Level, TOTAL_DUNGEON_DICE - DragonsLair);
            int transformedChests = 0;

            for (int i = 0; i < dungeonDiceToRoll; i++)
            {
                var die = new DungeonDie();
                // if dragon add it to dragon's lair and continue
                if (die.DungeonDieType == DungeonDieType.Dragon)
                {
                    DragonsLair++;
                    // we got a dragon continue with a new die
                    continue;
                }
                // transform chest into potion if die is a chest
                if (die.DungeonDieType == DungeonDieType.Chest)
                {
                    die.DungeonDieType = DungeonDieType.Potion;
                    transformedChests++;
                }
                // at it to dungeon dice
                DungeonDice.Add(die);
            }
            string dragons         = DragonsLair > 0 ? $"The number of dragon dice in the Dragon's lair is {DragonsLair}. " : "";
            string chestsToPotions = "";

            if (transformedChests == 1)
            {
                chestsToPotions = "One chest was transformed to a potion. ";
            }
            if (transformedChests > 1)
            {
                chestsToPotions = $"{transformedChests} chests were transformed to potions. ";
            }
            string message = $"{SoundManager.DiceRollSound(true)} {dragons}{chestsToPotions}";

            return(message);
        }
Пример #9
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);
        }
Пример #10
0
        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);
        }
Пример #11
0
 public GameState DetermineDungeonPhase()
 {// this method checks the status of the dungeon and returns a game state enum to determine which phase we should be in
     // first check if there are any monsters
     if (DungeonDice.Any(d => d.IsMonster))
     {
         // we have a monster we should be in omnster phase
         return(GameState.MonsterPhase);
     }
     // no monsters, let's check if there is loot
     if (HasLoot)
     {
         // we found loot, should be in loot phase
         return(GameState.LootPhase);
     }
     // lets check if we should go to dragon phase
     if (DragonsLair > 2)
     {
         // there are 3 or more dragons in the lair, we should fight the dragon
         return(GameState.DragonPhase);
     }
     // TODO: Consider checking if level 10 is cleared to mark the end of a delve and award points
     // if we are here, dungeon level is clear and we should be in the regroup phase
     return(GameState.RegroupPhase);
 }
Пример #12
0
 public string IgnoreLoot()
 {
     // player decided to ignore loot, so we need to remove it from dungeon dice
     DungeonDice.Clear();
     return("You decided to ignore the remaining loot and continue. ");
 }
Пример #13
0
 public bool IsMonsterInDungeon(DungeonDieType monster)
 {
     // checks if the monster is present in the dungeon
     return(DungeonDice.Any(d => d.DungeonDieType == monster && d.IsMonster));
 }
Пример #14
0
 public bool IsMonsterInDungeon(string monsterName)
 {
     // checks if the monster is present in the dungeon
     return(DungeonDice.Any(d => d.Name == monsterName && d.IsMonster));
 }