コード例 #1
0
        public void DiceRollKeepsPreviousDie2Result()
        {
            RollResult previousResult = new RollResult(4, 7, 4);

            RollResult currentResult = master.RollDice(true, false, true, previousResult);

            Assert.AreEqual(7, currentResult.Die2());
        }
コード例 #2
0
        public void RollResultCorrectlyAssignesInputs()
        {
            RollResult rr = new RollResult(1, 2, 3);

            Assert.AreEqual(1, rr.Die1());
            Assert.AreEqual(2, rr.Die2());
            Assert.AreEqual(3, rr.Die3());
        }
コード例 #3
0
        public void DiceRollDoesNotKeepPreviousResultOfZero()
        {
            RollResult previousResult = new RollResult(4, 0, 4);

            RollResult currentResult = master.RollDice(true, false, true, previousResult);

            Assert.AreNotEqual(0, currentResult.Die2());
        }
コード例 #4
0
        public RollResult RollDice(bool rollDie1, bool rollDie2, bool rollDie3, RollResult previousResult)
        {
            RollResult previousRoll = null != previousResult ? previousResult : new NullRollResult();

            int temp1 = 0;
            int temp2 = 0;
            int temp3 = 0;

            if (rollDie1 || 0 == previousResult.Die1())
            {
                temp1 = diceSet[0].Roll();
            }
            else
            {
                temp1 = previousResult.Die1();
            }

            if (rollDie2 || 0 == previousResult.Die2())
            {
                temp2 = diceSet[1].Roll();
            }
            else
            {
                temp2 = previousResult.Die2();
            }

            if (rollDie3 || 0 == previousResult.Die3())
            {
                temp3 = diceSet[2].Roll();
            }
            else
            {
                temp3 = previousResult.Die3();
            }

            return(new RollResult(temp1, temp2, temp3));
        }
コード例 #5
0
        public RollResult RollDice(bool rollDie1, bool rollDie2, bool rollDie3, RollResult previousResult)
        {
            RollResult previousRoll = null != previousResult ? previousResult : new NullRollResult();

            int temp1 = 0;
            int temp2 = 0;
            int temp3 = 0;

            if (rollDie1 || 0 == previousResult.Die1())
            {
                temp1 = diceSet[0].Roll();
            }
            else
            {
                temp1 = previousResult.Die1();
            }

            if (rollDie2 || 0 == previousResult.Die2())
            {
                temp2 = diceSet[1].Roll();
            }
            else
            {
                temp2 = previousResult.Die2();
            }

            if (rollDie3 || 0 == previousResult.Die3())
            {
                temp3 = diceSet[2].Roll();
            }
            else
            {
                temp3 = previousResult.Die3();
            }

            return new RollResult(temp1, temp2, temp3);
        }