/// <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); }
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; }
public void SixAbilitiyScoresReturned() { // Arrange var scores = new DiceTypes().ReturnAbilityScores(); // Assert Assert.Equal(6, scores.Length); }
public void D12ReturnsValidInt() { // Arrange var D12 = new DiceTypes().RollD12(); // Assert Assert.IsType <int>(D12[0][0]); }
public void D12ReturnsWithinRange() { // Arrange var D12 = new DiceTypes().RollD12(); // Assert Assert.InRange(D12[0][0], 1, 12); }
public void D10ReturnsWithinRange() { // Arrange var D10 = new DiceTypes().RollD10(); // Assert Assert.InRange(D10[0][0], 1, 10); }
public void D8ReturnsWithinRange() { // Arrange var D8 = new DiceTypes().RollD8(); // Assert Assert.InRange(D8[0][0], 1, 8); }
public void D8ReturnsValidInt() { // Arrange var D8 = new DiceTypes().RollD8(); // Assert Assert.IsType <int>(D8[0][0]); }
public void D20ReturnsValidInt() { // Arrange var D20 = new DiceTypes().RollD20(); // Assert Assert.IsType <int>(D20[0][0]); }
public void D4ReturnsValidInt() { // Arrange var D4 = new DiceTypes().RollD4(); // Assert Assert.IsType <int>(D4[0][0]); }
public void D4ReturnsWithinRange() { // Arrange var D4 = new DiceTypes().RollD4(); // Assert Assert.InRange(D4[0][0], 1, 4); }
public void D20ReturnsWithinRange() { // Arrange var D20 = new DiceTypes().RollD20(); // Assert Assert.InRange(D20[0][0], 1, 20); }
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); }
//-----------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"); } }
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; }
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); }
public bool IsDiceAnthemaToOtherDice(DiceTypes dice, DiceTypes otherDice) { return refAnthema[dice] == otherDice; }
public Success(DiceTypes die, int targetNumber) { _die = die; _targetNumber = targetNumber; _dice = new Regular(_die); }
public Regular(DiceTypes type) { _die = type; _sides = type.ConvertToInt(); }
/// <summary> /// Creates an Dice object /// </summary> /// <param name="size">Dice size</param> public Dice(DiceTypes size) : this(size, 1, 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) { }
/// <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) { }
private void SetDice(Dice[] targetPlayerDiceArray, int idx, DiceTypes diceType) { Dice d = new Dice(); d.Init(diceType); targetPlayerDiceArray[idx] = d; }
/// <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;
public Dices(DiceTypes diceType) { DiceType = diceType; }
public Die(DiceTypes die) { Sides = die.ConvertToInt(); _Die = die; }