Introducing constant values for CollectionTypes.

This commit is contained in:
marcins78@gmail.com
2012-12-29 22:36:50 +00:00
parent 3a82bab75e
commit 205a476874
12 changed files with 19 additions and 16 deletions

View File

@@ -1,6 +1,9 @@
package com.gempukku.lotro.db.vo;
public final class CollectionType {
public final static CollectionType MY_CARDS = new CollectionType("permanent", "My cards");
public final static CollectionType ALL_CARDS = new CollectionType("default", "All cards");
private final String _code;
private final String _fullName;

View File

@@ -29,7 +29,7 @@ public class HallServer extends AbstractServer {
private CollectionsManager _collectionsManager;
private LotroServer _lotroServer;
private CollectionType _allCardsCollectionType = new CollectionType("default", "All cards");
private CollectionType _allCardsCollectionType = CollectionType.ALL_CARDS;
private final int _playerInactivityPeriod = 1000 * 20; // 10 seconds
@@ -62,7 +62,7 @@ public class HallServer extends AbstractServer {
_hallChat = _chatServer.createChatRoom("Game Hall", 10);
_tournamentQueues.put("fotr_queue", new SingleEliminationRecurringQueue(0, "fotr_block",
new CollectionType("default", "All cards"), "fotrQueue-", "Test Fellowship Block 4-man", 4,
CollectionType.ALL_CARDS, "fotrQueue-", "Test Fellowship Block 4-man", 4,
true, tournamentService));
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
public class ConstructedLeagueData implements LeagueData {
private List<LeagueSerieData> _series = new ArrayList<LeagueSerieData>();
private CollectionType _prizeCollectionType = new CollectionType("permanent", "My cards");
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private float _prizeMultiplier;
private LeaguePrizes _leaguePrizes = new NewLeaguePrizes();

View File

@@ -94,7 +94,7 @@ public class LeagueService {
if (isPlayerInLeague(league, player))
return false;
int cost = league.getCost();
if (_collectionsManager.removeCurrencyFromPlayerCollection("Joining "+league.getName()+" league", player, new CollectionType("permanent", "My cards"), cost)) {
if (_collectionsManager.removeCurrencyFromPlayerCollection("Joining "+league.getName()+" league", player, CollectionType.MY_CARDS, cost)) {
_leagueParticipationDAO.userJoinsLeague(league.getType(), player, remoteAddr);
league.getLeagueData().joinLeague(_collectionsManager, player, DateUtils.getCurrentDate());
@@ -160,7 +160,7 @@ public class LeagueService {
else
prize = serie.getPrizeForLeagueMatchLoser(count, playerMatchesPlayedOn.size());
if (prize != null)
_collectionsManager.addItemsToPlayerCollection(true, "Prize for winning league game", player, new CollectionType("permanent", "My cards"), prize.getAll().values());
_collectionsManager.addItemsToPlayerCollection(true, "Prize for winning league game", player, CollectionType.MY_CARDS, prize.getAll().values());
}
public synchronized Collection<LeagueMatchResult> getPlayerMatchesInSerie(League league, LeagueSerieData serie, String player) {

View File

@@ -14,7 +14,7 @@ import java.util.List;
public class NewConstructedLeagueData implements LeagueData {
private List<LeagueSerieData> _series = new ArrayList<LeagueSerieData>();
private CollectionType _prizeCollectionType = new CollectionType("permanent", "My cards");
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private LeaguePrizes _leaguePrizes = new NewLeaguePrizes();
private float _prizeMultiplier;
@@ -23,9 +23,9 @@ public class NewConstructedLeagueData implements LeagueData {
int start = Integer.parseInt(params[0]);
CollectionType collectionType;
if (params[1].equals("default"))
collectionType = new CollectionType("default", "All cards");
collectionType = CollectionType.ALL_CARDS;
else if (params[1].equals("permanent"))
collectionType = new CollectionType("permanent", "My cards");
collectionType = CollectionType.MY_CARDS;
else
throw new IllegalArgumentException("Unkown collection type");
_prizeMultiplier = Float.parseFloat(params[2]);

View File

@@ -18,7 +18,7 @@ public class NewSealedLeagueData implements LeagueData {
private SealedLeagueType _leagueType;
private List<LeagueSerieData> _series;
private CollectionType _collectionType;
private CollectionType _prizeCollectionType = new CollectionType("permanent", "My cards");
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private NewLeaguePrizes _leaguePrizes;
private SealedLeagueProduct _leagueProduct;

View File

@@ -18,7 +18,7 @@ public class SealedLeagueData implements LeagueData {
private String _format;
private List<LeagueSerieData> _series;
private CollectionType _collectionType;
private CollectionType _prizeCollectionType = new CollectionType("permanent", "My cards");
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private LeaguePrizes _leaguePrizes;
private SealedLeagueProduct _leagueProduct;

View File

@@ -28,7 +28,7 @@ public class MerchantService {
private Map<String, Integer> _fixedPriceItems = new HashMap<String, Integer>();
private CollectionType _permanentCollection = new CollectionType("permanent", "My cards");
private CollectionType _permanentCollection = CollectionType.MY_CARDS;
private CollectionsManager _collectionsManager;
public MerchantService(LotroCardBlueprintLibrary library, CollectionsManager collectionsManager, MerchantDAO merchantDAO) {

View File

@@ -13,7 +13,7 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
private String _format;
private CollectionType _collectionType;
private String _tournamentQueueName;
private CollectionType _currencyCollection = new CollectionType("permanent", "My cards");
private CollectionType _currencyCollection = CollectionType.MY_CARDS;
private Set<String> _players = new HashSet<String>();
private Map<String, LotroDeck> _playerDecks = new HashMap<String, LotroDeck>();

View File

@@ -36,11 +36,11 @@ public abstract class AbstractResource {
Integer lastReward = player.getLastLoginReward();
if (lastReward == null) {
_playerDao.setLastReward(player, latestMonday);
_collectionManager.addCurrencyToPlayerCollection(true, "Initial currency balance", player, new CollectionType("permanent", "My cards"), 20000);
_collectionManager.addCurrencyToPlayerCollection(true, "Initial currency balance", player, CollectionType.MY_CARDS, 20000);
} else {
if (latestMonday != lastReward) {
if (_playerDao.updateLastReward(player, lastReward, latestMonday))
_collectionManager.addCurrencyToPlayerCollection(true, "Weekly activity reward", player, new CollectionType("permanent", "My cards"), 5000);
_collectionManager.addCurrencyToPlayerCollection(true, "Weekly activity reward", player, CollectionType.MY_CARDS, 5000);
}
}
}

View File

@@ -348,7 +348,7 @@ public class AdminResource extends AbstractResource {
private CollectionType createCollectionType(String collectionType) {
if (collectionType.equals("permanent"))
return new CollectionType("permanent", "My cards");
return CollectionType.MY_CARDS;
return _leagueService.getCollectionTypeByCode(collectionType);
}

View File

@@ -248,7 +248,7 @@ public class CollectionResource extends AbstractResource {
private CollectionType createCollectionType(String collectionType) {
if (collectionType.equals("permanent"))
return new CollectionType("permanent", "My cards");
return CollectionType.MY_CARDS;
return _leagueService.getCollectionTypeByCode(collectionType);
}