Manifest: fixed check with worms of the earth

This commit is contained in:
Hanmac
2018-02-16 14:02:34 +01:00
parent efed143a11
commit e72edb95b5
3 changed files with 28 additions and 6 deletions

View File

@@ -268,6 +268,10 @@ public class GameAction {
// if something would only be a land when entering the battlefield and not before // if something would only be a land when entering the battlefield and not before
// put it into the graveyard instead // put it into the graveyard instead
zoneTo = c.getOwner().getZone(ZoneType.Graveyard); zoneTo = c.getOwner().getZone(ZoneType.Graveyard);
// reset facedown
copied.setState(CardStateName.Original, false);
copied.setManifested(false);
copied.updateStateForView();
} }
} }

View File

@@ -167,9 +167,9 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
Card movedCard = null; Card movedCard = null;
if (sa.hasParam("GainControl")) { if (sa.hasParam("GainControl")) {
c.setController(sa.getActivatingPlayer(), game.getNextTimestamp()); c.setController(sa.getActivatingPlayer(), game.getNextTimestamp());
movedCard = game.getAction().moveToPlay(c, sa.getActivatingPlayer(), null); movedCard = game.getAction().moveToPlay(c, sa.getActivatingPlayer(), sa);
} else { } else {
movedCard = game.getAction().moveTo(destination, c, libraryPos, null); movedCard = game.getAction().moveTo(destination, c, libraryPos, sa);
if (destination == ZoneType.Exile && !c.isToken()) { if (destination == ZoneType.Exile && !c.isToken()) {
Card host = sa.getOriginalHost(); Card host = sa.getOriginalHost();
if (host == null) { if (host == null) {

View File

@@ -1,27 +1,33 @@
package forge.game.ability.effects; package forge.game.ability.effects;
import com.google.common.collect.Sets;
import forge.card.CardStateName;
import forge.game.Game;
import forge.game.GlobalRuleChange;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect; import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.card.CardCollection; import forge.game.card.CardCollection;
import forge.game.card.CardLists; import forge.game.card.CardLists;
import forge.game.card.CardUtil;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType;
public class ManifestEffect extends SpellAbilityEffect { public class ManifestEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final Game game = source.getGame();
// Usually a number leaving possibility for X, Sacrifice X land: Manifest X creatures. // Usually a number leaving possibility for X, Sacrifice X land: Manifest X creatures.
final int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(sa.getHostCard(), final int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(source,
sa.getParam("Amount"), sa) : 1; sa.getParam("Amount"), sa) : 1;
// Most commonly "defined" is Top of Library // Most commonly "defined" is Top of Library
final String defined = sa.hasParam("Defined") ? sa.getParam("Defined") : "TopOfLibrary"; final String defined = sa.hasParam("Defined") ? sa.getParam("Defined") : "TopOfLibrary";
final TargetRestrictions tgt = sa.getTargetRestrictions();
for (final Player p : getTargetPlayers(sa, "DefinedPlayer")) { for (final Player p : getTargetPlayers(sa, "DefinedPlayer")) {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if (sa.usesTargeting() || p.canBeTargetedBy(sa)) {
CardCollection tgtCards; CardCollection tgtCards;
if ("TopOfLibrary".equals(defined)) { if ("TopOfLibrary".equals(defined)) {
tgtCards = p.getTopXCardsFromLibrary(amount); tgtCards = p.getTopXCardsFromLibrary(amount);
@@ -34,6 +40,18 @@ public class ManifestEffect extends SpellAbilityEffect {
} }
for(Card c : tgtCards) { for(Card c : tgtCards) {
//check if lki would be a land entering the battlefield
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLandBattlefield)) {
Card lki = CardUtil.getLKICopy(c);
lki.setState(CardStateName.FaceDown, false);
lki.setManifested(true);
lki.setLastKnownZone(p.getZone(ZoneType.Battlefield));
CardCollection preList = new CardCollection(lki);
game.getAction().checkStaticAbilities(false, Sets.newHashSet(lki), preList);
if (lki.isLand()) {
continue;
}
}
Card rem = c.manifest(p, sa); Card rem = c.manifest(p, sa);
if (sa.hasParam("RememberManifested") && rem != null) { if (sa.hasParam("RememberManifested") && rem != null) {
source.addRemembered(rem); source.addRemembered(rem);