From 0488da6b222eff4e385fee9aa264ef4d97a5bf8f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 8 Dec 2015 15:24:24 +0100 Subject: [PATCH] * Amoeboid Changeling, Wings of Veles-Vel - Fixed that the character types were changed on the wrong layer. --- .../mage/sets/lorwyn/AmoeboidChangeling.java | 14 ++--- .../src/mage/sets/lorwyn/WingsOfVelisVel.java | 14 ++--- .../sets/stronghold/HibernationSliver.java | 4 +- .../abilities/keywords/ChangelingTest.java | 54 ++++++++++++++++--- .../continuous/GainAbilityTargetEffect.java | 6 ++- ...DuringEachOtherPlayersUntapStepEffect.java | 2 +- 6 files changed, 73 insertions(+), 21 deletions(-) diff --git a/Mage.Sets/src/mage/sets/lorwyn/AmoeboidChangeling.java b/Mage.Sets/src/mage/sets/lorwyn/AmoeboidChangeling.java index 5141b2e47a0..6d29eed8e10 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/AmoeboidChangeling.java +++ b/Mage.Sets/src/mage/sets/lorwyn/AmoeboidChangeling.java @@ -28,7 +28,6 @@ package mage.sets.lorwyn; import java.util.UUID; - import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -39,7 +38,9 @@ import mage.abilities.keyword.ChangelingAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Layer; import mage.constants.Rarity; +import mage.constants.SubLayer; import mage.constants.Zone; import mage.target.common.TargetCreaturePermanent; @@ -58,17 +59,18 @@ public class AmoeboidChangeling extends CardImpl { // Changeling this.addAbility(ChangelingAbility.getInstance()); - + // {tap}: Target creature gains all creature types until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilityTargetEffect(ChangelingAbility.getInstance(), Duration.EndOfTurn), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new GainAbilityTargetEffect(ChangelingAbility.getInstance(), Duration.EndOfTurn, null, false, Layer.TypeChangingEffects_4, SubLayer.NA), new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); - + this.addAbility(ability); - + // {tap}: Target creature loses all creature types until end of turn. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseAllCreatureTypesTargetEffect(Duration.EndOfTurn), new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); - + this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/lorwyn/WingsOfVelisVel.java b/Mage.Sets/src/mage/sets/lorwyn/WingsOfVelisVel.java index c6288c24a5d..ffe50cb4db3 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/WingsOfVelisVel.java +++ b/Mage.Sets/src/mage/sets/lorwyn/WingsOfVelisVel.java @@ -36,7 +36,9 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Layer; import mage.constants.Rarity; +import mage.constants.SubLayer; import mage.target.common.TargetCreaturePermanent; /** @@ -52,20 +54,20 @@ public class WingsOfVelisVel extends CardImpl { // Changeling this.addAbility(ChangelingAbility.getInstance()); - + // Target creature becomes 4/4, gains all creature types, and gains flying until end of turn. this.getSpellAbility().addTarget(new TargetCreaturePermanent()); Effect effect = new SetPowerToughnessTargetEffect(4, 4, Duration.EndOfTurn); effect.setText("Target creature becomes 4/4"); - this.getSpellAbility().addEffect(effect); - - effect = new GainAbilityTargetEffect(ChangelingAbility.getInstance(), Duration.EndOfTurn); + this.getSpellAbility().addEffect(effect); + + effect = new GainAbilityTargetEffect(ChangelingAbility.getInstance(), Duration.EndOfTurn, null, false, Layer.TypeChangingEffects_4, SubLayer.NA); effect.setText(", gains all creature types"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(effect); effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn); effect.setText(", and gains flying until end of turn"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(effect); } public WingsOfVelisVel(final WingsOfVelisVel card) { diff --git a/Mage.Sets/src/mage/sets/stronghold/HibernationSliver.java b/Mage.Sets/src/mage/sets/stronghold/HibernationSliver.java index 9421f6bcb79..11faedca0d4 100644 --- a/Mage.Sets/src/mage/sets/stronghold/HibernationSliver.java +++ b/Mage.Sets/src/mage/sets/stronghold/HibernationSliver.java @@ -61,7 +61,9 @@ public class HibernationSliver extends CardImpl { Effect effect = new ReturnToHandSourceEffect(true); effect.setText("Return this permanent to its owner's hand"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new PayLifeCost(2)); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(ability, Duration.WhileOnBattlefield, new FilterPermanent("Sliver", "All Slivers"), "All Slivers have \"Pay 2 life: Return this permanent to its owner's hand"))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, + new GainAbilityAllEffect(ability, Duration.WhileOnBattlefield, + new FilterPermanent("Sliver", "All Slivers"), "All Slivers have \"Pay 2 life: Return this permanent to its owner's hand"))); } public HibernationSliver(final HibernationSliver card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java index c2010548151..80ce765fa67 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java @@ -27,8 +27,11 @@ */ package org.mage.test.cards.abilities.keywords; +import mage.abilities.Ability; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.game.permanent.Permanent; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -36,18 +39,17 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - public class ChangelingTest extends CardTestPlayerBase { /** - * Casting changelings with a Long-Forgotten Gohei in play reduces its casting cost by {1}. + * Casting changelings with a Long-Forgotten Gohei in play reduces its + * casting cost by {1}. */ - @Test public void testLongForgottenGohei() { addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); addCard(Zone.HAND, playerA, "Woodland Changeling"); - + addCard(Zone.BATTLEFIELD, playerA, "Long-Forgotten Gohei"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Woodland Changeling"); @@ -58,6 +60,46 @@ public class ChangelingTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Woodland Changeling", 0); // Casting cost of spell is not reduced so not on the battlefield assertHandCount(playerA, "Woodland Changeling", 1); - } + } -} \ No newline at end of file + /** + * Another bug, was playing Slivers again. I had a Amoeboid Changeling, a + * Hibernation Sliver and a Prophet of Kruphix. In response to a boardwipe, + * I tapped my Changeling, giving my Prophet Changeling. However, it didn't + * gain any Sliver abilities despite having all creature types, including + * Sliver, so I couldn't save it with my Hibernation Sliver. I clicked the + * Prophet and nothing happened at all. + */ + @Test + public void testGainingChangeling() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + addCard(Zone.BATTLEFIELD, playerA, "Island", 3); + // Untap all creatures and lands you control during each other player's untap step. + // You may cast creature cards as though they had flash. + addCard(Zone.HAND, playerA, "Prophet of Kruphix");// {3}{G}{U} + // Changeling + // {T}: Target creature gains all creature types until end of turn. + // {T}: Target creature loses all creature types until end of turn. + addCard(Zone.BATTLEFIELD, playerA, "Amoeboid Changeling"); + // All Slivers have "Pay 2 life: Return this permanent to its owner's hand." + addCard(Zone.BATTLEFIELD, playerA, "Hibernation Sliver"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Prophet of Kruphix"); + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}: Target creature gains", "Prophet of Kruphix"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertTapped("Amoeboid Changeling", true); + + Permanent prophet = getPermanent("Prophet of Kruphix", playerA); + boolean abilityFound = false; + for (Ability ability : prophet.getAbilities()) { + if (ability.getRule().startsWith("Pay 2 life")) { + abilityFound = true; + } + } + Assert.assertTrue("Prophet of Kruphix has to have the 'Pay 2 life: Return this permanent to its owner's hand.' ability, but has not.", abilityFound); + + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java index 8117823221a..2532cd38a5b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityTargetEffect.java @@ -66,7 +66,11 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl { } public GainAbilityTargetEffect(Ability ability, Duration duration, String rule, boolean onCard) { - super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, + this(ability, duration, rule, onCard, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA); + } + + public GainAbilityTargetEffect(Ability ability, Duration duration, String rule, boolean onCard, Layer layer, SubLayer subLayer) { + super(duration, layer, subLayer, ability.getEffects().size() > 0 ? ability.getEffects().get(0).getOutcome() : Outcome.AddAbility); this.ability = ability; staticText = rule; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java index 2513b9a9f5e..2fdb87193bf 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java @@ -70,7 +70,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff applied = Boolean.FALSE; } if (!applied && layer.equals(Layer.RulesEffects)) { - if (!game.getActivePlayerId().equals(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) { + if (!source.getControllerId().equals(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { boolean untap = true;