League auto-product giving.
This commit is contained in:
@@ -43,10 +43,11 @@ public class CollectionsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerCollection(Player player, String collectionType, CardCollection cardCollection) {
|
||||
public void addPlayerCollection(LeagueService leagueService, Player player, String collectionType, CardCollection cardCollection) {
|
||||
_readWriteLock.writeLock().lock();
|
||||
try {
|
||||
_collectionDAO.setCollectionForPlayer(player.getId(), collectionType, cardCollection);
|
||||
addPackage(leagueService, player, collectionType, cardCollection);
|
||||
} finally {
|
||||
_readWriteLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ public class LeagueSerieDAO {
|
||||
private Map<String, Integer> createCollection(String collection) {
|
||||
Map<String, Integer> result = new HashMap<String, Integer>();
|
||||
if (collection != null) {
|
||||
final String[] items = collection.split("|");
|
||||
final String[] items = collection.split("\n");
|
||||
for (String item : items) {
|
||||
final String[] xes = item.split("x", 2);
|
||||
final String[] xes = item.trim().split("x", 2);
|
||||
result.put(xes[1], Integer.parseInt(xes[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,12 @@ public class LeagueService {
|
||||
_winnerPromos.put("ttt_block", tttPromos);
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
_leagueSerieStandings.clear();
|
||||
_leagueStandings.clear();
|
||||
_activeLeaguesLoadedDate = 0;
|
||||
}
|
||||
|
||||
private int getCurrentDate() {
|
||||
Calendar date = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
||||
return date.get(Calendar.YEAR) * 10000 + (date.get(Calendar.MONTH) + 1) * 100 + date.get(Calendar.DAY_OF_MONTH);
|
||||
@@ -123,7 +129,7 @@ public class LeagueService {
|
||||
private void processLoadedLeagues(int currentDate) {
|
||||
for (League activeLeague : _activeLeagues) {
|
||||
for (LeagueSerie leagueSerie : _leagueSeasonDao.getSeriesForLeague(activeLeague)) {
|
||||
if (leagueSerie.getStart() >= currentDate && !leagueSerie.wasCollectionGiven()) {
|
||||
if (leagueSerie.getStart() <= currentDate && !leagueSerie.wasCollectionGiven()) {
|
||||
for (Map.Entry<Player, CardCollection> playerLeagueCollection : _collectionsManager.getPlayersCollection(activeLeague.getType()).entrySet()) {
|
||||
_collectionsManager.addItemsToPlayerCollection(this, playerLeagueCollection.getKey(), activeLeague.getType(), leagueSerie.getSerieCollection());
|
||||
}
|
||||
@@ -150,7 +156,7 @@ public class LeagueService {
|
||||
startingCollection.addItem(serieCollectionItem.getKey(), serieCollectionItem.getValue());
|
||||
}
|
||||
}
|
||||
_collectionsManager.addPlayerCollection(player, league.getType(), startingCollection);
|
||||
_collectionsManager.addPlayerCollection(this, player, league.getType(), startingCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class AdminResource extends AbstractResource {
|
||||
_collectionsManager.clearDBCache();
|
||||
_deckDao.clearCache();
|
||||
_leagueDao.clearCache();
|
||||
_leagueService.clearCache();
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user