mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Soulflayer - Fixed a bug that Soulflayer had abilities from previous casts when leaving and returning to battlefield.
This commit is contained in:
parent
306a0874dd
commit
d07d3228a1
1 changed files with 48 additions and 46 deletions
|
@ -32,6 +32,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
@ -59,6 +60,7 @@ import mage.constants.SubLayer;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -95,10 +97,11 @@ public class Soulflayer extends CardImpl {
|
|||
class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
private Set<Ability> abilitiesToAdd;
|
||||
private MageObjectReference objectReference = null;
|
||||
|
||||
public SoulflayerEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
staticText = "If a creature card with flying was exiled with Soulflayer's delve ability, Soulflayer has flying. The same is true for first strike, double strike, deathtouch, haste, hexproof, indestructible, lifelink, reach, trample, and vigilance";
|
||||
staticText = "If a creature card with flying was exiled with {this}'s delve ability, {this} has flying. The same is true for first strike, double strike, deathtouch, haste, hexproof, indestructible, lifelink, reach, trample, and vigilance";
|
||||
abilitiesToAdd = null;
|
||||
}
|
||||
|
||||
|
@ -108,6 +111,7 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
|||
this.abilitiesToAdd = new HashSet<>();
|
||||
this.abilitiesToAdd.addAll(effect.abilitiesToAdd);
|
||||
}
|
||||
this.objectReference = effect.objectReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,11 +123,11 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (abilitiesToAdd == null) {
|
||||
for (Ability ability :permanent.getAbilities()) {
|
||||
if (ability instanceof DelveAbility) {
|
||||
List<Card> delvedCards = ((DelveAbility) ability).getDelvedCards();
|
||||
if (objectReference == null || !objectReference.refersTo(permanent)) {
|
||||
abilitiesToAdd = new HashSet<>();
|
||||
this.objectReference = new MageObjectReference(permanent);
|
||||
String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game, true);
|
||||
List<Card> delvedCards = (List<Card>) game.getState().getValue(keyString);
|
||||
if (delvedCards != null) {
|
||||
for(Card card: delvedCards) {
|
||||
if (!card.getCardType().contains(CardType.CREATURE)) {
|
||||
|
@ -167,8 +171,6 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Ability ability: abilitiesToAdd) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue