mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
* Finished card attribute change handling for color of cards (card subtype not supported yet) related to #408
This commit is contained in:
parent
199ff16c0c
commit
93dcf2d59f
6 changed files with 131 additions and 34 deletions
|
|
@ -37,7 +37,6 @@ import mage.constants.SetType;
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class Conspiracy extends ExpansionSet {
|
public class Conspiracy extends ExpansionSet {
|
||||||
|
|
||||||
private static final Conspiracy fINSTANCE = new Conspiracy();
|
private static final Conspiracy fINSTANCE = new Conspiracy();
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public class CeruleanWisps extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||||
this.getSpellAbility().addEffect(new BecomesColorTargetEffect(ObjectColor.BLUE, Duration.EndOfTurn));
|
this.getSpellAbility().addEffect(new BecomesColorTargetEffect(ObjectColor.BLUE, Duration.EndOfTurn));
|
||||||
this.getSpellAbility().addEffect(new UntapTargetEffect());
|
this.getSpellAbility().addEffect(new UntapTargetEffect());
|
||||||
|
|
||||||
// Draw a card.
|
// Draw a card.
|
||||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,15 +78,15 @@ class DragonsClawAbility extends TriggeredAbilityImpl {
|
||||||
return new DragonsClawAbility(this);
|
return new DragonsClawAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == EventType.SPELL_CAST;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.SPELL_CAST) {
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
return spell != null && spell.getColor(game).isRed();
|
||||||
if (spell != null && spell.getColor(game).isRed()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,13 @@ public class PaintersServantTest extends CardTestPlayerBase {
|
||||||
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isWhite());
|
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isWhite());
|
||||||
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isBlue());
|
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isBlue());
|
||||||
|
|
||||||
|
for(Card card: playerA.getLibrary().getCards(currentGame)) {
|
||||||
|
Assert.assertEquals(card.getName() + " should be blue",true, card.getColor(currentGame).isBlue());
|
||||||
|
}
|
||||||
|
for(Card card: playerB.getLibrary().getCards(currentGame)) {
|
||||||
|
Assert.assertEquals(card.getName() + " should be blue",true, card.getColor(currentGame).isBlue());
|
||||||
|
}
|
||||||
|
|
||||||
for(Card card: playerA.getHand().getCards(currentGame)) {
|
for(Card card: playerA.getHand().getCards(currentGame)) {
|
||||||
Assert.assertEquals(true, card.getColor(currentGame).isRed());
|
Assert.assertEquals(true, card.getColor(currentGame).isRed());
|
||||||
Assert.assertEquals(true, card.getColor(currentGame).isBlue());
|
Assert.assertEquals(true, card.getColor(currentGame).isBlue());
|
||||||
|
|
@ -131,6 +138,13 @@ public class PaintersServantTest extends CardTestPlayerBase {
|
||||||
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isWhite());
|
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isWhite());
|
||||||
Assert.assertEquals(false, silvercoatLion.getColor(currentGame).isBlue());
|
Assert.assertEquals(false, silvercoatLion.getColor(currentGame).isBlue());
|
||||||
|
|
||||||
|
for(Card card: playerA.getLibrary().getCards(currentGame)) {
|
||||||
|
Assert.assertEquals(card.getName() + " should not be blue",false, card.getColor(currentGame).isBlue());
|
||||||
|
}
|
||||||
|
for(Card card: playerB.getLibrary().getCards(currentGame)) {
|
||||||
|
Assert.assertEquals(card.getName() + " should not be blue",false, card.getColor(currentGame).isBlue());
|
||||||
|
}
|
||||||
|
|
||||||
for(Card card: playerA.getHand().getCards(currentGame)) {
|
for(Card card: playerA.getHand().getCards(currentGame)) {
|
||||||
Assert.assertEquals(true, card.getColor(currentGame).isRed());
|
Assert.assertEquals(true, card.getColor(currentGame).isRed());
|
||||||
Assert.assertEquals(false, card.getColor(currentGame).isBlue());
|
Assert.assertEquals(false, card.getColor(currentGame).isBlue());
|
||||||
|
|
@ -154,4 +168,83 @@ public class PaintersServantTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5/1/2008 While Painter's Servant is on the battlefield, an effect that
|
||||||
|
* changes an object's colors will overwrite Painter's Servant's effect. For
|
||||||
|
* example, casting Cerulean Wisps on a creature will turn it blue,
|
||||||
|
* regardless of the color chosen for Painter's Servant.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testColorOverwrite() {
|
||||||
|
// As Painter's Servant enters the battlefield, choose a color.
|
||||||
|
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
|
||||||
|
addCard(Zone.HAND, playerA, "Painter's Servant", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
|
||||||
|
|
||||||
|
// Target creature becomes blue until end of turn. Untap that creature.
|
||||||
|
// Draw a card.
|
||||||
|
addCard(Zone.HAND, playerB, "Cerulean Wisps", 1); // Instant {U}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Island", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
||||||
|
setChoice(playerA, "Red");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Cerulean Wisps", "Silvercoat Lion", "Painter's Servant", StackClause.WHILE_NOT_ON_STACK);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Painter's Servant", 1);
|
||||||
|
|
||||||
|
Permanent silvercoatLion = getPermanent("Silvercoat Lion", playerA);
|
||||||
|
Assert.assertEquals(false, silvercoatLion.getColor(currentGame).isWhite());
|
||||||
|
Assert.assertEquals(false, silvercoatLion.getColor(currentGame).isRed());
|
||||||
|
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isBlue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check color of spells
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testColorSpell() {
|
||||||
|
// As Painter's Servant enters the battlefield, choose a color.
|
||||||
|
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
|
||||||
|
addCard(Zone.HAND, playerA, "Painter's Servant", 1);
|
||||||
|
// Draw two cards.
|
||||||
|
addCard(Zone.HAND, playerA, "Divination", 1); // {U}{2}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
|
||||||
|
// Whenever a player casts a red spell, you may gain 1 life.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Dragon's Claw");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
|
||||||
|
|
||||||
|
// Target creature becomes blue until end of turn. Untap that creature.
|
||||||
|
// Draw a card.
|
||||||
|
addCard(Zone.HAND, playerB, "Cerulean Wisps", 1); // Instant {U}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Island", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
||||||
|
setChoice(playerA, "Red");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Cerulean Wisps", "Silvercoat Lion", "Painter's Servant", StackClause.WHILE_NOT_ON_STACK);
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Divination", NO_TARGET, "Painter's Servant", StackClause.WHILE_NOT_ON_STACK);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Painter's Servant", 1);
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Divination", 1);
|
||||||
|
assertGraveyardCount(playerB, "Cerulean Wisps", 1);
|
||||||
|
assertLife(playerA, 22); // + 1 from Cerulean Wisps + 1 from Divination
|
||||||
|
|
||||||
|
Permanent silvercoatLion = getPermanent("Silvercoat Lion", playerA);
|
||||||
|
Assert.assertEquals(false, silvercoatLion.getColor(currentGame).isWhite());
|
||||||
|
Assert.assertEquals(false, silvercoatLion.getColor(currentGame).isRed());
|
||||||
|
Assert.assertEquals(true, silvercoatLion.getColor(currentGame).isBlue());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -803,7 +803,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Must be called here for some effects to be able to work correctly
|
// Must be called here for some effects to be able to work correctly
|
||||||
// TODO: add info which effects that need
|
// TODO: add info which effects need that call
|
||||||
game.applyEffects();
|
game.applyEffects();
|
||||||
} while (true);
|
} while (true);
|
||||||
return caught;
|
return caught;
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ import mage.constants.Layer;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubLayer;
|
import mage.constants.SubLayer;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.game.stack.StackObject;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,7 +48,7 @@ import mage.players.Player;
|
||||||
*/
|
*/
|
||||||
public class BecomesColorTargetEffect extends ContinuousEffectImpl {
|
public class BecomesColorTargetEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
private final ObjectColor setColor;
|
private ObjectColor setColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color of a spell or permanent
|
* Set the color of a spell or permanent
|
||||||
|
|
@ -76,49 +74,55 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public void init(Ability source, Game game) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
boolean result = false;
|
|
||||||
ObjectColor objectColor;
|
|
||||||
if (setColor == null) {
|
if (setColor == null) {
|
||||||
ChoiceColor choice = new ChoiceColor();
|
ChoiceColor choice = new ChoiceColor();
|
||||||
while (!choice.isChosen()) {
|
while (!choice.isChosen()) {
|
||||||
controller.choose(Outcome.PutManaInPool, choice, game);
|
controller.choose(Outcome.PutManaInPool, choice, game);
|
||||||
if (!controller.isInGame()) {
|
if (!controller.isInGame()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (choice.getColor() != null) {
|
if (choice.getColor() != null) {
|
||||||
objectColor = choice.getColor();
|
setColor = choice.getColor();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(controller.getLogName() + " has chosen the color: " + objectColor.toString());
|
game.informPlayers(controller.getLogName() + " has chosen the color: " + setColor.toString());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
objectColor = this.setColor;
|
|
||||||
}
|
}
|
||||||
if (objectColor != null) {
|
|
||||||
|
|
||||||
|
super.init(source, game); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
if (controller == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (setColor != null) {
|
||||||
|
boolean objectFound = false;
|
||||||
for (UUID targetId :targetPointer.getTargets(game, source)) {
|
for (UUID targetId :targetPointer.getTargets(game, source)) {
|
||||||
MageObject o = game.getObject(targetId);
|
MageObject targetObject = game.getObject(targetId);
|
||||||
if (o != null) {
|
if (targetObject != null) {
|
||||||
if (o instanceof Permanent || o instanceof StackObject) {
|
objectFound = true;
|
||||||
o.getColor(game).setColor(objectColor);
|
targetObject.getColor(game).setColor(setColor);
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!objectFound && this.getDuration().equals(Duration.Custom)) {
|
||||||
if (!result) {
|
|
||||||
if (this.getDuration().equals(Duration.Custom)) {
|
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException("No color set");
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue