mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Chief Engineer - Fixed that convoke did not work for Artifacts while Chief Engineer was on the battlefield.
This commit is contained in:
parent
70f152feb1
commit
1067ba296b
4 changed files with 58 additions and 45 deletions
|
@ -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,55 +89,50 @@ 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) {
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
|
if (player != null && permanent != null) {
|
||||||
|
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||||
|
StackObject stackObject = iterator.next();
|
||||||
|
// only cast spells, so no copies
|
||||||
|
if (!stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) {
|
||||||
|
if (stackObject instanceof Spell) {
|
||||||
|
Spell spell = (Spell) stackObject;
|
||||||
|
if (filter.match(spell, game)) {
|
||||||
|
if (!spell.getAbilities().contains(ability)) {
|
||||||
|
game.getState().addOtherAbility(spell.getCard(), ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
|
||||||
if (object != null) {
|
|
||||||
Card card = (Card) object;
|
|
||||||
Ability ability = new ConvokeAbility();
|
|
||||||
game.getState().addOtherAbility(card, ability);
|
|
||||||
ability.setControllerId(source.getControllerId());
|
|
||||||
ability.setSourceId(card.getId());
|
|
||||||
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 false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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).
|
||||||
|
|
|
@ -251,9 +251,10 @@ 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");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue