* Fixed that the corresponding token image was not always set correctly.

This commit is contained in:
LevelX2 2015-11-07 21:23:22 +01:00
parent f3e8a93316
commit 5702c694a9
4 changed files with 21 additions and 17 deletions

View file

@ -28,10 +28,6 @@
package mage.sets.morningtide;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -42,8 +38,11 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterLandCard;
import mage.game.Game;
@ -70,7 +69,7 @@ public class CountrysideCrusher extends CardImpl {
// Whenever a land card is put into your graveyard from anywhere, put a +1/+1 counter on Countryside Crusher.
this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility(
new AddCountersSourceEffect(CounterType.P1P1.createInstance()),
false, new FilterLandCard("a land card"),TargetController.YOU
false, new FilterLandCard("a land card"), TargetController.YOU
));
}
@ -111,7 +110,7 @@ class CountrysideCrusherEffect extends OneShotEffect {
Card card = controller.getLibrary().getFromTop(game);
cards.add(card);
if (card.getCardType().contains(CardType.LAND)) {
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
} else {
break;
}

View file

@ -29,12 +29,10 @@ package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.token.Token;
@ -99,7 +97,7 @@ public class CreateTokenEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
if (!expansionSetCodeChecked) {
updateExpansionSetCode(game, source);
expansionSetCodeChecked = Token.updateExpansionSetCode(game, source, token);
}
int value = amount.calculate(game, source, this);
token.putOntoBattlefield(value, game, source.getSourceId(), source.getControllerId(), tapped, attacking);
@ -108,14 +106,6 @@ public class CreateTokenEffect extends OneShotEffect {
return true;
}
private void updateExpansionSetCode(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject instanceof Card) {
token.setExpansionSetCodeForImage(((Card) sourceObject).getExpansionSetCode());
}
expansionSetCodeChecked = true;
}
public UUID getLastAddedTokenId() {
return lastAddedTokenId;
}

View file

@ -19,6 +19,7 @@ public class CreateTokenTargetEffect extends OneShotEffect {
private DynamicValue amount;
private boolean tapped;
private boolean attacking;
private boolean expansionSetCodeChecked;
public CreateTokenTargetEffect(Token token) {
this(token, new StaticValue(1));
@ -38,6 +39,7 @@ public class CreateTokenTargetEffect extends OneShotEffect {
this.amount = amount.copy();
this.tapped = tapped;
this.attacking = attacking;
this.expansionSetCodeChecked = false;
}
public CreateTokenTargetEffect(final CreateTokenTargetEffect effect) {
@ -46,6 +48,7 @@ public class CreateTokenTargetEffect extends OneShotEffect {
this.token = effect.token.copy();
this.tapped = effect.tapped;
this.attacking = effect.attacking;
this.expansionSetCodeChecked = effect.expansionSetCodeChecked;
}
@Override
@ -55,6 +58,9 @@ public class CreateTokenTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
if (!expansionSetCodeChecked) {
expansionSetCodeChecked = Token.updateExpansionSetCode(game, source, token);
}
int value = amount.calculate(game, source, this);
if (value > 0) {
return token.putOntoBattlefield(value, game, source.getSourceId(), targetPointer.getFirst(game, source), tapped, attacking);

View file

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectImpl;
import mage.ObjectColor;
import mage.abilities.Abilities;
@ -238,4 +239,12 @@ public class Token extends MageObjectImpl {
}
}
}
public static boolean updateExpansionSetCode(Game game, Ability source, Token token) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject instanceof Card) {
token.setExpansionSetCodeForImage(((Card) sourceObject).getExpansionSetCode());
}
return true;
}
}