示例#1
0
        public void DiceRollTest()
        {
            // Declare

            var pool = new DicePool();

            pool.AddDie(DiceType.Ability);
            pool.AddDie(DiceType.Boost);
            pool.AddDie(DiceType.Challenge);
            pool.AddDie(DiceType.Difficulty);
            pool.AddDie(DiceType.Force);
            pool.AddDie(DiceType.Proficiency);
            pool.AddDie(DiceType.Setback);


            // Setup

            var result = pool.Roll();

            foreach (var res in result.Keys)
            {
                Console.WriteLine($"{res} : {result[res]}");
            }

            // Assert
            Assert.AreEqual(8, result.Count);
            Assert.AreEqual(7, pool.Pool.Count);
        }
示例#2
0
        public void TestMethod1()
        {
            var testPool = new DicePool();

            testPool.AddDie(new SuccessTestDie());
            var result = testPool.Roll();

            Assert.AreEqual("1 success ", result);
        }
        public virtual bool Roll(int modifier = 0)
        {
            DicePool rollDicePool = new DicePool(3);
            int      roll         = rollDicePool.Roll();
            var      required     = RollRequired(modifier);

            if (roll <= required)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
文件: Action.cs 项目: thesau31/Sau
        public ActionResult Do(IDiceBag bag, ICharacter source)
        {
            if (bag == null)
            {
                throw new ArgumentNullException("bag");
            }
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            var times = 0;

            AttributesUsed.ForEach(x => times += source.Attributes[x]);
            SkillsUsed.ForEach(x => times     += source.Skills[x]);

            var pool    = new DicePool(bag, times);
            var results = (Limit == LimitType.None)
                ? pool.Roll()
                : pool.Roll(source.Attributes.LimitValue(Limit));
            var rollNotation = buildNotation(source);

            return(new ActionResult(rollNotation, results));
        }
        public virtual bool RollAgainst(int number1, int number2)
        {
            int success = 11 + number1 - (number2);

            DicePool rollDicePool = new DicePool(3);

            int roll = rollDicePool.Roll();

            if (roll <= success)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
            public void Valid()
            {
                // arrange
                const int seed          = 1234;
                const int _numberOfDice = 3;
                var       bag           = new DiceBag(seed);
                var       actual        = new DicePool(bag, _numberOfDice);
                var       expected      = new DicePoolResults(new List <int> {
                    2, 5, 2
                });

                // act
                var results = actual.Roll();

                // assert
                Assert.AreEqual(expected.RollResults.Count, results.RollResults.Count);
                for (int i = 0; i < results.RollResults.Count; i++)
                {
                    Assert.AreEqual(expected.RollResults[i], results.RollResults[i]);
                }
            }
示例#7
0
        public void BoostDieTest()
        {
            // Declare
            var pool = new DicePool();

            pool.AddDie(DiceType.Boost);

            // Setup
            var results = pool.Roll();

            foreach (var res in results.Keys)
            {
                Console.WriteLine($"{res} : {results[res]}");
            }

            // Assert
            Assert.IsTrue(results[ResultTypes.DarkPoint] == 0);
            Assert.IsTrue(results[ResultTypes.Dispair] == 0);
            Assert.IsTrue(results[ResultTypes.Failure] == 0);
            Assert.IsTrue(results[ResultTypes.LightPoint] == 0);
            Assert.IsTrue(results[ResultTypes.Threat] == 0);
            Assert.IsTrue(results[ResultTypes.Triumph] == 0);
        }