protected CancellableSetCounterBase(IGameCounter currentGameCounter, EnumTeams initialServiceRight)
 {
     SetCountA           = SetCountB = 0;
     CurrentGameCounter  = currentGameCounter ?? throw new ArgumentNullException(nameof(currentGameCounter));
     History             = new Stack <SetCounterHistoryItem>();
     CurrentServiceRight = initialServiceRight;
     PushHistory(new SetCounterHistoryItem(currentGameCounter, new TeamedValuePair <int>(0, 0), initialServiceRight));
 }
Beispiel #2
0
 protected CancellablePointCounterBase(TPoint internalPointA, TPoint internalPointB, EnumTeams initialServiceRight)
 {
     InternalPointA      = internalPointA;
     InternalPointB      = internalPointB;
     History             = new Stack <PointCounterHistoryItem <TPoint> >();
     CurrentServiceRight = initialServiceRight;
     PushHistory(new PointCounterHistoryItem <TPoint>(new TeamedValuePair <TPoint>(internalPointA, internalPointB), initialServiceRight));
 }
Beispiel #3
0
 protected CancellableGameCounterBase(IPointCounter initialPointCounter, EnumTeams initialServiceRight)
 {
     GameCountA          = GameCountB = 0;
     CurrentPointCounter = initialPointCounter ?? throw new ArgumentNullException(nameof(initialPointCounter));
     History             = new Stack <GameCounterHistoryItem>();
     CurrentServiceRight = initialServiceRight;
     PushHistory(new GameCounterHistoryItem(initialPointCounter, new TeamedValuePair <int>(0, 0), initialServiceRight));
 }
 public MatchTieBreakSetCounter(IParametricFactory <IGameCounter, EnumTeams> gameCounterFactory, int totalSets, int matchTieBreakPointCount,
                                int matchTieBreakPointLeastDifference, EnumTeams initialServiceRight) : base(gameCounterFactory.Create(initialServiceRight) ??
                                                                                                             throw new ArgumentNullException(nameof(gameCounterFactory)), initialServiceRight)
 {
     GameCounterFactory                = gameCounterFactory ?? throw new ArgumentNullException(nameof(gameCounterFactory));
     TotalSets                         = totalSets;
     MatchTieBreakPointCount           = matchTieBreakPointCount;
     MatchTieBreakPointLeastDifference = matchTieBreakPointLeastDifference;
 }
Beispiel #5
0
        protected override GameCounterHistoryItem HandleIncrementB()
        {
            var npb = GameCountB + 1;

            if (SatisfiesSetEndingCondition(npb, GameCountA))
            {
                npb = -npb;
            }
            else
            {
                EnumTeams newServiceRight = CurrentServiceRight.Flip();
                return(new GameCounterHistoryItem(NormalGamePointCounterFactory.Create(newServiceRight), new TeamedValuePair <int>(GameCountA, npb), newServiceRight));
            }
            return(new GameCounterHistoryItem(null, new TeamedValuePair <int>(GameCountA, npb), CurrentServiceRight));
        }
        protected override SetCounterHistoryItem HandleIncrementB()
        {
            var npb = SetCountB + 1;

            if (CurrentGameCounter is MatchTieBreakFinalSetGameCounter || SatisfiesMatchEndingCondition(npb, SetCountA))
            {
                npb = -npb;
            }
            else
            {
                var       newPoint        = new TeamedValuePair <int>(SetCountA, npb);
                EnumTeams newServiceRight = CurrentGameCounter.CurrentServiceRight.Flip();
                return(new SetCounterHistoryItem(SatisfiesTieBreakCondition(npb, SetCountA) ?
                                                 new MatchTieBreakFinalSetGameCounter(new TieBrakingPointCounter(MatchTieBreakPointCount, MatchTieBreakPointLeastDifference, newServiceRight), newServiceRight) :
                                                 GameCounterFactory.Create(newServiceRight), newPoint, newServiceRight));
            }
            return(new SetCounterHistoryItem(null, new TeamedValuePair <int>(SetCountA, npb), CurrentServiceRight));
        }
Beispiel #7
0
        protected override GameCounterHistoryItem HandleIncrementB()
        {
            var npb = GameCountB + 1;

            if (CurrentPointCounter is TieBrakingPointCounter || SatisfiesGameEndingCondition(npb, GameCountA))
            {
                npb = -npb;
                return(new GameCounterHistoryItem(null, new TeamedValuePair <int>(GameCountA, npb), CurrentServiceRight));
            }
            else
            {
                var       newPoints = new TeamedValuePair <int>(GameCountA, npb);
                EnumTeams nsr       = CurrentServiceRight.Flip();
                return(SatisfiesTieBreakingCondition(npb, GameCountA)
                    ? new GameCounterHistoryItem(TieBreakingGamePointCounterFactory.Create(nsr), newPoints, nsr)
                    : new GameCounterHistoryItem(NormalGamePointCounterFactory.Create(nsr), newPoints, nsr));
            }
        }
Beispiel #8
0
 public GameCounterHistoryItem(IPointCounter counter, TeamedValuePair <int> gameCounts, EnumTeams serviceRight)
 {
     Counter      = counter;
     GameCounts   = gameCounts;
     ServiceRight = serviceRight;
 }
Beispiel #9
0
 public PointCounterHistoryItem(TeamedValuePair <TPoint> pointCounts, EnumTeams serviceRight)
 {
     PointCounts  = pointCounts;
     ServiceRight = serviceRight;
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchStandalone{TTeam}"/> class.
 /// </summary>
 /// <param name="teamA">Team a.</param>
 /// <param name="teamB">Team b.</param>
 /// <param name="rule">Rule.</param>
 /// <param name="initialService">The team that serves initially.</param>
 /// <param name="setCounter">The set counter.</param>
 /// <exception cref="ArgumentException">Occures when the <paramref name="initialService"/> is equal to neither <paramref name="teamA"/> nor <paramref name="teamB"/>.</exception>
 public MatchStandalone(TTeam teamA, TTeam teamB, MatchRule rule, EnumTeams initialService, ISetCounter setCounter)
     : base(teamA, teamB, rule, setCounter)
 {
 }
Beispiel #11
0
 public static T Switch <T>(this EnumTeams value, T valueA, T valueB) => value == EnumTeams.TeamA ? valueA : valueB;
Beispiel #12
0
 public FifteenBasedPointCounter(bool hasDeuce, EnumTeams initialServiceRight) : base(PointNumber.Love, PointNumber.Love, initialServiceRight)
 {
     HasDeuce = hasDeuce;
 }
 public void Deconstruct(out IGameCounter gameCounter, out TeamedValuePair <int> setCounts, out EnumTeams serviceRight)
 {
     gameCounter  = GameCounter;
     setCounts    = SetCounts;
     serviceRight = ServiceRight;
 }
 public SetCounterHistoryItem(IGameCounter gameCounter, TeamedValuePair <int> setCounts, EnumTeams serviceRight)
 {
     GameCounter  = gameCounter;
     SetCounts    = setCounts;
     ServiceRight = serviceRight;
 }
Beispiel #15
0
 public MatchTieBreakFinalSetGameCounter(IPointCounter initialPointCounter, EnumTeams initialServiceRight) : base(initialPointCounter, initialServiceRight)
 {
 }
Beispiel #16
0
 public TieBreakSetGameCounter(IParametricFactory <IPointCounter, EnumTeams> normalGamePointCounterFactory,
                               IParametricFactory <TieBrakingPointCounter, EnumTeams> tieBreakingGamePointCounterFactory, int leastWinningGames, int baseWinningDifference, EnumTeams initialServiceRight)
     : base(normalGamePointCounterFactory?.Create(initialServiceRight) ?? throw new ArgumentNullException(nameof(normalGamePointCounterFactory)), initialServiceRight)
 {
     NormalGamePointCounterFactory      = normalGamePointCounterFactory ?? throw new ArgumentNullException(nameof(normalGamePointCounterFactory));
     TieBreakingGamePointCounterFactory = tieBreakingGamePointCounterFactory ?? throw new ArgumentNullException(nameof(tieBreakingGamePointCounterFactory));
     LeastWinningGames     = leastWinningGames;
     BaseWinningDifference = baseWinningDifference;
 }
Beispiel #17
0
 public TieBrakingPointCounter(int leastWinningPoint, int leastWinningDifference, EnumTeams initialServiceRight) : base(0, 0, initialServiceRight)
 {
     LeastWinningPoint      = leastWinningPoint;
     LeastWinningDifference = leastWinningDifference;
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Volley.Matches.Competitors.ServiceRightManager`1"/> class.
 /// </summary>
 /// <param name="teamA">Team a.</param>
 /// <param name="teamB">Team b.</param>
 /// <param name="initialService">Initial service.</param>
 public ServiceRightManager(TTeam teamA, TTeam teamB, EnumTeams initialService)
 {
     TeamA = teamA ?? throw new ArgumentNullException(nameof(teamA));
     TeamB = teamB ?? throw new ArgumentNullException(nameof(teamB));
     CurrentServiceRight = initialService;
 }
Beispiel #19
0
 public AdvantageSetGameCounter(IParametricFactory <IPointCounter, EnumTeams> normalGamePointCounterFactory, int leastWinningGames, int leastWinningDifference, EnumTeams initialServiceRight)
     : base(normalGamePointCounterFactory?.Create(initialServiceRight) ?? throw new ArgumentNullException(nameof(normalGamePointCounterFactory)), initialServiceRight)
 {
     NormalGamePointCounterFactory = normalGamePointCounterFactory ?? throw new ArgumentNullException(nameof(normalGamePointCounterFactory));
     LeastWinningGames             = leastWinningGames > 0 ? leastWinningGames :
                                     throw new ArgumentOutOfRangeException(nameof(leastWinningGames), $"The leastWinningGames must be grater than 0!");
     LeastWinningDifference = leastWinningDifference >= 0 ? leastWinningDifference :
                              throw new ArgumentOutOfRangeException(nameof(leastWinningDifference), $"The leastWinningGames must be grater than or equal to 0!");
 }
Beispiel #20
0
 public void Deconstruct(out IPointCounter pointCounter, out TeamedValuePair <int> gameCounts, out EnumTeams serviceRight)
 {
     pointCounter = Counter;
     gameCounts   = GameCounts;
     serviceRight = ServiceRight;
 }
Beispiel #21
0
 public StandardSetCounter(IParametricFactory <IGameCounter, EnumTeams> gameCounterFactory, int totalSets, EnumTeams initialServiceRight)
     : base(gameCounterFactory?.Create(initialServiceRight) ?? throw new ArgumentNullException(nameof(gameCounterFactory)), initialServiceRight)
 {
     GameCounterFactory = gameCounterFactory ?? throw new ArgumentNullException(nameof(gameCounterFactory));
     TotalSets          = totalSets;
 }
Beispiel #22
0
 public static EnumTeams Flip(this EnumTeams value) => value.Switch(EnumTeams.TeamB, EnumTeams.TeamA);