Skip to content

Commit

Permalink
feat: add easy functions to find win/lose progression match
Browse files Browse the repository at this point in the history
  • Loading branch information
CouchPartyGames committed Dec 2, 2024
1 parent fc4f8a9 commit 85b712e
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/Tournament.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,26 @@ public class Tournament<TOpponent>

public Tournament() { }

public Match<TOpponent> GetMatch(int localMatchId) {
//return Matches.Where(m => m.LocalMatchId == localMatchId).First();
throw new NotImplementedException();
public Match<TOpponent>? GetMatch(int localMatchId) {
return Matches.FirstOrDefault(m => m.LocalMatchId == localMatchId);
}

// <summary>
// Find the next match
public Match<TOpponent> GetNextMatch(int localMatchId) {
/*
var nextMatchId = Matches.Where(m => m.LocalMatchId == localMatchId).Select(m => m.WinProgression).FirstOrDefault();
if (nextMatchId is null) {
return NotFound;
} else if (nextMatchId == -1) {
return NoMatch;
} */

/*
public Match<TOpponent>? GetWinProgressionMatch(int localMatchId) {
return Matches
.Where(m => m.LocalMatchId == localMatchId)
.Select(m => m.WinProgression)
.First();
*/
throw new NotImplementedException();
.Select(m => Matches.FirstOrDefault(m2 => m2.LocalMatchId == m.WinProgression))
.FirstOrDefault();
}

public Match<TOpponent>? GetLoseProgressionMatch(int localMatchId)
{
return Matches.Where(m => m.LocalMatchId == localMatchId)
.Select(m => Matches.FirstOrDefault(m2 => m2.LocalMatchId == m.LoseProgression))
.FirstOrDefault();
}

// <summary>
/*
public Match GetNextMatch(int localMatchId, IOpponent opponent) =>
Expand Down

0 comments on commit 85b712e

Please sign in to comment.