Adding support for playing the same person multiple times in a league

- Extended the LeagueData definition to include a field for maximum number of matches between a pair of players
- Ensured that the default is 1 for all league types
- Constructed leagues now support reading a custom max rematch limit from the DB, although the UI doesn't reflect this
This commit is contained in:
Christian 'ketura' McCarty
2022-12-25 19:31:49 -06:00
parent 7c2f28d45d
commit 4983e5c815
4 changed files with 25 additions and 8 deletions

View File

@@ -342,7 +342,9 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
String code = String.valueOf(System.currentTimeMillis());
StringBuilder sb = new StringBuilder();
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.size());
//The 1 is a hard-coded maximum number of player matches per league.
//TODO: Get this put into the UI properly.
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + "1" + "," + formats.size());
for (int i = 0; i < formats.size(); i++)
sb.append("," + formats.get(i) + "," + serieDurations.get(i) + "," + maxMatches.get(i));
@@ -390,7 +392,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
int cost = Integer.parseInt(costStr);
StringBuilder sb = new StringBuilder();
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.size());
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + "1" + "," + formats.size());
for (int i = 0; i < formats.size(); i++)
sb.append("," + formats.get(i) + "," + serieDurations.get(i) + "," + maxMatches.get(i));

View File

@@ -18,4 +18,8 @@ public interface LeagueData {
CardCollection joinLeague(CollectionsManager collecionsManager, Player player, int currentTime);
int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime);
default int getMaxRepeatMatchesPerSerie() {
return 1;
}
}

View File

@@ -237,10 +237,13 @@ public class LeagueService {
public synchronized boolean canPlayRankedGameAgainst(League league, LeagueSerieData season, String playerOne, String playerTwo) {
Collection<LeagueMatchResult> playedInSeason = getPlayerMatchesInSerie(league, season, playerOne);
int maxGames = league.getLeagueData(_cardLibrary, _formatLibrary, _soloDraftDefinitions)
.getMaxRepeatMatchesPerSerie();
int totalGames = 0;
for (LeagueMatchResult leagueMatch : playedInSeason) {
if (playerTwo.equals(leagueMatch.getWinner()) || playerTwo.equals(leagueMatch.getLoser()))
return false;
totalGames++;
}
return true;
return totalGames < maxGames;
}
}

View File

@@ -21,6 +21,8 @@ public class NewConstructedLeagueData implements LeagueData {
private final CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private final CollectionType _collectionType;
private final int _maxRepeatGames;
public NewConstructedLeagueData(LotroCardBlueprintLibrary library, LotroFormatLibrary formatLibrary, String parameters) {
_leaguePrizes = new FixedLeaguePrizes(library);
@@ -31,13 +33,14 @@ public class NewConstructedLeagueData implements LeagueData {
if (_collectionType == null)
throw new IllegalArgumentException("Unknown collection type");
int series = Integer.parseInt(params[3]);
_maxRepeatGames = Integer.parseInt(params[3]);
int series = Integer.parseInt(params[4]);
int serieStart = start;
for (int i = 0; i < series; i++) {
String format = params[4 + i * 3];
int duration = Integer.parseInt(params[5 + i * 3]);
int maxMatches = Integer.parseInt(params[6 + i * 3]);
String format = params[5 + i * 3];
int duration = Integer.parseInt(params[6 + i * 3]);
int maxMatches = Integer.parseInt(params[7 + i * 3]);
_series.add(new DefaultLeagueSerieData(_leaguePrizes, false, "Serie " + (i + 1),
serieStart, DateUtils.offsetDate(serieStart, duration - 1),
maxMatches, formatLibrary.getFormat(format), _collectionType));
@@ -91,4 +94,9 @@ public class NewConstructedLeagueData implements LeagueData {
return status;
}
@Override
public int getMaxRepeatMatchesPerSerie() {
return _maxRepeatGames;
}
}