mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Toxin Sliver - Fixed not corretly working triggerd ability.
This commit is contained in:
parent
25e0dfa699
commit
a3659826a8
4 changed files with 100 additions and 101 deletions
|
@ -28,7 +28,7 @@
|
|||
package mage.cards.q;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.DealsDamageToACreatureAllTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.RemoveCountersSourceCost;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
|
@ -37,13 +37,10 @@ import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedCreatureEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +54,11 @@ public class QuestForTheGemblades extends CardImpl {
|
|||
|
||||
|
||||
// Whenever a creature you control deals combat damage to a creature, you may put a quest counter on Quest for the Gemblades.
|
||||
this.addAbility(new QuestForTheGembladesTriggeredAbility());
|
||||
this.addAbility(new DealsDamageToACreatureAllTriggeredAbility(
|
||||
new AddCountersSourceEffect(CounterType.QUEST.createInstance()), false,
|
||||
StaticFilters.FILTER_CONTROLLED_A_CREATURE,
|
||||
SetTargetPointer.PERMANENT, true));
|
||||
|
||||
// Remove a quest counter from Quest for the Gemblades and sacrifice it: Put four +1/+1 counters on target creature.
|
||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new AddCountersTargetEffect(CounterType.P1P1.createInstance(4)),
|
||||
|
@ -76,43 +77,3 @@ public class QuestForTheGemblades extends CardImpl {
|
|||
return new QuestForTheGemblades(this);
|
||||
}
|
||||
}
|
||||
|
||||
class QuestForTheGembladesTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public QuestForTheGembladesTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance()), true);
|
||||
}
|
||||
|
||||
public QuestForTheGembladesTriggeredAbility(final QuestForTheGembladesTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuestForTheGembladesTriggeredAbility copy() {
|
||||
return new QuestForTheGembladesTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_CREATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((DamagedCreatureEvent) event).isCombatDamage()) {
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent == null) {
|
||||
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE) && permanent.getControllerId().equals(this.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a creature you control deals combat damage to a creature, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,13 @@ package mage.cards.t;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.DealsDamageToACreatureTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.common.DealsDamageToACreatureAllTriggeredAbility;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,7 +51,10 @@ public class ToxinSliver extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// Whenever a Sliver deals combat damage to a creature, destroy that creature. It can't be regenerated.
|
||||
this.addAbility(new DealsDamageToACreatureTriggeredAbility(new DestroyTargetEffect(true), true, false, true));
|
||||
this.addAbility(new DealsDamageToACreatureAllTriggeredAbility(
|
||||
new DestroyTargetEffect(true), false,
|
||||
new FilterCreaturePermanent("Sliver","a Sliver"),
|
||||
SetTargetPointer.PERMANENT, true));
|
||||
|
||||
}
|
||||
|
||||
|
@ -69,48 +67,3 @@ public class ToxinSliver extends CardImpl {
|
|||
return new ToxinSliver(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DealsDamageTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private boolean setTargetPointer;
|
||||
|
||||
public DealsDamageTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
public DealsDamageTriggeredAbility(final DealsDamageTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsDamageTriggeredAbility copy() {
|
||||
return new DealsDamageTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_CREATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (game.getPermanent(event.getSourceId()).hasSubtype("Sliver", game)) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(game.getControllerId(event.getTargetId())));
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a Sliver deals damage to a creature" + super.getRule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedCreatureEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ludwig.Hirth
|
||||
*/
|
||||
public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final boolean combatDamageOnly;
|
||||
private final FilterPermanent filterPermanent;
|
||||
private final SetTargetPointer setTargetPointer;
|
||||
|
||||
public DealsDamageToACreatureAllTriggeredAbility(Effect effect, boolean optional, FilterPermanent filterPermanent, SetTargetPointer setTargetPointer, boolean combatDamageOnly) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.combatDamageOnly = combatDamageOnly;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
this.filterPermanent = filterPermanent;
|
||||
}
|
||||
|
||||
public DealsDamageToACreatureAllTriggeredAbility(final DealsDamageToACreatureAllTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.combatDamageOnly = ability.combatDamageOnly;
|
||||
this.filterPermanent = ability.filterPermanent;
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsDamageToACreatureAllTriggeredAbility copy() {
|
||||
return new DealsDamageToACreatureAllTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_CREATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!combatDamageOnly || ((DamagedCreatureEvent) event).isCombatDamage()) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
if (permanent != null && filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("damage", event.getAmount());
|
||||
effect.setValue("sourceId", event.getSourceId());
|
||||
switch (setTargetPointer) {
|
||||
case PLAYER:
|
||||
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
||||
break;
|
||||
case PERMANENT:
|
||||
effect.setTargetPointer(new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game)));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever " + filterPermanent.getMessage() + " deals "
|
||||
+ (combatDamageOnly ? "combat ":"") + "damage to a creature, " + super.getRule();
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import mage.constants.CardType;
|
|||
import mage.filter.common.FilterArtifactCard;
|
||||
import mage.filter.common.FilterArtifactCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledArtifactPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.common.FilterCreatureSpell;
|
||||
|
@ -25,6 +26,7 @@ public class StaticFilters {
|
|||
public static final FilterCreaturePermanent FILTER_ARTIFACT_CREATURE_PERMANENT = new FilterArtifactCreaturePermanent();
|
||||
public static final FilterPermanent FILTER_PERMANENT_ARTIFACT_OR_CREATURE = new FilterPermanent("artifact or creature");
|
||||
public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE = new FilterControlledPermanent("artifact or creature you control");
|
||||
public static final FilterControlledPermanent FILTER_CONTROLLED_A_CREATURE = new FilterControlledCreaturePermanent("a creature you control");
|
||||
public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_ARTIFACT = new FilterControlledArtifactPermanent();
|
||||
public static final FilterArtifactCard FILTER_CARD_ARTIFACT = new FilterArtifactCard();
|
||||
public static final FilterNonlandCard FILTER_CARD_NON_LAND = new FilterNonlandCard();
|
||||
|
|
Loading…
Reference in a new issue