* Allow more than 4 Wastes land in constructed decks (fixes #1454).

This commit is contained in:
LevelX2 2016-01-11 00:00:21 +01:00
parent d8128d3741
commit 4eb9719769
4 changed files with 71 additions and 70 deletions

View file

@ -46,8 +46,8 @@ import mage.util.CardUtil;
*/
public class Commander extends DeckValidator {
protected List<String> banned = new ArrayList<>();
protected List<String> bannedCommander = new ArrayList<>();
protected List<String> banned = new ArrayList<>();
protected List<String> bannedCommander = new ArrayList<>();
public Commander() {
this("Commander");
@ -103,7 +103,7 @@ public class Commander extends DeckValidator {
valid = false;
}
List<String> basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains",
List<String> basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains", "Wastes",
"Snow-Covered Forest", "Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains"));
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
@ -130,22 +130,22 @@ public class Commander extends DeckValidator {
invalid.put("Commander", "Commander invalid ");
return false;
}
if ((commander.getCardType().contains(CardType.CREATURE) && commander.getSupertype().contains("Legendary")) ||
(commander.getCardType().contains(CardType.PLANESWALKER) && commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
if ((commander.getCardType().contains(CardType.CREATURE) && commander.getSupertype().contains("Legendary"))
|| (commander.getCardType().contains(CardType.PLANESWALKER) && commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
if (!bannedCommander.contains(commander.getName())) {
FilterMana color = CardUtil.getColorIdentity(commander);
for (Card card : deck.getCards()) {
if (!cardHasValidColor(color, card)) {
invalid.put(card.getName(), "Invalid color (" + commander.getName() +")");
invalid.put(card.getName(), "Invalid color (" + commander.getName() + ")");
valid = false;
}
}
} else {
invalid.put("Commander", "Commander banned (" + commander.getName() +")");
invalid.put("Commander", "Commander banned (" + commander.getName() + ")");
valid = false;
}
} else {
invalid.put("Commander", "Commander invalid (" + commander.getName() +")");
invalid.put("Commander", "Commander invalid (" + commander.getName() + ")");
valid = false;
}
} else {

View file

@ -27,12 +27,13 @@
*/
package mage.deck;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckValidator;
import java.util.*;
/**
*
* @author nigelzor

View file

@ -120,7 +120,7 @@ public class TinyLeaders extends DeckValidator {
valid = false;
}
List<String> basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains",
List<String> basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains", "Wastes",
"Snow-Covered Forest", "Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains"));
Map<String, Integer> counts = new HashMap<>();
counts.put(deck.getName(), 1); // add the commander to the counts, so it can't be in the deck or sideboard again
@ -145,19 +145,20 @@ public class TinyLeaders extends DeckValidator {
if (deck.getSideboard().size() <= 10) {
Card commander = GameTinyLeadersImpl.getCommanderCard(deck.getName(), null);
/**
* 905.5b - Each card must have a converted mana cost of three of less.
* Cards with {X} in their mana cost count X as zero.
* Split and double-face cards are legal only if both of their halves would be legal independently.
* 905.5b - Each card must have a converted mana cost of three of
* less. Cards with {X} in their mana cost count X as zero. Split
* and double-face cards are legal only if both of their halves
* would be legal independently.
*/
if (commander == null || commander.getManaCost().convertedManaCost() > 3) {
if (commander == null || commander.getManaCost().convertedManaCost() > 3) {
if (commander == null) {
if (deck.getName() == null) {
invalid.put("Leader", "You have to save your deck with the leader card name entered to the DECK NAME field of the DECK EDITOR (top left) so that XMage knows your leader." +
"(You can use the \"Sultai\" for a UBG (2/2) default Commander.)");
invalid.put("Leader", "You have to save your deck with the leader card name entered to the DECK NAME field of the DECK EDITOR (top left) so that XMage knows your leader."
+ "(You can use the \"Sultai\" for a UBG (2/2) default Commander.)");
} else {
invalid.put("Leader", "Leader [" + deck.getName() + "] not found. You have to enter the name of the leader card into the DECK NAME field of the DECK EDITOR (top left). Check your spelling " +
"(use the \"Sultai\" for a UBG (2/2) default Commander)");
invalid.put("Leader", "Leader [" + deck.getName() + "] not found. You have to enter the name of the leader card into the DECK NAME field of the DECK EDITOR (top left). Check your spelling "
+ "(use the \"Sultai\" for a UBG (2/2) default Commander)");
}
}
@ -172,12 +173,12 @@ public class TinyLeaders extends DeckValidator {
FilterMana color = CardUtil.getColorIdentity(commander);
for (Card card : deck.getCards()) {
if (!isCardFormatValid(card, commander, color)) {
valid = false;
valid = false;
}
}
for (Card card : deck.getSideboard()) {
if (!isCardFormatValid(card, commander, color)) {
valid = false;
valid = false;
}
}
} else {
@ -204,14 +205,14 @@ public class TinyLeaders extends DeckValidator {
//905.5b - Converted mana cost must be 3 or less
if (card instanceof SplitCard) {
if (((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() > 3) {
if (((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() > 3) {
invalid.put(card.getName(), "Invalid cost (" + ((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() + ")");
return false;
return false;
}
if (((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() > 3 ) {
if (((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() > 3) {
invalid.put(card.getName(), "Invalid cost (" + ((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() + ")");
return false;
}
return false;
}
} else {
if (card.getManaCost().convertedManaCost() > 3) {
invalid.put(card.getName(), "Invalid cost (" + card.getManaCost().convertedManaCost() + ")");
@ -220,7 +221,7 @@ public class TinyLeaders extends DeckValidator {
}
return true;
}
/**
*
* @param commander FilterMana object with Color Identity of Commander set

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.decks;
import java.util.ArrayList;
@ -47,7 +46,7 @@ import org.apache.log4j.Logger;
public class Constructed extends DeckValidator {
private static final Logger logger = Logger.getLogger(DeckValidator.class);
protected List<String> banned = new ArrayList<>();
protected List<String> restricted = new ArrayList<>();
protected List<String> setCodes = new ArrayList<>();
@ -63,7 +62,7 @@ public class Constructed extends DeckValidator {
@Override
public boolean validate(Deck deck) {
logger.debug("DECK validate start: " + name + " deckname: " + deck.getName() );
logger.debug("DECK validate start: " + name + " deckname: " + deck.getName());
boolean valid = true;
//20091005 - 100.2a
if (deck.getCards().size() < 60) {
@ -76,12 +75,12 @@ public class Constructed extends DeckValidator {
valid = false;
}
List<String> basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains",
"Snow-Covered Forest", "Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains"));
List<String> basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains", "Wastes",
"Snow-Covered Forest", "Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains"));
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Entry<String, Integer> entry: counts.entrySet()) {
for (Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 4) {
if (!basicLandNames.contains(entry.getKey()) && !entry.getKey().equals("Relentless Rats") && !entry.getKey().equals("Shadowborn Apostle")) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
@ -89,14 +88,14 @@ public class Constructed extends DeckValidator {
}
}
}
for (String bannedCard: banned) {
for (String bannedCard : banned) {
if (counts.containsKey(bannedCard)) {
invalid.put(bannedCard, "Banned");
valid = false;
}
}
for (String restrictedCard: restricted) {
for (String restrictedCard : restricted) {
if (counts.containsKey(restrictedCard)) {
int count = counts.get(restrictedCard);
if (count > 1) {
@ -107,27 +106,27 @@ public class Constructed extends DeckValidator {
}
if (!rarities.isEmpty()) {
for (Card card: deck.getCards()) {
for (Card card : deck.getCards()) {
if (!rarities.contains(card.getRarity())) {
invalid.put(card.getName(), "Invalid rarity: " + card.getRarity());
valid = false;
}
}
for (Card card: deck.getSideboard()) {
}
for (Card card : deck.getSideboard()) {
if (!rarities.contains(card.getRarity())) {
invalid.put(card.getName(), "Invalid rarity: " + card.getRarity());
valid = false;
}
}
}
}
if (!setCodes.isEmpty()) {
for (Card card: deck.getCards()) {
for (Card card : deck.getCards()) {
if (!setCodes.contains(card.getExpansionSetCode())) {
// check if card is legal if taken from other set
boolean legal = false;
List<CardInfo> cardInfos = CardRepository.instance.findCards(card.getName());
for (CardInfo cardInfo: cardInfos) {
for (CardInfo cardInfo : cardInfos) {
if (setCodes.contains(cardInfo.getSetCode())) {
legal = true;
break;
@ -139,12 +138,12 @@ public class Constructed extends DeckValidator {
}
}
}
for (Card card: deck.getSideboard()) {
for (Card card : deck.getSideboard()) {
if (!setCodes.contains(card.getExpansionSetCode())) {
// check if card is legal if taken from other set
boolean legal = false;
List<CardInfo> cardInfos = CardRepository.instance.findCards(card.getName());
for (CardInfo cardInfo: cardInfos) {
for (CardInfo cardInfo : cardInfos) {
if (setCodes.contains(cardInfo.getSetCode())) {
legal = true;
break;