mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Added onlyCombat damage option to DealsDamageToAPlayerAttachedTriggeredAbility.
This commit is contained in:
parent
3e71b3dbd5
commit
4db53c3b27
6 changed files with 83 additions and 67 deletions
|
@ -30,7 +30,7 @@ package mage.sets.alarareborn;
|
|||
import java.util.UUID;
|
||||
|
||||
import mage.constants.*;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerAttachedTriggeredAbility;
|
||||
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.common.DrawCardControllerEffect;
|
||||
|
@ -56,7 +56,7 @@ public class MaskOfRiddles extends CardImpl<MaskOfRiddles> {
|
|||
// Equipped creature has fear.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FearAbility.getInstance(), AttachmentType.EQUIPMENT)));
|
||||
// Whenever equipped creature deals combat damage to a player, you may draw a card.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerAttachedTriggeredAbility(new DrawCardControllerEffect(1), "equipped", true));
|
||||
this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DrawCardControllerEffect(1), "equipped", true));
|
||||
// Equip {2}
|
||||
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2)));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
|||
|
||||
import mage.constants.*;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerAttachedTriggeredAbility;
|
||||
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DiscardTargetEffect;
|
||||
|
@ -68,7 +68,7 @@ public class ElderMastery extends CardImpl<ElderMastery> {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3, Duration.WhileOnBattlefield)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA, Duration.WhileOnBattlefield)));
|
||||
// Whenever enchanted creature deals damage to a player, that player discards two cards.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerAttachedTriggeredAbility(new DiscardTargetEffect(2), "enchanted", false, true));
|
||||
this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DiscardTargetEffect(2), "enchanted", false, true));
|
||||
}
|
||||
|
||||
public ElderMastery(final ElderMastery card) {
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerAttachedTriggeredAbility;
|
||||
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -64,7 +64,7 @@ public class ElbrusTheBindingBlade extends CardImpl<ElbrusTheBindingBlade> {
|
|||
// Equipped creature gets +1/+0.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 0)));
|
||||
// When equipped creature deals combat damage to a player, unattach Elbrus, the Binding Blade, then transform it.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerAttachedTriggeredAbility(new ElbrusTheBindingBladeEffect(), "equipped", true));
|
||||
this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new ElbrusTheBindingBladeEffect(), "equipped", true));
|
||||
// Equip {1}
|
||||
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1)));
|
||||
}
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
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.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
*/
|
||||
public class DealsCombatDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbilityImpl<DealsCombatDamageToAPlayerAttachedTriggeredAbility> {
|
||||
private boolean setFixedTargetPointer;
|
||||
private String attachedDescription;
|
||||
|
||||
public DealsCombatDamageToAPlayerAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) {
|
||||
this(effect, attachedDescription, optional, false);
|
||||
}
|
||||
|
||||
public DealsCombatDamageToAPlayerAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setFixedTargetPointer = setFixedTargetPointer;
|
||||
this.attachedDescription = attachedDescription;
|
||||
}
|
||||
|
||||
public DealsCombatDamageToAPlayerAttachedTriggeredAbility(final DealsCombatDamageToAPlayerAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setFixedTargetPointer = ability.setFixedTargetPointer;
|
||||
this.attachedDescription = ability.attachedDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsCombatDamageToAPlayerAttachedTriggeredAbility copy() {
|
||||
return new DealsCombatDamageToAPlayerAttachedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event instanceof DamagedPlayerEvent) {
|
||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
|
||||
Permanent p = game.getPermanent(event.getSourceId());
|
||||
if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
|
||||
if (setFixedTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever " + attachedDescription + " creature deals combat damage to a player, " + super.getRule();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
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.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
*/
|
||||
public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbilityImpl<DealsDamageToAPlayerAttachedTriggeredAbility> {
|
||||
private boolean setFixedTargetPointer;
|
||||
private String attachedDescription;
|
||||
private boolean onlyCombat;
|
||||
|
||||
public DealsDamageToAPlayerAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) {
|
||||
this(effect, attachedDescription, optional, false);
|
||||
}
|
||||
|
||||
public DealsDamageToAPlayerAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer) {
|
||||
this(effect, attachedDescription, optional, setFixedTargetPointer, true);
|
||||
}
|
||||
|
||||
public DealsDamageToAPlayerAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer, boolean onlyCombat) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setFixedTargetPointer = setFixedTargetPointer;
|
||||
this.attachedDescription = attachedDescription;
|
||||
}
|
||||
|
||||
public DealsDamageToAPlayerAttachedTriggeredAbility(final DealsDamageToAPlayerAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setFixedTargetPointer = ability.setFixedTargetPointer;
|
||||
this.attachedDescription = ability.attachedDescription;
|
||||
this.onlyCombat = ability.onlyCombat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsDamageToAPlayerAttachedTriggeredAbility copy() {
|
||||
return new DealsDamageToAPlayerAttachedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event instanceof DamagedPlayerEvent) {
|
||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
|
||||
Permanent p = game.getPermanent(event.getSourceId());
|
||||
if ((!onlyCombat || damageEvent.isCombatDamage())
|
||||
&& p != null && p.getAttachments().contains(this.getSourceId())) {
|
||||
if (setFixedTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder("Whenever ").append(attachedDescription);
|
||||
sb.append(" creature deals");
|
||||
if (!onlyCombat) {
|
||||
sb.append(" combat");
|
||||
}
|
||||
sb.append(" damage to a player, ").append(super.getRule());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -94,6 +94,9 @@ public class ReturnToHandTargetEffect extends OneShotEffect<ReturnToHandTargetEf
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
if (mode.getTargets().size() < 1) {
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue