From 3f4698434b0ea7e79fee2a6d829c214fd83fdf2f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 29 Sep 2020 19:35:32 -0400 Subject: [PATCH] fixed random mystery booster test failures --- .../mage/test/sets/BoosterGenerationTest.java | 29 +++++++++++-------- .../src/main/java/mage/filter/FilterMana.java | 24 +++++++++++++++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java b/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java index f2a33abe00..040180b167 100644 --- a/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java @@ -134,23 +134,28 @@ public class BoosterGenerationTest extends MageTestBase { Assert.assertNotNull(booster); Assert.assertEquals("Pack contains 15 cards", 15, booster.size()); - Assert.assertTrue("Slot 1 is white", booster.get(0).getColor(null).isWhite()); - Assert.assertTrue("Slot 2 is white", booster.get(1).getColor(null).isWhite()); + Assert.assertTrue("Slot 1 is white (" + booster.get(0).getName() + ')', booster.get(0).getColorIdentity().isWhite()); + Assert.assertTrue("Slot 2 is white (" + booster.get(1).getName() + ')', booster.get(1).getColorIdentity().isWhite()); - Assert.assertTrue("Slot 3 is blue", booster.get(2).getColor(null).isBlue()); - Assert.assertTrue("Slot 4 is blue", booster.get(3).getColor(null).isBlue()); + Assert.assertTrue("Slot 3 is blue (" + booster.get(2).getName() + ')', booster.get(2).getColorIdentity().isBlue()); + Assert.assertTrue("Slot 4 is blue (" + booster.get(3).getName() + ')', booster.get(3).getColorIdentity().isBlue()); - Assert.assertTrue("Slot 5 is black", booster.get(4).getColor(null).isBlack()); - Assert.assertTrue("Slot 6 is black", booster.get(5).getColor(null).isBlack()); + Assert.assertTrue("Slot 5 is black (" + booster.get(4).getName() + ')', booster.get(4).getColorIdentity().isBlack()); + Assert.assertTrue("Slot 6 is black (" + booster.get(5).getName() + ')', booster.get(5).getColorIdentity().isBlack()); - Assert.assertTrue("Slot 7 is red", booster.get(6).getColor(null).isRed()); - Assert.assertTrue("Slot 8 is red", booster.get(7).getColor(null).isRed()); + Assert.assertTrue("Slot 7 is red (" + booster.get(6).getName() + ')', booster.get(6).getColorIdentity().isRed()); + Assert.assertTrue("Slot 8 is red (" + booster.get(7).getName() + ')', booster.get(7).getColorIdentity().isRed()); - Assert.assertTrue("Slot 9 is green", booster.get(8).getColor(null).isGreen()); - Assert.assertTrue("Slot 10 is green", booster.get(9).getColor(null).isGreen()); + Assert.assertTrue("Slot 9 is green (" + booster.get(8).getName() + ')', booster.get(8).getColorIdentity().isGreen()); + Assert.assertTrue("Slot 10 is green (" + booster.get(9).getName() + ')', booster.get(9).getColorIdentity().isGreen()); - Assert.assertTrue("Slot 11 is multicolored", booster.get(10).getColor(null).isMulticolored()); - Assert.assertTrue("Slot 12 is colorless", booster.get(11).getColor(null).isColorless()); + Assert.assertTrue("Slot 11 is multicolored (" + booster.get(10).getName() + ')', booster.get(10).getColorIdentity().isMulticolored()); + Assert.assertTrue( + "Slot 12 is colorless (" + booster.get(11).getName() + ')', + booster.get(11).getColor(null).isColorless() + || booster.get(11).isLand() + || booster.get(11).isArtifact() + ); Assert.assertEquals("Slot 15 is from FMB1 set", "FMB1", booster.get(14).getExpansionSetCode()); } diff --git a/Mage/src/main/java/mage/filter/FilterMana.java b/Mage/src/main/java/mage/filter/FilterMana.java index bf323dce32..3b7cee6d3c 100644 --- a/Mage/src/main/java/mage/filter/FilterMana.java +++ b/Mage/src/main/java/mage/filter/FilterMana.java @@ -85,6 +85,30 @@ public class FilterMana implements Serializable { this.colorless = colorless; } + public boolean isMulticolored() { + return getColorCount() > 1; + } + + public int getColorCount() { + int colorCount = 0; + if (this.white) { + colorCount += 1; + } + if (this.blue) { + colorCount += 1; + } + if (this.black) { + colorCount += 1; + } + if (this.red) { + colorCount += 1; + } + if (this.green) { + colorCount += 1; + } + return colorCount; + } + public FilterMana copy() { return new FilterMana(this); }