public ObtainingATwoPair() { var diceSet = new DiceRoll(_bothPairs); var pairRule = new PairRule(); result = pairRule.CountPoints(diceSet); }
public DieRollResult CountPoints(DiceRoll diceRoll) { if (IsApplicable(diceRoll)) { return(new DieRollResult(DiceCombination.FiveOfAKind, _points)); } return(DieRollResult.Default()); }
public DieRollResult CountPoints(DiceRoll diceRoll) { if (!IsApplicable(diceRoll)) { return(DieRollResult.Default()); } return(Combination(diceRoll)); }
public ObtainingAHighStraight() { var dice = new DieRoll[] { DieRoll.Two, DieRoll.Four, DieRoll.Three, DieRoll.Five, DieRoll.Six }; var diceSet = new DiceRoll(dice); var rule = new StraightRule(); result = rule.CountPoints(diceSet); }
public DieRollResult CountPoints(DiceRoll diceRoll) { if (IsApplicable(diceRoll)) { return(new DieRollResult(DiceCombination.ThreeOfAKind, GetPoints(diceRoll))); } else { return(DieRollResult.Default()); } }
public DieRollResult CountPoints(DiceRoll diceRoll) { if (IsApplicable(diceRoll)) { return(new DieRollResult(DiceCombination.FullHouse, _points)); } else { return(DieRollResult.Default()); } }
public IEnumerator RollDice(DieRollResult cb) { if (!areDiceAtRest()) { return(false); } Vector3 savedCamPos = diceCam.transform.position; Quaternion savedCamRot = diceCam.transform.rotation; diceCam.camera.enabled = true; foreach (Die die in dice) { die.transform.position = transform.position; die.transform.rotation = Random.rotation; die.rigidbody.AddForce(dieInitialForce); die.rigidbody.AddTorque(dieInitialTorque); yield return(new WaitForSeconds(timeBetweenDieThrows)); } yield return(new WaitForSeconds(minTimeToWaitAfterThrow)); while (!areDiceAtRest()) { Vector3 avgPos = avgDicePos(); diceCam.transform.position = Vector3.Lerp(savedCamPos, avgPos, distanceFromDice); diceCam.transform.LookAt(avgPos); yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(delayAfterDiceResult)); diceCam.camera.enabled = false; diceCam.transform.position = savedCamPos; diceCam.transform.rotation = savedCamRot; cb(dice[0].GetResult(), dice[1].GetResult()); }
public DieRollResult CountPoints(DiceRoll diceRoll) { var dice = diceRoll.AllDice.ToIntArray().OrderBy(x => x).ToArray(); if (dice.Distinct().Count() != 5) { return(DieRollResult.Default()); } else { if (dice.Any((x => x == (int)DieRoll.One)) && IsSequenceConsecutive(dice)) { return(new DieRollResult(DiceCombination.StraightLow, _points)); } else if (IsSequenceConsecutive(dice)) { return(new DieRollResult(DiceCombination.StraightHigh, _points)); } else { return(DieRollResult.Default()); } } }
public static DieRollResult Max(DieRollResult first, DieRollResult second) { // TODO: // Create logic for rules overriding return(first.Points > second.Points ? first : second); }