mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Fixed Necrotic Plague
This commit is contained in:
parent
2493ba4f11
commit
7659039670
1 changed files with 12 additions and 32 deletions
|
|
@ -21,7 +21,6 @@ import mage.players.Player;
|
|||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.common.TargetOpponentsCreaturePermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -50,7 +49,6 @@ public final class NecroticPlague extends CardImpl {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||
|
||||
ability = new DiesAttachedTriggeredAbility(new NecroticPlagueEffect(), "enchanted creature", false);
|
||||
ability.setTargetAdjuster(NecroticPlagueAdjuster.instance);
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
|
@ -66,29 +64,6 @@ public final class NecroticPlague extends CardImpl {
|
|||
|
||||
}
|
||||
|
||||
enum NecroticPlagueAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
Permanent attachedTo = null;
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
attachedTo = (Permanent) effect.getValue("attachedTo");
|
||||
}
|
||||
if (attachedTo == null) {
|
||||
return;
|
||||
}
|
||||
Player creatureController = game.getPlayer(attachedTo.getControllerId());
|
||||
if (creatureController == null) {
|
||||
return;
|
||||
}
|
||||
ability.setControllerId(creatureController.getId());
|
||||
ability.getTargets().clear();
|
||||
TargetPermanent target = new TargetOpponentsCreaturePermanent();
|
||||
ability.getTargets().add(target);
|
||||
}
|
||||
}
|
||||
|
||||
class NecroticPlagueEffect extends OneShotEffect {
|
||||
|
||||
public NecroticPlagueEffect() {
|
||||
|
|
@ -104,18 +79,23 @@ class NecroticPlagueEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent attachedTo = (Permanent) this.getValue("attachedTo");
|
||||
if (attachedTo != null) {
|
||||
Player sourceController = game.getPlayer(source.getControllerId());
|
||||
Card sourceEnchantmentCard = game.getCard(source.getSourceId());
|
||||
if (attachedTo != null && sourceController != null && sourceEnchantmentCard != null) {
|
||||
Player creatureController = game.getPlayer(attachedTo.getControllerId());
|
||||
if (creatureController != null) {
|
||||
Card sourceEnchantmentCard = game.getCard(source.getSourceId());
|
||||
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (sourceEnchantmentCard != null && creature != null) {
|
||||
TargetOpponentsCreaturePermanent target = new TargetOpponentsCreaturePermanent();
|
||||
if (target.canChoose(sourceEnchantmentCard.getId(), creatureController.getId(), game)) {
|
||||
creatureController.chooseTarget(outcome, target, source, game);
|
||||
Permanent creature = game.getPermanent(target.getFirstTarget());
|
||||
if (creature != null) {
|
||||
game.getState().setValue("attachTo:" + sourceEnchantmentCard.getId(), creature);
|
||||
creatureController.moveCards(sourceEnchantmentCard, Zone.BATTLEFIELD, source, game);
|
||||
sourceController.moveCards(sourceEnchantmentCard, Zone.BATTLEFIELD, source, game);
|
||||
return creature.addAttachment(sourceEnchantmentCard.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue