* Sideboarding: fixed that it possible to auto-submit 40 cards deck instead 60 in constructed formats (#5579);

Sideboarding: fixed that cheated deck with sideboard can be used instead lose the game;
This commit is contained in:
Oleg Agafonov 2019-04-01 07:34:46 +04:00
parent 3dd6836559
commit de4befb9c2
22 changed files with 204 additions and 124 deletions

View file

@ -31,6 +31,7 @@ import java.util.Locale;
public class PlayGameTest extends MageTestBase {
private static final List<String> colorChoices = new ArrayList<>(Arrays.asList("bu", "bg", "br", "bw", "ug", "ur", "uw", "gr", "gw", "rw", "bur", "buw", "bug", "brg", "brw", "bgw", "wur", "wug", "wrg", "rgu"));
private static final int DECK_SIZE = 40;
@Ignore
@Test
@ -42,8 +43,8 @@ public class PlayGameTest extends MageTestBase {
// Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
Deck deck = generateRandomDeck();
if (deck.getCards().size() < 40) {
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
if (deck.getCards().size() < DECK_SIZE) {
throw new IllegalArgumentException("Couldn't load deck, deck size = " + deck.getCards().size() + ", but must be " + DECK_SIZE);
}
game.addPlayer(computerA, deck);
game.loadCards(deck.getCards(), computerA.getId());
@ -52,8 +53,8 @@ public class PlayGameTest extends MageTestBase {
// Player playerB = createPlayer("ComputerB", "Computer - mad");
// Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
Deck deck2 = generateRandomDeck();
if (deck2.getCards().size() < 40) {
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
if (deck2.getCards().size() < DECK_SIZE) {
throw new IllegalArgumentException("Couldn't load deck, deck size = " + deck2.getCards().size() + ", but must be " + DECK_SIZE);
}
game.addPlayer(computerB, deck2);
game.loadCards(deck2.getCards(), computerB.getId());
@ -89,6 +90,6 @@ public class PlayGameTest extends MageTestBase {
allowedColors.add(ColoredManaSymbol.lookup(c));
}
List<Card> cardPool = Sets.generateRandomCardPool(45, allowedColors);
return ComputerPlayer.buildDeck(cardPool, allowedColors);
return ComputerPlayer.buildDeck(DECK_SIZE, cardPool, allowedColors);
}
}

View file

@ -30,6 +30,7 @@ import java.util.Locale;
public class TestPlayRandomGame extends MageTestBase {
private static final List<String> colorChoices = new ArrayList<>(Arrays.asList("bu", "bg", "br", "bw", "ug", "ur", "uw", "gr", "gw", "rw", "bur", "buw", "bug", "brg", "brw", "bgw", "wur", "wug", "wrg", "rgu"));
private static final int DECK_SIZE = 40;
@Test
@Ignore
@ -46,16 +47,16 @@ public class TestPlayRandomGame extends MageTestBase {
Player computerA = createRandomPlayer("ComputerA");
Deck deck = generateRandomDeck();
if (deck.getCards().size() < 40) {
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
if (deck.getCards().size() < DECK_SIZE) {
throw new IllegalArgumentException("Couldn't load deck, deck size = " + deck.getCards().size() + ", but must be " + DECK_SIZE);
}
game.addPlayer(computerA, deck);
game.loadCards(deck.getCards(), computerA.getId());
Player computerB = createRandomPlayer("ComputerB");
Deck deck2 = generateRandomDeck();
if (deck2.getCards().size() < 40) {
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
if (deck2.getCards().size() < DECK_SIZE) {
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size() + ", but must be " + DECK_SIZE);
}
game.addPlayer(computerB, deck2);
game.loadCards(deck2.getCards(), computerB.getId());
@ -80,6 +81,6 @@ public class TestPlayRandomGame extends MageTestBase {
allowedColors.add(ColoredManaSymbol.lookup(c));
}
List<Card> cardPool = Sets.generateRandomCardPool(45, allowedColors);
return ComputerPlayer.buildDeck(cardPool, allowedColors);
return ComputerPlayer.buildDeck(DECK_SIZE, cardPool, allowedColors);
}
}

View file

@ -18,6 +18,8 @@ import java.util.List;
*/
public class DeckTestUtils {
private static final int DECK_SIZE = 40;
public static Deck buildRandomDeck(String colors, boolean onlyBasicLands) {
return buildRandomDeck(colors, onlyBasicLands, "");
}
@ -41,7 +43,7 @@ public class DeckTestUtils {
}
List<Card> cardPool = Sets.generateRandomCardPool(45, allowedColors, onlyBasicLands, allowedList);
return ComputerPlayer.buildDeck(cardPool, allowedColors, onlyBasicLands);
return ComputerPlayer.buildDeck(DECK_SIZE, cardPool, allowedColors, onlyBasicLands);
}
public static DeckCardLists buildRandomDeckAndInitCards(String colors, boolean onlyBasicLands) {