GUI: deck legality improves:

* Added partly valid status for deck legality panel (if all cards are fine but user must add more cards to complete, see #6854);
 * Improved legality errors sorting (important errors visible at the top now, e.g. commander's errors);
This commit is contained in:
Oleg Agafonov 2020-08-03 02:03:54 +04:00
parent 9dfc6eed69
commit e95b9f145c
20 changed files with 335 additions and 201 deletions

View file

@ -2,6 +2,7 @@ package mage.deck;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckValidator;
import mage.cards.decks.DeckValidatorErrorType;
import java.util.HashMap;
import java.util.Map;
@ -28,17 +29,17 @@ public class Limited extends DeckValidator {
@Override
public boolean validate(Deck deck) {
boolean valid = true;
invalid.clear();
errorsList.clear();
//20091005 - 100.2b
if (deck.getCards().size() < getDeckMinSize()) {
invalid.put("Deck", "Must contain at least " + getDeckMinSize() + " cards: has only " + deck.getCards().size() + " cards");
addError(DeckValidatorErrorType.DECK_SIZE, "Deck", "Must contain at least " + getDeckMinSize() + " cards: has only " + deck.getCards().size() + " cards");
valid = false;
}
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}