Exemplo n.º 1
0
 public SinglePlayerLeg WithAdditionalThrow(ThrowResult throwResult)
 {
     if (Score == 0)
     {
         throw new InvalidOperationException("Leg is over");
     }
     return(new SinglePlayerLeg(InitialScore, AddThrowIntoTurns(throwResult)));
 }
Exemplo 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));
		}
Exemplo 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;
		}
Exemplo 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)));
 }
Exemplo 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();
     }
 }
Exemplo 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)));
 }
Exemplo 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;
     }
 }
Exemplo n.º 8
0
		protected bool Equals(ThrowResult other)
		{
			return Section == other.Section && SectionArea == other.SectionArea;
		}
Exemplo 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();
		}
Exemplo n.º 10
0
		public SinglePlayerLeg WithAdditionalThrow(ThrowResult throwResult)
		{
			if (Score == 0) throw new InvalidOperationException("Leg is over");
			return new SinglePlayerLeg(InitialScore, AddThrowIntoTurns(throwResult));
		}
Exemplo n.º 11
0
 protected bool Equals(ThrowResult other)
 {
     return(Section == other.Section && SectionArea == other.SectionArea);
 }
Exemplo 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));
		}