mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
GUI: added problem cards selection on legality label clicks (#6854)
This commit is contained in:
parent
a4af5501f9
commit
486c0d7c2c
17 changed files with 167 additions and 105 deletions
|
|
@ -77,7 +77,7 @@ public class Constructed extends DeckValidator {
|
|||
|
||||
for (String bannedCard : banned) {
|
||||
if (counts.containsKey(bannedCard)) {
|
||||
addError(DeckValidatorErrorType.BANNED, "Banned", bannedCard);
|
||||
addError(DeckValidatorErrorType.BANNED, bannedCard, "Banned", true);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public class Constructed extends DeckValidator {
|
|||
if (counts.containsKey(restrictedCard)) {
|
||||
int count = counts.get(restrictedCard);
|
||||
if (count > 1) {
|
||||
addError(DeckValidatorErrorType.OTHER, restrictedCard, "Restricted amount: " + count);
|
||||
addError(DeckValidatorErrorType.OTHER, restrictedCard, "Restricted amount: " + count, true);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ public class Constructed extends DeckValidator {
|
|||
}
|
||||
}
|
||||
if (!legal && !errorsListContainsGroup(card.getName())) {
|
||||
addError(DeckValidatorErrorType.OTHER, card.getName(), "Invalid rarity: " + card.getRarity());
|
||||
addError(DeckValidatorErrorType.OTHER, card.getName(), "Invalid rarity: " + card.getRarity(), true);
|
||||
}
|
||||
return legal;
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ public class Constructed extends DeckValidator {
|
|||
}
|
||||
|
||||
if (!legal && !errorsListContainsGroup(card.getName())) {
|
||||
addError(DeckValidatorErrorType.WRONG_SET, card.getName(), "Invalid set: " + card.getExpansionSetCode());
|
||||
addError(DeckValidatorErrorType.WRONG_SET, card.getName(), "Invalid set: " + card.getExpansionSetCode(), true);
|
||||
}
|
||||
return legal;
|
||||
}
|
||||
|
|
@ -192,11 +192,11 @@ public class Constructed extends DeckValidator {
|
|||
if (entry.getValue() > maxCopies
|
||||
&& !basicLandNames.contains(entry.getKey())
|
||||
&& !anyNumberCardsAllowed.contains(entry.getKey())) {
|
||||
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue());
|
||||
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
|
||||
valid = false;
|
||||
}
|
||||
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) {
|
||||
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue());
|
||||
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public abstract class DeckValidator implements Serializable {
|
|||
int otherErrorsCount = list.size() - maxErrors;
|
||||
list = list.stream().limit(maxErrors).collect(Collectors.toList());
|
||||
list.add(new DeckValidatorError(DeckValidatorErrorType.OTHER, "...",
|
||||
"and more " + otherErrorsCount + " error" + (otherErrorsCount > 1 ? "s" : "")));
|
||||
"and more " + otherErrorsCount + " error" + (otherErrorsCount > 1 ? "s" : ""), null));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
@ -106,8 +106,19 @@ public abstract class DeckValidator implements Serializable {
|
|||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isCardError group contains card name that can be selected as wrong card
|
||||
*/
|
||||
public void addError(DeckValidatorErrorType errorType, String group, String message, boolean isCardError) {
|
||||
addError(errorType, group, message, (isCardError ? group : null));
|
||||
}
|
||||
|
||||
public void addError(DeckValidatorErrorType errorType, String group, String message) {
|
||||
this.errorsList.add(new DeckValidatorError(errorType, group, message));
|
||||
addError(errorType, group, message, null);
|
||||
}
|
||||
|
||||
private void addError(DeckValidatorErrorType errorType, String group, String message, String cardName) {
|
||||
this.errorsList.add(new DeckValidatorError(errorType, group, message, cardName));
|
||||
}
|
||||
|
||||
public boolean errorsListContainsGroup(String group) {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ public class DeckValidatorError {
|
|||
private final DeckValidatorErrorType errorType;
|
||||
private final String group;
|
||||
private final String message;
|
||||
private final String cardName;
|
||||
|
||||
public DeckValidatorError(DeckValidatorErrorType errorType, String group, String message) {
|
||||
public DeckValidatorError(DeckValidatorErrorType errorType, String group, String message, String cardName) {
|
||||
this.errorType = errorType;
|
||||
this.group = group;
|
||||
this.message = message;
|
||||
this.cardName = cardName;
|
||||
}
|
||||
|
||||
public DeckValidatorErrorType getErrorType() {
|
||||
|
|
@ -26,4 +28,8 @@ public class DeckValidatorError {
|
|||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public String getCardName() {
|
||||
return this.cardName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue