mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
- Refactor EnchantedCreatureBlockedTriggeredAbility to BecomesBlockedAttachedTriggeredAbility
This commit is contained in:
parent
0d83a8e09a
commit
3d0cd99655
4 changed files with 57 additions and 5 deletions
|
@ -4,7 +4,7 @@ package mage.cards.b;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EnchantedCreatureBlockedTriggeredAbility;
|
||||
import mage.abilities.common.BecomesBlockedAttachedTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
|
@ -46,7 +46,7 @@ public final class BestialFury extends CardImpl {
|
|||
new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1), Duration.OneUse)), false));
|
||||
|
||||
// Whenever enchanted creature becomes blocked, it gets +4/+0 and gains trample until end of turn.
|
||||
Ability pumpAbility = new EnchantedCreatureBlockedTriggeredAbility(new BoostEnchantedEffect(4, 0, Duration.EndOfTurn), false);
|
||||
Ability pumpAbility = new BecomesBlockedAttachedTriggeredAbility(new BoostEnchantedEffect(4, 0, Duration.EndOfTurn), false);
|
||||
pumpAbility.addEffect(new GainAbilityAttachedEffect(TrampleAbility.getInstance(), AttachmentType.AURA, Duration.EndOfTurn));
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class Insubordination extends CardImpl {
|
|||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package mage.cards.l;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EnchantedCreatureBlockedTriggeredAbility;
|
||||
import mage.abilities.common.BecomesBlockedAttachedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -41,7 +41,7 @@ public final class LaccolithRig extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Whenever enchanted creature becomes blocked, you may have it deal damage equal to its power to target creature. If you do, the first creature assigns no combat damage this turn.
|
||||
Ability ability2 = new EnchantedCreatureBlockedTriggeredAbility(new LaccolithRigEffect(), true);
|
||||
Ability ability2 = new BecomesBlockedAttachedTriggeredAbility(new LaccolithRigEffect(), true);
|
||||
ability2.addTarget(new TargetCreaturePermanent());
|
||||
Effect effect = new GainAbilityTargetEffect(new SimpleStaticAbility(Zone.BATTLEFIELD, new AssignNoCombatDamageSourceEffect(Duration.Custom, true).setText("")), Duration.EndOfTurn, "If you do, the first creature assigns no combat damage this turn");
|
||||
ability2.addEffect(effect);
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author L_J
|
||||
*/
|
||||
public class BecomesBlockedAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public BecomesBlockedAttachedTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
public BecomesBlockedAttachedTriggeredAbility(final BecomesBlockedAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CREATURE_BLOCKED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent equipment = game.getPermanent(sourceId);
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent equipped = game.getPermanent(equipment.getAttachedTo());
|
||||
if (equipped.getId().equals(event.getTargetId())) {
|
||||
getEffects().get(1).setTargetPointer(new FixedTarget(equipped, game));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever enchanted creature becomes blocked, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesBlockedAttachedTriggeredAbility copy() {
|
||||
return new BecomesBlockedAttachedTriggeredAbility(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue