- Corrected the deck validation rules, including added restricted cards by name (Bilbo, Gandalf).

This commit is contained in:
marcin.sciesinski
2017-11-13 12:47:31 -08:00
parent 1d38a8c592
commit 5b17a6e3fe
6 changed files with 72 additions and 33 deletions

View File

@@ -367,10 +367,23 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri
appendCards(result, limit3Cards);
result.append("</li>");
}
result.append("<li>Additional valid: ");
List<String> additionalValidCards = lotroFormat.getValidCards();
appendCards(result, additionalValidCards);
result.append("</li>");
if (lotroFormat.getRestrictedCardNames().size() > 0) {
result.append("<li>Restricted by card name: ");
boolean first = true;
for (String cardName : lotroFormat.getRestrictedCardNames()) {
if (!first)
result.append(", ");
result.append(cardName);
first = false;
}
result.append("</li>");
}
if (lotroFormat.getValidCards().size() > 0) {
result.append("<li>Additional valid: ");
List<String> additionalValidCards = lotroFormat.getValidCards();
appendCards(result, additionalValidCards);
result.append("</li>");
}
result.append("</ul>");
}

View File

@@ -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).
<b>17 Dec. 2015</b>
- "Armor of Khazad" no longer allows to return itself from discard and can now be transferred.

View File

@@ -36,6 +36,8 @@ public interface LotroFormat {
public List<String> getLimit3Cards();
public List<String> getRestrictedCardNames();
public Block getSiteBlock();
public String getSurveyUrl();

View File

@@ -38,6 +38,7 @@ public class DefaultLotroFormat implements LotroFormat {
private List<String> _restrictedCards = new ArrayList<String>();
private List<String> _validCards = new ArrayList<String>();
private List<Integer> _validSets = new ArrayList<Integer>();
private List<String> _restrictedCardNames = new ArrayList<String>();
private String _surveyUrl;
//Additional Hobbit Draft parameters
@@ -119,6 +120,11 @@ public class DefaultLotroFormat implements LotroFormat {
return Collections.unmodifiableList(_restrictedCards);
}
@Override
public List<String> getRestrictedCardNames() {
return Collections.unmodifiableList(_restrictedCardNames);
}
@Override
public List<String> 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<String, Integer> 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) {

View File

@@ -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");

View File

@@ -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
}
]