/// <summary> /// Simulates rolling the dice and returns a face. /// </summary> public void Roll() { var face = _faces[_random.Next(_faces.Count)]; var rotation = _rotation[_random.Next(_rotation.Length)]; face.ApplyRotation(rotation); VisibleFace = face; }
/// <summary> /// Initialises a new instance of the <see cref="Dice" /> class. /// </summary> /// <param name="faces">Represents 6 faces of the dice.</param> public Dice(int position, IReadOnlyList <DiceFace> faces) { Position = Guard.Argument(position, nameof(position)) .NotNegative() .LessThan(16) .Value; _faces = Guard.Argument(faces, nameof(faces)) .NotNull() .NotEmpty() .Count(6) .Value; VisibleFace = _faces[0]; }