Working on leagues.
This commit is contained in:
@@ -9,5 +9,5 @@ public interface LotroFormat {
|
||||
|
||||
public boolean hasMulliganRule();
|
||||
|
||||
public void validateDeck(LotroDeck deck) throws DeckInvalidException;
|
||||
public void validateDeck(Player player, LotroDeck deck) throws DeckInvalidException;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gempukku.lotro.db.vo;
|
||||
package com.gempukku.lotro.game;
|
||||
|
||||
public class Player {
|
||||
private int _id;
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionSerializer;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.MutableCardCollection;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.DeckVO;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.GameHistoryEntry;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueMatch;
|
||||
import com.gempukku.lotro.db.vo.LeagueSeason;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -16,14 +17,14 @@ public class LeagueMatchDAO {
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public Collection<LeagueMatch> getPlayerMatchesPlayedOn(League league, String player, int datePlayed) {
|
||||
public Collection<LeagueMatch> getPlayerMatchesPlayedOn(League league, LeagueSeason leagueSeason, String player) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select winner, loser from leaguematch where league_id=? and date=? and (winner=? or loser=?)");
|
||||
PreparedStatement statement = conn.prepareStatement("select winner, loser from league_match where league_type=? and season_type=? and (winner=? or loser=?)");
|
||||
try {
|
||||
statement.setInt(1, league.getId());
|
||||
statement.setInt(2, datePlayed);
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, leagueSeason.getType());
|
||||
statement.setString(3, player);
|
||||
statement.setString(4, player);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
@@ -50,14 +51,14 @@ public class LeagueMatchDAO {
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayedMatch(League league, String winner, String loser, int datePlayed) {
|
||||
public void addPlayedMatch(League league, LeagueSeason leagueSeason, String winner, String loser) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("insert into leaguematch (league_id, date, winner, loser) values (?, ?, ?, ?)");
|
||||
PreparedStatement statement = conn.prepareStatement("insert into league_match (league_type, season_type, winner, loser) values (?, ?, ?, ?)");
|
||||
try {
|
||||
statement.setInt(1, league.getId());
|
||||
statement.setInt(2, datePlayed);
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, leagueSeason.getType());
|
||||
statement.setString(3, winner);
|
||||
statement.setString(4, loser);
|
||||
statement.execute();
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSeason;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class LeaguePointsDAO {
|
||||
private DbAccess _dbAccess;
|
||||
|
||||
public LeaguePointsDAO(DbAccess dbAccess) {
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public void addPoints(League league, LeagueSeason season, String playerName, int points) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("insert into league_points (league_type, season_type, player_name, points) values (?, ?, ?, ?)");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, season.getType());
|
||||
statement.setString(3, playerName);
|
||||
statement.setInt(4, points);
|
||||
statement.execute();
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSeason;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class LeagueSeasonDAO {
|
||||
private DbAccess _dbAccess;
|
||||
|
||||
public LeagueSeasonDAO(DbAccess dbAccess) {
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public LeagueSeason getSeasonForLeague(League league, int inTime) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select season_type, max_matches from league_season where league_type=? and start>=? and end<=?");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
statement.setInt(2, inTime);
|
||||
statement.setInt(3, inTime);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
try {
|
||||
if (rs.next()) {
|
||||
String type = rs.getString(1);
|
||||
int maxMatches = rs.getInt(2);
|
||||
return new LeagueSeason(type, maxMatches);
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
rs.close();
|
||||
}
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.sql.Connection;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.gempukku.lotro.db.vo;
|
||||
|
||||
public class LeagueSeason {
|
||||
private String _type;
|
||||
private int _maxMatches;
|
||||
|
||||
public LeagueSeason(String type, int maxMatches) {
|
||||
_type = type;
|
||||
_maxMatches = maxMatches;
|
||||
}
|
||||
|
||||
public int getMaxMatches() {
|
||||
return _maxMatches;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.GameHistoryDAO;
|
||||
import com.gempukku.lotro.db.vo.DeckVO;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.logic.timing.GameResultListener;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@@ -4,10 +4,7 @@ import com.gempukku.lotro.common.Block;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Side;
|
||||
import com.gempukku.lotro.game.DeckInvalidException;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprint;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.LotroFormat;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -69,7 +66,7 @@ public abstract class DefaultLotroFormat implements LotroFormat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateDeck(LotroDeck deck) throws DeckInvalidException {
|
||||
public void validateDeck(Player player, LotroDeck deck) throws DeckInvalidException {
|
||||
try {
|
||||
// Ring-bearer
|
||||
if (deck.getRingBearer() == null)
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gempukku.lotro.hall;
|
||||
import com.gempukku.lotro.AbstractServer;
|
||||
import com.gempukku.lotro.chat.ChatServer;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.game.formats.*;
|
||||
import com.gempukku.lotro.league.LeagueService;
|
||||
@@ -97,7 +96,7 @@ public class HallServer extends AbstractServer {
|
||||
// Maybe it's a league format?
|
||||
league = _leagueService.getLeagueByType(type);
|
||||
if (league != null) {
|
||||
format = _leagueService.getLeagueFormat(league, player);
|
||||
format = _leagueService.getLeagueFormat(league);
|
||||
formatName = league.getName();
|
||||
}
|
||||
}
|
||||
@@ -123,7 +122,7 @@ public class HallServer extends AbstractServer {
|
||||
throw new HallException("You don't have a deck registered yet");
|
||||
|
||||
try {
|
||||
format.validateDeck(lotroDeck);
|
||||
format.validateDeck(player, lotroDeck);
|
||||
} catch (DeckInvalidException e) {
|
||||
throw new HallException("Your registered deck is not valid for this format: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -1,38 +1,45 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.common.Block;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.CollectionUtils;
|
||||
import com.gempukku.lotro.game.DeckInvalidException;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.game.formats.DefaultLotroFormat;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LeagueFormat extends DefaultLotroFormat {
|
||||
private CardCollection _playerCardCollection;
|
||||
private LotroCardBlueprintLibrary _library;
|
||||
private LeagueService _leagueService;
|
||||
private League _league;
|
||||
private boolean _orderedSites;
|
||||
|
||||
public LeagueFormat(LotroCardBlueprintLibrary library, CardCollection playerCardCollection, boolean orderedSites) {
|
||||
public LeagueFormat(LotroCardBlueprintLibrary library, LeagueService leagueService, League league, boolean orderedSites) {
|
||||
super(library, Block.FELLOWSHIP, true, 60, Integer.MAX_VALUE, true, true);
|
||||
_playerCardCollection = playerCardCollection;
|
||||
_library = library;
|
||||
_leagueService = leagueService;
|
||||
_league = league;
|
||||
_orderedSites = orderedSites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateDeck(LotroDeck deck) throws DeckInvalidException {
|
||||
public void validateDeck(Player player, LotroDeck deck) throws DeckInvalidException {
|
||||
// First validate the deck is valid at all
|
||||
super.validateDeck(deck);
|
||||
super.validateDeck(player, deck);
|
||||
|
||||
CardCollection playerCardCollection = _leagueService.getLeagueCollection(player, _league);
|
||||
|
||||
// Now check if player owns all the cards
|
||||
Map<String, Integer> deckCardCounts = CollectionUtils.getTotalCardCountForDeck(deck);
|
||||
final Map<String, Integer> collectionCardCounts = _playerCardCollection.getAll();
|
||||
final Map<String, Integer> collectionCardCounts = playerCardCollection.getAll();
|
||||
|
||||
for (Map.Entry<String, Integer> cardCount : deckCardCounts.entrySet()) {
|
||||
final Integer collectionCount = collectionCardCounts.get(cardCount.getKey());
|
||||
if (collectionCount == null || collectionCount < cardCount.getValue())
|
||||
throw new DeckInvalidException("You don't have the required cards in collection for this format");
|
||||
if (collectionCount == null || collectionCount < cardCount.getValue()) {
|
||||
String cardName = _library.getLotroCardBlueprint(cardCount.getKey()).getName();
|
||||
int owned = (collectionCount == null) ? 0 : collectionCount;
|
||||
throw new DeckInvalidException("You don't have the required cards in collection: " + cardName + " required " + cardCount.getValue() + ", owned " + owned);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.db.CollectionDAO;
|
||||
import com.gempukku.lotro.db.LeagueDAO;
|
||||
import com.gempukku.lotro.db.LeagueMatchDAO;
|
||||
import com.gempukku.lotro.db.*;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.db.vo.LeagueMatch;
|
||||
import com.gempukku.lotro.db.vo.LeagueSeason;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.logic.timing.GameResultListener;
|
||||
|
||||
@@ -12,12 +11,16 @@ import java.util.*;
|
||||
|
||||
public class LeagueService {
|
||||
private LeagueDAO _leagueDao;
|
||||
private LeagueSeasonDAO _leagueSeasonDao;
|
||||
private LeaguePointsDAO _leaguePointsDao;
|
||||
private LeagueMatchDAO _leagueMatchDao;
|
||||
private CollectionDAO _collectionDao;
|
||||
private LotroCardBlueprintLibrary _library;
|
||||
|
||||
public LeagueService(LeagueDAO leagueDao, LeagueMatchDAO leagueMatchDao, CollectionDAO collectionDao, LotroCardBlueprintLibrary library) {
|
||||
public LeagueService(LeagueDAO leagueDao, LeagueSeasonDAO leagueSeasonDao, LeaguePointsDAO leaguePointsDao, LeagueMatchDAO leagueMatchDao, CollectionDAO collectionDao, LotroCardBlueprintLibrary library) {
|
||||
_leagueDao = leagueDao;
|
||||
_leagueSeasonDao = leagueSeasonDao;
|
||||
_leaguePointsDao = leaguePointsDao;
|
||||
_leagueMatchDao = leagueMatchDao;
|
||||
_collectionDao = collectionDao;
|
||||
_library = library;
|
||||
@@ -53,18 +56,23 @@ public class LeagueService {
|
||||
return null;
|
||||
}
|
||||
|
||||
public LotroFormat getLeagueFormat(League league, Player player) {
|
||||
return new LeagueFormat(_library, getLeagueCollection(player, league), true);
|
||||
public LotroFormat getLeagueFormat(League league) {
|
||||
return new LeagueFormat(_library, this, league, true);
|
||||
}
|
||||
|
||||
public void leagueGameStarting(final League league, LotroGameMediator gameMediator) {
|
||||
final int startDay = getCurrentDate();
|
||||
if (isRanked(league, gameMediator, startDay)) {
|
||||
|
||||
final LeagueSeason season = _leagueSeasonDao.getSeasonForLeague(league, startDay);
|
||||
if (season != null && isRanked(league, season, gameMediator)) {
|
||||
gameMediator.addGameResultListener(
|
||||
new GameResultListener() {
|
||||
@Override
|
||||
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons) {
|
||||
_leagueMatchDao.addPlayedMatch(league, winnerPlayerId, loserPlayerIdsWithReasons.keySet().iterator().next(), startDay);
|
||||
String loser = loserPlayerIdsWithReasons.keySet().iterator().next();
|
||||
_leagueMatchDao.addPlayedMatch(league, season, winnerPlayerId, loser);
|
||||
_leaguePointsDao.addPoints(league, season, winnerPlayerId, 3);
|
||||
_leaguePointsDao.addPoints(league, season, loser, 1);
|
||||
}
|
||||
});
|
||||
gameMediator.sendMessageToPlayers("This is a ranked game in " + league.getName());
|
||||
@@ -78,10 +86,17 @@ public class LeagueService {
|
||||
return date.get(Calendar.YEAR) * 10000 + (date.get(Calendar.MONTH) + 1) * 100 + date.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
private boolean isRanked(League league, LotroGameMediator gameMediator, int startDate) {
|
||||
for (String player : gameMediator.getPlayersPlaying()) {
|
||||
if (_leagueMatchDao.getPlayerMatchesPlayedOn(league, player, startDate).size() >= 2)
|
||||
private boolean isRanked(League league, LeagueSeason season, LotroGameMediator gameMediator) {
|
||||
Set<String> playersPlaying = gameMediator.getPlayersPlaying();
|
||||
for (String player : playersPlaying) {
|
||||
int maxMatches = season.getMaxMatches();
|
||||
Collection<LeagueMatch> playedInSeason = _leagueMatchDao.getPlayerMatchesPlayedOn(league, season, player);
|
||||
if (playedInSeason.size() >= maxMatches)
|
||||
return false;
|
||||
for (LeagueMatch leagueMatch : playedInSeason) {
|
||||
if (playersPlaying.contains(leagueMatch.getWinner()) && playersPlaying.contains(leagueMatch.getLoser()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.db.PlayerDAO;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.gempukku.lotro.server;
|
||||
import com.gempukku.lotro.db.CollectionDAO;
|
||||
import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.LeagueDAO;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.hall.HallServer;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gempukku.lotro.server;
|
||||
import com.gempukku.lotro.chat.ChatMessage;
|
||||
import com.gempukku.lotro.chat.ChatRoomMediator;
|
||||
import com.gempukku.lotro.chat.ChatServer;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
@@ -3,11 +3,7 @@ package com.gempukku.lotro.server;
|
||||
import com.gempukku.lotro.common.Side;
|
||||
import com.gempukku.lotro.db.CollectionDAO;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.LotroServer;
|
||||
import com.gempukku.lotro.game.MutableCardCollection;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.league.LeagueService;
|
||||
import com.gempukku.lotro.packs.PacksStorage;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
|
||||
@@ -19,7 +19,9 @@ public class DaoProvider implements InjectableProvider<Context, Type> {
|
||||
private Injectable<GameHistoryDAO> _gameHistoryDAOInjectable;
|
||||
|
||||
private Injectable<LeagueDAO> _leagueDaoInjectable;
|
||||
private Injectable<LeagueSeasonDAO> _leagueSeasonDAOInjectable;
|
||||
private Injectable<LeagueMatchDAO> _leagueMatchDAOInjectable;
|
||||
private Injectable<LeaguePointsDAO> _leaguePointsDAOInjectable;
|
||||
|
||||
@Context
|
||||
private LotroCardBlueprintLibrary _library;
|
||||
@@ -41,11 +43,28 @@ public class DaoProvider implements InjectableProvider<Context, Type> {
|
||||
return getGameHistoryDaoSafely();
|
||||
else if (type.equals(LeagueDAO.class))
|
||||
return getLeagueDaoSafely();
|
||||
else if (type.equals(LeagueSeasonDAO.class))
|
||||
return getLeagueSeasonDaoSafely();
|
||||
else if (type.equals(LeagueMatchDAO.class))
|
||||
return getLeagueMatchDaoSafely();
|
||||
else if (type.equals(LeaguePointsDAO.class))
|
||||
return getLeaguePointsDaoSafely();
|
||||
return null;
|
||||
}
|
||||
|
||||
private synchronized Injectable<LeaguePointsDAO> getLeaguePointsDaoSafely() {
|
||||
if (_leaguePointsDAOInjectable == null) {
|
||||
final LeaguePointsDAO leaguePointsDAO = new LeaguePointsDAO(_dbAccess);
|
||||
_leaguePointsDAOInjectable = new Injectable<LeaguePointsDAO>() {
|
||||
@Override
|
||||
public LeaguePointsDAO getValue() {
|
||||
return leaguePointsDAO;
|
||||
}
|
||||
};
|
||||
}
|
||||
return _leaguePointsDAOInjectable;
|
||||
}
|
||||
|
||||
private synchronized Injectable<LeagueMatchDAO> getLeagueMatchDaoSafely() {
|
||||
if (_leagueMatchDAOInjectable == null) {
|
||||
final LeagueMatchDAO leagueMatchDao = new LeagueMatchDAO(_dbAccess);
|
||||
@@ -59,6 +78,19 @@ public class DaoProvider implements InjectableProvider<Context, Type> {
|
||||
return _leagueMatchDAOInjectable;
|
||||
}
|
||||
|
||||
private synchronized Injectable<LeagueSeasonDAO> getLeagueSeasonDaoSafely() {
|
||||
if (_leagueSeasonDAOInjectable == null) {
|
||||
final LeagueSeasonDAO leagueSeasonDao = new LeagueSeasonDAO(_dbAccess);
|
||||
_leagueSeasonDAOInjectable = new Injectable<LeagueSeasonDAO>() {
|
||||
@Override
|
||||
public LeagueSeasonDAO getValue() {
|
||||
return leagueSeasonDao;
|
||||
}
|
||||
};
|
||||
}
|
||||
return _leagueSeasonDAOInjectable;
|
||||
}
|
||||
|
||||
private synchronized Injectable<LeagueDAO> getLeagueDaoSafely() {
|
||||
if (_leagueDaoInjectable == null) {
|
||||
final LeagueDAO leagueDao = new LeagueDAO(_dbAccess, _library);
|
||||
@@ -72,7 +104,6 @@ public class DaoProvider implements InjectableProvider<Context, Type> {
|
||||
return _leagueDaoInjectable;
|
||||
}
|
||||
|
||||
|
||||
private synchronized Injectable<GameHistoryDAO> getGameHistoryDaoSafely() {
|
||||
if (_gameHistoryDAOInjectable == null)
|
||||
_gameHistoryDAOInjectable = new GameHistoryDaoInjectable(new GameHistoryDAO(_dbAccess));
|
||||
|
||||
@@ -2,11 +2,7 @@ package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.common.Side;
|
||||
import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.DeckInvalidException;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.LotroFormat;
|
||||
import com.gempukku.lotro.game.LotroServer;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.hall.HallServer;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
@@ -165,7 +161,7 @@ public class DeckResource extends AbstractResource {
|
||||
String formatName = supportedFormats.getValue();
|
||||
LotroFormat format = _hallServer.getSupportedFormat(supportedFormats.getKey());
|
||||
try {
|
||||
format.validateDeck(deck);
|
||||
format.validateDeck(resourceOwner, deck);
|
||||
sb.append("<b>" + formatName + "</b>: <font color='green'>valid</font><br/>");
|
||||
} catch (DeckInvalidException exp) {
|
||||
sb.append("<b>" + formatName + "</b>: <font color='red'>" + exp.getMessage() + "</font><br/>");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.LotroGameMediator;
|
||||
import com.gempukku.lotro.game.LotroServer;
|
||||
import com.gempukku.lotro.game.ParticipantCommunicationVisitor;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.game.state.EventSerializer;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.logic.modifiers.LoggingThreadLocal;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.hall.HallException;
|
||||
import com.gempukku.lotro.hall.HallInfoVisitor;
|
||||
import com.gempukku.lotro.hall.HallServer;
|
||||
|
||||
@@ -27,8 +27,12 @@ public class ServerProvider implements InjectableProvider<Context, Type> {
|
||||
@Context
|
||||
private LeagueDAO _leagueDao;
|
||||
@Context
|
||||
private LeagueSeasonDAO _leagueSeasonDao;
|
||||
@Context
|
||||
private LeagueMatchDAO _leagueMatchDao;
|
||||
@Context
|
||||
private LeaguePointsDAO _leaguePointsDao;
|
||||
@Context
|
||||
private CollectionDAO _collectionDao;
|
||||
@Context
|
||||
private GameHistoryDAO _gameHistoryDao;
|
||||
@@ -50,7 +54,7 @@ public class ServerProvider implements InjectableProvider<Context, Type> {
|
||||
|
||||
private synchronized Injectable<LeagueService> getLeagueServiceInjectable() {
|
||||
if (_leagueServerInjectable == null) {
|
||||
final LeagueService leagueService = new LeagueService(_leagueDao, _leagueMatchDao, _collectionDao, _library);
|
||||
final LeagueService leagueService = new LeagueService(_leagueDao, _leagueSeasonDao, _leaguePointsDao, _leagueMatchDao, _collectionDao, _library);
|
||||
_leagueServerInjectable = new Injectable<LeagueService>() {
|
||||
@Override
|
||||
public LeagueService getValue() {
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.gempukku.lotro.chat.ChatServer;
|
||||
import com.gempukku.lotro.common.ApplicationRoot;
|
||||
import com.gempukku.lotro.db.GameHistoryDAO;
|
||||
import com.gempukku.lotro.db.vo.GameHistoryEntry;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.LotroServer;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.hall.HallServer;
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
Reference in New Issue
Block a user