Started working on tournaments.

This commit is contained in:
marcins78@gmail.com
2012-05-01 16:17:57 +00:00
parent 6d152c06cb
commit b6db348386
13 changed files with 381 additions and 43 deletions

View File

@@ -1,13 +1,13 @@
package com.gempukku.lotro.league;
package com.gempukku.lotro;
public class LeagueStanding {
public class PlayerStanding {
private String _playerName;
private int _points;
private int _gamesPlayed;
private float _opponentWin;
private int _standing;
public LeagueStanding(String playerName, int points, int gamesPlayed) {
public PlayerStanding(String playerName, int points, int gamesPlayed) {
_playerName = playerName;
_points = points;
_gamesPlayed = gamesPlayed;

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.CardCollection;
@@ -52,12 +53,12 @@ public class ConstructedLeagueData implements LeagueData {
}
@Override
public int process(CollectionsManager collectionsManager, List<LeagueStanding> leagueStandings, int oldStatus, int currentTime) {
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) {
int status = oldStatus;
if (status == 0) {
LeagueSerieData lastSerie = _series.get(_series.size() - 1);
if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) {
for (LeagueStanding leagueStanding : leagueStandings) {
for (PlayerStanding leagueStanding : leagueStandings) {
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier, _leaguePrizePool);
if (leaguePrize != null)
collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll());

View File

@@ -1,5 +1,6 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.Player;
@@ -11,5 +12,5 @@ public interface LeagueData {
public CardCollection joinLeague(CollectionsManager collecionsManager, Player player, int currentTime);
public int process(CollectionsManager collectionsManager, List<LeagueStanding> leagueStandings, int oldStatus, int currentTime);
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime);
}

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.cache.ExpireObjectCache;
import com.gempukku.lotro.cache.Producable;
import com.gempukku.lotro.collection.CollectionsManager;
@@ -23,11 +24,11 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
public class LeagueService {
private Comparator<LeagueStanding> LEAGUE_STANDING_COMPARATOR =
new MultipleComparator<LeagueStanding>(
new DescComparator<LeagueStanding>(new PointsComparator()),
private Comparator<PlayerStanding> LEAGUE_STANDING_COMPARATOR =
new MultipleComparator<PlayerStanding>(
new DescComparator<PlayerStanding>(new PointsComparator()),
new GamesPlayedComparator(),
new DescComparator<LeagueStanding>(new OpponentsWinComparator()));
new DescComparator<PlayerStanding>(new OpponentsWinComparator()));
private LeagueDAO _leagueDao;
private LeaguePointsDAO _leaguePointsDao;
@@ -36,8 +37,8 @@ public class LeagueService {
private LeagueParticipationDAO _leagueParticipationDAO;
private CollectionsManager _collectionsManager;
private Map<League, List<LeagueStanding>> _leagueStandings = new ConcurrentHashMap<League, List<LeagueStanding>>();
private Map<LeagueSerieData, List<LeagueStanding>> _leagueSerieStandings = new ConcurrentHashMap<LeagueSerieData, List<LeagueStanding>>();
private Map<League, List<PlayerStanding>> _leagueStandings = new ConcurrentHashMap<League, List<PlayerStanding>>();
private Map<LeagueSerieData, List<PlayerStanding>> _leagueSerieStandings = new ConcurrentHashMap<LeagueSerieData, List<PlayerStanding>>();
private Map<League, Set<String>> _playersParticipating = new ConcurrentHashMap<League, Set<String>>();
private Map<League, Set<String>> _playersNotParticipating = new ConcurrentHashMap<League, Set<String>>();
@@ -310,8 +311,8 @@ public class LeagueService {
return result;
}
public List<LeagueStanding> getLeagueStandings(League league) {
List<LeagueStanding> leagueStandings = _leagueStandings.get(league);
public List<PlayerStanding> getLeagueStandings(League league) {
List<PlayerStanding> leagueStandings = _leagueStandings.get(league);
if (leagueStandings == null) {
synchronized (this) {
leagueStandings = createLeagueStandings(league);
@@ -321,8 +322,8 @@ public class LeagueService {
return leagueStandings;
}
public List<LeagueStanding> getLeagueSerieStandings(League league, LeagueSerieData leagueSerie) {
List<LeagueStanding> serieStandings = _leagueSerieStandings.get(leagueSerie);
public List<PlayerStanding> getLeagueSerieStandings(League league, LeagueSerieData leagueSerie) {
List<PlayerStanding> serieStandings = _leagueSerieStandings.get(leagueSerie);
if (serieStandings == null) {
synchronized (this) {
serieStandings = createLeagueSerieStandings(league, leagueSerie);
@@ -332,21 +333,21 @@ public class LeagueService {
return serieStandings;
}
private List<LeagueStanding> createLeagueSerieStandings(League league, LeagueSerieData leagueSerie) {
private List<PlayerStanding> createLeagueSerieStandings(League league, LeagueSerieData leagueSerie) {
final Map<String, LeaguePointsDAO.Points> points = getLeagueSeriePoints(league, leagueSerie);
final Collection<LeagueMatch> matches = getLeagueSerieMatches(league, leagueSerie);
return createStandingsForMatchesAndPoints(points, matches);
}
private List<LeagueStanding> createLeagueStandings(League league) {
private List<PlayerStanding> createLeagueStandings(League league) {
final Map<String, LeaguePointsDAO.Points> points = getLeaguePoints(league);
final Collection<LeagueMatch> matches = getLeagueMatches(league);
return createStandingsForMatchesAndPoints(points, matches);
}
private List<LeagueStanding> createStandingsForMatchesAndPoints(Map<String, LeaguePointsDAO.Points> points, Collection<LeagueMatch> matches) {
private List<PlayerStanding> createStandingsForMatchesAndPoints(Map<String, LeaguePointsDAO.Points> points, Collection<LeagueMatch> matches) {
Map<String, List<String>> playerOpponents = new HashMap<String, List<String>>();
Map<String, Integer> playerWins = new HashMap<String, Integer>();
Map<String, Integer> playerLoss = new HashMap<String, Integer>();
@@ -356,9 +357,9 @@ public class LeagueService {
appendMatch(playerWins, playerLoss, leagueMatch.getWinner(), leagueMatch.getLoser());
}
List<LeagueStanding> leagueStandings = new LinkedList<LeagueStanding>();
List<PlayerStanding> leagueStandings = new LinkedList<PlayerStanding>();
for (Map.Entry<String, LeaguePointsDAO.Points> playerPoints : points.entrySet()) {
LeagueStanding standing = new LeagueStanding(playerPoints.getKey(), playerPoints.getValue().getPoints(), playerPoints.getValue().getGamesPlayed());
PlayerStanding standing = new PlayerStanding(playerPoints.getKey(), playerPoints.getValue().getPoints(), playerPoints.getValue().getGamesPlayed());
List<String> opponents = playerOpponents.get(playerPoints.getKey());
int opponentWins = 0;
int opponentGames = 0;
@@ -374,8 +375,8 @@ public class LeagueService {
int standing = 0;
int position = 1;
LeagueStanding lastStanding = null;
for (LeagueStanding leagueStanding : leagueStandings) {
PlayerStanding lastStanding = null;
for (PlayerStanding leagueStanding : leagueStandings) {
if (lastStanding == null || LEAGUE_STANDING_COMPARATOR.compare(leagueStanding, lastStanding) != 0)
standing = position;
leagueStanding.setStanding(standing);
@@ -428,23 +429,23 @@ public class LeagueService {
return true;
}
private class PointsComparator implements Comparator<LeagueStanding> {
private class PointsComparator implements Comparator<PlayerStanding> {
@Override
public int compare(LeagueStanding o1, LeagueStanding o2) {
public int compare(PlayerStanding o1, PlayerStanding o2) {
return o1.getPoints() - o2.getPoints();
}
}
private class GamesPlayedComparator implements Comparator<LeagueStanding> {
private class GamesPlayedComparator implements Comparator<PlayerStanding> {
@Override
public int compare(LeagueStanding o1, LeagueStanding o2) {
public int compare(PlayerStanding o1, PlayerStanding o2) {
return o1.getGamesPlayed() - o2.getGamesPlayed();
}
}
private class OpponentsWinComparator implements Comparator<LeagueStanding> {
private class OpponentsWinComparator implements Comparator<PlayerStanding> {
@Override
public int compare(LeagueStanding o1, LeagueStanding o2) {
public int compare(PlayerStanding o1, PlayerStanding o2) {
final float diff = o1.getOpponentWin() - o2.getOpponentWin();
if (diff < 0)
return -1;

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.CardCollection;
@@ -54,12 +55,12 @@ public class NewConstructedLeagueData implements LeagueData {
}
@Override
public int process(CollectionsManager collectionsManager, List<LeagueStanding> leagueStandings, int oldStatus, int currentTime) {
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) {
int status = oldStatus;
if (status == 0) {
LeagueSerieData lastSerie = _series.get(_series.size() - 1);
if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) {
for (LeagueStanding leagueStanding : leagueStandings) {
for (PlayerStanding leagueStanding : leagueStandings) {
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier, null);
if (leaguePrize != null)
collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll());

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.CardCollection;
@@ -64,7 +65,7 @@ public class NewSealedLeagueData implements LeagueData {
}
@Override
public int process(CollectionsManager collectionsManager, List<LeagueStanding> leagueStandings, int oldStatus, int currentTime) {
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) {
int status = oldStatus;
for (int i = status; i < _series.size(); i++) {
@@ -82,12 +83,12 @@ public class NewSealedLeagueData implements LeagueData {
if (status == _series.size()) {
LeagueSerieData lastSerie = _series.get(_series.size() - 1);
if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) {
for (LeagueStanding leagueStanding : leagueStandings) {
for (PlayerStanding leagueStanding : leagueStandings) {
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f, _format);
if (leaguePrize != null)
collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll());
}
// for (LeagueStanding leagueStanding : leagueStandings) {
// for (PlayerStanding leagueStanding : leagueStandings) {
// collectionsManager.moveCollectionToCollection(leagueStanding.getPlayerName(), _collectionType, _prizeCollectionType);
// }
status++;

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.CardCollection;
@@ -64,7 +65,7 @@ public class SealedLeagueData implements LeagueData {
}
@Override
public int process(CollectionsManager collectionsManager, List<LeagueStanding> leagueStandings, int oldStatus, int currentTime) {
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) {
int status = oldStatus;
for (int i = status; i < _series.size(); i++) {
@@ -82,12 +83,12 @@ public class SealedLeagueData implements LeagueData {
if (status == _series.size()) {
LeagueSerieData lastSerie = _series.get(_series.size() - 1);
if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) {
for (LeagueStanding leagueStanding : leagueStandings) {
for (PlayerStanding leagueStanding : leagueStandings) {
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f, _format);
if (leaguePrize != null)
collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll());
}
// for (LeagueStanding leagueStanding : leagueStandings) {
// for (PlayerStanding leagueStanding : leagueStandings) {
// collectionsManager.moveCollectionToCollection(leagueStanding.getPlayerName(), _collectionType, _prizeCollectionType);
// }
status++;

View File

@@ -0,0 +1,268 @@
package com.gempukku.lotro.tournament;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.logic.vo.LotroDeck;
import com.gempukku.util.DescComparator;
import com.gempukku.util.MultipleComparator;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
public class Tournament {
private Comparator<PlayerStanding> LEAGUE_STANDING_COMPARATOR =
new MultipleComparator<PlayerStanding>(
new DescComparator<PlayerStanding>(new PointsComparator()),
new GamesPlayedComparator(),
new DescComparator<PlayerStanding>(new OpponentsWinComparator()));
private TournamentMatchDao _tournamentMatchDao;
private Map<String, LotroDeck> _players;
private Set<String>[] _droppedPlayers;
private int _roundCount;
// Current round
private int _currentRound;
private String _id;
private LotroFormat _format;
private Set<TournamentMatch>[] _finishedMatches;
private Map<String, String> _currentRoundPairings;
private Set<String> _playersWithByes;
private TournamentTask _nextTournamentTask;
private List<PlayerStanding> _currentStandings;
public Tournament(TournamentMatchDao tournamentMatchDao, Map<String, LotroDeck> players, Set<String>[] droppedPlayers, int roundCount, int status, String id, LotroFormat format) {
_tournamentMatchDao = tournamentMatchDao;
_droppedPlayers = droppedPlayers;
_roundCount = roundCount;
_currentRound = status;
_id = id;
_format = format;
_players = new ConcurrentHashMap<String, LotroDeck>(players);
for (int i = 0; i < _currentRound; i++) {
Set<String> allPlayers = new HashSet<String>(players.keySet());
// Remove all players dropped so far
for (int j = 0; j <= i; j++)
allPlayers.removeAll(droppedPlayers[j]);
// Fill the information about all the matches finished or scheduled so far
for (TournamentMatch tournamentMatch : _tournamentMatchDao.getMatches(_id, i + 1)) {
if (tournamentMatch.getWinner() != null)
_finishedMatches[i].add(tournamentMatch);
else
_currentRoundPairings.put(tournamentMatch.getPlayerOne(), tournamentMatch.getPlayerTwo());
// Removed playing (or played) players
allPlayers.remove(tournamentMatch.getPlayerOne());
allPlayers.remove(tournamentMatch.getPlayerTwo());
}
// Remaining players had a bye
_playersWithByes.addAll(allPlayers);
}
if (_currentRoundPairings.isEmpty()) {
_nextTournamentTask = new DelayedTournamentTask() {
@Override
public int executeTask(TournamentCallback tournamentCallback) {
return roundFinished(tournamentCallback);
}
};
} else {
_nextTournamentTask = new DelayedTournamentTask() {
@Override
public int executeTask(TournamentCallback tournamentCallback) {
tournamentCallback.createGames(_currentRoundPairings, _players);
return _currentRound;
}
};
}
}
private int roundFinished(TournamentCallback tournamentCallback) {
if (_currentRound < _roundCount) {
_currentRound++;
boolean success = tryCreatingNewPairings();
if (success) {
Map<String, String> currentRoundPairings = _currentRoundPairings;
for (Map.Entry<String, String> pairing : currentRoundPairings.entrySet())
_tournamentMatchDao.addMatch(_id, _currentRound, pairing.getKey(), pairing.getValue());
tournamentCallback.createGames(currentRoundPairings, _players);
return _currentRound;
} else {
return distributePrizes(tournamentCallback);
}
} else if (_currentRound == _roundCount) {
return distributePrizes(tournamentCallback);
} else {
return _currentRound;
}
}
private boolean tryCreatingNewPairings() {
return false;
}
private int distributePrizes(TournamentCallback tournamentCallback) {
_currentRound = _roundCount + 1;
// Distribute prizes
return _currentRound;
}
public synchronized void dropPlayerBeforeRound(int round, String playerName) {
if (_droppedPlayers[round] == null)
_droppedPlayers[round] = new CopyOnWriteArraySet<String>();
_droppedPlayers[round].add(playerName);
}
public synchronized void executePendingTasks(TournamentCallback tournamentCallback) {
if (_nextTournamentTask != null && _nextTournamentTask.getExecuteAfter() < System.currentTimeMillis()) {
TournamentTask task = _nextTournamentTask;
_nextTournamentTask = null;
task.executeTask(tournamentCallback);
}
}
public List<PlayerStanding> getCurrentStandings() {
List<PlayerStanding> result = _currentStandings;
if (result != null)
return result;
synchronized (this) {
if (_currentStandings == null)
calculateCurrentStandings();
return _currentStandings;
}
}
private void calculateCurrentStandings() {
Map<String, PlayerStanding> playersStandings = new HashMap<String, PlayerStanding>();
for (String player : _players.keySet()) {
int points = 0;
int gamesPlayed = 0;
for (int i = 0; i < _currentRound; i++) {
if (_droppedPlayers[i] != null && _droppedPlayers[i].contains(player))
break;
TournamentMatch match = getPlayerMatch(i, player);
if (match != null) {
gamesPlayed++;
if (match.getWinner().equals(player))
points++;
} else if (_currentRoundPairings.containsKey(player) || _currentRoundPairings.containsValue(player)) {
// Do nothing
} else {
// Bye
points++;
gamesPlayed++;
}
}
playersStandings.put(player, new PlayerStanding(player, points, gamesPlayed));
}
for (String player : _players.keySet()) {
int opponentPoints = 0;
int opponentGamesPlayed = 0;
for (int i = 0; i < _currentRound; i++) {
if (_droppedPlayers[i] != null && _droppedPlayers[i].contains(player))
break;
TournamentMatch match = getPlayerMatch(i, player);
if (match != null) {
String opponent;
if (match.getPlayerOne().equals(player))
opponent = match.getPlayerTwo();
else
opponent = match.getPlayerOne();
PlayerStanding opponentStanding = playersStandings.get(opponent);
opponentPoints += opponentStanding.getPoints();
opponentGamesPlayed += opponentStanding.getGamesPlayed();
}
}
float opponentWinPerc = opponentPoints * 1f / opponentGamesPlayed;
playersStandings.get(player).setOpponentWin(opponentWinPerc);
}
List<PlayerStanding> result = new ArrayList<PlayerStanding>(playersStandings.values());
Collections.sort(result, LEAGUE_STANDING_COMPARATOR);
int standing = 0;
int position = 1;
PlayerStanding lastStanding = null;
for (PlayerStanding playerStanding : result) {
if (lastStanding == null || LEAGUE_STANDING_COMPARATOR.compare(playerStanding, lastStanding) != 0)
standing = position;
playerStanding.setStanding(standing);
position++;
lastStanding = playerStanding;
}
_currentStandings = Collections.unmodifiableList(result);
}
private TournamentMatch getPlayerMatch(int roundIndex, String player) {
for (TournamentMatch tournamentMatch : _finishedMatches[roundIndex]) {
if (tournamentMatch.getPlayerOne().equals(player)
|| tournamentMatch.getPlayerTwo().equals(player))
return tournamentMatch;
}
return null;
}
private interface TournamentTask {
public int executeTask(TournamentCallback tournamentCallback);
public long getExecuteAfter();
}
private abstract class DelayedTournamentTask implements TournamentTask {
private final long _time;
private DelayedTournamentTask() {
_time = System.currentTimeMillis();
}
@Override
public final long getExecuteAfter() {
return _time + 1000 * 60 * 2;
}
}
private class PointsComparator implements Comparator<PlayerStanding> {
@Override
public int compare(PlayerStanding o1, PlayerStanding o2) {
return o1.getPoints() - o2.getPoints();
}
}
private class GamesPlayedComparator implements Comparator<PlayerStanding> {
@Override
public int compare(PlayerStanding o1, PlayerStanding o2) {
return o1.getGamesPlayed() - o2.getGamesPlayed();
}
}
private class OpponentsWinComparator implements Comparator<PlayerStanding> {
@Override
public int compare(PlayerStanding o1, PlayerStanding o2) {
final float diff = o1.getOpponentWin() - o2.getOpponentWin();
if (diff < 0)
return -1;
if (diff > 0)
return 1;
return 0;
}
}
}

View File

@@ -0,0 +1,9 @@
package com.gempukku.lotro.tournament;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.Map;
public interface TournamentCallback {
public void createGames(Map<String, String> pairings, Map<String, LotroDeck> playerDecks);
}

View File

@@ -0,0 +1,31 @@
package com.gempukku.lotro.tournament;
public class TournamentMatch {
private String _playerOne;
private String _playerTwo;
private String _winner;
private int _round;
public TournamentMatch(String playerOne, String playerTwo, String winner, int round) {
_playerOne = playerOne;
_playerTwo = playerTwo;
_winner = winner;
_round = round;
}
public String getPlayerOne() {
return _playerOne;
}
public String getPlayerTwo() {
return _playerTwo;
}
public String getWinner() {
return _winner;
}
public int getRound() {
return _round;
}
}

View File

@@ -0,0 +1,11 @@
package com.gempukku.lotro.tournament;
import java.util.List;
public interface TournamentMatchDao {
public void addMatch(String tournamentId, int round, String playerOne, String playerTwo);
public void setMatchResult(String tournamentId, int round, String winner);
public List<TournamentMatch> getMatches(String tournamentId, int round);
}

View File

@@ -0,0 +1,13 @@
package com.gempukku.lotro.tournament;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.Map;
public interface TournamentPlayerDao {
public void addPlayer(String tournamentId, String playerName, LotroDeck deck);
public void removePlayer(String tournamentId, String playerName);
public Map<String, LotroDeck> getPlayers(String tournamentId);
}

View File

@@ -1,13 +1,13 @@
package com.gempukku.lotro.server;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerStanding;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.league.LeagueData;
import com.gempukku.lotro.league.LeagueSerieData;
import com.gempukku.lotro.league.LeagueService;
import com.gempukku.lotro.league.LeagueStanding;
import com.sun.jersey.spi.resource.Singleton;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -126,8 +126,8 @@ public class LeagueResource extends AbstractResource {
serieElem.setAttribute("collection", serie.getCollectionType().getFullName());
serieElem.setAttribute("limited", String.valueOf(serie.isLimited()));
final List<LeagueStanding> standings = _leagueService.getLeagueSerieStandings(league, serie);
for (LeagueStanding standing : standings) {
final List<PlayerStanding> standings = _leagueService.getLeagueSerieStandings(league, serie);
for (PlayerStanding standing : standings) {
Element standingElem = doc.createElement("standing");
setStandingAttributes(standing, standingElem);
serieElem.appendChild(standingElem);
@@ -136,8 +136,8 @@ public class LeagueResource extends AbstractResource {
leagueElem.appendChild(serieElem);
}
List<LeagueStanding> leagueStandings = _leagueService.getLeagueStandings(league);
for (LeagueStanding standing : leagueStandings) {
List<PlayerStanding> leagueStandings = _leagueService.getLeagueStandings(league);
for (PlayerStanding standing : leagueStandings) {
Element standingElem = doc.createElement("leagueStanding");
setStandingAttributes(standing, standingElem);
leagueElem.appendChild(standingElem);
@@ -156,7 +156,7 @@ public class LeagueResource extends AbstractResource {
return null;
}
private void setStandingAttributes(LeagueStanding standing, Element standingElem) {
private void setStandingAttributes(PlayerStanding standing, Element standingElem) {
standingElem.setAttribute("player", standing.getPlayerName());
standingElem.setAttribute("standing", String.valueOf(standing.getStanding()));
standingElem.setAttribute("points", String.valueOf(standing.getPoints()));