* Chief Engineer - Fixed that convoke did not work for Artifacts while Chief Engineer was on the battlefield.

This commit is contained in:
LevelX2 2015-05-11 19:17:38 +02:00 committed by Luna Skyrise
parent 70f152feb1
commit 1067ba296b
4 changed files with 58 additions and 45 deletions

View file

@ -27,22 +27,30 @@
*/ */
package mage.sets.magic2015; package mage.sets.magic2015;
import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.ConvokeAbility; import mage.abilities.keyword.ConvokeAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
/** /**
* *
@ -50,18 +58,25 @@ import mage.game.events.GameEvent;
*/ */
public class ChiefEngineer extends CardImpl { public class ChiefEngineer extends CardImpl {
private static final FilterSpell filter = new FilterSpell("Artifact spells you cast");
static {
filter.add(new CardTypePredicate(CardType.ARTIFACT));
}
public ChiefEngineer(UUID ownerId) { public ChiefEngineer(UUID ownerId) {
super(ownerId, 47, "Chief Engineer", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{U}"); super(ownerId, 47, "Chief Engineer", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.expansionSetCode = "M15"; this.expansionSetCode = "M15";
this.subtype.add("Vedalken"); this.subtype.add("Vedalken");
this.subtype.add("Artificer"); this.subtype.add("Artificer");
this.color.setBlue(true);
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Artifact spells you cast have convoke. // Artifact spells you cast have convoke.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ChiefEngineerEffect())); this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD, new ChiefEngineerGainAbilitySpellsEffect(new ConvokeAbility(), filter)));
} }
public ChiefEngineer(final ChiefEngineer card) { public ChiefEngineer(final ChiefEngineer card) {
@ -74,54 +89,49 @@ public class ChiefEngineer extends CardImpl {
} }
} }
class ChiefEngineerEffect extends ReplacementEffectImpl { class ChiefEngineerGainAbilitySpellsEffect extends ContinuousEffectImpl {
public ChiefEngineerEffect() { private final Ability ability;
super(Duration.WhileOnBattlefield, Outcome.Benefit); private final FilterSpell filter;
staticText = "Artifact spells you cast have convoke";
public ChiefEngineerGainAbilitySpellsEffect(Ability ability, FilterSpell filter) {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.ability = ability;
this.filter = filter;
staticText = filter.getMessage() + " have " + ability.getRule();
} }
public ChiefEngineerEffect(final ChiefEngineerEffect effect) { public ChiefEngineerGainAbilitySpellsEffect(final ChiefEngineerGainAbilitySpellsEffect effect) {
super(effect); super(effect);
this.ability = effect.ability;
this.filter = effect.filter;
} }
@Override @Override
public ChiefEngineerEffect copy() { public ChiefEngineerGainAbilitySpellsEffect copy() {
return new ChiefEngineerEffect(this); return new ChiefEngineerGainAbilitySpellsEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return true; Player player = game.getPlayer(source.getControllerId());
} Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
@Override for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
public boolean replaceEvent(GameEvent event, Ability source, Game game) { StackObject stackObject = iterator.next();
MageObject object = game.getObject(event.getSourceId()); // only cast spells, so no copies
if (object != null) { if (!stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) {
Card card = (Card) object; if (stackObject instanceof Spell) {
Ability ability = new ConvokeAbility(); Spell spell = (Spell) stackObject;
game.getState().addOtherAbility(card, ability); if (filter.match(spell, game)) {
ability.setControllerId(source.getControllerId()); if (!spell.getAbilities().contains(ability)) {
ability.setSourceId(card.getId()); game.getState().addOtherAbility(spell.getCard(), ability);
game.getState().addAbility(ability, source.getSourceId(), card); }
} }
return false; }
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ((event.getType() == GameEvent.EventType.CAST_SPELL)
&& event.getPlayerId() == source.getControllerId()) {
MageObject spellObject = game.getObject(event.getSourceId());
if (spellObject != null && spellObject.getCardType().contains(CardType.ARTIFACT)) {
return true;
} }
return true;
} }
return false; return false;
} }

View file

@ -246,6 +246,7 @@ public abstract class AbilityImpl implements Ability {
if (controller == null) { if (controller == null) {
return false; return false;
} }
game.applyEffects();
/* 20130201 - 601.2b /* 20130201 - 601.2b
* If the spell is modal the player announces the mode choice (see rule 700.2). * If the spell is modal the player announces the mode choice (see rule 700.2).

View file

@ -251,8 +251,9 @@ class ConvokeEffect extends OneShotEffect {
manaPool.unlockManaType(ManaType.COLORLESS); manaPool.unlockManaType(ManaType.COLORLESS);
manaName = "colorless"; manaName = "colorless";
} }
if (!game.isSimulation()) if (!game.isSimulation()) {
game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana"); game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana");
}
} }
} }

View file

@ -13,6 +13,7 @@ import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.mana.AlternateManaPaymentAbility; import mage.abilities.costs.mana.AlternateManaPaymentAbility;
import mage.cards.Card;
import mage.game.Game; import mage.game.Game;
/** /**
@ -351,8 +352,8 @@ public class ManaUtil {
public static String addSpecialManaPayAbilities(Ability source, Game game, ManaCost unpaid) { public static String addSpecialManaPayAbilities(Ability source, Game game, ManaCost unpaid) {
// check for special mana payment possibilities // check for special mana payment possibilities
MageObject mageObject = source.getSourceObject(game); MageObject mageObject = source.getSourceObject(game);
if (mageObject != null) { if (mageObject instanceof Card) {
for (Ability ability :mageObject.getAbilities()) { for (Ability ability :((Card)mageObject).getAbilities(game)) {
if (ability instanceof AlternateManaPaymentAbility) { if (ability instanceof AlternateManaPaymentAbility) {
((AlternateManaPaymentAbility) ability).addSpecialAction(source, game, unpaid); ((AlternateManaPaymentAbility) ability).addSpecialAction(source, game, unpaid);
} }