mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
* Modal double faces cards - fixed that color identity doesn't contains second side colors;
This commit is contained in:
parent
10ac8ab86f
commit
31d134843a
4 changed files with 48 additions and 24 deletions
|
|
@ -7,6 +7,7 @@ import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.permanent.PermanentCard;
|
import mage.game.permanent.PermanentCard;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
import mage.util.ManaUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
@ -242,12 +243,15 @@ public class ModalDoubleFacesCardsTest extends CardTestPlayerBase {
|
||||||
// mdf and legendary
|
// mdf and legendary
|
||||||
addCard(Zone.HAND, playerA, "Halvar, God of Battle");
|
addCard(Zone.HAND, playerA, "Halvar, God of Battle");
|
||||||
|
|
||||||
|
// mdf and color identity
|
||||||
|
addCard(Zone.HAND, playerA, "Esika, God of the Tree");
|
||||||
|
|
||||||
setStrictChooseMode(true);
|
setStrictChooseMode(true);
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
execute();
|
execute();
|
||||||
assertAllCommandsUsed();
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
Assert.assertEquals(2, getHandCards(playerA).size());
|
Assert.assertEquals(3, getHandCards(playerA).size());
|
||||||
|
|
||||||
// stats in hand - normal
|
// stats in hand - normal
|
||||||
Card card = getHandCards(playerA).stream().filter(c -> CardUtil.haveSameNames(c, "Akoum Warrior", currentGame)).findFirst().get();
|
Card card = getHandCards(playerA).stream().filter(c -> CardUtil.haveSameNames(c, "Akoum Warrior", currentGame)).findFirst().get();
|
||||||
|
|
@ -262,6 +266,10 @@ public class ModalDoubleFacesCardsTest extends CardTestPlayerBase {
|
||||||
Assert.assertTrue("must be legendary", card.isLegendary());
|
Assert.assertTrue("must be legendary", card.isLegendary());
|
||||||
Assert.assertTrue("must be creature", card.isCreature());
|
Assert.assertTrue("must be creature", card.isCreature());
|
||||||
Assert.assertTrue("must be god", card.hasSubtype(SubType.GOD, currentGame));
|
Assert.assertTrue("must be god", card.hasSubtype(SubType.GOD, currentGame));
|
||||||
|
|
||||||
|
// stats in hand - mdf - color identity must be from both sides
|
||||||
|
card = getHandCards(playerA).stream().filter(c -> CardUtil.haveSameNames(c, "Esika, God of the Tree", currentGame)).findFirst().get();
|
||||||
|
Assert.assertEquals("color identity of mdf card must be from both sides", "{W}{U}{B}{R}{G}", ManaUtil.getColorIdentity(card).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestCommander3PlayersFFA;
|
import org.mage.test.serverside.base.CardTestCommander3PlayersFFA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class CommanderColorIdentityTest extends CardTestCommander3PlayersFFA {
|
public class CommanderColorIdentityTest extends CardTestCommander3PlayersFFA {
|
||||||
|
|
@ -24,17 +23,17 @@ public class CommanderColorIdentityTest extends CardTestCommander3PlayersFFA {
|
||||||
Assert.assertEquals("{W}", getColorIdentityString("Silvercoat Lion"));
|
Assert.assertEquals("{W}", getColorIdentityString("Silvercoat Lion"));
|
||||||
|
|
||||||
// Multicolor
|
// Multicolor
|
||||||
Assert.assertEquals("{G}{W}", getColorIdentityString("Veteran Warleader"));
|
Assert.assertEquals("{W}{G}", getColorIdentityString("Veteran Warleader"));
|
||||||
Assert.assertEquals("{B}{R}", getColorIdentityString("Forerunner of Slaughter"));
|
Assert.assertEquals("{B}{R}", getColorIdentityString("Forerunner of Slaughter"));
|
||||||
Assert.assertEquals("{R}{U}", getColorIdentityString("Brutal Expulsion"));
|
Assert.assertEquals("{U}{R}", getColorIdentityString("Brutal Expulsion"));
|
||||||
Assert.assertEquals("{B}{G}", getColorIdentityString("Catacomb Sifter"));
|
Assert.assertEquals("{B}{G}", getColorIdentityString("Catacomb Sifter"));
|
||||||
Assert.assertEquals("{B}{U}", getColorIdentityString("Fathom Feeder"));
|
Assert.assertEquals("{U}{B}", getColorIdentityString("Fathom Feeder"));
|
||||||
|
|
||||||
Assert.assertEquals("{R}{W}", getColorIdentityString("Angelic Captain"));
|
Assert.assertEquals("{W}{R}", getColorIdentityString("Angelic Captain"));
|
||||||
Assert.assertEquals("{G}{U}", getColorIdentityString("Bring to Light"));
|
Assert.assertEquals("{U}{G}", getColorIdentityString("Bring to Light"));
|
||||||
Assert.assertEquals("{B}{W}", getColorIdentityString("Drana's Emissary"));
|
Assert.assertEquals("{W}{B}", getColorIdentityString("Drana's Emissary"));
|
||||||
Assert.assertEquals("{G}{R}", getColorIdentityString("Grove Rumbler"));
|
Assert.assertEquals("{R}{G}", getColorIdentityString("Grove Rumbler"));
|
||||||
Assert.assertEquals("{U}{W}", getColorIdentityString("Roil Spout"));
|
Assert.assertEquals("{W}{U}", getColorIdentityString("Roil Spout"));
|
||||||
|
|
||||||
// Cards with colors in the rule text
|
// Cards with colors in the rule text
|
||||||
Assert.assertEquals("{B}{R}", getColorIdentityString("Fires of Undeath"));
|
Assert.assertEquals("{B}{R}", getColorIdentityString("Fires of Undeath"));
|
||||||
|
|
@ -47,7 +46,7 @@ public class CommanderColorIdentityTest extends CardTestCommander3PlayersFFA {
|
||||||
Assert.assertEquals("{B}", getColorIdentityString("Dismember"));
|
Assert.assertEquals("{B}", getColorIdentityString("Dismember"));
|
||||||
|
|
||||||
// Hybrid mana
|
// Hybrid mana
|
||||||
Assert.assertEquals("{G}{W}", getColorIdentityString("Kitchen Finks"));
|
Assert.assertEquals("{W}{G}", getColorIdentityString("Kitchen Finks"));
|
||||||
|
|
||||||
// Lands with colored activation costs
|
// Lands with colored activation costs
|
||||||
Assert.assertEquals("{G}", getColorIdentityString("Treetop Village"));
|
Assert.assertEquals("{G}", getColorIdentityString("Treetop Village"));
|
||||||
|
|
@ -56,10 +55,18 @@ public class CommanderColorIdentityTest extends CardTestCommander3PlayersFFA {
|
||||||
Assert.assertEquals("{W}", getColorIdentityString("Knight of Obligation"));
|
Assert.assertEquals("{W}", getColorIdentityString("Knight of Obligation"));
|
||||||
|
|
||||||
// Two face cards
|
// Two face cards
|
||||||
Assert.assertEquals("{G}{R}", getColorIdentityString("Daybreak Ranger"));
|
Assert.assertEquals("{R}{G}", getColorIdentityString("Daybreak Ranger"));
|
||||||
Assert.assertEquals("{R}{W}", getColorIdentityString("Archangel Avacyn"));
|
Assert.assertEquals("{W}{R}", getColorIdentityString("Archangel Avacyn"));
|
||||||
Assert.assertEquals("{R}{U}", getColorIdentityString("Civilized Scholar"));
|
Assert.assertEquals("{U}{R}", getColorIdentityString("Civilized Scholar"));
|
||||||
|
|
||||||
|
// Split cards
|
||||||
|
Assert.assertEquals("{U}{R}", getColorIdentityString("Fire // Ice"));
|
||||||
|
|
||||||
|
// MDF cards
|
||||||
|
Assert.assertEquals("{W}{U}{B}{R}{G}", getColorIdentityString("Esika, God of the Tree"));
|
||||||
|
|
||||||
|
// Adventure cards
|
||||||
|
Assert.assertEquals("{G}", getColorIdentityString("Rosethorn Acolyte"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getColorIdentityString(String cardName) {
|
private String getColorIdentityString(String cardName) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.filter;
|
package mage.filter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -115,11 +114,11 @@ public class FilterMana implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return (black ? "{B}" : "")
|
// wubrg order
|
||||||
+ (green ? "{G}" : "")
|
return (white ? "{W}" : "")
|
||||||
+ (red ? "{R}" : "")
|
|
||||||
+ (blue ? "{U}" : "")
|
+ (blue ? "{U}" : "")
|
||||||
+ (white ? "{W}" : "");
|
+ (black ? "{B}" : "")
|
||||||
|
+ (red ? "{R}" : "")
|
||||||
|
+ (green ? "{G}" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@ import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.mana.*;
|
import mage.abilities.mana.*;
|
||||||
|
import mage.cards.AdventureCard;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
import mage.cards.ModalDoubleFacesCard;
|
||||||
|
import mage.cards.SplitCard;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.filter.FilterMana;
|
import mage.filter.FilterMana;
|
||||||
|
|
@ -610,10 +613,17 @@ public final class ManaUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FilterMana getColorIdentity(Card card) {
|
public static FilterMana getColorIdentity(Card card) {
|
||||||
// TODO: is it support mdf cards?
|
Card secondSide;
|
||||||
// TODO: is it support adventure cards?
|
if (card instanceof SplitCard) {
|
||||||
Card secondSide = card.getSecondCardFace();
|
secondSide = ((SplitCard) card).getRightHalfCard();
|
||||||
return getColorIdentity(card.getColor(null), card.getManaCost().getSymbols(), card.getRules(), secondSide);
|
} else if (card instanceof AdventureCard) {
|
||||||
|
secondSide = ((AdventureCard) card).getSpellCard();
|
||||||
|
} else if (card instanceof ModalDoubleFacesCard) {
|
||||||
|
secondSide = ((ModalDoubleFacesCard) card).getRightHalfCard();
|
||||||
|
} else {
|
||||||
|
secondSide = card.getSecondCardFace();
|
||||||
|
}
|
||||||
|
return getColorIdentity(card.getColor(), card.getManaCost().getSymbols(), card.getRules(), secondSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getColorIdentityHash(FilterMana colorIdentity) {
|
public static int getColorIdentityHash(FilterMana colorIdentity) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue