mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
reimplement Phyrexian Negator (#12792)
Rewrote Phyrexian Negator using DealtDamageToSourceTriggeredAbility to simplify code
This commit is contained in:
parent
cd99594c38
commit
4ef3aa0ace
1 changed files with 10 additions and 55 deletions
|
|
@ -1,30 +1,26 @@
|
|||
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.common.SacrificeEffect;
|
||||
import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.SavedDamageValue;
|
||||
import mage.abilities.effects.common.SacrificeControllerEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.filter.StaticFilters;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
* @author Svyatoslav28
|
||||
*/
|
||||
public final class PhyrexianNegator extends CardImpl {
|
||||
|
||||
public PhyrexianNegator(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
|
||||
this.subtype.add(SubType.PHYREXIAN);
|
||||
this.subtype.add(SubType.HORROR);
|
||||
|
||||
|
|
@ -34,7 +30,7 @@ public final class PhyrexianNegator extends CardImpl {
|
|||
// Trample
|
||||
this.addAbility(TrampleAbility.getInstance());
|
||||
// Whenever Phyrexian Negator is dealt damage, sacrifice that many permanents.
|
||||
this.addAbility(new PhyrexianNegatorTriggeredAbility());
|
||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(new SacrificeControllerEffect(StaticFilters.FILTER_PERMANENTS, SavedDamageValue.MANY, ""), false));
|
||||
}
|
||||
|
||||
private PhyrexianNegator(final PhyrexianNegator card) {
|
||||
|
|
@ -46,44 +42,3 @@ public final class PhyrexianNegator extends CardImpl {
|
|||
return new PhyrexianNegator(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhyrexianNegatorTriggeredAbility extends TriggeredAbilityImpl {
|
||||
PhyrexianNegatorTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new SacrificeEffect(new FilterPermanent(), 0,""));
|
||||
}
|
||||
|
||||
private PhyrexianNegatorTriggeredAbility(final PhyrexianNegatorTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhyrexianNegatorTriggeredAbility copy() {
|
||||
return new PhyrexianNegatorTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_BATCH_FOR_ONE_PERMANENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getTargetId().equals(this.sourceId)) {
|
||||
UUID controller = game.getControllerId(event.getTargetId());
|
||||
if (controller != null) {
|
||||
Player player = game.getPlayer(controller);
|
||||
if (player != null) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
|
||||
((SacrificeEffect) getEffects().get(0)).setAmount(StaticValue.get(event.getAmount()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} is dealt damage, sacrifice that many permanents.";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue