- Added support for the Pre-shadow Multipath format.

This commit is contained in:
marcins78@gmail.com
2012-08-28 19:22:52 +00:00
parent 2f34e56563
commit ef1c5a7d0e
7 changed files with 66 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
package com.gempukku.lotro.common;
public enum Block {
FELLOWSHIP("Fellowship"), TWO_TOWERS("Towers"), KING("King"), SHADOWS("Shadows and onwards");
FELLOWSHIP("Fellowship"), TWO_TOWERS("Towers"), KING("King"), SHADOWS("Shadows and onwards"), SPECIAL("Special");
private String _humanReadable;

View File

@@ -22,5 +22,7 @@ public interface LotroFormat {
public List<String> getRestrictedCards();
public List<String> getValidCards();
public Block getSiteBlock();
}

View File

@@ -24,6 +24,7 @@ public class DefaultLotroFormat implements LotroFormat {
private int _minimumDeckSize = 60;
private List<String> _bannedCards = new ArrayList<String>();
private List<String> _restrictedCards = new ArrayList<String>();
private List<String> _validCards = new ArrayList<String>();
private List<Integer> _validSets = new ArrayList<Integer>();
public DefaultLotroFormat(LotroCardBlueprintLibrary library, String name, Block siteBlock, boolean validateShadowFPCount, int minimumDeckSize, int maximumSameName, boolean mulliganRule, boolean canCancelRingBearerSkirmish) {
@@ -72,6 +73,11 @@ public class DefaultLotroFormat implements LotroFormat {
return Collections.unmodifiableList(_restrictedCards);
}
@Override
public List<String> getValidCards() {
return Collections.unmodifiableList(_validCards);
}
@Override
public Block getSiteBlock() {
return _siteBlock;
@@ -101,12 +107,26 @@ public class DefaultLotroFormat implements LotroFormat {
_restrictedCards.add(baseBlueprintId);
}
protected void addValidCard(String baseBlueprintId) {
if (baseBlueprintId.contains("-")) {
String[] parts = baseBlueprintId.split("_");
String set = parts[0];
int from = Integer.parseInt(parts[1].split("-")[0]);
int to = Integer.parseInt(parts[1].split("-")[1]);
for (int i = from; i <= to; i++)
_validCards.add(set + "_" + i);
} else
_validCards.add(baseBlueprintId);
}
protected void addValidSet(int setNo) {
_validSets.add(setNo);
}
private void validateSet(String blueprintId) throws DeckInvalidException {
blueprintId = _library.getBaseBlueprintId(blueprintId);
if (_validCards.contains(blueprintId))
return;
for (int validSet : _validSets)
if (blueprintId.startsWith(validSet + "_")
|| _library.hasAlternateInSet(blueprintId, validSet))
@@ -141,8 +161,21 @@ public class DefaultLotroFormat implements LotroFormat {
LotroCardBlueprint siteBlueprint = _library.getLotroCardBlueprint(site);
if (siteBlueprint.getCardType() != CardType.SITE)
throw new DeckInvalidException("Card assigned as Site is not really a site");
if (siteBlueprint.getSiteBlock() != _siteBlock)
if (siteBlueprint.getSiteBlock() != _siteBlock && _siteBlock != Block.SPECIAL)
throw new DeckInvalidException("Invalid site: " + GameUtils.getFullName(siteBlueprint));
if (_siteBlock == Block.SPECIAL && siteBlueprint.getSiteBlock() == Block.SHADOWS)
throw new DeckInvalidException("Invalid site: " + GameUtils.getFullName(siteBlueprint));
}
if (_siteBlock == Block.SPECIAL) {
Block usedBlock = null;
for (String site : deck.getSites()) {
LotroCardBlueprint siteBlueprint = _library.getLotroCardBlueprint(site);
Block block = siteBlueprint.getSiteBlock();
if (usedBlock == null)
usedBlock = block;
else if (usedBlock != block)
throw new DeckInvalidException("All your sites have to be from the same block");
}
}
if (_validSets.size() > 0) {

View File

@@ -52,6 +52,12 @@ public class LotroFormatLibrary {
format.addRestrictedCard((String) restricted);
}
JSONArray validCards = (JSONArray) formatDef.get("valid");
if (validCards != null)
for (Object valid : validCards) {
format.addValidCard((String) valid);
}
_allFormats.put(formatCode, format);
Boolean hallFormat = (Boolean) formatDef.get("hall");

View File

@@ -222,5 +222,13 @@
"restricted":["11_132", "11_100"],
"set":[10, 11, 12, 13, 14],
"hall":false
},
{
"name":"Pre-Shadows Multipath",
"code":"multipath",
"sites":"SPECIAL",
"banned":["8_1", "3_38", "3_106", "1_40", "2_32", "1_248", "3_108", "1_45", "10_11", "7_96", "3_42", "4_73", "10_2", "10_91", "1_108", "1_80", "3_67", "1_195", "1_311", "3_68", "1_139", "7_49", "1_313", "1_234"],
"valid":["0_56-60"],
"set":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
]

View File

@@ -68,6 +68,12 @@ public class HallResource extends AbstractResource {
if (lotroFormat.getRestrictedCards().size() == 0)
result.append("none,");
result.append("</li>");
result.append("<li>Additional valid: ");
for (String blueprintId : lotroFormat.getValidCards())
result.append(GameUtils.getCardLink(blueprintId, _library.getLotroCardBlueprint(blueprintId)) + ", ");
if (lotroFormat.getValidCards().size() == 0)
result.append("none,");
result.append("</li>");
result.append("</ul>");
}
@@ -105,6 +111,12 @@ public class HallResource extends AbstractResource {
if (lotroFormat.getRestrictedCards().size() == 0)
result.append("none,");
result.append("</li>");
result.append("<li>Additional valid: ");
for (String blueprintId : lotroFormat.getValidCards())
result.append(GameUtils.getCardLink(blueprintId, _library.getLotroCardBlueprint(blueprintId)) + ", ");
if (lotroFormat.getValidCards().size() == 0)
result.append("none,");
result.append("</li>");
result.append("</ul>");
return result.toString();

View File

@@ -1,4 +1,7 @@
<pre style="font-size:80%">
<b>28 Aug. 2012</b>
- Added support for the Pre-shadow Multipath format.
<b>11 Aug. 2012</b>
- "Watch and Wait" can't be attached to Ring-bearer anymore.