mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
- Fixed #6205
This commit is contained in:
parent
897dcb3343
commit
eb730d4fc3
1 changed files with 18 additions and 27 deletions
|
@ -2,23 +2,18 @@ package mage.cards.h;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
|
||||||
import mage.abilities.keyword.LifelinkAbility;
|
import mage.abilities.keyword.LifelinkAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterPermanent;
|
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
|
||||||
import mage.filter.predicate.permanent.EnchantedPredicate;
|
|
||||||
import mage.game.Controllable;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
|
@ -35,7 +30,8 @@ public final class HatefulEidolon extends CardImpl {
|
||||||
// Lifelink
|
// Lifelink
|
||||||
this.addAbility(LifelinkAbility.getInstance());
|
this.addAbility(LifelinkAbility.getInstance());
|
||||||
|
|
||||||
// Whenever an enchanted creature dies, draw a card for each Aura you controlled that was attached to it.
|
// Whenever an enchanted creature dies, draw a card for each
|
||||||
|
// Aura you controlled that was attached to it.
|
||||||
this.addAbility(new HatefulEidolonTriggeredAbility());
|
this.addAbility(new HatefulEidolonTriggeredAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +47,6 @@ public final class HatefulEidolon extends CardImpl {
|
||||||
|
|
||||||
class HatefulEidolonTriggeredAbility extends TriggeredAbilityImpl {
|
class HatefulEidolonTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
private static final FilterPermanent filter = new FilterCreaturePermanent();
|
|
||||||
|
|
||||||
static {
|
|
||||||
filter.add(EnchantedPredicate.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
HatefulEidolonTriggeredAbility() {
|
HatefulEidolonTriggeredAbility() {
|
||||||
super(Zone.BATTLEFIELD, null, false);
|
super(Zone.BATTLEFIELD, null, false);
|
||||||
}
|
}
|
||||||
|
@ -77,21 +67,21 @@ class HatefulEidolonTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
int auraCount = 0;
|
||||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
if (!zEvent.isDiesEvent() || !filter.match(zEvent.getTarget(), game)) {
|
if (!zEvent.isDiesEvent()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int auraCount = zEvent
|
Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
||||||
.getTarget()
|
if (deadCreature.getAttachments().isEmpty()) {
|
||||||
.getAttachments()
|
return false;
|
||||||
.stream()
|
}
|
||||||
.map(game::getPermanentOrLKIBattlefield)
|
for (UUID auraId : deadCreature.getAttachments()) {
|
||||||
.filter(Objects::nonNull)
|
Permanent aura = game.getPermanentOrLKIBattlefield(auraId);
|
||||||
.filter(permanent -> permanent.hasSubtype(SubType.AURA, game))
|
if (aura.getControllerId().equals(controllerId)) {
|
||||||
.map(Controllable::getControllerId)
|
auraCount += 1;
|
||||||
.filter(this.getControllerId()::equals)
|
}
|
||||||
.mapToInt(x -> 1)
|
}
|
||||||
.sum();
|
|
||||||
this.getEffects().clear();
|
this.getEffects().clear();
|
||||||
this.addEffect(new DrawCardSourceControllerEffect(auraCount));
|
this.addEffect(new DrawCardSourceControllerEffect(auraCount));
|
||||||
return true;
|
return true;
|
||||||
|
@ -99,6 +89,7 @@ class HatefulEidolonTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "Whenever an enchanted creature dies, draw a card for each Aura you controlled that was attached to it.";
|
return "Whenever an enchanted creature dies, draw a card for each "
|
||||||
|
+ "Aura you controlled that was attached to it.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue