- "Relentless Warg" should no longer cause the game to freeze.
This commit is contained in:
@@ -43,7 +43,7 @@ public class Card17_089 extends AbstractAttachable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Modifier> getAlwaysOnModifiers(LotroGame game, PhysicalCard self) {
|
||||
public List<? extends Modifier> getAlwaysOnModifiers(LotroGame game, final PhysicalCard self) {
|
||||
List<Modifier> modifiers = new LinkedList<Modifier>();
|
||||
modifiers.add(
|
||||
new StrengthModifier(self, Filters.hasAttached(self), 2));
|
||||
@@ -52,9 +52,21 @@ public class Card17_089 extends AbstractAttachable {
|
||||
modifiers.add(
|
||||
new KeywordModifier(self, Filters.hasAttached(self), Keyword.FIERCE));
|
||||
modifiers.add(
|
||||
new StrengthModifier(self, Filters.and(Filters.hasAttached(self), Filters.inSkirmishAgainst(CardType.COMPANION, (Race) self.getWhileInZoneData())), 3));
|
||||
new StrengthModifier(self, Filters.and(Filters.hasAttached(self), Filters.inSkirmishAgainst(CardType.COMPANION,
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return self.getWhileInZoneData() != null && physicalCard.getBlueprint().getRace() == self.getWhileInZoneData();
|
||||
}
|
||||
})), 3));
|
||||
modifiers.add(
|
||||
new KeywordModifier(self, Filters.and(Filters.hasAttached(self), Filters.inSkirmishAgainst(CardType.COMPANION, (Race) self.getWhileInZoneData())), Keyword.DAMAGE, 1));
|
||||
new KeywordModifier(self, Filters.and(Filters.hasAttached(self), Filters.inSkirmishAgainst(CardType.COMPANION,
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return self.getWhileInZoneData() != null && physicalCard.getBlueprint().getRace() == self.getWhileInZoneData();
|
||||
}
|
||||
})), Keyword.DAMAGE, 1));
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,5 +42,11 @@
|
||||
<version>4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -49,7 +49,7 @@ public class LeagueDAO {
|
||||
public Set<League> loadActiveLeagues(int currentTime) throws SQLException, IOException {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select id, name, type, start, end from league where start<=? and end>=? order by start desc");
|
||||
PreparedStatement statement = conn.prepareStatement("select id, name, type, class, parameters, start, end, status from league where start<=? and end>=? order by start desc");
|
||||
try {
|
||||
statement.setInt(1, currentTime);
|
||||
statement.setInt(2, currentTime);
|
||||
@@ -60,9 +60,12 @@ public class LeagueDAO {
|
||||
int id = rs.getInt(1);
|
||||
String name = rs.getString(2);
|
||||
String type = rs.getString(3);
|
||||
int start = rs.getInt(4);
|
||||
int end = rs.getInt(5);
|
||||
activeLeagues.add(new League(id, type, name, start, end));
|
||||
String clazz = rs.getString(4);
|
||||
String parameters = rs.getString(5);
|
||||
int start = rs.getInt(6);
|
||||
int end = rs.getInt(7);
|
||||
int status = rs.getInt(8);
|
||||
activeLeagues.add(new League(id, name, type, clazz, parameters, start, end, status));
|
||||
}
|
||||
return activeLeagues;
|
||||
} finally {
|
||||
@@ -75,4 +78,26 @@ public class LeagueDAO {
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatus(League league, int newStatus) {
|
||||
try {
|
||||
Connection connection = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
String sql = "update league set status=? where id=?";
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
try {
|
||||
statement.setInt(1, newStatus);
|
||||
statement.setInt(2, league.getId());
|
||||
statement.execute();
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException("Unable to update league status", exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +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.LeagueSerie;
|
||||
import com.gempukku.lotro.league.LeagueSerieData;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -48,14 +48,14 @@ public class LeagueMatchDAO {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<LeagueMatch> getLeagueSerieMatches(League league, LeagueSerie leagueSerie) {
|
||||
public Collection<LeagueMatch> getLeagueSerieMatches(League league, LeagueSerieData leagueSerie) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select winner, loser from league_match where league_type=? and season_type=?");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, leagueSerie.getType());
|
||||
statement.setString(2, leagueSerie.getName());
|
||||
ResultSet rs = statement.executeQuery();
|
||||
try {
|
||||
Set<LeagueMatch> result = new HashSet<LeagueMatch>();
|
||||
@@ -80,14 +80,14 @@ public class LeagueMatchDAO {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<LeagueMatch> getPlayerMatchesPlayedOn(League league, LeagueSerie leagueSeason, String player) {
|
||||
public Collection<LeagueMatch> getPlayerMatchesPlayedOn(League league, LeagueSerieData leagueSeason, String player) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select winner, loser from league_match where league_type=? and season_type=? and (winner=? or loser=?)");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, leagueSeason.getType());
|
||||
statement.setString(2, leagueSeason.getName());
|
||||
statement.setString(3, player);
|
||||
statement.setString(4, player);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
@@ -114,14 +114,14 @@ public class LeagueMatchDAO {
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayedMatch(League league, LeagueSerie leagueSeason, String winner, String loser) {
|
||||
public void addPlayedMatch(League league, LeagueSerieData leagueSeason, String winner, String loser) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("insert into league_match (league_type, season_type, winner, loser) values (?, ?, ?, ?)");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, leagueSeason.getType());
|
||||
statement.setString(2, leagueSeason.getName());
|
||||
statement.setString(3, winner);
|
||||
statement.setString(4, loser);
|
||||
statement.execute();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
import com.gempukku.lotro.league.LeagueSerieData;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -17,14 +17,14 @@ public class LeaguePointsDAO {
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public synchronized void addPoints(League league, LeagueSerie serie, String playerName, int points) {
|
||||
public synchronized void addPoints(League league, LeagueSerieData serie, 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, serie.getType());
|
||||
statement.setString(2, serie.getName());
|
||||
statement.setString(3, playerName);
|
||||
statement.setInt(4, points);
|
||||
statement.execute();
|
||||
@@ -74,14 +74,14 @@ public class LeaguePointsDAO {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Points> getLeagueSeriePoints(League league, LeagueSerie serie) {
|
||||
public Map<String, Points> getLeagueSeriePoints(League league, LeagueSerieData serie) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select player_name, sum(points), count(*) from league_points where league_type=? and season_type=? group by player_name order by 2 desc, 3 asc");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
statement.setString(2, serie.getType());
|
||||
statement.setString(2, serie.getName());
|
||||
ResultSet rs = statement.executeQuery();
|
||||
try {
|
||||
return createPoints(rs);
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.gempukku.lotro.db;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LeagueSerieDAO {
|
||||
private DbAccess _dbAccess;
|
||||
|
||||
public LeagueSerieDAO(DbAccess dbAccess) {
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public void addSerie(String leagueType, String seasonType, String format, String collection, int start, int end, int maxMatches) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("insert into league_season (league_type, season_type, format, collection, status, start, end, max_matches) values (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
try {
|
||||
statement.setString(1, leagueType);
|
||||
statement.setString(2, seasonType);
|
||||
statement.setString(3, format);
|
||||
statement.setString(4, collection);
|
||||
statement.setInt(5, 0);
|
||||
statement.setInt(6, start);
|
||||
statement.setInt(7, end);
|
||||
statement.setInt(8, maxMatches);
|
||||
statement.execute();
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCollectionGiven(LeagueSerie leagueSerie) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("update league_season set status = 1 where league_type = ? and season_type = ?");
|
||||
try {
|
||||
statement.setString(1, leagueSerie.getLeagueType());
|
||||
statement.setString(2, leagueSerie.getType());
|
||||
statement.execute();
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
public List<LeagueSerie> getSeriesForLeague(League league) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select league_type, season_type, format, collection, status, max_matches, start, end from league_season where league_type=? order by start asc");
|
||||
try {
|
||||
statement.setString(1, league.getType());
|
||||
ResultSet rs = statement.executeQuery();
|
||||
try {
|
||||
List<LeagueSerie> seasons = new LinkedList<LeagueSerie>();
|
||||
while (rs.next()) {
|
||||
String leagueType = rs.getString(1);
|
||||
String type = rs.getString(2);
|
||||
String format = rs.getString(3);
|
||||
Map<String, Integer> collection = createCollection(rs.getString(4));
|
||||
int status = rs.getInt(5);
|
||||
int maxMatches = rs.getInt(6);
|
||||
int start = rs.getInt(7);
|
||||
int end = rs.getInt(8);
|
||||
seasons.add(new LeagueSerie(leagueType, type, format, collection, status, maxMatches, start, end));
|
||||
}
|
||||
return seasons;
|
||||
} finally {
|
||||
rs.close();
|
||||
}
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Integer> createCollection(String collection) {
|
||||
Map<String, Integer> result = new HashMap<String, Integer>();
|
||||
if (collection != null) {
|
||||
final String[] items = collection.split("\n");
|
||||
for (String item : items) {
|
||||
final String[] xes = item.trim().split("x", 2);
|
||||
result.put(xes[1], Integer.parseInt(xes[0]));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public LeagueSerie getSerieForLeague(League league, int inTime) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("select league_type, season_type, format, collection, status, max_matches, start, end 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 leagueType = rs.getString(1);
|
||||
String type = rs.getString(2);
|
||||
String format = rs.getString(3);
|
||||
Map<String, Integer> collection = createCollection(rs.getString(4));
|
||||
int status = rs.getInt(5);
|
||||
int maxMatches = rs.getInt(6);
|
||||
int start = rs.getInt(7);
|
||||
int end = rs.getInt(8);
|
||||
return new LeagueSerie(leagueType, type, format, collection, status, maxMatches, start, end);
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
rs.close();
|
||||
}
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gempukku.lotro.db.vo;
|
||||
|
||||
public class CollectionType {
|
||||
private String _code;
|
||||
private String _fullName;
|
||||
public final class CollectionType {
|
||||
private final String _code;
|
||||
private final String _fullName;
|
||||
|
||||
public CollectionType(String code, String fullName) {
|
||||
_code = code;
|
||||
@@ -16,4 +16,24 @@ public class CollectionType {
|
||||
public String getFullName() {
|
||||
return _fullName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CollectionType that = (CollectionType) o;
|
||||
|
||||
if (_code != null ? !_code.equals(that._code) : that._code != null) return false;
|
||||
if (_fullName != null ? !_fullName.equals(that._fullName) : that._fullName != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = _code != null ? _code.hashCode() : 0;
|
||||
result = 31 * result + (_fullName != null ? _fullName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,62 @@
|
||||
package com.gempukku.lotro.db.vo;
|
||||
|
||||
import com.gempukku.lotro.league.LeagueData;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class League {
|
||||
private int _id;
|
||||
private String _type;
|
||||
private String _name;
|
||||
private String _type;
|
||||
private String _clazz;
|
||||
private String _parameters;
|
||||
private int _start;
|
||||
private int _end;
|
||||
private int _status;
|
||||
|
||||
public League(int id, String type, String name, int start, int end) {
|
||||
public League(int id, String name, String type, String clazz, String parameters, int start, int end, int status) {
|
||||
_id = id;
|
||||
_type = type;
|
||||
_name = name;
|
||||
_type = type;
|
||||
_clazz = clazz;
|
||||
_parameters = parameters;
|
||||
_start = start;
|
||||
_end = end;
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
public CollectionType getCollectionType() {
|
||||
return new CollectionType(_type, _name);
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return _name;
|
||||
public LeagueData getLeagueData() {
|
||||
try {
|
||||
Class<?> aClass = Class.forName(_clazz);
|
||||
Constructor<?> constructor = aClass.getConstructor(String.class);
|
||||
return (LeagueData) constructor.newInstance(_parameters);
|
||||
} catch (Exception exp) {
|
||||
throw new RuntimeException("Unable to create LeagueData", exp);
|
||||
}
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return _start;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return _end;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return _start;
|
||||
public int getStatus() {
|
||||
return _status;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.gempukku.lotro.db.vo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class LeagueSerie {
|
||||
private String _leagueType;
|
||||
private String _type;
|
||||
private String _format;
|
||||
private Map<String, Integer> _serieCollection;
|
||||
private int _status;
|
||||
private int _maxMatches;
|
||||
private int _start;
|
||||
private int _end;
|
||||
|
||||
public LeagueSerie(String leagueType, String type, String format, Map<String, Integer> serieCollection, int status, int maxMatches, int start, int end) {
|
||||
_leagueType = leagueType;
|
||||
_type = type;
|
||||
_format = format;
|
||||
_serieCollection = serieCollection;
|
||||
_status = status;
|
||||
_maxMatches = maxMatches;
|
||||
_start = start;
|
||||
_end = end;
|
||||
}
|
||||
|
||||
public int getMaxMatches() {
|
||||
return _maxMatches;
|
||||
}
|
||||
|
||||
public String getLeagueType() {
|
||||
return _leagueType;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return _format;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return _end;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return _start;
|
||||
}
|
||||
|
||||
public boolean wasCollectionGiven() {
|
||||
return _status == 1;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getSerieCollection() {
|
||||
return Collections.unmodifiableMap(_serieCollection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
LeagueSerie that = (LeagueSerie) o;
|
||||
|
||||
if (_leagueType != null ? !_leagueType.equals(that._leagueType) : that._leagueType != null) return false;
|
||||
if (_type != null ? !_type.equals(that._type) : that._type != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = _leagueType != null ? _leagueType.hashCode() : 0;
|
||||
result = 31 * result + (_type != null ? _type.hashCode() : 0);
|
||||
result = 31 * result + (_format != null ? _format.hashCode() : 0);
|
||||
result = 31 * result + _maxMatches;
|
||||
result = 31 * result + _start;
|
||||
result = 31 * result + _end;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package com.gempukku.lotro.hall;
|
||||
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
import com.gempukku.lotro.game.LotroFormat;
|
||||
import com.gempukku.lotro.game.LotroGameParticipant;
|
||||
import com.gempukku.lotro.league.LeagueSerieData;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -12,12 +12,12 @@ public class AwaitingTable {
|
||||
private CollectionType _collectionType;
|
||||
private LotroFormat _lotroFormat;
|
||||
private League _league;
|
||||
private LeagueSerie _leagueSerie;
|
||||
private LeagueSerieData _leagueSerie;
|
||||
private Map<String, LotroGameParticipant> _players = new HashMap<String, LotroGameParticipant>();
|
||||
|
||||
private int _capacity = 2;
|
||||
|
||||
public AwaitingTable(LotroFormat lotroFormat, CollectionType collectionType, League league, LeagueSerie leagueSerie) {
|
||||
public AwaitingTable(LotroFormat lotroFormat, CollectionType collectionType, League league, LeagueSerieData leagueSerie) {
|
||||
_lotroFormat = lotroFormat;
|
||||
_collectionType = collectionType;
|
||||
_league = league;
|
||||
@@ -58,7 +58,7 @@ public class AwaitingTable {
|
||||
return _league;
|
||||
}
|
||||
|
||||
public LeagueSerie getLeagueSerie() {
|
||||
public LeagueSerieData getLeagueSerie() {
|
||||
return _leagueSerie;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import com.gempukku.lotro.chat.ChatServer;
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.game.formats.*;
|
||||
import com.gempukku.lotro.league.LeagueSerieData;
|
||||
import com.gempukku.lotro.league.LeagueService;
|
||||
import com.gempukku.lotro.logic.timing.GameResultListener;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
@@ -106,7 +106,7 @@ public class HallServer extends AbstractServer {
|
||||
_hallDataAccessLock.writeLock().lock();
|
||||
try {
|
||||
League league = null;
|
||||
LeagueSerie leagueSerie = null;
|
||||
LeagueSerieData leagueSerie = null;
|
||||
CollectionType collectionType = _allCardsCollectionType;
|
||||
LotroFormat format = _supportedFormats.get(type);
|
||||
|
||||
@@ -121,7 +121,7 @@ public class HallServer extends AbstractServer {
|
||||
if (!_leagueService.canPlayRankedGame(league, leagueSerie, player.getName()))
|
||||
throw new HallException("You have already played max games in league");
|
||||
format = _supportedFormats.get(leagueSerie.getFormat());
|
||||
collectionType = league.getCollectionType();
|
||||
collectionType = leagueSerie.getCollectionType();
|
||||
}
|
||||
}
|
||||
// It's not a normal format and also not a league one
|
||||
@@ -293,7 +293,7 @@ public class HallServer extends AbstractServer {
|
||||
String tournamentName = "Casual";
|
||||
final League league = table.getLeague();
|
||||
if (league != null)
|
||||
tournamentName = league.getName() + " - " + table.getLeagueSerie().getType();
|
||||
tournamentName = league.getName() + " - " + table.getLeagueSerie().getName();
|
||||
return tournamentName;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ public class HallServer extends AbstractServer {
|
||||
Set<LotroGameParticipant> players = awaitingTable.getPlayers();
|
||||
LotroGameParticipant[] participants = players.toArray(new LotroGameParticipant[players.size()]);
|
||||
final League league = awaitingTable.getLeague();
|
||||
final LeagueSerie leagueSerie = awaitingTable.getLeagueSerie();
|
||||
final LeagueSerieData leagueSerie = awaitingTable.getLeagueSerie();
|
||||
String gameId = _lotroServer.createNewGame(awaitingTable.getLotroFormat(), participants, league != null);
|
||||
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(gameId);
|
||||
if (league != null) {
|
||||
@@ -321,7 +321,7 @@ public class HallServer extends AbstractServer {
|
||||
private void joinTableInternal(String tableId, String playerId, AwaitingTable awaitingTable, String deckName, LotroDeck lotroDeck) throws HallException {
|
||||
League league = awaitingTable.getLeague();
|
||||
if (league != null) {
|
||||
LeagueSerie leagueSerie = awaitingTable.getLeagueSerie();
|
||||
LeagueSerieData leagueSerie = awaitingTable.getLeagueSerie();
|
||||
if (!_leagueService.canPlayRankedGame(league, leagueSerie, playerId))
|
||||
throw new HallException("You have already played max games in league");
|
||||
if (awaitingTable.getPlayerNames().size() != 0 && !_leagueService.canPlayRankedGame(league, leagueSerie, awaitingTable.getPlayerNames().iterator().next(), playerId))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LeagueData {
|
||||
public List<LeagueSerieData> getSeries();
|
||||
|
||||
public CardCollection joinLeague(CollectionsManager collecionsManager, Player player, int currentTime);
|
||||
|
||||
public int process(CollectionsManager collectionsManager, int oldStatus, int currentTime);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public interface LeagueSerieData {
|
||||
public int getStart();
|
||||
|
||||
public int getEnd();
|
||||
|
||||
public int getMaxMatches();
|
||||
|
||||
public boolean isLimited();
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getFormat();
|
||||
|
||||
public CollectionType getCollectionType();
|
||||
|
||||
public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie);
|
||||
|
||||
public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie);
|
||||
}
|
||||
@@ -4,14 +4,10 @@ import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.db.LeagueDAO;
|
||||
import com.gempukku.lotro.db.LeagueMatchDAO;
|
||||
import com.gempukku.lotro.db.LeaguePointsDAO;
|
||||
import com.gempukku.lotro.db.LeagueSerieDAO;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueMatch;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
import com.gempukku.lotro.game.MutableCardCollection;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -27,26 +23,22 @@ public class LeagueService {
|
||||
new DescComparator<LeagueStanding>(new OpponentsWinComparator()));
|
||||
|
||||
private LeagueDAO _leagueDao;
|
||||
private LeagueSerieDAO _leagueSeasonDao;
|
||||
private LeaguePointsDAO _leaguePointsDao;
|
||||
private LeagueMatchDAO _leagueMatchDao;
|
||||
private CollectionsManager _collectionsManager;
|
||||
private LeaguePrizes _leaguePrizes;
|
||||
|
||||
private Map<League, List<LeagueStanding>> _leagueStandings = new ConcurrentHashMap<League, List<LeagueStanding>>();
|
||||
private Map<LeagueSerie, List<LeagueStanding>> _leagueSerieStandings = new ConcurrentHashMap<LeagueSerie, List<LeagueStanding>>();
|
||||
private Map<LeagueSerieData, List<LeagueStanding>> _leagueSerieStandings = new ConcurrentHashMap<LeagueSerieData, List<LeagueStanding>>();
|
||||
|
||||
private int _activeLeaguesLoadedDate;
|
||||
private Set<League> _activeLeagues;
|
||||
|
||||
public LeagueService(LeagueDAO leagueDao, LeagueSerieDAO leagueSeasonDao, LeaguePointsDAO leaguePointsDao, LeagueMatchDAO leagueMatchDao,
|
||||
public LeagueService(LeagueDAO leagueDao, LeaguePointsDAO leaguePointsDao, LeagueMatchDAO leagueMatchDao,
|
||||
CollectionsManager collectionsManager) {
|
||||
_leagueDao = leagueDao;
|
||||
_leagueSeasonDao = leagueSeasonDao;
|
||||
_leaguePointsDao = leaguePointsDao;
|
||||
_leagueMatchDao = leagueMatchDao;
|
||||
_collectionsManager = collectionsManager;
|
||||
_leaguePrizes = new LeaguePrizes();
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
@@ -86,36 +78,24 @@ public class LeagueService {
|
||||
|
||||
private void processLoadedLeagues(int currentDate) {
|
||||
for (League activeLeague : _activeLeagues) {
|
||||
for (LeagueSerie leagueSerie : _leagueSeasonDao.getSeriesForLeague(activeLeague)) {
|
||||
if (leagueSerie.getStart() <= currentDate && !leagueSerie.wasCollectionGiven()) {
|
||||
for (Map.Entry<Player, CardCollection> playerLeagueCollection : _collectionsManager.getPlayersCollection(activeLeague.getType()).entrySet()) {
|
||||
_collectionsManager.addItemsToPlayerCollection(playerLeagueCollection.getKey(), activeLeague.getCollectionType(), leagueSerie.getSerieCollection());
|
||||
}
|
||||
_leagueSeasonDao.setCollectionGiven(leagueSerie);
|
||||
}
|
||||
}
|
||||
int oldStatus = activeLeague.getStatus();
|
||||
int newStatus = activeLeague.getLeagueData().process(_collectionsManager, oldStatus, currentDate);
|
||||
if (newStatus != oldStatus)
|
||||
_leagueDao.setStatus(activeLeague, newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void ensurePlayerIsInLeague(Player player, League league) {
|
||||
if (_collectionsManager.getPlayerCollection(player, league.getType()) == null)
|
||||
playerJoinsLeague(player, league);
|
||||
}
|
||||
|
||||
private void playerJoinsLeague(Player player, League league) {
|
||||
for (League activeLeague : getActiveLeagues()) {
|
||||
if (activeLeague.getType().equals(league.getType())) {
|
||||
MutableCardCollection startingCollection = new DefaultCardCollection();
|
||||
final List<LeagueSerie> seriesForLeague = _leagueSeasonDao.getSeriesForLeague(league);
|
||||
for (LeagueSerie leagueSerie : seriesForLeague) {
|
||||
if (leagueSerie.wasCollectionGiven()) {
|
||||
for (Map.Entry<String, Integer> serieCollectionItem : leagueSerie.getSerieCollection().entrySet())
|
||||
startingCollection.addItem(serieCollectionItem.getKey(), serieCollectionItem.getValue());
|
||||
}
|
||||
public synchronized CardCollection ensurePlayerHasCollection(Player player, String collectionType) {
|
||||
for (League league : getActiveLeagues()) {
|
||||
LeagueData leagueData = league.getLeagueData();
|
||||
for (LeagueSerieData leagueSerieData : leagueData.getSeries()) {
|
||||
CollectionType serieCollectionType = leagueSerieData.getCollectionType();
|
||||
if (serieCollectionType != null && serieCollectionType.getCode().equals(collectionType)) {
|
||||
return leagueData.joinLeague(_collectionsManager, player, getCurrentDate());
|
||||
}
|
||||
_collectionsManager.addPlayerCollection(player, league.getCollectionType(), startingCollection);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public League getLeagueByType(String type) {
|
||||
@@ -126,13 +106,29 @@ public class LeagueService {
|
||||
return null;
|
||||
}
|
||||
|
||||
public LeagueSerie getCurrentLeagueSerie(League league) {
|
||||
final int startDay = getCurrentDate();
|
||||
|
||||
return _leagueSeasonDao.getSerieForLeague(league, startDay);
|
||||
public CollectionType getCollectionTypeByCode(String collectionTypeCode) {
|
||||
for (League league : getActiveLeagues()) {
|
||||
for (LeagueSerieData leagueSerieData : league.getLeagueData().getSeries()) {
|
||||
CollectionType collectionType = leagueSerieData.getCollectionType();
|
||||
if (collectionType != null && collectionType.getCode().equals(collectionTypeCode))
|
||||
return collectionType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void reportLeagueGameResult(League league, LeagueSerie serie, String winner, String loser) {
|
||||
public LeagueSerieData getCurrentLeagueSerie(League league) {
|
||||
final int currentDate = getCurrentDate();
|
||||
|
||||
for (LeagueSerieData leagueSerieData : league.getLeagueData().getSeries()) {
|
||||
if (currentDate >= leagueSerieData.getStart() && currentDate <= leagueSerieData.getEnd())
|
||||
return leagueSerieData;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void reportLeagueGameResult(League league, LeagueSerieData serie, String winner, String loser) {
|
||||
_leagueMatchDao.addPlayedMatch(league, serie, winner, loser);
|
||||
_leaguePointsDao.addPoints(league, serie, winner, 2);
|
||||
_leaguePointsDao.addPoints(league, serie, loser, 1);
|
||||
@@ -143,7 +139,7 @@ public class LeagueService {
|
||||
awardPrizesToPlayer(league, serie, loser, false);
|
||||
}
|
||||
|
||||
private void awardPrizesToPlayer(League league, LeagueSerie serie, String player, boolean winner) {
|
||||
private void awardPrizesToPlayer(League league, LeagueSerieData serie, String player, boolean winner) {
|
||||
int count = 0;
|
||||
Collection<LeagueMatch> playerMatchesPlayedOn = _leagueMatchDao.getPlayerMatchesPlayedOn(league, serie, player);
|
||||
for (LeagueMatch leagueMatch : playerMatchesPlayedOn) {
|
||||
@@ -153,9 +149,9 @@ public class LeagueService {
|
||||
|
||||
CardCollection prize;
|
||||
if (winner)
|
||||
prize = _leaguePrizes.getPrizeForLeagueMatchWinner(count, playerMatchesPlayedOn.size(), league, serie);
|
||||
prize = serie.getPrizeForLeagueMatchWinner(count, playerMatchesPlayedOn.size());
|
||||
else
|
||||
prize = _leaguePrizes.getPrizeForLeagueMatchLoser(count, playerMatchesPlayedOn.size(), league, serie);
|
||||
prize = serie.getPrizeForLeagueMatchLoser(count, playerMatchesPlayedOn.size());
|
||||
if (prize != null)
|
||||
_collectionsManager.addItemsToPlayerCollection(player, new CollectionType("permanent", "My cards"), prize.getAll());
|
||||
}
|
||||
@@ -171,7 +167,7 @@ public class LeagueService {
|
||||
return leagueStandings;
|
||||
}
|
||||
|
||||
public List<LeagueStanding> getLeagueSerieStandings(League league, LeagueSerie leagueSerie) {
|
||||
public List<LeagueStanding> getLeagueSerieStandings(League league, LeagueSerieData leagueSerie) {
|
||||
List<LeagueStanding> serieStandings = _leagueSerieStandings.get(leagueSerie);
|
||||
if (serieStandings == null) {
|
||||
synchronized (this) {
|
||||
@@ -182,7 +178,7 @@ public class LeagueService {
|
||||
return serieStandings;
|
||||
}
|
||||
|
||||
private List<LeagueStanding> createLeagueSerieStandings(League league, LeagueSerie leagueSerie) {
|
||||
private List<LeagueStanding> createLeagueSerieStandings(League league, LeagueSerieData leagueSerie) {
|
||||
final Map<String, LeaguePointsDAO.Points> points = _leaguePointsDao.getLeagueSeriePoints(league, leagueSerie);
|
||||
final Collection<LeagueMatch> matches = _leagueMatchDao.getLeagueSerieMatches(league, leagueSerie);
|
||||
|
||||
@@ -242,7 +238,7 @@ public class LeagueService {
|
||||
opponents.add(opponent);
|
||||
}
|
||||
|
||||
public boolean canPlayRankedGame(League league, LeagueSerie season, String player) {
|
||||
public boolean canPlayRankedGame(League league, LeagueSerieData season, String player) {
|
||||
int maxMatches = season.getMaxMatches();
|
||||
Collection<LeagueMatch> playedInSeason = _leagueMatchDao.getPlayerMatchesPlayedOn(league, season, player);
|
||||
if (playedInSeason.size() >= maxMatches)
|
||||
@@ -250,7 +246,7 @@ public class LeagueService {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlayRankedGame(League league, LeagueSerie season, String playerOne, String playerTwo) {
|
||||
public boolean canPlayRankedGame(League league, LeagueSerieData season, String playerOne, String playerTwo) {
|
||||
Collection<LeagueMatch> playedInSeason = _leagueMatchDao.getPlayerMatchesPlayedOn(league, season, playerOne);
|
||||
for (LeagueMatch leagueMatch : playedInSeason) {
|
||||
if (playerTwo.equals(leagueMatch.getWinner()) || playerTwo.equals(leagueMatch.getLoser()))
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
import com.gempukku.lotro.game.MutableCardCollection;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class SealedLeagueData implements LeagueData {
|
||||
private String _format;
|
||||
private List<LeagueSerieData> _series;
|
||||
private CollectionType _collectionType;
|
||||
private SealedLeaguePrizes _leaguePrizes;
|
||||
private SealedLeagueProduct _leagueProduct;
|
||||
|
||||
public SealedLeagueData(String parameters) {
|
||||
String[] params = parameters.split(",");
|
||||
_format = params[0];
|
||||
int start = Integer.parseInt(params[1]);
|
||||
_collectionType = new CollectionType(params[2], params[3]);
|
||||
|
||||
int serieDuration = 7;
|
||||
int maxMatches = 10;
|
||||
|
||||
_leaguePrizes = new SealedLeaguePrizes();
|
||||
_leagueProduct = new SealedLeagueProduct();
|
||||
|
||||
_series = new LinkedList<LeagueSerieData>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
_series.add(
|
||||
new SealedLeagueSerieData(_leaguePrizes, "Week " + (i + 1),
|
||||
getDate(start, i * serieDuration), getDate(start, (i + 1) * serieDuration - 1), maxMatches, _format, _collectionType));
|
||||
}
|
||||
}
|
||||
|
||||
private int getDate(int start, int dayOffset) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
Date date = format.parse(String.valueOf(start));
|
||||
date.setDate(date.getDate() + dayOffset);
|
||||
return Integer.parseInt(format.format(date));
|
||||
} catch (ParseException exp) {
|
||||
throw new RuntimeException("Can't parse date", exp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LeagueSerieData> getSeries() {
|
||||
return Collections.unmodifiableList(_series);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection joinLeague(CollectionsManager collectionManager, Player player, int currentTime) {
|
||||
MutableCardCollection startingCollection = new DefaultCardCollection();
|
||||
for (int i = 0; i < _series.size(); i++) {
|
||||
LeagueSerieData serie = _series.get(i);
|
||||
if (currentTime >= serie.getStart()) {
|
||||
CardCollection leagueProduct = _leagueProduct.getCollectionForSerie(_format, i);
|
||||
|
||||
for (Map.Entry<String, Integer> serieCollectionItem : leagueProduct.getAll().entrySet())
|
||||
startingCollection.addItem(serieCollectionItem.getKey(), serieCollectionItem.getValue());
|
||||
}
|
||||
}
|
||||
collectionManager.addPlayerCollection(player, _collectionType, startingCollection);
|
||||
return startingCollection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int process(CollectionsManager collectionsManager, int oldStatus, int currentTime) {
|
||||
int status = oldStatus;
|
||||
|
||||
for (int i = status; i < _series.size(); i++) {
|
||||
LeagueSerieData serie = _series.get(i);
|
||||
if (currentTime >= serie.getStart()) {
|
||||
CardCollection leagueProduct = _leagueProduct.getCollectionForSerie(_format, i);
|
||||
Map<Player, CardCollection> map = collectionsManager.getPlayersCollection(_collectionType.getCode());
|
||||
for (Map.Entry<Player, CardCollection> playerCardCollectionEntry : map.entrySet()) {
|
||||
collectionsManager.addItemsToPlayerCollection(playerCardCollectionEntry.getKey(), _collectionType, leagueProduct.getAll());
|
||||
}
|
||||
status = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == _series.size()) {
|
||||
LeagueSerieData lastSerie = _series.get(_series.size() - 1);
|
||||
if (currentTime >= getDate(lastSerie.getEnd(), 1)) {
|
||||
// Award prizes and move collections
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,17 @@ package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.cards.packs.RarityReader;
|
||||
import com.gempukku.lotro.cards.packs.SetRarity;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LeaguePrizes {
|
||||
public class SealedLeaguePrizes {
|
||||
private Map<String, List<String>> _blockPromos = new HashMap<String, List<String>>();
|
||||
private Map<String, List<String>> _blockCommons = new HashMap<String, List<String>>();
|
||||
private Map<String, List<String>> _blockUncommons = new HashMap<String, List<String>>();
|
||||
|
||||
public LeaguePrizes() {
|
||||
public SealedLeaguePrizes() {
|
||||
List<String> fotrPromos = new ArrayList<String>();
|
||||
fotrPromos.add("0_1");
|
||||
fotrPromos.add("0_2");
|
||||
@@ -93,14 +91,14 @@ public class LeaguePrizes {
|
||||
_blockUncommons.put("ttt_block", tttUncommons);
|
||||
}
|
||||
|
||||
public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie, League league, LeagueSerie leagueSerie) {
|
||||
public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie, String format) {
|
||||
DefaultCardCollection winnerPrize = new DefaultCardCollection();
|
||||
if (winCountThisSerie == 1 || winCountThisSerie == 3 || winCountThisSerie == 5 || winCountThisSerie == 8 || winCountThisSerie == 10)
|
||||
winnerPrize.addItem("(S)Booster Choice", 1);
|
||||
else {
|
||||
List<String> blockCommons = _blockCommons.get(leagueSerie.getFormat());
|
||||
List<String> blockUncommons = _blockUncommons.get(leagueSerie.getFormat());
|
||||
List<String> blockPromos = _blockPromos.get(leagueSerie.getFormat());
|
||||
List<String> blockCommons = _blockCommons.get(format);
|
||||
List<String> blockUncommons = _blockUncommons.get(format);
|
||||
List<String> blockPromos = _blockPromos.get(format);
|
||||
if (winCountThisSerie == 2)
|
||||
winnerPrize.addItem(getRandom(blockCommons) + "*", 1);
|
||||
else if (winCountThisSerie == 4)
|
||||
@@ -117,7 +115,7 @@ public class LeaguePrizes {
|
||||
return winnerPrize;
|
||||
}
|
||||
|
||||
public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie, League league, LeagueSerie leagueSerie) {
|
||||
public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie, String format) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
import com.gempukku.lotro.game.MutableCardCollection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SealedLeagueProduct {
|
||||
private Map<String, List<CardCollection>> _collections = new HashMap<String, List<CardCollection>>();
|
||||
|
||||
public SealedLeagueProduct() {
|
||||
createFellowshipBlock();
|
||||
createTowersBlock();
|
||||
}
|
||||
|
||||
private void createFellowshipBlock() {
|
||||
List<CardCollection> fotrBlock = new ArrayList<CardCollection>();
|
||||
|
||||
MutableCardCollection firstWeek = new DefaultCardCollection();
|
||||
firstWeek.addItem("(S)FotR - Starter", 1);
|
||||
firstWeek.addItem("FotR - Booster", 6);
|
||||
firstWeek.addItem("1_231", 2);
|
||||
fotrBlock.add(firstWeek);
|
||||
|
||||
MutableCardCollection secondWeek = new DefaultCardCollection();
|
||||
secondWeek.addItem("(S)MoM - Starter", 1);
|
||||
secondWeek.addItem("MoM - Booster", 3);
|
||||
secondWeek.addItem("2_51", 1);
|
||||
fotrBlock.add(secondWeek);
|
||||
|
||||
MutableCardCollection thirdWeek = new DefaultCardCollection();
|
||||
thirdWeek.addItem("(S)RotEL - Starter", 1);
|
||||
thirdWeek.addItem("RotEL - Booster", 3);
|
||||
fotrBlock.add(thirdWeek);
|
||||
|
||||
MutableCardCollection fourthWeek = new DefaultCardCollection();
|
||||
fourthWeek.addItem("FotR - Booster", 2);
|
||||
fourthWeek.addItem("MoM - Booster", 2);
|
||||
fourthWeek.addItem("RotEL - Booster", 2);
|
||||
fotrBlock.add(fourthWeek);
|
||||
|
||||
_collections.put("fotr_block", fotrBlock);
|
||||
}
|
||||
|
||||
private void createTowersBlock() {
|
||||
List<CardCollection> tttBlock = new ArrayList<CardCollection>();
|
||||
|
||||
MutableCardCollection firstWeek = new DefaultCardCollection();
|
||||
firstWeek.addItem("(S)TTT - Starter", 1);
|
||||
firstWeek.addItem("TTT - Booster", 6);
|
||||
firstWeek.addItem("4_356", 1);
|
||||
firstWeek.addItem("4_249", 2);
|
||||
tttBlock.add(firstWeek);
|
||||
|
||||
MutableCardCollection secondWeek = new DefaultCardCollection();
|
||||
secondWeek.addItem("(S)BoHD - Starter", 1);
|
||||
secondWeek.addItem("BoHD - Booster", 3);
|
||||
tttBlock.add(secondWeek);
|
||||
|
||||
MutableCardCollection thirdWeek = new DefaultCardCollection();
|
||||
thirdWeek.addItem("(S)EoF - Starter", 1);
|
||||
thirdWeek.addItem("EoF - Booster", 3);
|
||||
tttBlock.add(thirdWeek);
|
||||
|
||||
MutableCardCollection fourthWeek = new DefaultCardCollection();
|
||||
fourthWeek.addItem("TTT - Booster", 2);
|
||||
fourthWeek.addItem("BoHD - Booster", 2);
|
||||
fourthWeek.addItem("EoF - Booster", 2);
|
||||
tttBlock.add(fourthWeek);
|
||||
|
||||
_collections.put("ttt_block", tttBlock);
|
||||
}
|
||||
|
||||
public CardCollection getCollectionForSerie(String format, int serieIndex) {
|
||||
return _collections.get(format).get(serieIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public class SealedLeagueSerieData implements LeagueSerieData {
|
||||
private SealedLeaguePrizes _leaguePrizes;
|
||||
private String _name;
|
||||
private int _start;
|
||||
private int _end;
|
||||
private int _maxMatches;
|
||||
private String _format;
|
||||
private CollectionType _collectionType;
|
||||
|
||||
public SealedLeagueSerieData(SealedLeaguePrizes leaguePrizes, String name, int start, int end, int maxMatches, String format, CollectionType collectionType) {
|
||||
_leaguePrizes = leaguePrizes;
|
||||
_name = name;
|
||||
_start = start;
|
||||
_end = end;
|
||||
_maxMatches = maxMatches;
|
||||
_format = format;
|
||||
_collectionType = collectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStart() {
|
||||
return _start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnd() {
|
||||
return _end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMatches() {
|
||||
return _maxMatches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLimited() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return _format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionType getCollectionType() {
|
||||
return _collectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie) {
|
||||
return _leaguePrizes.getPrizeForLeagueMatchWinner(winCountThisSerie, totalGamesPlayedThisSerie, _format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie) {
|
||||
return _leaguePrizes.getPrizeForLeagueMatchLoser(winCountThisSerie, totalGamesPlayedThisSerie, _format);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.verification.Times;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SealedLeagueDataTest {
|
||||
@Test
|
||||
public void testJoinLeagueFirstWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData("fotr_block,20120101,test,Test Collection");
|
||||
CollectionType collectionType = new CollectionType("test", "Test Collection");
|
||||
for (int i = 20120101; i < 20120108; i++) {
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
Player player = new Player(1, "Test", "A");
|
||||
data.joinLeague(collectionsManager, player, i);
|
||||
Mockito.verify(collectionsManager, new Times(1)).addPlayerCollection(Mockito.eq(player), Mockito.eq(collectionType), Mockito.argThat(
|
||||
new BaseMatcher<CardCollection>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Expected collection");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object o) {
|
||||
CardCollection cards = (CardCollection) o;
|
||||
Map<String, Integer> cardMap = cards.getAll();
|
||||
if (cardMap.size() != 3)
|
||||
return false;
|
||||
if (cardMap.get("(S)FotR - Starter") != 1)
|
||||
return false;
|
||||
if (cardMap.get("FotR - Booster") != 6)
|
||||
return false;
|
||||
if (cardMap.get("1_231") != 2)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
));
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinLeagueSecondWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData("fotr_block,20120101,test,Test Collection");
|
||||
CollectionType collectionType = new CollectionType("test", "Test Collection");
|
||||
for (int i = 20120108; i < 20120115; i++) {
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
Player player = new Player(1, "Test", "A");
|
||||
data.joinLeague(collectionsManager, player, i);
|
||||
Mockito.verify(collectionsManager, new Times(1)).addPlayerCollection(Mockito.eq(player), Mockito.eq(collectionType), Mockito.argThat(
|
||||
new BaseMatcher<CardCollection>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Expected collection");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object o) {
|
||||
CardCollection cards = (CardCollection) o;
|
||||
Map<String, Integer> cardMap = cards.getAll();
|
||||
if (cardMap.size() != 6)
|
||||
return false;
|
||||
if (cardMap.get("(S)FotR - Starter") != 1)
|
||||
return false;
|
||||
if (cardMap.get("FotR - Booster") != 6)
|
||||
return false;
|
||||
if (cardMap.get("1_231") != 2)
|
||||
return false;
|
||||
if (cardMap.get("(S)MoM - Starter") != 1)
|
||||
return false;
|
||||
if (cardMap.get("MoM - Booster") != 3)
|
||||
return false;
|
||||
if (cardMap.get("2_51") != 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
));
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchToFirstWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData("fotr_block,20120101,test,Test Collection");
|
||||
for (int i = 20120101; i < 20120108; i++) {
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(new HashMap<Player, CardCollection>());
|
||||
int result = data.process(collectionsManager, 0, i);
|
||||
assertEquals(1, result);
|
||||
Mockito.verify(collectionsManager, new Times(1)).getPlayersCollection("test");
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessMidFirstWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData("fotr_block,20120101,test,Test Collection");
|
||||
for (int i = 20120101; i < 20120108; i++) {
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(new HashMap<Player, CardCollection>());
|
||||
int result = data.process(collectionsManager, 1, i);
|
||||
assertEquals(1, result);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchToSecondWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData("fotr_block,20120101,test,Test Collection");
|
||||
CollectionType collectionType = new CollectionType("test", "Test Collection");
|
||||
for (int i = 20120108; i < 20120115; i++) {
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
Map<Player, CardCollection> playersInLeague = new HashMap<Player, CardCollection>();
|
||||
Player player = new Player(1, "Test", "A");
|
||||
playersInLeague.put(player, new DefaultCardCollection());
|
||||
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(playersInLeague);
|
||||
int result = data.process(collectionsManager, 1, i);
|
||||
assertEquals(2, result);
|
||||
Map<String, Integer> expectedToAdd = new HashMap<String, Integer>();
|
||||
expectedToAdd.put("(S)MoM - Starter", 1);
|
||||
expectedToAdd.put("MoM - Booster", 3);
|
||||
expectedToAdd.put("2_51", 1);
|
||||
Mockito.verify(collectionsManager, new Times(1)).getPlayersCollection("test");
|
||||
Mockito.verify(collectionsManager, new Times(1)).addItemsToPlayerCollection(Mockito.eq(player), Mockito.eq(collectionType), Mockito.eq(expectedToAdd));
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessMidSecondWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData("fotr_block,20120101,test,Test Collection");
|
||||
for (int i = 20120108; i < 20120115; i++) {
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(new HashMap<Player, CardCollection>());
|
||||
int result = data.process(collectionsManager, 2, i);
|
||||
assertEquals(2, result);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
import com.gempukku.lotro.db.vo.LeagueSerie;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LeaguePrizesTest {
|
||||
public class SealedLeaguePrizesTest {
|
||||
@Test
|
||||
public void test() {
|
||||
LeaguePrizes leaguePrizes = new LeaguePrizes();
|
||||
League league = new League(1, "a", "bla", 1, 1);
|
||||
LeagueSerie leagueSerie = new LeagueSerie("a", "b", "fotr_block", null, 0, 0, 0, 0);
|
||||
CardCollection prize = leaguePrizes.getPrizeForLeagueMatchWinner(2, 2, league, leagueSerie);
|
||||
SealedLeaguePrizes leaguePrizes = new SealedLeaguePrizes();
|
||||
CardCollection prize = leaguePrizes.getPrizeForLeagueMatchWinner(2, 2, "fotr_block");
|
||||
for (Map.Entry<String, Integer> stringIntegerEntry : prize.getAll().entrySet()) {
|
||||
System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue());
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
<b>5 Mar. 2012</b>
|
||||
- "Discard to heal" actions now shows the card to the opponent, the same way, as in case of played events.
|
||||
- Stacking discarded Hobbits on Treebeard should no longer cancel their action, for which the cost was discarding them.
|
||||
- "Relentless Warg" should no longer cause the game to freeze.
|
||||
|
||||
<b>3 Mar. 2012</b>
|
||||
- "The Palantir of Orthanc, Recovered Seeing Stone" should no longer discard itself.
|
||||
|
||||
Reference in New Issue
Block a user