Example #1
0
        /// <summary>
        /// Determine if the Dice asked to be rolled is allowed
        /// </summary>
        /// <param name="type">DiceType</param>
        /// <returns>bool true if allowed or false otherwise</returns>
        public static bool Allowed(this DiceTypes type)
        {
            bool retValue = false;

            switch (type)
            {
            case DiceTypes.None:
                break;

            case DiceTypes.D3:
            case DiceTypes.D4:
            case DiceTypes.D6:
            case DiceTypes.D8:
            case DiceTypes.D10:
            case DiceTypes.D12:
            case DiceTypes.D20:
            case DiceTypes.D30:
            case DiceTypes.D100:
            {
                retValue = true;
                break;
            }
            }

            return(retValue);
        }
Example #2
0
 public static BasicDiceSide CreateDiceSide(int val, DiceTypes dieType)
 {
     BasicDiceSide retVal;
     switch (dieType)
     {
         case DiceTypes.TypeA:
             retVal = new TypeADiceSide(val);
             break;
         case DiceTypes.TypeB:
             retVal = new TypeBDiceSide(val);
             break;
         case DiceTypes.TypeC:
             retVal = new TypeCDiceSide(val);
             break;
         case DiceTypes.TypeD:
             retVal = new TypeDDiceSide(val);
             break;
         case DiceTypes.TypeE:
             retVal = new TypeEDiceSide(val);
             break;
         default:
             retVal = null;
             break;
     }
     return retVal;
 }
Example #3
0
        public void SixAbilitiyScoresReturned()
        {
            // Arrange
            var scores = new DiceTypes().ReturnAbilityScores();

            // Assert
            Assert.Equal(6, scores.Length);
        }
Example #4
0
        public void D12ReturnsValidInt()
        {
            // Arrange
            var D12 = new DiceTypes().RollD12();

            // Assert
            Assert.IsType <int>(D12[0][0]);
        }
Example #5
0
        public void D12ReturnsWithinRange()
        {
            // Arrange
            var D12 = new DiceTypes().RollD12();

            // Assert
            Assert.InRange(D12[0][0], 1, 12);
        }
Example #6
0
        public void D10ReturnsWithinRange()
        {
            // Arrange
            var D10 = new DiceTypes().RollD10();

            // Assert
            Assert.InRange(D10[0][0], 1, 10);
        }
Example #7
0
        public void D8ReturnsWithinRange()
        {
            // Arrange
            var D8 = new DiceTypes().RollD8();

            // Assert
            Assert.InRange(D8[0][0], 1, 8);
        }
Example #8
0
        public void D8ReturnsValidInt()
        {
            // Arrange
            var D8 = new DiceTypes().RollD8();

            // Assert
            Assert.IsType <int>(D8[0][0]);
        }
Example #9
0
        public void D20ReturnsValidInt()
        {
            // Arrange
            var D20 = new DiceTypes().RollD20();

            // Assert
            Assert.IsType <int>(D20[0][0]);
        }
Example #10
0
        public void D4ReturnsValidInt()
        {
            // Arrange
            var D4 = new DiceTypes().RollD4();

            // Assert
            Assert.IsType <int>(D4[0][0]);
        }
Example #11
0
        public void D4ReturnsWithinRange()
        {
            // Arrange
            var D4 = new DiceTypes().RollD4();

            // Assert
            Assert.InRange(D4[0][0], 1, 4);
        }
Example #12
0
        public void D20ReturnsWithinRange()
        {
            // Arrange
            var D20 = new DiceTypes().RollD20();

            // Assert
            Assert.InRange(D20[0][0], 1, 20);
        }
Example #13
0
        public void SixAbilitiyScoresNotNull()
        {
            // Arrange
            var scores = new DiceTypes().ReturnAbilityScores();

            // Assert
            Assert.NotNull(scores);
        }
 public DiceRollViewModel()
 {
     DiceTypes.Add(4);
     DiceTypes.Add(6);
     DiceTypes.Add(8);
     DiceTypes.Add(10);
     DiceTypes.Add(12);
     DiceTypes.Add(20);
     DiceTypes.Add(100);
     Roll = new AsyncCommand(RollAsync);
 }
Example #15
0
 //-----------UpdateResults()-------------
 // Update result visually in UI
 //-------------------------------
 public void UpdateResults(DiceTypes diceType, int result)
 {
     ThrowResults.Add(result);
     if (ResultCounter != null)
     {
         count++;
         ResultCounter.text += diceType.ToString() + " Rolled: " + result + "\n";
         RectTransform _rectObject = ResultCounter.GetComponent <RectTransform> ();
         _rectObject.sizeDelta = new Vector2(_rectObject.sizeDelta.x, 50.05f + (15 * count));
     }
     else
     {
         Debug.LogWarning("There's no UI text object attached to the tablescipt, results will not be shown");
     }
 }
Example #16
0
        public static int[] GetDiceTypeCompersionStatisics(DiceTypes firstType, DiceTypes secondType)
        {
            int[] retVal = new int[3]{0, 0, 0};

            Dice firstDice = new Dice();
            firstDice.Init(firstType);
            Dice secondDice = new Dice();
            secondDice.Init(secondType);

            for (int i = 0; i < 6; i++ )
            {
                BasicDiceSide sideFromFirstDice = firstDice.GetDiceRoll(i);
                for (int j = 0; j < 6; j++)
                {
                    BasicDiceSide sideFromSecondDice = secondDice.GetDiceRoll(j);
                    int fightResult = sideFromFirstDice.InteractWithOtherDice(sideFromSecondDice);
                    retVal[fightResult + 1]++;
                }
            }
            return retVal;
        }
Example #17
0
        public void Init(DiceTypes diceType)
        {
            DiceTypes mainType = diceType;
            DiceTypes weaknessProtection = diceType;
            DiceTypes anethemaProtection = diceType;

            switch (diceType)
            {
                case DiceTypes.TypeA:
                    weaknessProtection = DiceTypes.TypeD;
                    anethemaProtection = DiceTypes.TypeE;
                    break;
                case DiceTypes.TypeB:
                    weaknessProtection = DiceTypes.TypeE;
                    anethemaProtection = DiceTypes.TypeA;
                    break;
                case DiceTypes.TypeC:
                    weaknessProtection = DiceTypes.TypeA;
                    anethemaProtection = DiceTypes.TypeD;
                    break;
                case DiceTypes.TypeD:
                    weaknessProtection = DiceTypes.TypeB;
                    anethemaProtection = DiceTypes.TypeE;
                    break;
                case DiceTypes.TypeE:
                    weaknessProtection = DiceTypes.TypeC;
                    anethemaProtection = DiceTypes.TypeA;
                    break;
                default:
                    break;
            }

            m_diceRoll[0] = Factory.CreateDiceSide(1, mainType);
            m_diceRoll[1] = Factory.CreateDiceSide(2, mainType);
            m_diceRoll[2] = Factory.CreateDiceSide(3, mainType);
            m_diceRoll[3] = Factory.CreateDiceSide(4, mainType);
            m_diceRoll[4] = Factory.CreateDiceSide(1, weaknessProtection);
            m_diceRoll[5] = Factory.CreateDiceSide(2, anethemaProtection);
        }
Example #18
0
 public bool IsDiceAnthemaToOtherDice(DiceTypes dice, DiceTypes otherDice)
 {
     return refAnthema[dice] == otherDice;
 }
Example #19
0
 public Success(DiceTypes die, int targetNumber)
 {
     _die          = die;
     _targetNumber = targetNumber;
     _dice         = new Regular(_die);
 }
Example #20
0
 public Regular(DiceTypes type)
 {
     _die   = type;
     _sides = type.ConvertToInt();
 }
Example #21
0
 /// <summary>
 /// Creates an Dice object
 /// </summary>
 /// <param name="size">Dice size</param>
 public Dice(DiceTypes size)
     : this(size, 1, 0)
 {
 }
Example #22
0
 /// <summary>
 /// Creates an Dice object
 /// </summary>
 /// <param name="size">Dice size</param>
 /// <param name="amount">Amount of dice</param>
 public Dice(DiceTypes size, int amount)
     : this(size, amount, 0)
 {
 }
Example #23
0
 /// <summary>
 /// Creates an Dice object
 /// </summary>
 /// <param name="size">Dice size</param>
 /// <param name="amount">Amount of dice</param>
 /// <param name="modifier">Dice modifier</param>
 public Dice(DiceTypes size, int amount, int modifier)
     : this((int)size, amount, modifier)
 {
 }
Example #24
0
 private void SetDice(Dice[] targetPlayerDiceArray, int idx, DiceTypes diceType)
 {
     Dice d = new Dice();
     d.Init(diceType);
     targetPlayerDiceArray[idx] = d;
 }
Example #25
0
 /// <summary>
 /// Converts the DiceType from enum to int
 /// </summary>
 /// <param name="type">DiceType</param>
 /// <returns>int value of the DiceType</returns>
 public static int ConvertToInt(this DiceTypes type) => (int)type;
Example #26
0
 public Dices(DiceTypes diceType)
 {
     DiceType = diceType;
 }
Example #27
0
 public Die(DiceTypes die)
 {
     Sides = die.ConvertToInt();
     _Die  = die;
 }