Validation of decks with Shadow+ sites.

This commit is contained in:
marcins78@gmail.com
2011-11-21 17:11:52 +00:00
parent 4ad9187a56
commit e3f5b2e670

View File

@@ -115,6 +115,27 @@ public abstract class DefaultLotroFormat implements LotroFormat {
throw new DeckInvalidException("Deck has multiple of the same site number: " + blueprint.getSiteNumber()); throw new DeckInvalidException("Deck has multiple of the same site number: " + blueprint.getSiteNumber());
sites[blueprint.getSiteNumber() - 1] = true; sites[blueprint.getSiteNumber() - 1] = true;
} }
} else {
Set<LotroCardBlueprint> siteBlueprints = new HashSet<LotroCardBlueprint>();
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<Integer, Integer> twilightCount = new HashMap<Integer, Integer>();
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<Integer, Integer> twilightCountEntry : twilightCount.entrySet()) {
if (twilightCountEntry.getValue() > 3)
throw new DeckInvalidException("Deck contains " + twilightCountEntry.getValue() + " sites with twilight number of " + twilightCountEntry.getKey());
}
} }
// Deck // Deck