/// <summary> /// The command handler that rolls the dice /// </summary> /// <param name="sender">The sender object</param> /// <param name="e">The event arguments</param> private void RollDice(object sender, ExecutedRoutedEventArgs e) { // Update round information _prevRisk = _prevSave = 0; // Score all saved dice DiceItems.Where(d => d.State == DiceState.Saved).ToList().ForEach(d => d.State = DiceState.Scored); // Check if all dice scored if (DiceItems.All(d => d.State == DiceState.Scored)) { DiceItems.ToList().ForEach(delegate(Dice d) { d.State = DiceState.Roll; d.Group = null; }); } // Roll all the roll dice DiceItems.Where(d => d.State == DiceState.Roll).ToList().ForEach(d => d.Roll()); Update(); }
/// <summary> /// The command handler that scores a round /// </summary> /// <param name="sender">The sender object</param> /// <param name="e">The event arguments</param> private void ScoreTurn(object sender, ExecutedRoutedEventArgs e) { // Update round information CurrentRound.IsFarkle = Status == FarkleStatus.Farkle; CurrentRound.IsFinal = true; CurrentRoundIndex++; OnPropertyChanged("TotalScore"); // Update the dice and roll them if (CurrentRoundExists) { DiceItems.ToList().ForEach(delegate(Dice d) { d.State = DiceState.Roll; d.Group = null; }); RollDice(sender, e); } else { Update(); } }