From e3f5b2e670fe8f76fd4616f3306965b70b3a2e71 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Mon, 21 Nov 2011 17:11:52 +0000 Subject: [PATCH] Validation of decks with Shadow+ sites. --- .../game/formats/DefaultLotroFormat.java | 21 +++++++++++++++++++ 1 file changed, 21 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 dea21836e..fd343a744 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 @@ -115,6 +115,27 @@ public abstract class DefaultLotroFormat implements LotroFormat { throw new DeckInvalidException("Deck has multiple of the same site number: " + blueprint.getSiteNumber()); sites[blueprint.getSiteNumber() - 1] = true; } + } else { + Set siteBlueprints = new HashSet(); + for (String site : deck.getSites()) + siteBlueprints.add(_library.getLotroCardBlueprint(site)); + + if (siteBlueprints.size() < 9) + throw new DeckInvalidException("Deck contains multiple of the same site"); + + Map twilightCount = new HashMap(); + for (LotroCardBlueprint siteBlueprint : siteBlueprints) { + int twilight = siteBlueprint.getTwilightCost(); + Integer count = twilightCount.get(twilight); + if (count == null) + count = 0; + twilightCount.put(twilight, count + 1); + } + + for (Map.Entry twilightCountEntry : twilightCount.entrySet()) { + if (twilightCountEntry.getValue() > 3) + throw new DeckInvalidException("Deck contains " + twilightCountEntry.getValue() + " sites with twilight number of " + twilightCountEntry.getKey()); + } } // Deck