From 0ae031b1c9b2b305582fca7b3d58a3c3282e9d49 Mon Sep 17 00:00:00 2001 From: PhallenCassidy Date: Sat, 8 Oct 2016 20:41:00 -0400 Subject: [PATCH] Added Hobbit card number limiters, exception for One Ring --- .../game/formats/DefaultLotroFormat.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) 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 2e3e91c1f..a6b10c681 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 @@ -39,6 +39,10 @@ public class DefaultLotroFormat implements LotroFormat { private List _validCards = new ArrayList(); private List _validSets = new ArrayList(); private String _surveyUrl; + + //Additional Hobbit Draft parameters + private List _limit2Cards = new ArrayList(); + private List _limit3Cards = new ArrayList(); public DefaultLotroFormat(Adventure adventure, LotroCardBlueprintLibrary library, String name, String surveyUrl, @@ -120,6 +124,17 @@ public class DefaultLotroFormat implements LotroFormat { return Collections.unmodifiableList(_validCards); } + //Additional Hobbit Draft parameters + @Override + public List getLimit2Cards() { + return Collections.unmodifiableList(_limit2Cards); + } + + @Override + public List getLimit3Cards() { + return Collections.unmodifiableList(_limit3Cards); + } + @Override public Block getSiteBlock() { return _siteBlock; @@ -174,6 +189,14 @@ public class DefaultLotroFormat implements LotroFormat { protected void addValidSet(int setNo) { _validSets.add(setNo); } + + //Additional Hobbit Draft card lists + protected void addLimit2Card(String baseBlueprintId) { + _limit2Cards.add(baseBlueprintId); + } + protected void addLimit3Card(String baseBlueprintId) { + _limit3Cards.add(baseBlueprintId); + } @Override public void validateCard(String blueprintId) throws DeckInvalidException { @@ -251,6 +274,20 @@ public class DefaultLotroFormat implements LotroFormat { if (count != null && count > 1) 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 == 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))); + } + } } catch (CardNotFoundException exp) { throw new DeckInvalidException("Deck contains card removed from the set"); } catch (IllegalArgumentException exp) { @@ -340,7 +377,11 @@ public class DefaultLotroFormat implements LotroFormat { private void validateRing(LotroDeck deck) throws DeckInvalidException, CardNotFoundException { if (deck.getRing() == null) + //Additional Hobbit Draft exception + if (_siteBlock == Block.HOBBIT) { + } else { throw new DeckInvalidException("Deck doesn't have a Ring"); + } LotroCardBlueprint ring = _library.getLotroCardBlueprint(deck.getRing()); if (ring.getCardType() != CardType.THE_ONE_RING) throw new DeckInvalidException("Card assigned as Ring is not The One Ring");