diff --git a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java index b3be26f4f..09313153f 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java +++ b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java @@ -367,10 +367,23 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri appendCards(result, limit3Cards); result.append(""); } - result.append("
  • Additional valid: "); - List additionalValidCards = lotroFormat.getValidCards(); - appendCards(result, additionalValidCards); - result.append("
  • "); + if (lotroFormat.getRestrictedCardNames().size() > 0) { + result.append("
  • Restricted by card name: "); + boolean first = true; + for (String cardName : lotroFormat.getRestrictedCardNames()) { + if (!first) + result.append(", "); + result.append(cardName); + first = false; + } + result.append("
  • "); + } + if (lotroFormat.getValidCards().size() > 0) { + result.append("
  • Additional valid: "); + List additionalValidCards = lotroFormat.getValidCards(); + appendCards(result, additionalValidCards); + result.append("
  • "); + } result.append(""); } diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/includes/changeLog.html b/gemp-lotr/gemp-lotr-async/src/main/web/includes/changeLog.html index 7f6b6b367..56d7fecc3 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/includes/changeLog.html +++ b/gemp-lotr/gemp-lotr-async/src/main/web/includes/changeLog.html @@ -14,6 +14,7 @@ (previous change). - "Gandalf, Friend of Thorin" now works according to the card image's text. - "Smaug's Den" now points to a correct image address. +- Corrected the deck validation rules, including added restricted cards by name (Bilbo, Gandalf). 17 Dec. 2015 - "Armor of Khazad" no longer allows to return itself from discard and can now be transferred. diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/LotroFormat.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/LotroFormat.java index c1db28ffc..124792402 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/LotroFormat.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/LotroFormat.java @@ -36,6 +36,8 @@ public interface LotroFormat { public List getLimit3Cards(); + public List getRestrictedCardNames(); + public Block getSiteBlock(); public String getSurveyUrl(); diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/DefaultLotroFormat.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/DefaultLotroFormat.java index a10173d32..333333256 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/DefaultLotroFormat.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/DefaultLotroFormat.java @@ -38,6 +38,7 @@ public class DefaultLotroFormat implements LotroFormat { private List _restrictedCards = new ArrayList(); private List _validCards = new ArrayList(); private List _validSets = new ArrayList(); + private List _restrictedCardNames = new ArrayList(); private String _surveyUrl; //Additional Hobbit Draft parameters @@ -119,6 +120,11 @@ public class DefaultLotroFormat implements LotroFormat { return Collections.unmodifiableList(_restrictedCards); } + @Override + public List getRestrictedCardNames() { + return Collections.unmodifiableList(_restrictedCardNames); + } + @Override public List getValidCards() { return Collections.unmodifiableList(_validCards); @@ -150,7 +156,7 @@ public class DefaultLotroFormat implements LotroFormat { return 8; } - protected void addBannedCard(String baseBlueprintId) { + public void addBannedCard(String baseBlueprintId) { if (baseBlueprintId.contains("-")) { String[] parts = baseBlueprintId.split("_"); String set = parts[0]; @@ -162,7 +168,7 @@ public class DefaultLotroFormat implements LotroFormat { _bannedCards.add(baseBlueprintId); } - protected void addRestrictedCard(String baseBlueprintId) { + public void addRestrictedCard(String baseBlueprintId) { if (baseBlueprintId.contains("-")) { String[] parts = baseBlueprintId.split("_"); String set = parts[0]; @@ -174,7 +180,7 @@ public class DefaultLotroFormat implements LotroFormat { _restrictedCards.add(baseBlueprintId); } - protected void addValidCard(String baseBlueprintId) { + public void addValidCard(String baseBlueprintId) { if (baseBlueprintId.contains("-")) { String[] parts = baseBlueprintId.split("_"); String set = parts[0]; @@ -186,19 +192,23 @@ public class DefaultLotroFormat implements LotroFormat { _validCards.add(baseBlueprintId); } - protected void addValidSet(int setNo) { + public void addValidSet(int setNo) { _validSets.add(setNo); } //Additional Hobbit Draft card lists - protected void addLimit2Card(String baseBlueprintId) { + public void addLimit2Card(String baseBlueprintId) { _limit2Cards.add(baseBlueprintId); } - protected void addLimit3Card(String baseBlueprintId) { + public void addLimit3Card(String baseBlueprintId) { _limit3Cards.add(baseBlueprintId); } + public void addRestrictedCardName(String cardName) { + _restrictedCardNames.add(cardName); + } + @Override public void validateCard(String blueprintId) throws DeckInvalidException { blueprintId = _library.getBaseBlueprintId(blueprintId); @@ -268,7 +278,7 @@ public class DefaultLotroFormat implements LotroFormat { for (Map.Entry count : cardCountByName.entrySet()) { if (count.getValue() > _maximumSameName) - throw new DeckInvalidException("Deck contains more of the same card than allowed (" + count.getValue() + ">" + _maximumSameName + "): " + count.getKey()); + throw new DeckInvalidException("Deck contains more of the same card than allowed - " + count.getKey() + " (" + count.getValue() + ">" + _maximumSameName + "): " + count.getKey()); } // Restricted cards @@ -278,19 +288,24 @@ public class DefaultLotroFormat implements LotroFormat { throw new DeckInvalidException("Deck contains more than one copy of an R-listed card: " + GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId))); } - //Additional Hobbit Draft restrictions - if (_siteBlock == Block.HOBBIT) { - for (String blueprintId : _limit2Cards) { - Integer count = cardCountByBaseBlueprintId.get(blueprintId); - if (count != null && count > 2) - throw new DeckInvalidException("Deck contains more than two copies of a 2x limited card: " + GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId))); - } - for (String blueprintId : _limit3Cards) { - Integer count = cardCountByBaseBlueprintId.get(blueprintId); - if (count != null && count > 3) - throw new DeckInvalidException("Deck contains more than three copies of a 3x limited card: " + GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId))); - } + // New Hobbit Draft restrictions + for (String blueprintId : _limit2Cards) { + Integer count = cardCountByBaseBlueprintId.get(blueprintId); + if (count != null && count > 2) + throw new DeckInvalidException("Deck contains more than two copies of a 2x limited card: " + GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId))); } + for (String blueprintId : _limit3Cards) { + Integer count = cardCountByBaseBlueprintId.get(blueprintId); + if (count != null && count > 3) + throw new DeckInvalidException("Deck contains more than three copies of a 3x limited card: " + GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId))); + } + + for (String restrictedCardName : _restrictedCardNames) { + Integer count = cardCountByName.get(restrictedCardName); + if (count != null && count > 1) + throw new DeckInvalidException("Deck contains more than one copy of a card restricted by name: " + restrictedCardName); + } + } catch (CardNotFoundException exp) { throw new DeckInvalidException("Deck contains card removed from the set"); } catch (IllegalArgumentException exp) { diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java index e01cdc2cb..c060c8dc6 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java @@ -71,20 +71,27 @@ public class LotroFormatLibrary { for (Object valid : validCards) { format.addValidCard((String) valid); } - + //Additional Hobbit Draft deck restrictions JSONArray limit2Cards = (JSONArray) formatDef.get("limit2"); if (limit2Cards != null) for (Object limit2 : limit2Cards) { format.addLimit2Card((String) limit2); } - + JSONArray limit3Cards = (JSONArray) formatDef.get("limit3"); if (limit3Cards != null) for (Object limit3 : limit3Cards) { - format.addLimit2Card((String) limit3); + format.addLimit3Card((String) limit3); } + JSONArray restrictedCardNames = (JSONArray) formatDef.get("restrictedName"); + if (restrictedCardNames != null) { + for (Object restrictedCardName : restrictedCardNames) { + format.addRestrictedCardName((String) restrictedCardName); + } + } + _allFormats.put(formatCode, format); Boolean hallFormat = (Boolean) formatDef.get("hall"); 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 6bf96c4fa..778f31fe8 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json +++ b/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json @@ -313,14 +313,15 @@ "hall":true }, { - "name":"Hobbit: The Short Rest", - "code":"hobbit_tsr", - "sites":"HOBBIT", + "name":"Hobbit: The Short Rest", + "code":"hobbit_tsr", + "sites":"HOBBIT", "cancelRingBearerSkirmish":true, - "restricted":["30_2", "30_22", "30_5", "30_43", "30_44", "30_45", "30_46", "30_6", "30_7", "30_8", "30_9", "30_21", "30_10", "30_25", "30_26", "30_27", "30_28", "30_29", "30_11", "30_12", "30_15", "30_16", "30_17", "30_18", "30_58", "30_47", "30_48", "30_19", "31_1", "31_4", "31_6", "31_8", "31_9", "31_10", "31_15", "31_24", "31_34", "31_36", "31_39", "31_58", "31_62", "31_65"], - "limit2":["30_33", "30_34", "30_36", "30_37", "30_38", "30_41", "31_13", "31_14", "31_16", "31_29", "31_40", "31_43", "31_56"], - "limit3":["30_23", "30_1", "30_3", "30_4", "30_24", "30_30", "30_13", "30_14", "30_31", "30_20", "30_32", "30_39", "30_40", "31_2", "31_3", "31_5", "31_7", "31_11", "31_12", "31_17", "31_18", "31_19", "31_20", "31_21", "31_22", "31_23", "31_25", "31_26", "31_27", "31_28", "31_30", "31_31", "31_32", "31_33", "31_35", "31_37", "31_38", "31_41", "31_42", "31_47", "31_57", "31_59", "31_60", "31_61", "31_63", "31_64", "31_66", "31_67", "31_68", "31_69"], - "set":[30, 31], + "restricted":["30_2", "30_22", "30_5", "30_43", "30_44", "30_45", "30_46", "30_6", "30_7", "30_8", "30_9", "30_21", "30_10", "30_25", "30_26", "30_27", "30_28", "30_29", "30_11", "30_12", "30_15", "30_16", "30_17", "30_18", "30_58", "30_47", "30_48", "30_19", "31_1", "31_4", "31_6", "31_8", "31_9", "31_10", "31_15", "31_24", "31_34", "31_36", "31_39", "31_58", "31_62", "31_65"], + "limit2":["30_33", "30_34", "30_36", "30_37", "30_38", "30_41", "31_13", "31_14", "31_16", "31_29", "31_40", "31_43", "31_56"], + "limit3":["30_23", "30_1", "30_3", "30_4", "30_24", "30_30", "30_13", "30_14", "30_31", "30_20", "30_32", "30_39", "30_40", "31_2", "31_3", "31_5", "31_7", "31_11", "31_12", "31_17", "31_18", "31_19", "31_20", "31_21", "31_22", "31_23", "31_25", "31_26", "31_27", "31_28", "31_30", "31_31", "31_32", "31_33", "31_35", "31_37", "31_38", "31_41", "31_42", "31_47", "31_57", "31_59", "31_60", "31_61", "31_63", "31_64", "31_66", "31_67", "31_68", "31_69"], + "set":[30, 31], + "restrictedName":["Gandalf", "Bilbo"], "hall":true } ]