mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
[C17] fix Mathas, Fiend Seeker ability coming back when another counter is added
This commit is contained in:
parent
dfd09d9a78
commit
794fb7d42e
1 changed files with 38 additions and 44 deletions
|
|
@ -1,43 +1,30 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.DiesSourceTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardAllEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.abilities.keyword.MenaceAbility;
|
||||
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.common.TargetOpponentsCreaturePermanent;
|
||||
|
||||
import static mage.filter.StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class MathasFiendSeeker extends CardImpl {
|
||||
|
||||
private static final String rule = "For as long as that creature has a bounty counter on it, it has \"When this creature dies, each opponent draws a card and gains 2 life.\"";
|
||||
|
||||
public MathasFiendSeeker(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}{W}{B}");
|
||||
|
||||
|
|
@ -50,12 +37,11 @@ public final class MathasFiendSeeker extends CardImpl {
|
|||
this.addAbility(new MenaceAbility(false));
|
||||
|
||||
// At the beginning of your end step, put a bounty counter on target creature an opponent controls. For as long as that creature has a bounty counter on it, it has "When this creature dies, each opponent draws a card and gains 2 life."
|
||||
Ability ability = new BeginningOfEndStepTriggeredAbility(new AddCountersTargetEffect(CounterType.BOUNTY.createInstance()));
|
||||
ability.addTarget(new TargetPermanent(FILTER_OPPONENTS_PERMANENT_CREATURE));
|
||||
Ability ability2 = new DiesSourceTriggeredAbility(new DrawCardAllEffect(1, TargetController.OPPONENT));
|
||||
ability2.addEffect(new OpponentsGainLifeEffect());
|
||||
Effect effect = new MathasFiendSeekerGainAbilityEffect(ability2, Duration.Custom, rule);
|
||||
ability.addEffect(effect);
|
||||
Ability ability = new BeginningOfEndStepTriggeredAbility(
|
||||
new AddCountersTargetEffect(CounterType.BOUNTY.createInstance())
|
||||
);
|
||||
ability.addEffect(new MathasFiendSeekerGainAbilityEffect());
|
||||
ability.addTarget(new TargetOpponentsCreaturePermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
@ -69,56 +55,64 @@ public final class MathasFiendSeeker extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class MathasFiendSeekerGainAbilityEffect extends GainAbilityTargetEffect {
|
||||
class MathasFiendSeekerGainAbilityEffect extends ContinuousEffectImpl {
|
||||
|
||||
MathasFiendSeekerGainAbilityEffect(Ability ability, Duration duration, String rule) {
|
||||
super(ability, duration, rule);
|
||||
private final Ability ability;
|
||||
|
||||
MathasFiendSeekerGainAbilityEffect() {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
staticText = "For as long as that creature has a bounty counter on it, " +
|
||||
"it has \"When this creature dies, each opponent draws a card and gains 2 life.\"";
|
||||
this.ability = new DiesSourceTriggeredAbility(new DrawCardAllEffect(1, TargetController.OPPONENT));
|
||||
this.ability.addEffect(new MathasFiendSeekerGainLifeEffect());
|
||||
}
|
||||
|
||||
private MathasFiendSeekerGainAbilityEffect(final MathasFiendSeekerGainAbilityEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (creature != null && creature.getCounters(game).getCount(CounterType.BOUNTY) < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
this.ability = effect.ability.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MathasFiendSeekerGainAbilityEffect copy() {
|
||||
return new MathasFiendSeekerGainAbilityEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (creature == null || !creature.getCounters(game).containsKey(CounterType.BOUNTY)) {
|
||||
discard();
|
||||
return false;
|
||||
}
|
||||
creature.addAbility(ability, source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class OpponentsGainLifeEffect extends OneShotEffect {
|
||||
class MathasFiendSeekerGainLifeEffect extends OneShotEffect {
|
||||
|
||||
OpponentsGainLifeEffect() {
|
||||
MathasFiendSeekerGainLifeEffect() {
|
||||
super(Outcome.GainLife);
|
||||
staticText = "and gains 2 life.";
|
||||
}
|
||||
|
||||
private OpponentsGainLifeEffect(final OpponentsGainLifeEffect effect) {
|
||||
private MathasFiendSeekerGainLifeEffect(final MathasFiendSeekerGainLifeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpponentsGainLifeEffect copy() {
|
||||
return new OpponentsGainLifeEffect(this);
|
||||
public MathasFiendSeekerGainLifeEffect copy() {
|
||||
return new MathasFiendSeekerGainLifeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
for (UUID playerId : game.getOpponents(source.getControllerId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && game.isOpponent(player, source.getControllerId())) {
|
||||
if (player != null) {
|
||||
player.gainLife(2, game, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue