Daily tournaments are now free, fixed number of rounds (3) and give 2 boosters/win.
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>1.18.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
|
||||
@@ -138,17 +138,17 @@ public class HallServer extends AbstractServer {
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
||||
try {
|
||||
_tournamentQueues.put("fotr_daily_eu", new RecurringScheduledQueue(sdf.parse("2013-01-15 19:30:00").getTime(), _repeatTournaments, "fotrDailyEu-", "Daily Gondor Fellowship Block", 1000,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss"),
|
||||
_tournamentQueues.put("fotr_daily_eu", new RecurringScheduledQueue(sdf.parse("2013-01-15 19:30:00").getTime(), _repeatTournaments, "fotrDailyEu-", "Daily Gondor Fellowship Block", 0,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss-3"),
|
||||
"fotr_block", 8));
|
||||
_tournamentQueues.put("fotr_daily_us", new RecurringScheduledQueue(sdf.parse("2013-01-16 00:30:00").getTime(), _repeatTournaments, "fotrDailyUs-", "Daily Rohan Fellowship Block", 1000,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss"),
|
||||
_tournamentQueues.put("fotr_daily_us", new RecurringScheduledQueue(sdf.parse("2013-01-16 00:30:00").getTime(), _repeatTournaments, "fotrDailyUs-", "Daily Rohan Fellowship Block", 0,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss-3"),
|
||||
"fotr_block", 8));
|
||||
_tournamentQueues.put("movie_daily_eu", new RecurringScheduledQueue(sdf.parse("2013-01-16 19:30:00").getTime(), _repeatTournaments, "movieDailyEu-", "Daily Gondor Movie Block", 1000,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss"),
|
||||
_tournamentQueues.put("movie_daily_eu", new RecurringScheduledQueue(sdf.parse("2013-01-16 19:30:00").getTime(), _repeatTournaments, "movieDailyEu-", "Daily Gondor Movie Block", 0,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss-3"),
|
||||
"movie", 8));
|
||||
_tournamentQueues.put("movie_daily_us", new RecurringScheduledQueue(sdf.parse("2013-01-17 00:30:00").getTime(), _repeatTournaments, "movieDailyUs-", "Daily Rohan Movie Block", 1000,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss"),
|
||||
_tournamentQueues.put("movie_daily_us", new RecurringScheduledQueue(sdf.parse("2013-01-17 00:30:00").getTime(), _repeatTournaments, "movieDailyUs-", "Daily Rohan Movie Block", 0,
|
||||
true, CollectionType.MY_CARDS, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes(cardSets, "daily"), _pairingMechanismRegistry.getPairingMechanism("swiss-3"),
|
||||
"movie", 8));
|
||||
} catch (ParseException exp) {
|
||||
// Ignore, can't happen
|
||||
|
||||
@@ -14,17 +14,7 @@ public class DailyTournamentPrizes implements TournamentPrizes {
|
||||
@Override
|
||||
public CardCollection getPrizeForTournament(PlayerStanding playerStanding, int playersCount) {
|
||||
DefaultCardCollection tournamentPrize = new DefaultCardCollection();
|
||||
if (playerStanding.getStanding() == 1) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 10);
|
||||
} else if (playerStanding.getStanding() == 2) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 8);
|
||||
} else if (playerStanding.getStanding() <=4) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 5);
|
||||
} else if (playerStanding.getStanding() <=8) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 2);
|
||||
} else {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 1);
|
||||
}
|
||||
tournamentPrize.addItem("(S)Booster Choice", playerStanding.getPoints());
|
||||
|
||||
if (tournamentPrize.getAll().size() == 0)
|
||||
return null;
|
||||
@@ -43,6 +33,6 @@ public class DailyTournamentPrizes implements TournamentPrizes {
|
||||
|
||||
@Override
|
||||
public String getPrizeDescription() {
|
||||
return "<div class='prizeHint' value='1st place - 10 boosters, 2nd place - 8 boosters, 3rd and 4th place - 5 boosters, 5th to 8th place - 2 boosters, all remaining players - 1 booster'>10-8-5-2-1</div>";
|
||||
return "2 boosters per win (or bye), max 3 rounds";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ public class PairingMechanismRegistry {
|
||||
return new SingleEliminationPairing("singleElimination");
|
||||
if (pairingType.equals("swiss"))
|
||||
return new SwissPairingMechanism("swiss");
|
||||
if (pairingType.equals("swiss-3"))
|
||||
return new SwissPairingMechanism("swiss-3", 3);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,26 @@ package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.competitive.PlayerStanding;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SwissPairingMechanism implements PairingMechanism {
|
||||
private String _registryRepresentation;
|
||||
private Integer _maxRounds;
|
||||
|
||||
public SwissPairingMechanism(String registryRepresentation) {
|
||||
_registryRepresentation = registryRepresentation;
|
||||
}
|
||||
|
||||
public SwissPairingMechanism(String registryRepresentation, int maxRounds) {
|
||||
this(registryRepresentation);
|
||||
_maxRounds = maxRounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryRepresentation() {
|
||||
return _registryRepresentation;
|
||||
@@ -28,6 +39,10 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
|
||||
@Override
|
||||
public boolean isFinished(int round, Set<String> players, Set<String> droppedPlayers) {
|
||||
if (_maxRounds != null) {
|
||||
if (round >= _maxRounds)
|
||||
return true;
|
||||
}
|
||||
return round >= getRoundCountBasedOnNumberOfPlayers(players.size());
|
||||
}
|
||||
|
||||
@@ -44,8 +59,9 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
|
||||
boolean success = tryPairBracketAndFurther(0, new HashSet<String>(), new HashSet<String>(), playersGroupedByBracket, playersWithByes, previouslyPaired, pairingResults, byeResults);
|
||||
// Managed to pair with this carry over count - proceed with the pairings
|
||||
if (success)
|
||||
if (success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We can't pair, just finish the tournament
|
||||
return true;
|
||||
@@ -67,8 +83,9 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
pairingsResult.put(firstCarryOver, player);
|
||||
// Lets give it a try
|
||||
boolean success = tryPairBracketAndFurther(bracketIndex, carryOverPlayers, carryOverFromThisBracket, playersGroupedByBracket, playersWithByes, previouslyPaired, pairingsResult, byes);
|
||||
if (success)
|
||||
if (success) {
|
||||
return true;
|
||||
}
|
||||
// Naah, it didn't work out
|
||||
pairingsResult.remove(firstCarryOver);
|
||||
}
|
||||
@@ -89,8 +106,9 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
pairingsResult.put(firstPlayer, secondPlayer);
|
||||
// Lets give it a try
|
||||
boolean success = tryPairBracketAndFurther(bracketIndex, Collections.<String>emptySet(), carryOverFromThisBracket, playersGroupedByBracket, playersWithByes, previouslyPaired, pairingsResult, byes);
|
||||
if (success)
|
||||
if (success) {
|
||||
return true;
|
||||
}
|
||||
// Naah, it didn't work out
|
||||
pairingsResult.remove(firstPlayer);
|
||||
}
|
||||
@@ -101,12 +119,12 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
}
|
||||
|
||||
// We have to go to next bracket
|
||||
if (bracketIndex+1 < playersGroupedByBracket.size()) {
|
||||
if (bracketIndex + 1 < playersGroupedByBracket.size()) {
|
||||
// Remaining players can't be paired within this bracket
|
||||
Set<String> carryOverForNextBracket = new HashSet<String>(carryOverFromThisBracket);
|
||||
carryOverForNextBracket.addAll(playersInBracket);
|
||||
|
||||
return tryPairBracketAndFurther(bracketIndex+1, carryOverForNextBracket, new HashSet<String>(), playersGroupedByBracket, playersWithByes, previouslyPaired, pairingsResult, byes);
|
||||
return tryPairBracketAndFurther(bracketIndex + 1, carryOverForNextBracket, new HashSet<String>(), playersGroupedByBracket, playersWithByes, previouslyPaired, pairingsResult, byes);
|
||||
} else {
|
||||
// There is no more brackets left, whatever is left, has to get a bye
|
||||
Set<String> leftoverPlayers = new HashSet<String>(carryOverFromThisBracket);
|
||||
@@ -114,9 +132,9 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
|
||||
// We only accept one bye
|
||||
int playersLeftWithoutPair = leftoverPlayers.size();
|
||||
switch(playersLeftWithoutPair) {
|
||||
switch (playersLeftWithoutPair) {
|
||||
case 0:
|
||||
return true;
|
||||
return true;
|
||||
case 1: {
|
||||
String lastPlayer = leftoverPlayers.iterator().next();
|
||||
if (playersWithByes.contains(lastPlayer)) {
|
||||
@@ -136,15 +154,17 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
private Set<String> getPlayersWithByes(Map<String, Integer> playerByes) {
|
||||
Set<String> playersWithByes = new HashSet<String>();
|
||||
for (Map.Entry<String, Integer> playerByeCount : playerByes.entrySet()) {
|
||||
if (playerByeCount.getValue() != null && playerByeCount.getValue() > 0)
|
||||
if (playerByeCount.getValue() != null && playerByeCount.getValue() > 0) {
|
||||
playersWithByes.add(playerByeCount.getKey());
|
||||
}
|
||||
}
|
||||
return playersWithByes;
|
||||
}
|
||||
|
||||
private void shufflePlayersWithinBrackets(List<List<String>> playersGroupedByPoints) {
|
||||
for (List<String> playersByPoint : playersGroupedByPoints)
|
||||
for (List<String> playersByPoint : playersGroupedByPoints) {
|
||||
Collections.shuffle(playersByPoint);
|
||||
}
|
||||
}
|
||||
|
||||
private List<List<String>> groupPlayersByPointBracket(Set<String> droppedPlayers, List<PlayerStanding> currentStandings, int maxNumberOfPoints) {
|
||||
@@ -164,8 +184,9 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
|
||||
List<List<String>> result = new ArrayList<List<String>>();
|
||||
for (List<String> playersByPoint : playersByPoints) {
|
||||
if (playersByPoint != null)
|
||||
if (playersByPoint != null) {
|
||||
result.add(playersByPoint);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -174,8 +195,9 @@ public class SwissPairingMechanism implements PairingMechanism {
|
||||
private int determineMaximumNumberOfPoints(Set<String> droppedPlayers, List<PlayerStanding> currentStandings) {
|
||||
int maxNumberOfPoints = 0;
|
||||
for (PlayerStanding currentStanding : currentStandings) {
|
||||
if (!droppedPlayers.contains(currentStanding.getPlayerName()))
|
||||
if (!droppedPlayers.contains(currentStanding.getPlayerName())) {
|
||||
maxNumberOfPoints = Math.max(currentStanding.getPoints(), maxNumberOfPoints);
|
||||
}
|
||||
}
|
||||
return maxNumberOfPoints;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user