public SinglePlayerLeg WithAdditionalThrow(ThrowResult throwResult) { if (Score == 0) { throw new InvalidOperationException("Leg is over"); } return(new SinglePlayerLeg(InitialScore, AddThrowIntoTurns(throwResult))); }
private ImmutableList<Turn> AddThrowIntoTurns(ThrowResult result) { if (!Turns.Any() || Turns.Last().Finished) return Turns .Add(new Turn(Score).WithAdditionalThrow(result)); return Turns .RemoveAt(Turns.Count - 1) .Add(Turns.Last().WithAdditionalThrow(result)); }
public void AddThrow(ThrowResult throwResult) { if (Finished) throw new InvalidOperationException("Leg is finished"); CurrentPlayer = CurrentPlayer.WithAdditionalThrow(throwResult); if (!CurrentPlayer.Turns.Last().Finished) return; if (CurrentPlayer.Score == 0) WinnerIndex = CurrentPlayerIndex; else CurrentPlayerIndex = (CurrentPlayerIndex + 1) % 2; }
private ImmutableList <Turn> AddThrowIntoTurns(ThrowResult result) { if (!Turns.Any() || Turns.Last().Finished) { return(Turns .Add(new Turn(Score).WithAdditionalThrow(result))); } return(Turns .RemoveAt(Turns.Count - 1) .Add(Turns.Last().WithAdditionalThrow(result))); }
public void AddThrow(ThrowResult throwResult) { if (Finished) { throw new InvalidOperationException("Match is finished"); } CurrentLeg.AddThrow(throwResult); if (CurrentLeg.Finished && Legs.Count < MaxLegsCount) { StartNewLeg(); } }
public Turn WithAdditionalThrow(ThrowResult throwResult) { if (throwResult == null) { throw new ArgumentNullException("throwResult"); } if (Finished) { throw new InvalidOperationException("Turn is over already."); } return(new Turn(ScoreBefore, Throws.Add(throwResult))); }
public void AddThrow(ThrowResult throwResult) { if (Finished) { throw new InvalidOperationException("Leg is finished"); } CurrentPlayer = CurrentPlayer.WithAdditionalThrow(throwResult); if (!CurrentPlayer.Turns.Last().Finished) { return; } if (CurrentPlayer.Score == 0) { WinnerIndex = CurrentPlayerIndex; } else { CurrentPlayerIndex = (CurrentPlayerIndex + 1) % 2; } }
protected bool Equals(ThrowResult other) { return Section == other.Section && SectionArea == other.SectionArea; }
public void AddThrow(ThrowResult throwResult) { if (Finished) throw new InvalidOperationException("Match is finished"); CurrentLeg.AddThrow(throwResult); if (CurrentLeg.Finished && Legs.Count < MaxLegsCount) StartNewLeg(); }
public SinglePlayerLeg WithAdditionalThrow(ThrowResult throwResult) { if (Score == 0) throw new InvalidOperationException("Leg is over"); return new SinglePlayerLeg(InitialScore, AddThrowIntoTurns(throwResult)); }
protected bool Equals(ThrowResult other) { return(Section == other.Section && SectionArea == other.SectionArea); }
public Turn WithAdditionalThrow(ThrowResult throwResult) { if (throwResult == null) throw new ArgumentNullException("throwResult"); if (Finished) throw new InvalidOperationException("Turn is over already."); return new Turn(ScoreBefore, Throws.Add(throwResult)); }