mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
fixed implementation of Diffusion Sliver (fixes #5941)
This commit is contained in:
parent
0680462835
commit
54f17ac78d
1 changed files with 25 additions and 28 deletions
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
|
|
@ -12,32 +10,33 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetStackObject;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class DiffusionSliver extends CardImpl {
|
||||
|
||||
public DiffusionSliver(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
|
||||
this.subtype.add(SubType.SLIVER);
|
||||
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever a Sliver creature you control becomes the target of a spell or ability an opponent controls, counter that spell or ability unless its controller pays {2}.
|
||||
this.addAbility(new DiffusionSliverTriggeredAbility(new CounterUnlessPaysEffect(new GenericManaCost(2))));
|
||||
this.addAbility(new DiffusionSliverTriggeredAbility());
|
||||
}
|
||||
|
||||
public DiffusionSliver(final DiffusionSliver card) {
|
||||
private DiffusionSliver(final DiffusionSliver card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
|
@ -49,17 +48,13 @@ public final class DiffusionSliver extends CardImpl {
|
|||
|
||||
class DiffusionSliverTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Sliver creature you control");
|
||||
private static final FilterPermanent filter = new FilterControlledCreaturePermanent(SubType.SLIVER);
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate(SubType.SLIVER));
|
||||
DiffusionSliverTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
public DiffusionSliverTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
|
||||
public DiffusionSliverTriggeredAbility(final DiffusionSliverTriggeredAbility ability) {
|
||||
private DiffusionSliverTriggeredAbility(final DiffusionSliverTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
|
@ -75,21 +70,23 @@ class DiffusionSliverTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
||||
Permanent creature = game.getPermanent(event.getTargetId());
|
||||
if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) {
|
||||
this.getTargets().clear();
|
||||
TargetStackObject target = new TargetStackObject();
|
||||
target.add(event.getSourceId(), game);
|
||||
this.addTarget(target);
|
||||
return true;
|
||||
}
|
||||
if (!game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Permanent creature = game.getPermanent(event.getTargetId());
|
||||
if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
this.getEffects().clear();
|
||||
Effect effect = new CounterUnlessPaysEffect(new GenericManaCost(2));
|
||||
effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
|
||||
this.addEffect(effect);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a Sliver creature you control becomes the target of a spell or ability an opponent controls, counter that spell or ability unless its controller pays {2}.";
|
||||
return "Whenever a Sliver creature you control becomes the target of a spell or ability an opponent controls, " +
|
||||
"counter that spell or ability unless its controller pays {2}.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue