forked from External/mage
* Felhide Spiritbinder - Fixed a bug that the copied token did not have a supertype l(e.g. Legendary).
This commit is contained in:
parent
ae8da01ba8
commit
022587e6f9
4 changed files with 34 additions and 12 deletions
|
|
@ -38,14 +38,15 @@ import mage.abilities.effects.common.DoIfCostPaid;
|
|||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.abilities.keyword.InspiredAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.sets.tokens.EmptyToken;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
|
@ -74,7 +75,7 @@ public class FelhideSpiritbinder extends CardImpl<FelhideSpiritbinder> {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// <i>Inspired</i> - Whenever Felhide Spiritbinder becomes untapped, you may pay {1}{R}. If you do, put a token onto the battlefield that's a copy of another target creature except it's an enchantment in addition to its other types. It gains haste. Exile it at the beginning of the next end step.
|
||||
Ability ability = new InspiredAbility(new DoIfCostPaid(new FelhideSpiritbinderEffect(), new ManaCostsImpl("{1}{R}")));
|
||||
Ability ability = new InspiredAbility(new DoIfCostPaid(new FelhideSpiritbinderEffect(), new ManaCostsImpl("{1}{R}"),"Use effect of {source}?"));
|
||||
ability.addTarget(new TargetCreaturePermanent(filter, true));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
@ -107,10 +108,13 @@ class FelhideSpiritbinderEffect extends OneShotEffect<FelhideSpiritbinderEffect>
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(source.getFirstTarget());
|
||||
if (card != null) {
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent == null) {
|
||||
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (permanent != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(card);
|
||||
CardUtil.copyTo(token).from(permanent);
|
||||
|
||||
if (!token.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
token.getCardType().add(CardType.ENCHANTMENT);
|
||||
|
|
|
|||
|
|
@ -13,17 +13,24 @@ import mage.util.CardUtil;
|
|||
public class DoIfCostPaid extends OneShotEffect<DoIfCostPaid> {
|
||||
private final OneShotEffect executingEffect;
|
||||
private final Cost cost;
|
||||
private String chooseUseText;
|
||||
|
||||
public DoIfCostPaid(OneShotEffect effect, Cost cost) {
|
||||
this(effect, cost, null);
|
||||
}
|
||||
|
||||
public DoIfCostPaid(OneShotEffect effect, Cost cost, String chooseUseText) {
|
||||
super(Outcome.Benefit);
|
||||
this.executingEffect = effect;
|
||||
this.cost = cost;
|
||||
this.chooseUseText = chooseUseText;
|
||||
}
|
||||
|
||||
public DoIfCostPaid(final DoIfCostPaid effect) {
|
||||
super(effect);
|
||||
this.executingEffect = (OneShotEffect) effect.executingEffect.copy();
|
||||
this.cost = effect.cost.copy();
|
||||
this.chooseUseText = effect.chooseUseText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -31,7 +38,12 @@ public class DoIfCostPaid extends OneShotEffect<DoIfCostPaid> {
|
|||
Player player = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (player != null && mageObject != null) {
|
||||
String message = new StringBuilder(getCostText()).append(" and ").append(executingEffect.getText(source.getModes().getMode())).append("?").toString();
|
||||
String message;
|
||||
if (chooseUseText == null) {
|
||||
message = new StringBuilder(getCostText()).append(" and ").append(executingEffect.getText(source.getModes().getMode())).append("?").toString();
|
||||
} else {
|
||||
message = chooseUseText;
|
||||
}
|
||||
message = CardUtil.replaceSourceName(message, mageObject.getName());
|
||||
if (player.chooseUse(executingEffect.getOutcome(), message, game)) {
|
||||
cost.clearPaid();
|
||||
|
|
|
|||
|
|
@ -75,11 +75,12 @@ public class PermanentToken extends PermanentImpl<PermanentToken> {
|
|||
for (ManaCost cost: token.getManaCost()) {
|
||||
this.getManaCost().add(cost.copy());
|
||||
}
|
||||
this.cardType = token.getCardType();
|
||||
this.color = token.getColor();
|
||||
this.power = token.getPower();
|
||||
this.toughness = token.getToughness();
|
||||
this.subtype = token.getSubtype();
|
||||
this.cardType.addAll(token.getCardType());
|
||||
this.color = token.getColor().copy();
|
||||
this.power.initValue(token.getPower().getValue());
|
||||
this.toughness.initValue(token.getToughness().getValue());
|
||||
this.supertype.addAll(token.getSupertype());
|
||||
this.subtype.addAll(token.getSubtype());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -117,7 +117,12 @@ public class Token extends MageObjectImpl<Token> {
|
|||
|
||||
public boolean putOntoBattlefield(int amount, Game game, UUID sourceId, UUID controllerId, boolean tapped, boolean attacking) {
|
||||
Card source = game.getCard(sourceId);
|
||||
String setCode = source != null ? source.getExpansionSetCode() : null;
|
||||
String setCode;
|
||||
if (this.getOriginalExpansionSetCode() != null && !this.getOriginalExpansionSetCode().isEmpty()) {
|
||||
setCode = this.getOriginalExpansionSetCode();
|
||||
} else {
|
||||
setCode = source != null ? source.getExpansionSetCode() : null;
|
||||
}
|
||||
GameEvent event = GameEvent.getEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount);
|
||||
if (!game.replaceEvent(event)) {
|
||||
amount = event.getAmount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue