Esempio n. 1
0
        private int ResolveDefense(Actor defender, int hits, StringBuilder attackMsg, StringBuilder defenseMsg)
        {
            int blocks = 0;

            if (hits > 0)
            {
                attackMsg.AppendFormat("Атака с рейтингом {0} попадания.", hits);
                defenseMsg.AppendFormat("   {0} защищается с рейтингом: ", defender.Name);

                DiceExpression defenseDice = new DiceExpression().Dice(defender.Defense, 100);
                DiceResult     defenseRoll = defenseDice.Roll();

                foreach (TermResult termResult in defenseRoll.Results)
                {
                    defenseMsg.Append(termResult.Value + ", ");

                    if (termResult.Value >= 100 - defender.DefenseChance)
                    {
                        blocks++;
                    }
                    defenseMsg.AppendFormat("{0}.", blocks);
                }
            }
            else
            {
                attackMsg.Append("и полностью промахивается.");
            }

            return(blocks);
        }
Esempio n. 2
0
        public override GrammarParseResult VisitSumRoll(SumRollContext context)
        {
            if (context == null)
            {
                return(GrammarParseResult.Unsuccessful(context.GetText()));
            }

            Debug.WriteLine($"VisitSumRoll \"{context.GetText()}\"");

            GrammarParseResult childNumDice = VisitExpression(context.num);

            childNumDice.Label = "# Dice";
            GrammarParseResult childDiceSides = VisitExpression(context.sides);

            childDiceSides.Label = "Dice Sides";
            int numDice   = childNumDice.Value;
            int diceSides = childDiceSides.Value;

            GrammarParseResult result = new GrammarParseResult(context.GetText());

            result.Children.Add(childNumDice);
            result.Children.Add(childDiceSides);

            result.EvaluatedText = $"{numDice}d{diceSides}";

            DiceResult diceResult = DiceUtil.Roll(numDice, diceSides);

            result.Value  = diceResult.Total;
            result.Output = String.Join(", ", diceResult.Values);

            return(result);
        }
        /// <summary>
        /// Gets the dice result for ai player.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Player> PlayGameForAIPlayer(int numberOfAiPlayers)
        {
            //null check
            if (numberOfAiPlayers <= int.MinValue)
            {
                return(new List <Player>());
            }
            var players = new List <Player>();

            //loop through AI players count
            for (var i = 0; i < numberOfAiPlayers; i++)
            {
                var diceResult = new DiceResult();
                //get the dice roll
                diceResult = _diceService.RollDice();
                //get the hand by roll
                var currentHand = _diceService.GetHandNameByRoll(diceResult.DiceResultDetails);
                //add player data to players
                players.Add(new Player()
                {
                    Name = $"Player{i + 1}",
                    Hand = new PlayerHand()
                    {
                        HandName = currentHand, ThrowResult = diceResult.Result
                    }
                });
            }
            //return dice results for all AI players
            return(players);
        }
Esempio n. 4
0
        public static void Play()
        {
            Console.WriteLine($"Välj hur många tärningar du vill kasta, välj ett heltal mellan {minDiceRolls}-{maxDiceRolls} :) ");
            int diceRolls = 0;
            var input     = Console.ReadLine();

            while (!int.TryParse(input, out diceRolls) || diceRolls < minDiceRolls || diceRolls > maxDiceRolls)
            {
                Console.WriteLine($"Inte ett heltal mellan {minDiceRolls}-{maxDiceRolls}, testa igen!");
                input = Console.ReadLine();
            }
            Console.Clear();
            Console.WriteLine($"OK, kastar tärningen {diceRolls} gånger!");
            var diceResult = new DiceResult
            {
                RolledCount = diceRolls
            };

            for (int i = 0; i < diceRolls; i++)
            {
                var rolledDice = RollDice(diceResult);
                diceResult.RolledCount = rolledDice.RolledCount;
                diceResult.TotalSum    = rolledDice.TotalSum;
                if (i + 1 < diceRolls)
                {
                    Console.WriteLine($"Summan av tärningarna är nu {diceResult.TotalSum}");
                }
            }
            Console.WriteLine($"Summan av tärningarna blev: {diceResult.TotalSum}");
            Console.WriteLine($"Tärningen kastades totalt {diceResult.RolledCount} gånger");
            Console.ReadLine();
        }
Esempio n. 5
0
        public void Dice_RollScalarMultiplierDiceTest()
        {
            // setup test
            IDice dice = new Dice();

            dice.Dice(8, 2, 10);

            // run test
            DiceResult result = dice.Roll(roller);

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual("OnePlat.DiceNotation.DieRoller.RandomDieRoller", result.DieRollerUsed);
            AssertHelpers.IsWithinRangeInclusive(20, 160, result.Value);
            Assert.AreEqual(2, result.Results.Count);
            int sum = 0;

            foreach (TermResult r in result.Results)
            {
                AssertHelpers.IsWithinRangeInclusive(1, 8, r.Value);
                sum += (int)(r.Value * r.Scalar);
            }
            Assert.AreEqual(sum, result.Value);
            Assert.AreEqual("2d8x10", result.DiceExpression);
        }
Esempio n. 6
0
        // The defender rolls based on his stats to see if he blocks any of the hits from the attacker
        private int ResolveDefense(Actor defender, int hits, StringBuilder attackMessage, StringBuilder defenseMessage)
        {
            int blocks = 0;

            if (hits > 0)
            {
                attackMessage.AppendFormat("scoring {0} hits.", hits);
                defenseMessage.AppendFormat("  {0} defends and rolls: ", defender.Name);

                // Roll a number of 100-sided dice equal to the Defense value of the defendering actor
                DiceExpression defenseDice = new DiceExpression().Dice(defender.Defense, 100);
                DiceResult     defenseRoll = defenseDice.Roll();

                // Look at the face value of each single die that was rolled
                foreach (TermResult termResult in defenseRoll.Results)
                {
                    defenseMessage.Append(termResult.Value + ", ");
                    // Compare the value to 100 minus the defense chance and add a block if it's greater
                    if (termResult.Value >= 100 - defender.DefenseChance)
                    {
                        blocks++;
                    }
                }
                defenseMessage.AppendFormat("resulting in {0} blocks.", blocks);
            }
            else
            {
                attackMessage.Append("and misses completely.");
            }

            return(blocks);
        }
Esempio n. 7
0
        public void Dice_RollMultipleFudgeDiceTest()
        {
            // setup test
            IDice dice = new Dice();

            dice.FudgeDice(6);

            // run test
            DiceResult result = dice.Roll(this.roller);

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual("OnePlat.DiceNotation.DieRoller.RandomDieRoller", result.DieRollerUsed);
            AssertHelpers.IsWithinRangeInclusive(-6, 6, result.Value);
            Assert.AreEqual(6, result.Results.Count);
            int sum = 0;

            foreach (TermResult r in result.Results)
            {
                AssertHelpers.IsWithinRangeInclusive(-1, 1, r.Value);
                sum += r.Value;
            }
            Assert.AreEqual(sum, result.Value);
            Assert.AreEqual("6f", result.DiceExpression);
        }
Esempio n. 8
0
        private float ResolveDefence()
        {
            if (GetComponent <Statistic>(ComponentType.Stats).Energy < 3)
            {
                return(0f);
            }

            GetComponent <Statistic>(ComponentType.Stats).Energy -= 3;
            float          blockPercent = 0;
            DiceExpression blockDice    = new DiceExpression().Dice(Stats.Defence, 100);
            DiceResult     blockResult  = blockDice.Roll();

            foreach (TermResult termResult in blockResult.Results)
            {
                if (termResult.Value >= (100 - Stats.DefenceChance))
                {
                    blockPercent++;
                }
            }

            var bp = blockPercent / (float)Stats.Defence;

            if (bp == 1 && Stats.Defence >= 20)
            {
                return(1);
            }

            bp = bp * (float)0.80;

            System.Console.WriteLine("BlockPercent:{0}", bp);

            return(bp);
        }
Esempio n. 9
0
        public void Dice_RollExplodingDiceTest()
        {
            // setup test
            IDice dice = new Dice();

            dice.Dice(6, 4, exploding: 6);

            // run test
            DiceResult result = dice.Roll(roller);

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual("OnePlat.DiceNotation.DieRoller.RandomDieRoller", result.DieRollerUsed);
            int sum = 0, count = 4;

            foreach (TermResult r in result.Results)
            {
                Assert.IsNotNull(r);
                Assert.AreEqual(1, r.Scalar);
                AssertHelpers.IsWithinRangeInclusive(1, 6, r.Value);
                Assert.AreEqual("DiceTerm.d6", r.Type);
                sum += r.Value;
                if (r.Value >= 6)
                {
                    count++;
                }
            }
            Assert.AreEqual(count, result.Results.Count);
            Assert.AreEqual(sum, result.Value);
            Assert.AreEqual("4d6!6", result.DiceExpression);
        }
        public void DiceParser_ParseDiceWithExplodingNoValueRandomTest()
        {
            // setup test
            DiceParser parser = new DiceParser();

            // run test
            DiceResult result = parser.Parse("10d6!", this.config, new RandomDieRoller());

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual("10d6!", result.DiceExpression);
            int sum = 0, count = 10;

            foreach (TermResult r in result.Results)
            {
                Assert.IsNotNull(r);
                Assert.AreEqual(1, r.Scalar);
                AssertHelpers.IsWithinRangeInclusive(1, 6, r.Value);
                Assert.AreEqual("DiceTerm.d6", r.Type);
                sum += r.Value;
                if (r.Value >= 6)
                {
                    count++;
                }
            }
            Assert.AreEqual(count, result.Results.Count);
            Assert.AreEqual(sum, result.Value);
        }
Esempio n. 11
0
        // El defensor tira el dado basado en sus estadísticas para ver si
        // bloquea cuaqluiera de los golpes del atacante.
        private static int ResolveDefense( Actor defender, int hits, StringBuilder attackMessage, StringBuilder defenderMessage)
        {
            int blocks = 0;

            if ( hits > 0 )
            {
                attackMessage.AppendFormat("puntuación {0} golpes.", hits);
                defenderMessage.AppendFormat(" {0} defiende y tira: ", defender.Name);

                // Rodamos un número de 100 dados de igual lado con el valor de la
                // defensa del defensor.
                DiceExpression defenseDice = new DiceExpression().Dice(defender.Defensa, 100);
                DiceResult defenseRoll = defenseDice.Roll();

                // Miramos el valor de la cara de cada dado que fue rodado.
                foreach( TermResult termResult in defenseRoll.Results )
                {
                    defenderMessage.Append(termResult.Value + ", ");
                    // Comparamos el valor a 100, menos la probabilidad de
                    // defender y añadimos un bloqueo si este es mayor.
                    if ( termResult.Value >= 100 - defender.DefensaChance )
                    {
                        blocks += 1;
                    }
                }

                defenderMessage.AppendFormat("resultando en {0} bloqueo(s).", blocks);
            }
            else
            {
                attackMessage.Append("y falla completamente.");
            }

            return blocks;
        }
Esempio n. 12
0
        /// <inheritdoc/>
        public bool Execute(object parameter)
        {
            try
            {
                IDice dice = new Dice();
                dice.Configuration.HasBoundedResult = this.vm.HasBoundedResult;
                dice.Configuration.DefaultDieSides  = this.vm.DefaultDieSides ?? 6;

                DiceResult result = dice.Roll(parameter as string, this.vm.DieRoller);

                if (this.vm.UseVerboseOutput)
                {
                    this.vm.DisplayText += this.VerboseRollDisplay(dice, result);
                }
                else
                {
                    this.vm.DisplayText += string.Format(
                        "DiceRoll => {0} [dice: {1}]",
                        this.diceConverter.Convert(result, typeof(string), null, "default"),
                        this.listConverter.Convert(result.Results, typeof(string), null, "default"));
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.vm.DisplayText += string.Format("Error: could not parse dice notation for {0}.\r\n", parameter);
                this.vm.DisplayText += string.Format("Exception thrown: {0} - {1}\r\n", ex.GetType(), ex.Message);

                return(false);
            }
        }
Esempio n. 13
0
    public override void Init(object args = null)
    {
        Rolled         = false;
        Finished       = false;
        Success        = false;
        PlayerResult   = new DiceResult();
        OpponentResult = new DiceResult();
        if (diceRoller == null)
        {
            Debug.LogError("Dice roller cannot be null");
            return;
        }

        if (args == null)
        {
            SimpleMode = true;
            NumDice    = 1;
            return;
        }
        SimpleMode = false;
        TestData   = args as TestData;

        if (TestData == null)
        {
            Debug.LogError("Cannot make a roll without a test");
            BackOut();
            return;
        }

        IsSuccessTest = string.IsNullOrEmpty(TestData.OpponentSkill);

        OpponentName = TestData.OpponentName;
    }
Esempio n. 14
0
        private static int ResolveDefense(Actor defender, int hits, StringBuilder attackMessage, StringBuilder defenseMessage)
        {
            int blocks = 0;

            if (hits > 0)
            {
                attackMessage.AppendFormat("atingindo {0} golpes", hits);
                defenseMessage.AppendFormat(" {0} defende e rola: ", defender.Name);

                DiceExpression defenseDice = new DiceExpression().Dice(defender.Defense, 100);
                DiceResult     defenseRoll = defenseDice.Roll();

                foreach (TermResult termResult in defenseRoll.Results)
                {
                    defenseMessage.Append(termResult.Value + ", ");

                    if (termResult.Value >= 100 - defender.DefenseChance)
                    {
                        blocks++;
                    }
                }

                defenseMessage.AppendFormat("resultando em {0} bloqueios", blocks);
            }
            else
            {
                attackMessage.Append("e erra completamente");
            }

            return(blocks);
        }
Esempio n. 15
0
        /// <summary>
        /// Display the dice roll results in verbose format.
        /// Helpful in debugging dice expression strings.
        /// </summary>
        /// <param name="dice">Dice expression used</param>
        /// <param name="result">Dice results to display</param>
        /// <returns>Resulting display text.</returns>
        private string VerboseRollDisplay(IDice dice, DiceResult result)
        {
            StringBuilder output = new StringBuilder();

            output.AppendFormat(
                "DiceRoll => {0}",
                this.diceConverter.Convert(result, typeof(string), null, "default"));

            output.AppendLine("===============================================");
            output.AppendFormat("  DiceResult.DieRollerUsed: {0}\r\n", result.DieRollerUsed);
            output.AppendFormat("  DiceResult.NumberTerms: {0}\r\n", result.Results.Count);
            output.AppendLine("  Terms list:");
            output.AppendLine("  ---------------------------");

            foreach (TermResult term in result.Results)
            {
                output.AppendFormat("    TermResult.Type: {0}\r\n", term.Type);
                output.AppendFormat("    TermResult.IncludeInResult: {0}\r\n", term.AppliesToResultCalculation);
                output.AppendFormat("    TermResult.Scalar: {0}\r\n", term.Scalar);
                output.AppendFormat("    TermResult.Value: {0}\r\n", term.Value);
                output.AppendLine();
            }

            output.AppendLine("  ---------------------------");
            output.AppendFormat("  Total Roll: {0}\r\n", result.Value);

            return(output.ToString());
        }
Esempio n. 16
0
        private static int ResolveDefense(Actor defender, int hits, StringBuilder attackMessage, StringBuilder defenseMessage)
        {
            int blocks = 0;

            if (hits > 0)
            {
                attackMessage.AppendFormat("scoring {0} hits.", hits);
                defenseMessage.AppendFormat("  {0} defends and rolls: ", defender.Name);
                DiceExpression defenseDice = new DiceExpression().Dice(defender.Defense, 100);

                DiceResult defenseRoll = defenseDice.Roll();
                foreach (TermResult termResult in defenseRoll.Results)
                {
                    defenseMessage.Append(termResult.Value + ", ");
                    if (termResult.Value >= 100 - defender.DefenseChance)
                    {
                        blocks++;
                    }
                }
                defenseMessage.AppendFormat("resulting in {0} blocks.", blocks);
            }
            else
            {
                attackMessage.Append("and misses completely.");
            }

            return(blocks);
        }
Esempio n. 17
0
        public void SingleDie(int value)
        {
            var diceResult = new DiceResult(new int[]{value});

            Assert.AreEqual(value, diceResult[0]);
            Assert.AreEqual(value, diceResult.Sum());
        }
Esempio n. 18
0
        public void SingleDie(int value)
        {
            var diceResult = new DiceResult(new int[] { value });

            Assert.AreEqual(value, diceResult[0]);
            Assert.AreEqual(value, diceResult.Sum());
        }
Esempio n. 19
0
        //check too see how many hits the attacker got on the defender and displays message
        private static int ResolveAttack(Actor attacker, Actor defender, StringBuilder attackMessage)
        {
            int hits = 0;

            //displays message of who is attacking which defender
            //attackMessage.AppendFormat("{0} attacks {1} and rolls: ", attacker.Name, defender.Name);

            //Roll a number 100-dice equal to the attack value of the attacking actor
            //gets the dice for that attacker
            DiceExpression attackDice = new DiceExpression().Dice(attacker.Attack, 100);
            //rolls the attackers dice and gets the dice result
            DiceResult attackResult = attackDice.Roll();

            //foreach dice roll in the attackers results
            foreach (TermResult termResult in attackResult.Results)
            {
                //appends the attack message adding the current attack dice value
                attackMessage.Append(termResult.Value + ", ");

                //if the current attack dice roll result was more than 100 - the attackers attack chance
                //it was a success and a hit is added
                if (termResult.Value >= 100 - attacker.AttackChance)
                {
                    hits++;
                }
            }

            return(hits);
        }
Esempio n. 20
0
        public void Dice_RollSingleDieTest()
        {
            // setup test
            IDice dice = new Dice();

            dice.Dice(20);

            // run test
            DiceResult result = dice.Roll(roller);

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual("OnePlat.DiceNotation.DieRoller.RandomDieRoller", result.DieRollerUsed);
            AssertHelpers.IsWithinRangeInclusive(1, 20, result.Value);
            Assert.AreEqual(1, result.Results.Count);
            int sum = 0;

            foreach (TermResult r in result.Results)
            {
                AssertHelpers.IsWithinRangeInclusive(1, 20, r.Value);
                sum += r.Value;
            }
            Assert.AreEqual(sum, result.Value);
            Assert.AreEqual("1d20", result.DiceExpression);
        }
Esempio n. 21
0
        // El atacante tira en función de sus estadísticas para ver si obtiene
        // algún resultado.
        private static int ResolveAttack( Actor attacker, Actor defender, StringBuilder attackMessage)
        {
            int hits = 0;

            attackMessage.AppendFormat("{0} ataca a {1} y tira: ", attacker.Name, defender.Name);

            // Rodamos un número de 100 dados de igual lados, que será igual al valor de
            // ataque del atacante {attacker}.
            DiceExpression attackDice = new DiceExpression().Dice(attacker.Attack, 100);
            DiceResult attackResult = attackDice.Roll();

            // Miramos el valor de la cara de cada dado que fue rodado.
            foreach ( TermResult termResult in attackResult.Results )
            {
                attackMessage.Append(termResult.Value + ", ");
                // Comparamos el valor a 100, menos la probabilidad de
                // ataque y añadimos el golpe si este es mayor.
                if ( termResult.Value >= 100 - attacker.AttackChance )
                {
                    hits += 1;
                }
            }

            return hits;
        }
Esempio n. 22
0
    public void MoveByDice(DiceResult diceResult)
    {
        LastDiceResult = diceResult;

        //If the player is in the well
        if (TurnInfo.InWell)
        {
            if (!diceResult.HasDone(6))
            {
                GameManager.EndTurn(); return;
            }                                                          //Pass turn..
            TurnInfo = TurnInfo.Builder().Build();
        }

        //If the player is on begin cell
        if (TurnInfo.OnBeginCell)
        {
            //6 and 3
            if (diceResult.HasDone(6, 3))
            {
                MoveManager.MoveAt(this, 26, true);
                return;
            }

            //5 and 4
            if (diceResult.HasDone(5, 4))
            {
                MoveManager.MoveAt(this, 53, true);
                return;
            }
        }

        MoveManager.Move(this, diceResult.Total);
    }
Esempio n. 23
0
        /// <summary>
        /// The attacker rolls based on his stats to see if he gets any hits
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="defender"></param>
        /// <param name="attackMessage"></param>
        /// <returns></returns>
        private static int ResolveAttack(Actor attacker, Actor defender, StringBuilder attackMessage)
        {
            int hits = 0;

            // Roll a number of 100-sided dice equal to the Attack value of the attacking actor
            DiceExpression attackDice   = new DiceExpression().Dice(attacker.Attack, 100);
            DiceResult     attackResult = attackDice.Roll();

            // Look at the face value of each single die that was rolled
            foreach (TermResult termResult in attackResult.Results)
            {
                // Compare the value to 100 minus the attack chance and add a hit if it's greater
                if (termResult.Value >= 100 - attacker.AttackChance)
                {
                    hits++;
                }
            }

            // TODO: Different messages based on how many hits were made
            if (hits == attacker.Attack)
            {
                attackMessage.AppendFormat("{0} slams into {1} with full force!", attacker.Name, defender.Name);
            }
            else if (hits > 0)
            {
                attackMessage.AppendFormat("{0} lunges at {1}.", attacker.Name, defender.Name);
            }
            else
            {
                attackMessage.AppendFormat("{0} launches offbalance toward {1}.", attacker.Name, defender.Name);
            }

            return(hits);
        }
Esempio n. 24
0
        private float ResolveAttack()
        {
            if (GetComponent <Statistic>(ComponentType.Stats).Energy < 2)
            {
                return(0f);
            }
            GetComponent <Statistic>(ComponentType.Stats).Energy -= 2;
            float          hitPercent   = 0;
            DiceExpression attackDice   = new DiceExpression().Dice(AttackValue, 100);
            DiceResult     attackResult = attackDice.Roll();

            foreach (TermResult termResult in attackResult.Results)
            {
                if (termResult.Value >= (100 - Stats.AttackChance))
                {
                    hitPercent++;
                }
            }

            float hp = hitPercent / (float)AttackValue;

            System.Console.WriteLine("HitPercent:{0}", hp);

            return(hp);
        }
        /// <summary>
        /// Command method to roll the dice and save the results.
        /// </summary>
        /// <param name="expression">String expression to roll.</param>
        public void RollCommand(string expression)
        {
            this.DiceExpression = expression;
            DiceResult result = this.dice.Roll(this.DiceExpression, this.dieRoller);

            this.RollResults.Insert(0, result);
        }
Esempio n. 26
0
        private static string FormatDiceResult(DiceResult diceResult)
        {
            var dicesfmt = FormatDices(diceResult.Dices);
            var namefmt  = FormatName(diceResult.Name);
            var descrfmt = FormatDescription(diceResult.Description);

            return($"{namefmt}{descrfmt} -> {dicesfmt}");
        }
Esempio n. 27
0
        public DiceResult Roll(int sides, int numDice = 1, int modifier = 0)
        {
            DiceResult result = Dice.Dice(sides, numDice).Constant(modifier).Roll(DieRoller);

            Dice.Clear();

            return(result);
        }
    internal void DisplayResult(DiceResult newResult, float time)
    {
        transform.position = toPos;
        result             = newResult;
        resultImage.sprite = result.resultSprite;

        iTween.MoveFrom(gameObject, fromPos, time);
    }
Esempio n. 29
0
        public void SummaryReturnsEmptyByDefault()
        {
            var diceResult  = new DiceResult(new int[0]);
            var orderedDice = diceResult.Summary();

            Assert.IsNotNull(orderedDice);
            Assert.IsEmpty(orderedDice);
            Assert.AreEqual(0, diceResult.Sum());
        }
Esempio n. 30
0
        public void SummaryReturnsEmptyByDefault()
        {
            var diceResult = new DiceResult(new int[0]);
            var orderedDice = diceResult.Summary();

            Assert.IsNotNull(orderedDice);
            Assert.IsEmpty(orderedDice);
            Assert.AreEqual(0, diceResult.Sum());
        }
Esempio n. 31
0
        public DiceResult Roll(int diceCount)
        {
            var rolls = new List<int>();
            for (int i = 0; i < diceCount; i++)
            {
                rolls.Add(_random.Next(1, 7));
            }

            var dice = new DiceResult(rolls);
            return dice;
        }
Esempio n. 32
0
        public void OrdersMultipleValuesAdded()
        {
            var diceResult = new DiceResult(new[] { 3, 5, 2, 3 });

            Assert.AreEqual(2, diceResult[0]);
            Assert.AreEqual(3, diceResult[1]);
            Assert.AreEqual(3, diceResult[2]);
            Assert.AreEqual(5, diceResult[3]);

            Assert.AreEqual(13, diceResult.Sum());
        }
Esempio n. 33
0
        public void OrdersMultipleValuesAdded()
        {
            var diceResult = new DiceResult(new []{3, 5, 2, 3});

            Assert.AreEqual(2, diceResult[0]);
            Assert.AreEqual(3, diceResult[1]);
            Assert.AreEqual(3, diceResult[2]);
            Assert.AreEqual(5, diceResult[3]);

            Assert.AreEqual(13, diceResult.Sum());
        }
Esempio n. 34
0
        private void AddRollStatistics(RollableStat stat, DiceResult dice)
        {
            string statName = stat.Name.Replace(" ", "").Replace("Défense:", "");

            if (!RollStatistics.ContainsKey(statName))
            {
                RollStatistics.Add(statName, new List <DiceResult>());
            }

            RollStatistics[statName].Add(dice);
        }