Esempio n. 1
0
 public SinglePlayerLeg WithAdditionalThrow(ThrowResult throwResult)
 {
     if (Score == 0)
     {
         throw new InvalidOperationException("Leg is over");
     }
     return(new SinglePlayerLeg(InitialScore, AddThrowIntoTurns(throwResult)));
 }
Esempio n. 2
0
		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));
		}
Esempio n. 3
0
		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;
		}
Esempio n. 4
0
 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)));
 }
Esempio n. 5
0
 public void AddThrow(ThrowResult throwResult)
 {
     if (Finished)
     {
         throw new InvalidOperationException("Match is finished");
     }
     CurrentLeg.AddThrow(throwResult);
     if (CurrentLeg.Finished && Legs.Count < MaxLegsCount)
     {
         StartNewLeg();
     }
 }
Esempio n. 6
0
 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)));
 }
Esempio n. 7
0
 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;
     }
 }
Esempio n. 8
0
		protected bool Equals(ThrowResult other)
		{
			return Section == other.Section && SectionArea == other.SectionArea;
		}
Esempio n. 9
0
		public void AddThrow(ThrowResult throwResult)
		{
			if (Finished) throw new InvalidOperationException("Match is finished");
			CurrentLeg.AddThrow(throwResult);
			if (CurrentLeg.Finished && Legs.Count < MaxLegsCount) StartNewLeg();
		}
Esempio n. 10
0
		public SinglePlayerLeg WithAdditionalThrow(ThrowResult throwResult)
		{
			if (Score == 0) throw new InvalidOperationException("Leg is over");
			return new SinglePlayerLeg(InitialScore, AddThrowIntoTurns(throwResult));
		}
Esempio n. 11
0
 protected bool Equals(ThrowResult other)
 {
     return(Section == other.Section && SectionArea == other.SectionArea);
 }
Esempio n. 12
0
		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));
		}