rework Banewasp Affliction

This commit is contained in:
xenohedron 2023-10-19 22:51:50 -04:00
parent 2d5ea0c1d5
commit 1c19280693
2 changed files with 60 additions and 41 deletions

View file

@ -1,24 +1,21 @@
package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.DiesAttachedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.AttachedPermanentToughnessCount;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Plopman
@ -29,7 +26,6 @@ public final class BanewaspAffliction extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
@ -38,7 +34,10 @@ public final class BanewaspAffliction extends CardImpl {
this.addAbility(ability);
// When enchanted creature dies, that creature's controller loses life equal to its toughness.
this.addAbility( new DiesAttachedTriggeredAbility(new BanewaspAfflictionLoseLifeEffect(), "enchanted creature"));
this.addAbility( new DiesAttachedTriggeredAbility(
new LoseLifeControllerAttachedEffect(AttachedPermanentToughnessCount.instance)
.setText("that creature's controller loses life equal to its toughness"),
"enchanted creature"));
}
private BanewaspAffliction(final BanewaspAffliction card) {
@ -50,35 +49,3 @@ public final class BanewaspAffliction extends CardImpl {
return new BanewaspAffliction(this);
}
}
class BanewaspAfflictionLoseLifeEffect extends OneShotEffect {
public BanewaspAfflictionLoseLifeEffect() {
super(Outcome.LoseLife);
this.staticText = "that creature's controller loses life equal to its toughness";
}
private BanewaspAfflictionLoseLifeEffect(final BanewaspAfflictionLoseLifeEffect copy) {
super(copy);
}
@Override
public BanewaspAfflictionLoseLifeEffect copy() {
return new BanewaspAfflictionLoseLifeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = (Permanent) getValue("attachedTo");
if(creature != null){
Player player = game.getPlayer(creature.getOwnerId());
if (player != null) {
player.loseLife(creature.getToughness().getValue(), game, source, false);
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,52 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author xenohedron
*/
public enum AttachedPermanentToughnessCount implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent attachmentPermanent = game.getPermanent(sourceAbility.getSourceId());
if (attachmentPermanent == null) {
attachmentPermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD, sourceAbility.getSourceObjectZoneChangeCounter());
}
if (attachmentPermanent == null || attachmentPermanent.getAttachedTo() == null) {
return 0;
}
Permanent attached;
if (effect.getValue("attachedTo") instanceof Permanent) {
// This way is needed to obtain correct LKI (e.g. Persist)
attached = (Permanent) effect.getValue("attachedTo");
} else {
attached = game.getPermanentOrLKIBattlefield(attachmentPermanent.getAttachedTo());
}
if (attached != null && attached.getToughness().getValue() >= 0) {
return attached.getToughness().getValue();
}
return 0;
}
@Override
public AttachedPermanentToughnessCount copy() {
return instance;
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "its toughness";
}
}