From 670cc4274805b171f9ab509e5ddb9c0b16c72a1a Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 24 May 2012 12:56:24 +0000 Subject: [PATCH] Simplifying the leagues a bit. --- .../java/com/gempukku/lotro/db/vo/League.java | 18 +- .../lotro/league/ConstructedLeagueData.java | 8 +- .../lotro/league/DefaultLeagueSerieData.java | 8 +- .../gempukku/lotro/league/LeaguePrizes.java | 6 +- .../league/NewConstructedLeagueData.java | 4 +- .../lotro/league/NewLeaguePrizes.java | 6 +- .../lotro/league/NewSealedLeagueData.java | 15 +- .../lotro/league/OldLeaguePrizes.java | 191 ------------- .../lotro/league/SealedLeagueData.java | 9 +- .../lotro/league/SealedLeagueProduct.java | 10 +- .../lotro/league/SealedLeagueType.java | 31 +++ .../src/main/resources/lotrFormats.json | 260 ++++++++++-------- .../lotro/league/LeaguePrizesTest.java | 4 +- 13 files changed, 218 insertions(+), 352 deletions(-) delete mode 100644 gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/OldLeaguePrizes.java create mode 100644 gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueType.java diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/vo/League.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/vo/League.java index 64b985901..d762b785a 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/vo/League.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/vo/League.java @@ -11,6 +11,7 @@ public class League { private String _clazz; private String _parameters; private int _status; + private LeagueData _leagueData; public League(int cost, String name, String type, String clazz, String parameters, int status) { _cost = cost; @@ -33,14 +34,17 @@ public class League { return _type; } - 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 synchronized LeagueData getLeagueData() { + if (_leagueData == null) { + try { + Class aClass = Class.forName(_clazz); + Constructor constructor = aClass.getConstructor(String.class); + _leagueData = (LeagueData) constructor.newInstance(_parameters); + } catch (Exception exp) { + throw new RuntimeException("Unable to create LeagueData", exp); + } } + return _leagueData; } public int getStatus() { diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java index d273fe095..2ed80efce 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java @@ -12,10 +12,9 @@ import java.util.List; public class ConstructedLeagueData implements LeagueData { private List _series = new ArrayList(); - private String _leaguePrizePool; private CollectionType _prizeCollectionType = new CollectionType("permanent", "My cards"); private float _prizeMultiplier; - private LeaguePrizes _leaguePrizes = new OldLeaguePrizes(); + private LeaguePrizes _leaguePrizes = new NewLeaguePrizes(); // Example params - 20120312,fotr_block,0.7,default,All cards,7,10,3,fotr1_block,fotr_block,fotr2_block,fotr_block,fotr_block,fotr_block // Which means - start date,league prize pool,prizes multiplier,collection type,collection name,serie length,serie match count,series count, @@ -25,7 +24,6 @@ public class ConstructedLeagueData implements LeagueData { public ConstructedLeagueData(String parameters) { String[] params = parameters.split(","); final int start = Integer.parseInt(params[0]); - _leaguePrizePool = params[1]; _prizeMultiplier = Float.parseFloat(params[2]); CollectionType collectionType = new CollectionType(params[3], params[4]); int days = Integer.parseInt(params[5]); @@ -37,7 +35,7 @@ public class ConstructedLeagueData implements LeagueData { DefaultLeagueSerieData data = new DefaultLeagueSerieData(_leaguePrizes, false, "Week " + (i + 1), DateUtils.offsetDate(start, i * days), DateUtils.offsetDate(start, ((i + 1) * days) - 1), - matchCount, format, seriePrizePool, collectionType); + matchCount, format, collectionType); _series.add(data); } } @@ -59,7 +57,7 @@ public class ConstructedLeagueData implements LeagueData { LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier, _leaguePrizePool); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll()); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/DefaultLeagueSerieData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/DefaultLeagueSerieData.java index 8d3eaa4d1..d8a2fa4d3 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/DefaultLeagueSerieData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/DefaultLeagueSerieData.java @@ -11,10 +11,9 @@ public class DefaultLeagueSerieData implements LeagueSerieData { private int _end; private int _maxMatches; private String _format; - private String _prizePool; private CollectionType _collectionType; - public DefaultLeagueSerieData(LeaguePrizes leaguePrizes, boolean limited, String name, int start, int end, int maxMatches, String format, String prizePool, CollectionType collectionType) { + public DefaultLeagueSerieData(LeaguePrizes leaguePrizes, boolean limited, String name, int start, int end, int maxMatches, String format, CollectionType collectionType) { _leaguePrizes = leaguePrizes; _limited = limited; _name = name; @@ -22,7 +21,6 @@ public class DefaultLeagueSerieData implements LeagueSerieData { _end = end; _maxMatches = maxMatches; _format = format; - _prizePool = prizePool; _collectionType = collectionType; } @@ -63,11 +61,11 @@ public class DefaultLeagueSerieData implements LeagueSerieData { @Override public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie) { - return _leaguePrizes.getPrizeForLeagueMatchWinner(winCountThisSerie, totalGamesPlayedThisSerie, _prizePool); + return _leaguePrizes.getPrizeForLeagueMatchWinner(winCountThisSerie, totalGamesPlayedThisSerie); } @Override public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie) { - return _leaguePrizes.getPrizeForLeagueMatchLoser(winCountThisSerie, totalGamesPlayedThisSerie, _prizePool); + return _leaguePrizes.getPrizeForLeagueMatchLoser(winCountThisSerie, totalGamesPlayedThisSerie); } } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java index aa5639876..d44bdd246 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java @@ -3,9 +3,9 @@ package com.gempukku.lotro.league; import com.gempukku.lotro.game.CardCollection; public interface LeaguePrizes { - public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie, String format); + public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie); - public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie, String format); + public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie); - public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier, String format); + public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java index 69ab86366..fca3ec4a9 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java @@ -38,7 +38,7 @@ public class NewConstructedLeagueData implements LeagueData { int maxMatches = Integer.parseInt(params[6 + i * 3]); _series.add(new DefaultLeagueSerieData(_leaguePrizes, false, "Serie " + (i + 1), serieStart, DateUtils.offsetDate(serieStart, duration - 1), - maxMatches, format, null, collectionType)); + maxMatches, format, collectionType)); serieStart = DateUtils.offsetDate(serieStart, duration); } @@ -61,7 +61,7 @@ public class NewConstructedLeagueData implements LeagueData { LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier, null); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll()); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java index 8e3c8d0c0..f10cf7761 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java @@ -23,7 +23,7 @@ public class NewLeaguePrizes implements LeaguePrizes { } } - public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie, String format) { + public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie) { DefaultCardCollection winnerPrize = new DefaultCardCollection(); if (winCountThisSerie == 1 || winCountThisSerie == 3 || winCountThisSerie == 5 || winCountThisSerie == 8 || winCountThisSerie == 10) winnerPrize.addItem("(S)Booster Choice", 1); @@ -44,11 +44,11 @@ public class NewLeaguePrizes implements LeaguePrizes { return winnerPrize; } - public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie, String format) { + public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie) { return null; } - public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier, String format) { + public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier) { DefaultCardCollection leaguePrize = new DefaultCardCollection(); int count = (int) Math.floor((2 * playersCount + 24) / (position + 9) - 2.4); if (count > 0) { diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java index 28bbe9c64..6e3eae323 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map; public class NewSealedLeagueData implements LeagueData { - private String _format; + private SealedLeagueType _leagueType; private List _series; private CollectionType _collectionType; private CollectionType _prizeCollectionType = new CollectionType("permanent", "My cards"); @@ -24,7 +24,7 @@ public class NewSealedLeagueData implements LeagueData { public NewSealedLeagueData(String parameters) { String[] params = parameters.split(","); - _format = params[0]; + _leagueType = SealedLeagueType.getLeagueType(params[0]); int start = Integer.parseInt(params[1]); int serieDuration = Integer.parseInt(params[2]); int maxMatches = Integer.parseInt(params[3]); @@ -39,7 +39,7 @@ public class NewSealedLeagueData implements LeagueData { _series.add( new DefaultLeagueSerieData(_leaguePrizes, true, "Serie " + (i + 1), DateUtils.offsetDate(start, i * serieDuration), DateUtils.offsetDate(start, (i + 1) * serieDuration - 1), maxMatches, - _format, _format, _collectionType)); + _leagueType.getFormat(), _collectionType)); } } @@ -54,7 +54,7 @@ public class NewSealedLeagueData implements LeagueData { for (int i = 0; i < _series.size(); i++) { LeagueSerieData serie = _series.get(i); if (currentTime >= serie.getStart()) { - CardCollection leagueProduct = _leagueProduct.getCollectionForSerie(_format, i); + CardCollection leagueProduct = _leagueProduct.getCollectionForSerie(_leagueType.getSealedCode(), i); for (Map.Entry serieCollectionItem : leagueProduct.getAll().entrySet()) startingCollection.addItem(serieCollectionItem.getKey(), serieCollectionItem.getValue()); @@ -71,7 +71,7 @@ public class NewSealedLeagueData implements LeagueData { for (int i = status; i < _series.size(); i++) { LeagueSerieData serie = _series.get(i); if (currentTime >= serie.getStart()) { - CardCollection leagueProduct = _leagueProduct.getCollectionForSerie(_format, i); + CardCollection leagueProduct = _leagueProduct.getCollectionForSerie(_leagueType.getSealedCode(), i); Map map = collectionsManager.getPlayersCollection(_collectionType.getCode()); for (Map.Entry playerCardCollectionEntry : map.entrySet()) { collectionsManager.addItemsToPlayerCollection(playerCardCollectionEntry.getKey(), _collectionType, leagueProduct.getAll()); @@ -84,13 +84,10 @@ public class NewSealedLeagueData implements LeagueData { LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f, _format); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll()); } -// for (PlayerStanding leagueStanding : leagueStandings) { -// collectionsManager.moveCollectionToCollection(leagueStanding.getPlayerName(), _collectionType, _prizeCollectionType); -// } status++; } } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/OldLeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/OldLeaguePrizes.java deleted file mode 100644 index 0e9b80d86..000000000 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/OldLeaguePrizes.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.gempukku.lotro.league; - -import com.gempukku.lotro.cards.packs.RarityReader; -import com.gempukku.lotro.cards.packs.SetRarity; -import com.gempukku.lotro.game.CardCollection; -import com.gempukku.lotro.game.DefaultCardCollection; - -import java.util.*; - -public class OldLeaguePrizes implements LeaguePrizes { - private Map> _blockPromos = new HashMap>(); - private Map> _blockCommons = new HashMap>(); - private Map> _blockUncommons = new HashMap>(); - private static final String FOTR_BLOCK = "fotr_block"; - private static final String TTT_BLOCK = "ttt_block"; - - public OldLeaguePrizes() { - List fotrPromos = new ArrayList(); - fotrPromos.add("0_1"); - fotrPromos.add("0_2"); - fotrPromos.add("0_3"); - fotrPromos.add("0_4"); - fotrPromos.add("0_5"); - fotrPromos.add("0_6"); - fotrPromos.add("0_7"); - fotrPromos.add("0_8"); - fotrPromos.add("0_9"); - fotrPromos.add("0_10"); - fotrPromos.add("0_11"); - fotrPromos.add("0_12"); - fotrPromos.add("0_13"); - fotrPromos.add("0_14"); - fotrPromos.add("0_15"); - fotrPromos.add("0_34"); - fotrPromos.add("0_36"); - fotrPromos.add("0_37"); - fotrPromos.add("0_41"); - fotrPromos.add("0_42"); - fotrPromos.add("0_43"); - _blockPromos.put(FOTR_BLOCK, fotrPromos); - - List tttPromos = new ArrayList(); - tttPromos.add("0_16"); - tttPromos.add("0_17"); - tttPromos.add("0_18"); - tttPromos.add("0_19"); - tttPromos.add("0_21"); - tttPromos.add("0_22"); - tttPromos.add("0_30"); - tttPromos.add("0_32"); - tttPromos.add("0_33"); - tttPromos.add("0_35"); - tttPromos.add("0_38"); - tttPromos.add("0_39"); - tttPromos.add("0_40"); - tttPromos.add("0_44"); - tttPromos.add("0_45"); - tttPromos.add("0_46"); - tttPromos.add("0_47"); - _blockPromos.put(TTT_BLOCK, tttPromos); - - RarityReader rarityReader = new RarityReader(); - SetRarity fotrRarity = rarityReader.getSetRarity("1"); - SetRarity momRarity = rarityReader.getSetRarity("2"); - SetRarity rotelRarity = rarityReader.getSetRarity("3"); - - SetRarity tttRarity = rarityReader.getSetRarity("4"); - SetRarity bohdRarity = rarityReader.getSetRarity("5"); - SetRarity eofRarity = rarityReader.getSetRarity("6"); - - List fotrCommons = new ArrayList(); - fotrCommons.addAll(fotrRarity.getCardsOfRarity("C")); - fotrCommons.addAll(momRarity.getCardsOfRarity("C")); - fotrCommons.addAll(rotelRarity.getCardsOfRarity("C")); - _blockCommons.put(FOTR_BLOCK, fotrCommons); - - List fotrUncommons = new ArrayList(); - fotrUncommons.addAll(fotrRarity.getCardsOfRarity("U")); - fotrUncommons.addAll(momRarity.getCardsOfRarity("U")); - fotrUncommons.addAll(rotelRarity.getCardsOfRarity("U")); - _blockUncommons.put(FOTR_BLOCK, fotrUncommons); - - List tttCommons = new ArrayList(); - tttCommons.addAll(tttRarity.getCardsOfRarity("C")); - tttCommons.addAll(bohdRarity.getCardsOfRarity("C")); - tttCommons.addAll(eofRarity.getCardsOfRarity("C")); - _blockCommons.put(TTT_BLOCK, tttCommons); - - List tttUncommons = new ArrayList(); - tttUncommons.addAll(tttRarity.getCardsOfRarity("U")); - tttUncommons.addAll(bohdRarity.getCardsOfRarity("U")); - tttUncommons.addAll(eofRarity.getCardsOfRarity("U")); - _blockUncommons.put(TTT_BLOCK, tttUncommons); - } - - 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 blockCommons = _blockCommons.get(format); - List blockUncommons = _blockUncommons.get(format); - List blockPromos = _blockPromos.get(format); - if (winCountThisSerie == 2) - winnerPrize.addItem(getRandom(blockCommons) + "*", 1); - else if (winCountThisSerie == 4) - winnerPrize.addItem(getRandom(blockPromos), 1); - else if (winCountThisSerie == 6) - winnerPrize.addItem(getRandom(blockPromos) + "*", 1); - else if (winCountThisSerie == 7) - winnerPrize.addItem(getRandom(blockUncommons) + "*", 1); - else if (winCountThisSerie == 9) { - winnerPrize.addItem(getRandom(blockPromos), 1); - winnerPrize.addItem(getRandom(blockCommons) + "*", 1); - } - } - return winnerPrize; - } - - public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie, String format) { - return null; - } - - public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier, String format) { - DefaultCardCollection leaguePrize = new DefaultCardCollection(); - int count = (int) Math.floor((2 * playersCount + 24) / (position + 9) - 2.4); - if (count > 0) { - count = 1 + (int) Math.floor((count - 1) * multiplier); - leaguePrize.addItem("(S)Booster Choice", count); - } - int tengwar = getTengwarCount(position); - if (tengwar > 0) { - if (format.equals(FOTR_BLOCK)) - leaguePrize.addItem("(S)FotR - Tengwar", tengwar); - else if (format.equals(TTT_BLOCK)) - leaguePrize.addItem("(S)TTT - Tengwar", tengwar); - } - if (position == 1) { - addPrizes(leaguePrize, getRandomFoil(_blockPromos.get(format), 3)); - } else if (position == 2) { - addPrizes(leaguePrize, getRandomFoil(_blockPromos.get(format), 2)); - addPrizes(leaguePrize, getRandom(_blockPromos.get(format), 1)); - } else if (position == 3) { - addPrizes(leaguePrize, getRandomFoil(_blockPromos.get(format), 1)); - addPrizes(leaguePrize, getRandom(_blockPromos.get(format), 2)); - } else if (position >= 4 && position <= 6) { - addPrizes(leaguePrize, getRandom(_blockPromos.get(format), 7 - position)); - } else if (position >= 9 && position <= 12) { - addPrizes(leaguePrize, getRandom(_blockPromos.get(format), 1)); - } - - if (leaguePrize.getAll().size() == 0) - return null; - return leaguePrize; - } - - private void addPrizes(DefaultCardCollection leaguePrize, List cards) { - for (String card : cards) - leaguePrize.addItem(card, 1); - } - - private int getTengwarCount(int position) { - if (position == 1) - return 4; - else if (position == 2) - return 3; - else if (position == 3) - return 2; - else if (position <= 8) - return 1; - return 0; - } - - private String getRandom(List list) { - return list.get(new Random().nextInt(list.size())); - } - - private List getRandom(List list, int count) { - List result = new LinkedList(list); - Collections.shuffle(result); - return result.subList(0, count); - } - - private List getRandomFoil(List list, int count) { - List result = new LinkedList(); - for (String element : list) - result.add(element + "*"); - Collections.shuffle(result); - return result.subList(0, count); - } -} \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java index 1b5cc7daf..b6732a938 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java @@ -31,7 +31,7 @@ public class SealedLeagueData implements LeagueData { int serieDuration = 7; int maxMatches = 10; - _leaguePrizes = new OldLeaguePrizes(); + _leaguePrizes = new NewLeaguePrizes(); _leagueProduct = new SealedLeagueProduct(); _series = new LinkedList(); @@ -39,7 +39,7 @@ public class SealedLeagueData implements LeagueData { _series.add( new DefaultLeagueSerieData(_leaguePrizes, true, "Week " + (i + 1), DateUtils.offsetDate(start, i * serieDuration), DateUtils.offsetDate(start, (i + 1) * serieDuration - 1), maxMatches, - _format, _format, _collectionType)); + _format, _collectionType)); } } @@ -84,13 +84,10 @@ public class SealedLeagueData implements LeagueData { LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f, _format); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll()); } -// for (PlayerStanding leagueStanding : leagueStandings) { -// collectionsManager.moveCollectionToCollection(leagueStanding.getPlayerName(), _collectionType, _prizeCollectionType); -// } status++; } } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueProduct.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueProduct.java index 4c0d59832..0e7e70efe 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueProduct.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueProduct.java @@ -44,7 +44,7 @@ public class SealedLeagueProduct { fourthWeek.addItem("RotEL - Booster", 2); fotrBlock.add(fourthWeek); - _collections.put("fotr_block", fotrBlock); + _collections.put(SealedLeagueType.FOTR_BLOCK.getSealedCode(), fotrBlock); } private void createTowersBlock() { @@ -73,7 +73,7 @@ public class SealedLeagueProduct { fourthWeek.addItem("EoF - Booster", 2); tttBlock.add(fourthWeek); - _collections.put("ttt_block", tttBlock); + _collections.put(SealedLeagueType.TTT_BLOCK.getSealedCode(), tttBlock); } private void createMovieBlock() { @@ -106,10 +106,10 @@ public class SealedLeagueProduct { fourthWeek.addItem("MD - Booster", 2); kingBlock.add(fourthWeek); - _collections.put("movie", kingBlock); + _collections.put(SealedLeagueType.MOVIE_BLOCK.getSealedCode(), kingBlock); } - public CardCollection getCollectionForSerie(String format, int serieIndex) { - return _collections.get(format).get(serieIndex); + public CardCollection getCollectionForSerie(String leagueCode, int serieIndex) { + return _collections.get(leagueCode).get(serieIndex); } } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueType.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueType.java new file mode 100644 index 000000000..d61a10e3d --- /dev/null +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueType.java @@ -0,0 +1,31 @@ +package com.gempukku.lotro.league; + +public enum SealedLeagueType { + FOTR_BLOCK("fotr_block", "limited_fotr"), + TTT_BLOCK("ttt_block", "limited_ttt"), + MOVIE_BLOCK("movie", "limited_king"); + + public static SealedLeagueType getLeagueType(String sealedCode) { + for (SealedLeagueType sealedLeagueType : SealedLeagueType.values()) { + if (sealedLeagueType.getSealedCode().equals(sealedCode)) + return sealedLeagueType; + } + return null; + } + + private String _sealedCode; + private String _format; + + private SealedLeagueType(String sealedCode, String format) { + _sealedCode = sealedCode; + _format = format; + } + + public String getSealedCode() { + return _sealedCode; + } + + public String getFormat() { + return _format; + } +} diff --git a/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json b/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json index b34c79890..71cec88a4 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json +++ b/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json @@ -1,161 +1,193 @@ [ { - "name": "Fellowship block", - "code": "fotr_block", - "sites": "FELLOWSHIP", - "cancelRingBearerSkirmish": true, - "restricted": ["1_248"], - "set": [1,2,3] + "name":"Fellowship block", + "code":"fotr_block", + "sites":"FELLOWSHIP", + "cancelRingBearerSkirmish":true, + "restricted":["1_248"], + "set":[1, 2, 3] }, { - "name": "Fellowship block - Set 1", - "code": "fotr1_block", - "sites": "FELLOWSHIP", - "cancelRingBearerSkirmish": true, - "restricted": ["1_248"], - "set": [1], - "hall": false + "name":"Fellowship block - Set 1", + "code":"fotr1_block", + "sites":"FELLOWSHIP", + "cancelRingBearerSkirmish":true, + "restricted":["1_248"], + "set":[1], + "hall":false }, { - "name": "Fellowship block - Sets 1&2", - "code": "fotr2_block", - "sites": "FELLOWSHIP", - "cancelRingBearerSkirmish": true, - "restricted": ["1_248"], - "set": [1,2], - "hall": false + "name":"Fellowship block - Sets 1&2", + "code":"fotr2_block", + "sites":"FELLOWSHIP", + "cancelRingBearerSkirmish":true, + "restricted":["1_248"], + "set":[1, 2], + "hall":false }, { - "name": "Towers block", - "code": "ttt_block", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": true, - "set":[4,5,6] + "name":"Towers block", + "code":"ttt_block", + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, + "set":[4, 5, 6] }, { - "name": "Towers block - Set 4", - "code": "ttt1_block", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": true, + "name":"Towers block - Set 4", + "code":"ttt1_block", + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, "set":[4], - "hall": false + "hall":false }, { - "name": "Towers block - Sets 4&5", - "code": "ttt2_block", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": true, - "set":[4,5], - "hall": false + "name":"Towers block - Sets 4&5", + "code":"ttt2_block", + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, + "set":[4, 5], + "hall":false }, { - "name": "Towers standard", + "name":"Towers standard", "code":"towers_standard", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": true, - "banned": ["1_40","1_45","1_80","1_108","1_139","1_234","1_248","1_313","2_32","2_101","2_108","3_38","3_42","3_68","4_192"], - "set":[1,2,3,4,5,6] + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, + "banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"], + "set":[1, 2, 3, 4, 5, 6] }, { - "name": "Towers standard - Sets 1-4", + "name":"Towers standard - Sets 1-4", "code":"ttt_standard", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": true, - "banned": ["1_40","1_45","1_80","1_108","1_139","1_234","1_248","1_313","2_32","2_101","2_108","3_38","3_42","3_68","4_192"], - "set":[1,2,3,4], - "hall": false + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, + "banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"], + "set":[1, 2, 3, 4], + "hall":false }, { - "name": "Towers standard - Sets 1-5", + "name":"Towers standard - Sets 1-5", "code":"bohd_standard", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": true, - "banned": ["1_40","1_45","1_80","1_108","1_139","1_234","1_248","1_313","2_32","2_101","2_108","3_38","3_42","3_68","4_192"], - "set":[1,2,3,4,5], - "hall": false + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, + "banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"], + "set":[1, 2, 3, 4, 5], + "hall":false }, { - "name": "Towers standard - Sets 1-6,9,14&16", + "name":"Towers standard - Sets 1-6,9,14&16", "code":"ts_reflections", - "sites": "TWO_TOWERS", - "cancelRingBearerSkirmish": false, - "banned": ["1_40","1_45","1_80","1_108","1_139","1_234","1_248","1_313","2_32","2_101","2_108","3_38","3_42","3_68","4_192"], - "set":[1,2,3,4,5,6,9,14,16], - "hall": false + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":false, + "banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"], + "set":[1, 2, 3, 4, 5, 6, 9, 14, 16], + "hall":false }, { - "name": "King block", - "code": "king_block", - "sites": "KING", - "cancelRingBearerSkirmish": true, - "restricted": ["7_49"], - "set": [7,8,10] + "name":"King block", + "code":"king_block", + "sites":"KING", + "cancelRingBearerSkirmish":true, + "restricted":["7_49"], + "set":[7, 8, 10] }, { - "name": "Movie block", - "code": "movie", - "sites": "KING", - "banned": ["8_1","3_38","3_106","1_40","2_32","1_248","3_108","1_45","7_96","3_42","10_2","10_91","1_108","1_80","3_67","1_195","3_68","1_139","7_49","1_313","1_234"], - "set": [1,2,3,4,5,6,7,8,9,10] + "name":"Movie block", + "code":"movie", + "sites":"KING", + "banned":["8_1", "3_38", "3_106", "1_40", "2_32", "1_248", "3_108", "1_45", "7_96", "3_42", "10_2", "10_91", "1_108", "1_80", "3_67", "1_195", "3_68", "1_139", "7_49", "1_313", "1_234"], + "set":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }, { - "name": "Movie block - Sets 1-7", - "code": "movie7", - "sites": "KING", - "banned": ["8_1","3_38","3_106","1_40","2_32","1_248","3_108","1_45","7_96","3_42","10_2","10_91","1_108","1_80","3_67","1_195","3_68","1_139","7_49","1_313","1_234"], - "set": [1,2,3,4,5,6,7], - "hall": false + "name":"Movie block - Sets 1-7", + "code":"movie7", + "sites":"KING", + "banned":["8_1", "3_38", "3_106", "1_40", "2_32", "1_248", "3_108", "1_45", "7_96", "3_42", "10_2", "10_91", "1_108", "1_80", "3_67", "1_195", "3_68", "1_139", "7_49", "1_313", "1_234"], + "set":[1, 2, 3, 4, 5, 6, 7], + "hall":false }, { - "name": "Movie block - Sets 1-8", - "code": "movie8", - "sites": "KING", - "banned": ["8_1","3_38","3_106","1_40","2_32","1_248","3_108","1_45","7_96","3_42","10_2","10_91","1_108","1_80","3_67","1_195","3_68","1_139","7_49","1_313","1_234"], - "set": [1,2,3,4,5,6,7,8], - "hall": false + "name":"Movie block - Sets 1-8", + "code":"movie8", + "sites":"KING", + "banned":["8_1", "3_38", "3_106", "1_40", "2_32", "1_248", "3_108", "1_45", "7_96", "3_42", "10_2", "10_91", "1_108", "1_80", "3_67", "1_195", "3_68", "1_139", "7_49", "1_313", "1_234"], + "set":[1, 2, 3, 4, 5, 6, 7, 8], + "hall":false }, { - "name": "Movie block - Sets 1-9", - "code": "movie9", - "sites": "KING", - "banned": ["8_1","3_38","3_106","1_40","2_32","1_248","3_108","1_45","7_96","3_42","10_2","10_91","1_108","1_80","3_67","1_195","3_68","1_139","7_49","1_313","1_234"], - "set": [1,2,3,4,5,6,7,8,9], - "hall": false + "name":"Movie block - Sets 1-9", + "code":"movie9", + "sites":"KING", + "banned":["8_1", "3_38", "3_106", "1_40", "2_32", "1_248", "3_108", "1_45", "7_96", "3_42", "10_2", "10_91", "1_108", "1_80", "3_67", "1_195", "3_68", "1_139", "7_49", "1_313", "1_234"], + "set":[1, 2, 3, 4, 5, 6, 7, 8, 9], + "hall":false }, { - "name": "War of the Ring block", - "code": "war_block", - "sites": "SHADOWS", - "restricted": ["11_132","11_100"], - "set": [11,12,13] + "name":"War of the Ring block", + "code":"war_block", + "sites":"SHADOWS", + "restricted":["11_132", "11_100"], + "set":[11, 12, 13] }, { - "name": "War of the Ring standard", - "code": "war_standard", - "sites": "SHADOWS", - "banned": ["4_73","4_276","4_304","7_49","8_1","10_2","10_11","10_91","11_31","11_100","11_132"], - "set": [4,5,6,7,8,9,10,11,12,13,14] + "name":"War of the Ring standard", + "code":"war_standard", + "sites":"SHADOWS", + "banned":["4_73", "4_276", "4_304", "7_49", "8_1", "10_2", "10_11", "10_91", "11_31", "11_100", "11_132"], + "set":[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] }, { - "name": "Standard", - "code": "standard", - "sites": "SHADOWS", - "banned": ["0_1-19","0_21","0_22","0_30-47","0_62-67","8_1","13_188","11_114","11_31","10_11","15_64","10_2","10_91","11_132","7_49","11_100"], - "set": [0,7,8,9,10,11,12,13,14,15,16,17,18,19] + "name":"Standard", + "code":"standard", + "sites":"SHADOWS", + "banned":["0_1-19", "0_21", "0_22", "0_30-47", "0_62-67", "8_1", "13_188", "11_114", "11_31", "10_11", "15_64", "10_2", "10_91", "11_132", "7_49", "11_100"], + "set":[0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] }, { - "name": "Open", - "code": "open", - "sites": "SHADOWS", - "restricted": ["1_248","7_49","10_2","10_91","11_100","11_132"], - "set": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] + "name":"Open", + "code":"open", + "sites":"SHADOWS", + "restricted":["1_248", "7_49", "10_2", "10_91", "11_100", "11_132"], + "set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] }, { - "name": "Expanded", - "code": "expanded", - "sites": "SHADOWS", - "banned": ["1_45","1_138","1_234","1_311","1_313","1_316","2_121","3_17","3_38","3_42","3_67","3_68","3_108","3_113","4_73","7_49","8_1","10_2","10_11","10_91","11_31","11_100","11_132"], - "restricted": ["1_40","1_80","1_108","1_139","1_195","1_248","2_32","2_75","3_106","4_276","4_304"], - "set": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] + "name":"Expanded", + "code":"expanded", + "sites":"SHADOWS", + "banned":["1_45", "1_138", "1_234", "1_311", "1_313", "1_316", "2_121", "3_17", "3_38", "3_42", "3_67", "3_68", "3_108", "3_113", "4_73", "7_49", "8_1", "10_2", "10_11", "10_91", "11_31", "11_100", "11_132"], + "restricted":["1_40", "1_80", "1_108", "1_139", "1_195", "1_248", "2_32", "2_75", "3_106", "4_276", "4_304"], + "set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] + }, + { + "name":"Limited", + "code":"limited_fotr", + "sites":"FELLOWSHIP", + "cancelRingBearerSkirmish":true, + "set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], + "hall":false + }, + { + "name":"Limited", + "code":"limited_ttt", + "sites":"TWO_TOWERS", + "cancelRingBearerSkirmish":true, + "set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], + "hall":false + }, + { + "name":"Limited", + "code":"limited_king", + "sites":"KING", + "cancelRingBearerSkirmish":true, + "set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], + "hall":false + }, + { + "name":"Limited", + "code":"limited_shadows", + "sites":"SHADOWS", + "cancelRingBearerSkirmish":true, + "set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], + "hall":false } ] \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java index 47e79794e..a2baf2c05 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java @@ -9,7 +9,7 @@ public class LeaguePrizesTest { @Test public void test() { LeaguePrizes leaguePrizes = new NewLeaguePrizes(); - CardCollection prize = leaguePrizes.getPrizeForLeagueMatchWinner(2, 2, "fotr_block"); + CardCollection prize = leaguePrizes.getPrizeForLeagueMatchWinner(2, 2); for (Map.Entry stringIntegerEntry : prize.getAll().entrySet()) { System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue()); } @@ -18,7 +18,7 @@ public class LeaguePrizesTest { @Test public void testLeaguePrize() { LeaguePrizes leaguePrizes = new NewLeaguePrizes(); - CardCollection prize = leaguePrizes.getPrizeForLeague(1, 100, 2f, "fotr_block"); + CardCollection prize = leaguePrizes.getPrizeForLeague(1, 100, 2f); for (Map.Entry stringIntegerEntry : prize.getAll().entrySet()) { System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue()); }