public void DiceCalculator_Threes_2ReturnsValidAndScoreOf6()
        {
            //arrange
            var rules = new List <Func <byte[], bool> >();
            Func <byte[], int> scoreFormula;

            byte valueToCheck = 3;
            byte minimumCount = 1;

            scoreFormula = DiceScoringFormulas.DiceSumOfSpecificNumber(valueToCheck);

            rules.Add(DiceValidations.DiceMustHaveCount(5));
            rules.Add(DiceValidations.DiceMustHaveValues1To6());
            rules.Add(DiceValidations.DiceMustContain(valueToCheck));
            rules.Add(DiceValidations.DiceMustHaveCountOfACertainValue(valueToCheck, minimumCount));

            var calculator = new DiceCalculator(rules, scoreFormula, "Threes",
                                                "The sum of the dice with the number 3");

            //act
            var results = calculator.Calculate(GetDiceByteArray(1, 3, 2, 4, 3));

            //assert)
            Assert.IsTrue(results.IsValid && results.Score == 6);
        }
 protected Weapon(string name, Type type, bool isSecondAct, DiceCalculator dice)
 {
     Name        = name;
     Type        = type;
     IsSecondAct = isSecondAct;
     Dice        = dice;
 }
Esempio n. 3
0
 protected Monster(Type type, bool isMaster, bool isSecondAct, DiceCalculator attackDice, DiceCalculator defenceDice)
 {
     Type        = type;
     IsMaster    = isMaster;
     IsSecondAct = isSecondAct;
     AttackDice  = attackDice;
     DefenceDice = defenceDice;
 }
        public void DiceCalculator_Aces_ReturnsSumOf1s(byte valueToCheck, byte[] bytes, int expected)
        {
            //arrange
            var rules        = new List <Func <byte[], bool> >();
            var scoreFormula = DiceScoringFormulas.DiceSumOfSpecificNumber(valueToCheck);

            rules.Add(DiceValidations.DiceAlwaysValid());

            var calculator = new DiceCalculator(rules, scoreFormula, "Aces", "The sum of the dice with the number 1");

            //act
            var results = calculator.Calculate(bytes);

            //assert)
            Assert.IsTrue(results.IsValid, "Results should have been valid.");
            Assert.IsTrue(results.Score == expected,
                          $"Score was expected to be {expected} but was {results.Score} instead.");
        }
Esempio n. 5
0
 public MasterMonster(Type type, DiceCalculator attackDice, DiceCalculator defenceDice, bool isSecondAct = false) : base(type, true, isSecondAct, attackDice, defenceDice)
 {
 }
Esempio n. 6
0
 public Monster(Type type, DiceCalculator attackDice, DiceCalculator defenceDice, bool isSecondAct = false) : this(type, false, isSecondAct, attackDice, defenceDice)
 {
 }
Esempio n. 7
0
 public RangedWeapon(string name, DiceCalculator dice, bool isSecondAct = false) : base(name, Type.Ranged, isSecondAct, dice)
 {
 }
Esempio n. 8
0
    // Handler for generating the new numbers and the acquiring the new textures for the dice.

    public void startGenerator()
    {
        // Handles each state of the game seperatly, depending on what cycle is active.
        if (cycle.stateAna)
        {
            calc = GameObject.FindWithTag("Analyse").GetComponent <DiceCalculator>();
            for (int i = 0; i < GameObject.FindWithTag("AnalyseDice").transform.childCount; i++)
            {
                diceToRoll = GameObject.FindWithTag("AnalyseDice").transform.GetChild(i);
                dice.Add(diceToRoll);
                Dice TESTING = dice[i].gameObject.GetComponent <Dice>();
                int  roll    = randomGenerator();
                TESTING.numberChange(textures[roll - 1]);
            }
            calc.anaCalc(totalDiceRoll);
            totalDiceRoll = 0;
            dice.Clear();
        }
        if (cycle.stateDev)
        {
            for (int i = 0; i < GameObject.FindWithTag("DevDice").transform.childCount; i++)
            {
                diceToRoll = GameObject.FindWithTag("DevDice").transform.GetChild(i);
                dice.Add(diceToRoll);
                Dice TESTING = dice[i].gameObject.GetComponent <Dice>();
                int  roll    = randomGenerator();
                TESTING.numberChange(textures[roll - 1]);
            }
            calc.devCalc(totalDiceRoll);
            totalDiceRoll = 0;
            dice.Clear();
        }
        if (cycle.stateDeploy)
        {
            for (int i = 0; i < GameObject.FindWithTag("DeployDice").transform.childCount; i++)
            {
                diceToRoll = GameObject.FindWithTag("DeployDice").transform.GetChild(i);
                dice.Add(diceToRoll);
                Dice TESTING = dice[i].gameObject.GetComponent <Dice>();
                int  roll    = randomGenerator();
                TESTING.numberChange(textures[roll - 1]);
            }
            calc.deployCalc(totalDiceRoll);
            totalDiceRoll = 0;
            dice.Clear();
        }
        if (cycle.stateTest)
        {
            for (int i = 0; i < GameObject.FindWithTag("TestDice").transform.childCount; i++)
            {
                diceToRoll = GameObject.FindWithTag("TestDice").transform.GetChild(i);
                dice.Add(diceToRoll);
                Dice TESTING = dice[i].gameObject.GetComponent <Dice>();
                int  roll    = randomGenerator();
                TESTING.numberChange(textures[roll - 1]);
            }
            calc.testCalc(totalDiceRoll);
            totalDiceRoll = 0;
            dice.Clear();
        }

        toggleScript();
    }
Esempio n. 9
0
 public MeleeWeapon(string name, DiceCalculator dice, bool isSecondAct = false) : base(name, Type.Melee, isSecondAct, dice)
 {
 }