* Fixed that a spell that becomes a permanent didn't had the colors of the spell (e.g. ERsatz Gnomes).

This commit is contained in:
LevelX2 2016-10-22 10:38:10 +02:00
parent da4e0bc20e
commit 97b872d926
10 changed files with 188 additions and 139 deletions

View file

@ -208,6 +208,8 @@ public class ZonesHandler {
// If we can't find the card we can't remove it.
return false;
}
// If needed take attributes from the spell (e.g. color of spell was changed)
card = takeAttributesFromSpell(card, event, game);
boolean success = false;
if (info.faceDown) {
card.setFaceDown(true, game);
@ -282,4 +284,23 @@ public class ZonesHandler {
order.add(cards.getCards(game).iterator().next());
return order;
}
private static Card takeAttributesFromSpell(Card card, ZoneChangeEvent event, Game game) {
if (Zone.STACK.equals(event.getFromZone())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null) {
boolean doCopy = false;
if (!card.getColor(game).equals(spell.getColor(game))) {
doCopy = true;
}
if (doCopy) {
// the card that is referenced to in the permanent is copied and the spell attributes are set to this copied card
card = card.copy();
card.getColor(game).setColor(spell.getColor(game));
}
}
}
return card;
}
}

View file

@ -132,7 +132,7 @@ public class PermanentCard extends PermanentImpl {
transformable = card.isTransformable();
if (transformable) {
this.nightCard = card.isNightCard();
if (! this.nightCard) {
if (!this.nightCard) {
this.secondSideCard = card.getSecondCardFace();
this.secondSideCardClazz = this.secondSideCard.getClass();
}

View file

@ -27,15 +27,9 @@
*/
package mage.game.permanent;
import java.util.ArrayList;
import java.util.UUID;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.cards.MeldCard;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
/**
*

View file

@ -277,9 +277,6 @@ public class Spell extends StackObjImpl implements Card {
}
} else {
updateOptionalCosts(0);
if (!getColor(game).equals(card.getColor(game))) { // if spell color was changed, the created permanent needs to be of that color
game.getState().getCreateCardAttribute(card).getColor().setColor(getColor(game));
}
return controller.moveCards(card, Zone.BATTLEFIELD, ability, game, false, faceDown, false, null);
}
}
@ -902,7 +899,7 @@ public class Spell extends StackObjImpl implements Card {
@Override
public void checkForCountersToAdd(Permanent permanent, Game game) {
throw new UnsupportedOperationException("Not supported for Spell");
card.checkForCountersToAdd(permanent, game);
}
@Override

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,20 +20,18 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game.turn;
import mage.constants.PhaseStep;
import mage.constants.TurnPhase;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.UUID;
import mage.constants.PhaseStep;
import mage.constants.TurnPhase;
/**
*
@ -41,10 +39,11 @@ import java.util.UUID;
*/
public class TurnMods extends ArrayList<TurnMod> {
public TurnMods() {}
public TurnMods() {
}
public TurnMods(final TurnMods mods) {
for (TurnMod mod: mods) {
for (TurnMod mod : mods) {
this.add(mod.copy());
}
}
@ -95,7 +94,7 @@ public class TurnMods extends ArrayList<TurnMod> {
it.remove();
}
}
// now delete all other - control next turn effect is not cumulative
// now delete all other effects that control current active player - control next turn of player effects are not cumulative
it = this.listIterator(this.size());
while (it.hasPrevious()) {
TurnMod turnMod = it.previous();