# Yatzy Dice Game

Yatzy Dice Game is a game where the player rolls five dice to attempt to make different combinations.  After each roll, the player can hold the value of any of the die by clicking on them.  A saved die turns yellow when its value is held.  After three rolls, the player must choose one of the available categories to apply the score.  After all of the categories are completed, the game is over.

## Scoring Categories

Aces – Sum of all the dice showing value value of 1.

Twos – Sum of all the dice showing value value of 2.

Threes – Sum of all the dice showing value value of 3.

Fours – Sum of all the dice showing value value of 4.

Fives – Sum of all the dice showing value value of 5.

Sixes – Sum of all the dice showing value value of 6.

Bonus for getting over 63 points in all of the above categories.

One Pair – Two dice have a matching value.

Two Pairs – Four dice have two different matching values

Three of a Kind – Three dice have the same value

Four of a Kind – Four dice have the same value.

Small Straight – Dice have the values 1 through 5.

Large Straight – Dice have the values 2 through 6.

Chance – Sum of all dice values.  Basically, choose this if no other category applies.

Full House – Three dice have one value and two dice have another value.

Yatzy – All five dice have the same value.

## Calculating the rolled dice value

Below is the code used for determining which value rolled, based on the transform rotation of the Unity GameObject.  This assumes that the die is modeled with 4 on top, 3 on bottom, 2 on front, 5 on back, 1 on left, and 6 on right.

```    public int getValue () {
int iValue = -1;
Vector3 dieRotation = gameObject.transform.eulerAngles;

dieRotation = new Vector3 (Mathf.RoundToInt (dieRotation.x), Mathf.RoundToInt (dieRotation.y), Mathf.RoundToInt (dieRotation.z));

if (dieRotation.x == 180 && dieRotation.y == 270 ||
dieRotation.x == 0 && dieRotation.z == 90) {
iValue = 1;
} else if (dieRotation.x == 270) {
iValue = 2;
} else if (dieRotation.x == 180 && dieRotation.z == 0 ||
dieRotation.x == 0 && dieRotation.z == 180) {
iValue = 3;
} else if (dieRotation.x == 180 && dieRotation.z == 180 ||
dieRotation.x == 0 && dieRotation.z == 0) {
iValue = 4;
} else if (dieRotation.x == 90) {
iValue = 5;
} else if (dieRotation.x == 0 && dieRotation.z == 270 ||
dieRotation.x == 180 && dieRotation.z == 90) {
iValue = 6;
}

//        Debug.Log("eulerAngles: " + dieRotation.x + ", " + dieRotation.y + ", " + dieRotation.z + " Value: " + iValue);

return iValue;
}
```