/// <summary> /// Finds an eliminated player's rank for a double-elim bracket. /// </summary> /// <param name="_matchNumber">Number of finished Match</param> /// <returns>Player's rank</returns> protected override int CalculateRank(int _matchNumber) { int rank = 2; // 2 = GrandFinal loser if (LowerMatches?.ContainsKey(_matchNumber) ?? false) { // Standard case: lower bracket match. Match match = GetInternalMatch(_matchNumber); rank = NumberOfMatches - GetLowerRound(match.RoundIndex).Last().MatchNumber + 2; } else if (Matches?.ContainsKey(_matchNumber) ?? false) { // Special case: upper bracket "play-in" round. // These special rounds eliminate their losers // instead of sending them to the lower bracket. rank = Convert.ToInt32(Math.Pow(2, NumberOfRounds - 1) + 1); } return(rank); }
/// <summary> /// Gets one Match, from its Match Number. /// If no matching Match is found, an exception is thrown. /// </summary> /// <param name="_matchNumber">Number of Match to find</param> /// <returns>relevant Match</returns> /// <remarks> /// This method is overriden in Group Stages. /// </remarks> protected virtual Match GetInternalMatch(int _matchNumber) { if (_matchNumber < 1) { throw new InvalidIndexException ("Match number cannot be less than 1!"); } if (grandFinal?.MatchNumber == _matchNumber) { return(grandFinal); } if (Matches?.ContainsKey(_matchNumber) ?? false) { return(Matches[_matchNumber]); } if (LowerMatches?.ContainsKey(_matchNumber) ?? false) { return(LowerMatches[_matchNumber]); } throw new MatchNotFoundException ("Match not found; match number may be invalid."); }