mirror of
https://github.com/correl/mage.git
synced 2025-04-12 01:01:04 -09:00
* Some deck format tests changed/added.
This commit is contained in:
parent
d80d588963
commit
71ed488c1e
2 changed files with 165 additions and 17 deletions
Mage.Sets/src/mage/sets
Mage.Tests/src/test/java/org/mage/test/serverside/deck
|
@ -27,9 +27,7 @@
|
|||
*/
|
||||
package mage.sets;
|
||||
|
||||
import mage.cards.CardGraphicInfo;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SetType;
|
||||
|
||||
|
@ -50,7 +48,6 @@ public class MasterpieceSeriesAmonkhet extends ExpansionSet {
|
|||
this.blockName = "Masterpiece Series";
|
||||
this.hasBoosters = false;
|
||||
this.hasBasicLands = false;
|
||||
CardGraphicInfo cardGraphicInfo = new CardGraphicInfo(FrameStyle.KLD_INVENTION, false);
|
||||
|
||||
cards.add(new SetCardInfo("Aggravated Assault", 25, Rarity.SPECIAL, mage.cards.a.AggravatedAssault.class));
|
||||
cards.add(new SetCardInfo("Armageddon", 31, Rarity.SPECIAL, mage.cards.a.Armageddon.class));
|
||||
|
|
|
@ -27,24 +27,24 @@
|
|||
*/
|
||||
package org.mage.test.serverside.deck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckValidator;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.deck.Limited;
|
||||
import mage.deck.Modern;
|
||||
import mage.deck.Standard;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.mage.test.serverside.base.MageTestBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DeckValidatorTest extends CardTestPlayerBase {
|
||||
public class DeckValidatorTest extends MageTestBase {
|
||||
|
||||
static class CardNameAmount {
|
||||
|
||||
|
@ -84,6 +84,38 @@ public class DeckValidatorTest extends CardTestPlayerBase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStandardValid() {
|
||||
ArrayList<CardNameAmount> deck = new ArrayList<>();
|
||||
|
||||
deck.add(new CardNameAmount("MPS-AKH", 28, 4)); // Rhonas the Indomitable
|
||||
deck.add(new CardNameAmount("Built to Smash", 4));
|
||||
deck.add(new CardNameAmount("Heroic Intervention", 4));
|
||||
deck.add(new CardNameAmount("Mountain", 48));
|
||||
|
||||
DeckValidator validator = new Standard();
|
||||
boolean validationSuccessful = testDeckValid(validator, deck);
|
||||
Assert.assertTrue(validator.getInvalid().toString(), validationSuccessful);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStandardNotValid() {
|
||||
ArrayList<CardNameAmount> deck = new ArrayList<>();
|
||||
|
||||
deck.add(new CardNameAmount("MPS-AKH", 28, 4)); // Rhonas the Indomitable
|
||||
deck.add(new CardNameAmount("Built to Smash", 4));
|
||||
deck.add(new CardNameAmount("Heroic Intervention", 4));
|
||||
deck.add(new CardNameAmount("Mountain", 47));
|
||||
|
||||
ArrayList<CardNameAmount> sideboard = new ArrayList<>();
|
||||
sideboard.add(new CardNameAmount("Mountain", 16));
|
||||
|
||||
DeckValidator validator = new Standard();
|
||||
testDeckValid(validator, deck, sideboard);
|
||||
Assert.assertEquals("invalid message not correct",
|
||||
"{Sideboard=Must contain no more than 15 cards : has 16 cards, Deck=Must contain at least 60 cards: has only 59 cards}", validator.getInvalid().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLimitedValid() {
|
||||
ArrayList<CardNameAmount> deck = new ArrayList<>();
|
||||
|
@ -226,37 +258,156 @@ public class DeckValidatorTest extends CardTestPlayerBase {
|
|||
@Test
|
||||
public void testModernBanned() {
|
||||
ArrayList<CardNameAmount> deckList = new ArrayList<>();
|
||||
DeckValidator validator = new Modern();
|
||||
|
||||
deckList.add(new CardNameAmount("Ancestral Vision", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
boolean validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertTrue(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Ancient Den", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.add(new CardNameAmount("Birthing Pod", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Blazing Shoal", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Bloodbraid Elf", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertTrue(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Chrome Mox", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Cloudpost", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Dark Depths", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Deathrite Shaman", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Dig Through Time", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Dread Return", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Glimpse of Nature", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Great Furnace", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Green Sun's Zenith", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Hypergenesis", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Jace, the Mind Sculptor", 4));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertTrue(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
|
||||
deckList.clear();
|
||||
deckList.add(new CardNameAmount("Mental Misstep", 4));
|
||||
Assert.assertFalse("banned cards are not allowed", testDeckValid(new Modern(), deckList));
|
||||
deckList.add(new CardNameAmount("Mountain", 56));
|
||||
validationSuccessful = testDeckValid(validator, deckList);
|
||||
Assert.assertFalse(validator.getInvalid().toString(), validationSuccessful);
|
||||
validator.getInvalid().clear();
|
||||
}
|
||||
|
||||
private boolean testDeckValid(DeckValidator validator, List<CardNameAmount> cards) {
|
||||
return testDeckValid(validator, cards, null);
|
||||
}
|
||||
|
||||
private boolean testDeckValid(DeckValidator validator, List<CardNameAmount> cards, List<CardNameAmount> cardsSideboard) {
|
||||
Deck deckToTest = new Deck();
|
||||
for (CardNameAmount cardNameAmount : cards) {
|
||||
CardInfo cardinfo;
|
||||
if (cardNameAmount.getName().isEmpty()) {
|
||||
cardinfo = CardRepository.instance.findCard(cardNameAmount.getSetCode(), cardNameAmount.getCardNumber());
|
||||
} else {
|
||||
cardinfo = CardRepository.instance.findCard(cardNameAmount.getName());
|
||||
if (cards != null) {
|
||||
for (CardNameAmount cardNameAmount : cards) {
|
||||
CardInfo cardinfo;
|
||||
if (cardNameAmount.getName().isEmpty()) {
|
||||
cardinfo = CardRepository.instance.findCard(cardNameAmount.getSetCode(), cardNameAmount.getCardNumber());
|
||||
} else {
|
||||
cardinfo = CardRepository.instance.findCard(cardNameAmount.getName());
|
||||
}
|
||||
for (int i = 0; i < cardNameAmount.getNumber(); i++) {
|
||||
deckToTest.getCards().add(cardinfo.getCard());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < cardNameAmount.getNumber(); i++) {
|
||||
deckToTest.getCards().add(cardinfo.getCard());
|
||||
}
|
||||
if (cardsSideboard != null) {
|
||||
for (CardNameAmount cardNameAmount : cardsSideboard) {
|
||||
CardInfo cardinfo;
|
||||
if (cardNameAmount.getName().isEmpty()) {
|
||||
cardinfo = CardRepository.instance.findCard(cardNameAmount.getSetCode(), cardNameAmount.getCardNumber());
|
||||
} else {
|
||||
cardinfo = CardRepository.instance.findCard(cardNameAmount.getName());
|
||||
}
|
||||
for (int i = 0; i < cardNameAmount.getNumber(); i++) {
|
||||
deckToTest.getSideboard().add(cardinfo.getCard());
|
||||
}
|
||||
}
|
||||
}
|
||||
return validator.validate(deckToTest);
|
||||
|
|
Loading…
Add table
Reference in a new issue