/// <summary> /// Sorting helper method for ordering the Rankings by finish position. /// This is used in knockout brackets and Group Stages. /// </summary> protected int SortRankingRanks(IPlayerScore first, IPlayerScore second) { int compare = first.Rank.CompareTo(second.Rank); return((compare != 0) ? compare : GetPlayerSeed(first.Id).CompareTo(GetPlayerSeed(second.Id))); }
/// <summary> /// Sorting helper method for ordering the Rankings by score metrics. /// This is used in scoring-type brackets, such as Round Robin. /// </summary> protected int SortRankingScores(IPlayerScore first, IPlayerScore second) { // Rankings sorting: MatchScore > OpponentsScore > GameScore > PointsScore > initial Seeding int compare = -1 * (first.CalculateScore(MatchWinValue, MatchTieValue, 0) .CompareTo(second.CalculateScore(MatchWinValue, MatchTieValue, 0))); compare = (compare != 0) ? compare : -1 * (first.OpponentsScore.CompareTo(second.OpponentsScore)); compare = (compare != 0) ? compare : -1 * (first.GameScore.CompareTo(second.GameScore)); compare = (compare != 0) ? compare : -1 * (first.PointsScore.CompareTo(second.PointsScore)); return((compare != 0) ? compare : GetPlayerSeed(first.Id).CompareTo(GetPlayerSeed(second.Id))); }
private void RoundPoint(IPlayerScore pointWinner, IPlayerScore pointLoser) { if (pointWinner.HasAdvantage) { pointWinner.WinTheGame(); return; } if (pointLoser.HasAdvantage) { pointWinner.DeuceScore(); pointLoser.DeuceScore(); return; } if (pointWinner.IsDeuce) { pointWinner.TakeTheAdvantage(); pointLoser.FortyScore(); return; } if (pointWinner.HasLessThanFortyPoints && pointLoser.HasLessThanFortyPoints) { pointWinner.IncreaseScore(); return; } if (pointWinner.HasFortyPoints) { pointWinner.WinTheGame(); return; } pointWinner.IncreaseScore(); if (pointWinner.HasFortyPoints && pointLoser.HasFortyPoints) { pointWinner.DeuceScore(); pointLoser.DeuceScore(); } }
public Game(IBattlefield battlefield, IPlayerScore playerScore) { Battlefield = battlefield; this.playerScore = playerScore; }
public Game(IPlayer player1, IPlayer player2) { playerScore1 = new PlayerScore(player1); playerScore2 = new PlayerScore(player2); }
public HitHandler(IPlayerScore playerScore, IShip hitShip) { this.playerScore = playerScore; this.hitShip = hitShip; }