/// <summary>
        /// Parses a string and extracts the dice and bonus damage, then replaces the current values in this object
        /// </summary>
        /// <param name="text"></param>
        public void ParseText(string text)
        {
            var matches = Regex.Match(text, @"(\d{1,2})([dD]\d{1,3})\s?[\+-]?\s?(\d{1,3})?");

            Debug.WriteLine("Matches: " + matches.Value);
            for (var i = 0; i < matches.Groups.Count; i++)
            {
                Debug.WriteLine("match " + i + " is " + matches.Groups[i].Value);
            }
            if (matches.Success && matches.Groups.Count >= 3)
            {
                var dieType = DieType.D4;
                if (int.TryParse(matches.Groups[1].Value, out int numDice))
                {
                    if (Enum.TryParse(matches.Groups[2].Value.ToUpper(), out dieType))
                    {
                        Dice.Clear();
                        Dice.Add(dieType, numDice);
                    }
                }

                if (matches.Length >= 4)
                {
                    if (int.TryParse(matches.Groups[3].Value, out int numBonus))
                    {
                        Bonus = numBonus;
                    }
                }
            }
        }
Example #2
0
        public void RollDice()
        {
            int numDie = Dice.Count;

            Dice.Clear();
            for (var i = 0; i < numDie; i++)
            {
                Dice.Add(new Die());
            }
        }
Example #3
0
        public void InvalidAdditionThrows()
        {
            Dice first  = new Dice(2, 3);
            Dice second = new Dice(3, 4);

            Assert.Throws <InvalidOperationException> (() =>
            {
                Dice value = first.Add(second);
            });
        }
Example #4
0
 public void RollDice(Random rand)
 {
     Dice.Clear();
     Dice.Add(rand.Next(1, 7));
     Dice.Add(rand.Next(1, 7));
     if (Dice[0] == Dice[1])
     {
         Dice.Add(Dice[1]);
         Dice.Add(Dice[1]);
     }
     Moves.Clear();
     GetListOfPossibleMoves();
     PropertyChanged(null, new PropertyChangedEventArgs("Dice"));
 }
Example #5
0
 public void MovePieces(List <Move> moves)
 {
     Dice.Clear();
     foreach (Move move in moves)
     {
         Dice.Add(move.Dice);
     }
     foreach (Move move in moves)
     {
         bool isWin = MovePiece(move.FromStack, move.ToStack, 1);
         if (isWin)
         {
             return;
         }
     }
 }
Example #6
0
 public GameManager()
 {
     StoreItemCosts.Add("Goblin", 1000);
     StoreItemCosts.Add("NewD4", 5 * DefaultDieCost);
     StoreItemCosts.Add("NewD6", 7 * DefaultDieCost);
     StoreItemCosts.Add("NewD8", 9 * DefaultDieCost);
     StoreItemCosts.Add("NewD10", 11 * DefaultDieCost);
     StoreItemCosts.Add("NewD12", 13 * DefaultDieCost);
     StoreItemCosts.Add("NewD20", 21 * DefaultDieCost);
     Dice.Add(4, 0);
     Dice.Add(6, 0);
     Dice.Add(8, 0);
     Dice.Add(10, 0);
     Dice.Add(12, 0);
     Dice.Add(20, 0);
     D4Count = 1;
     doGoblinClicks();
 }
Example #7
0
        public void RollDice()
        {
            if (Dice.Count() != 5)
            {
                for (int i = 0; i < 5; i++)
                {
                    Dice.Add(new Die());
                }
            }

            foreach (Die d in Dice)
            {
                if (!d.IsHeld)
                {
                    d.Roll();
                }
            }

            RollsLeft--;
        }
Example #8
0
 public void AddDie(Die die)
 {
     Dice.Add(die);
 }