* Electropotence - Fixed that it did not trigger for tokens and mana payment is now during resolution as it should be.

This commit is contained in:
LevelX2 2014-03-21 14:40:55 +01:00
parent e4231c7977
commit a079727608
2 changed files with 33 additions and 32 deletions

View file

@ -34,9 +34,9 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -76,7 +76,6 @@ class ElectropotenceTriggeredAbility extends TriggeredAbilityImpl<Electropotence
public ElectropotenceTriggeredAbility() { public ElectropotenceTriggeredAbility() {
super(Zone.BATTLEFIELD, new ElectropotenceEffect()); super(Zone.BATTLEFIELD, new ElectropotenceEffect());
this.costs.add(new ManaCostsImpl("{2}{R}"));
} }
public ElectropotenceTriggeredAbility(ElectropotenceTriggeredAbility ability) { public ElectropotenceTriggeredAbility(ElectropotenceTriggeredAbility ability) {
@ -87,14 +86,10 @@ class ElectropotenceTriggeredAbility extends TriggeredAbilityImpl<Electropotence
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.getCardType().contains(CardType.CREATURE) if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)
&& permanent.getControllerId().equals(this.controllerId)) { && permanent.getControllerId().equals(this.controllerId)) {
Player player = game.getPlayer(this.getControllerId()); this.getEffects().get(0).setValue("damageSource", event.getTargetId());
Card card = game.getCard(event.getTargetId()); return true;
if (player != null && card != null && player.chooseUse(Outcome.Damage, "Pay {2}{R}? If you do, " + card.getName() + " deals damage equal to its power to target creature or player.", game)) {
this.getEffects().get(0).setValue("damageSource", event.getTargetId());
return true;
}
} }
} }
return false; return false;
@ -129,23 +124,28 @@ class ElectropotenceEffect extends OneShotEffect<ElectropotenceEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
UUID creatureId = (UUID) getValue("damageSource"); UUID creatureId = (UUID) getValue("damageSource");
Permanent creature = game.getPermanent(creatureId); Permanent creature = game.getPermanentOrLKIBattlefield(creatureId);
if (creature == null) { Player controller = game.getPlayer(source.getControllerId());
creature = (Permanent) game.getLastKnownInformation(creatureId, Zone.BATTLEFIELD); if (creature != null && controller != null) {
} if (controller.chooseUse(Outcome.Damage, "Pay {2}{R} to do the damage?", game)) {
if (creature != null) { // if (controller.chooseUse(Outcome.Damage, "Pay {2}{R}? If you do, " + creature.getName() + " deals damage equal to its power to target creature or player.", game)) {
int amount = creature.getPower().getValue(); ManaCosts manaCosts = new ManaCostsImpl("{2}{R}");
UUID target = source.getTargets().getFirstTarget(); if (manaCosts.pay(source, game, source.getSourceId(), controller.getId(), false)) {
Permanent targetCreature = game.getPermanent(target); int amount = creature.getPower().getValue();
if (targetCreature != null) { UUID target = source.getTargets().getFirstTarget();
targetCreature.damage(amount, creature.getId(), game, true, false); Permanent targetCreature = game.getPermanent(target);
return true; if (targetCreature != null) {
} targetCreature.damage(amount, creature.getId(), game, true, false);
Player player = game.getPlayer(target); } else {
if (player != null) { Player player = game.getPlayer(target);
player.damage(amount, creature.getId(), game, false, true); if (player != null) {
return true; player.damage(amount, creature.getId(), game, false, true);
} }
}
}
}
return true;
} }
return false; return false;
} }

View file

@ -305,12 +305,13 @@ class ReboundCastSpellFromExileEffect extends OneShotEffect<ReboundCastSpellFrom
} }
Card reboundCard = zone.get(this.cardId, game); Card reboundCard = zone.get(this.cardId, game);
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
SpellAbility ability = reboundCard.getSpellAbility(); if (player != null && reboundCard != null) {
SpellAbility ability = reboundCard.getSpellAbility();
player.cast(ability, game, true); player.cast(ability, game, true);
zone.remove(reboundCard.getId()); zone.remove(reboundCard.getId());
return true;
return true; }
return false;
} }
@Override @Override