diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java index ea0729e16e9..6c410fd629e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java @@ -63,14 +63,20 @@ public class MasterOfThePearlTridentTest extends CardTestPlayerBase { public void testTurnToFrog() { addCard(Zone.BATTLEFIELD, playerA, "Island", 2); addCard(Zone.HAND, playerA, "Master of the Pearl Trident"); + // Creature — Merfolk 2/2, UU + // Other Merfolk creatures you control get +1/+1 and have islandwalk. (They can't be blocked as long as defending player controls an Island.) + addCard(Zone.BATTLEFIELD, playerA, "Merfolk of the Pearl Trident"); addCard(Zone.BATTLEFIELD, playerB, "Island", 2); addCard(Zone.BATTLEFIELD, playerB, "Llanowar Elves"); + // Creature — Elf Druid 1/1, G + // {T}: Add {G} to your mana pool. addCard(Zone.HAND, playerB, "Turn to Frog"); + // Target creature loses all abilities and becomes a 1/1 blue Frog until end of turn. castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Master of the Pearl Trident"); - castSpell(3, PhaseStep.DECLARE_ATTACKERS, playerB, "Turn to Frog", "Master of the Pearl Trident"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerB, "Turn to Frog", "Master of the Pearl Trident"); attack(3, playerA, "Merfolk of the Pearl Trident"); block(3, playerB, "Llanowar Elves", "Merfolk of the Pearl Trident"); diff --git a/Mage/src/mage/abilities/effects/ContinuousEffects.java b/Mage/src/mage/abilities/effects/ContinuousEffects.java index ddf3774dace..61f1b089464 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffects.java @@ -727,34 +727,31 @@ public class ContinuousEffects implements Serializable { effect.apply(Layer.ColorChangingEffects_5, SubLayer.NA, ability, game); } } - + Map> appliedEffects = new HashMap>(); - boolean allApplied = false; - while (!allApplied) { // loop needed if a added effect adds again an effect (e.g. Level 5- of Joraga Treespeaker) - boolean effectApplied = false; + boolean done = false; + while (!done) { // loop needed if a added effect adds again an effect (e.g. Level 5- of Joraga Treespeaker) + done = true; layer = filterLayeredEffects(layerEffects, Layer.AbilityAddingRemovingEffects_6); for (ContinuousEffect effect: layer) { if (layerEffects.contains(effect)) { List appliedAbilities = appliedEffects.get(effect); HashSet abilities = layeredEffects.getAbility(effect.getId()); - for (Ability ability : abilities) { + for (Ability ability : abilities) { if (appliedAbilities == null || !appliedAbilities.contains(ability)) { if (appliedAbilities == null) { appliedAbilities = new ArrayList(); appliedEffects.put(effect, appliedAbilities); } - appliedAbilities.add(ability); + appliedAbilities.add(ability); effect.apply(Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, ability, game); - effectApplied = true; + done = false; + // list must be updated after each applied effect (eg. if "Turn to Frog" removes abilities) + layerEffects = getLayeredEffects(game); } } } } - // if effect were applied, new effects of this layer could be added, so all yet not applied effects of this layer must still be applied - allApplied = !effectApplied; - if (effectApplied) { - layerEffects = getLayeredEffects(game); - } } layer = filterLayeredEffects(layerEffects, Layer.PTChangingEffects_7); @@ -770,7 +767,9 @@ public class ContinuousEffects implements Serializable { effect.apply(Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, ability, game); } } + applyCounters.apply(Layer.PTChangingEffects_7, SubLayer.Counters_7d, null, game); + for (ContinuousEffect effect: layer) { HashSet abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) {