diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java index 0879721c7f..7d4dbdbec2 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java @@ -50,6 +50,7 @@ public class DownloadJob extends AbstractLaternaBean { /** * Sets the job's state. If the state is {@link State#ABORTED}, it instead sets the error to "ABORTED" + * @param state */ public void setState(State state) { if (state == State.ABORTED) { @@ -62,6 +63,7 @@ public class DownloadJob extends AbstractLaternaBean { /** * Sets the job's state to {@link State#ABORTED} and the error message to the given message. Logs a warning * with the given message. + * @param message */ public void setError(String message) { setError(message, null); @@ -70,6 +72,7 @@ public class DownloadJob extends AbstractLaternaBean { /** * Sets the job's state to {@link State#ABORTED} and the error to the given exception. Logs a warning with the * given exception. + * @param error */ public void setError(Exception error) { setError(null, error); @@ -78,6 +81,8 @@ public class DownloadJob extends AbstractLaternaBean { /** * Sets the job's state to {@link State#ABORTED} and the error to the given exception. Logs a warning with the * given message and exception. + * @param message + * @param error */ public void setError(String message, Exception error) { if (message == null) { @@ -91,6 +96,7 @@ public class DownloadJob extends AbstractLaternaBean { /** * Sets the job's message. + * @param message */ public void setMessage(String message) { this.message.setValue(message); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java index 06b44259d9..e945991f49 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java @@ -6,7 +6,6 @@ package org.mage.plugins.card.dl; - import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; @@ -16,9 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import javax.swing.BoundedRangeModel; - import org.apache.log4j.Logger; import org.jetlang.channels.Channel; import org.jetlang.channels.MemoryChannel; @@ -32,7 +29,6 @@ import org.mage.plugins.card.dl.DownloadJob.State; import org.mage.plugins.card.dl.lm.AbstractLaternaBean; - /** * The class Downloader. * diff --git a/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java b/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java index f0e072a1a2..99831fe3ac 100644 --- a/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java +++ b/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java @@ -68,7 +68,6 @@ public class MikaeusTheUnhallowed extends CardImpl { this.subtype.add("Zombie"); this.subtype.add("Cleric"); - this.color.setBlack(true); this.power = new MageInt(5); this.toughness = new MageInt(5); @@ -105,9 +104,15 @@ class MikaeusTheUnhallowedAbility extends TriggeredAbilityImpl { return new MikaeusTheUnhallowedAbility(this); } + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + } + + @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER && event.getTargetId().equals(this.controllerId)) { + if (event.getTargetId().equals(this.controllerId)) { Permanent permanent = game.getPermanent(event.getSourceId()); if (permanent != null && permanent.hasSubtype("Human")) { this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java index 3f827caec1..1ab3383cd8 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java @@ -181,4 +181,30 @@ public class UndyingTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Butcher Ghoul", 0); assertExileCount("Butcher Ghoul", 1); } + + /** + * Tests that the undying granted by Mikaeus, the Unhallowed works + * + */ + @Test + public void testUndyingMikaeusTheUnhallowed() { + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + + // Other non-Human creatures you control get +1/+1 and have undying. + addCard(Zone.BATTLEFIELD, playerA, "Mikaeus, the Unhallowed", 1); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Lightning Bolt", 1); + + assertPermanentCount(playerA, "Silvercoat Lion", 1); + assertPermanentCount(playerA, "Mikaeus, the Unhallowed", 1); + assertPowerToughness(playerA, "Silvercoat Lion", 4, 4); + + } } diff --git a/Mage/src/mage/abilities/TriggeredAbilities.java b/Mage/src/mage/abilities/TriggeredAbilities.java index b3b341c8ab..a306d31b48 100644 --- a/Mage/src/mage/abilities/TriggeredAbilities.java +++ b/Mage/src/mage/abilities/TriggeredAbilities.java @@ -43,7 +43,6 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; -import mage.game.permanent.PermanentCard; /** * diff --git a/Mage/src/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java b/Mage/src/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java index e6737f9fdc..265c2d480a 100644 --- a/Mage/src/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java @@ -28,7 +28,10 @@ package mage.abilities.effects.common.continuous; +import java.util.HashMap; import java.util.Iterator; +import java.util.UUID; +import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.TriggeredAbility; @@ -38,6 +41,7 @@ import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; +import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -103,7 +107,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { for (Iterator it = affectedObjectList.iterator(); it.hasNext();) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost Permanent permanent = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper) if (permanent != null) { - permanent.addAbility(ability, source.getSourceId(), game); + permanent.addAbility(ability, source.getSourceId(), game, false); } else { it.remove(); // no longer on the battlefield, remove reference to object if (affectedObjectList.isEmpty()) { @@ -114,7 +118,19 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { } else { for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { - perm.addAbility(ability, source.getSourceId(), game); + perm.addAbility(ability, source.getSourceId(), game, false); + } + } + // still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger + HashMap LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD); + if (LKIBattlefield != null) { + for (MageObject mageObject: LKIBattlefield.values()) { + Permanent perm = (Permanent) mageObject; + if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { + if (filter.match(perm, source.getSourceId(), source.getControllerId(), game)) { + perm.addAbility(ability, source.getSourceId(), game, false); + } + } } } } diff --git a/Mage/src/mage/abilities/effects/common/continuous/GainAbilityControlledEffect.java b/Mage/src/mage/abilities/effects/common/continuous/GainAbilityControlledEffect.java index 69cac832c9..ff39516e6d 100644 --- a/Mage/src/mage/abilities/effects/common/continuous/GainAbilityControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/continuous/GainAbilityControlledEffect.java @@ -28,7 +28,10 @@ package mage.abilities.effects.common.continuous; +import java.util.HashMap; import java.util.Iterator; +import java.util.UUID; +import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.CompoundAbility; @@ -37,6 +40,7 @@ import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; +import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -126,6 +130,20 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl { } } } + // still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger + HashMap LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD); + if (LKIBattlefield != null) { + for (MageObject mageObject: LKIBattlefield.values()) { + Permanent perm = (Permanent) mageObject; + if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { + if (filter.match(perm, source.getSourceId(), source.getControllerId(), game)) { + for (Ability abilityToAdd : ability) { + perm.addAbility(abilityToAdd, source.getSourceId(), game, false); + } + } + } + } + } } return true; } diff --git a/Mage/src/mage/abilities/keyword/UndyingAbility.java b/Mage/src/mage/abilities/keyword/UndyingAbility.java index be16dd65a6..0f5b2636c6 100644 --- a/Mage/src/mage/abilities/keyword/UndyingAbility.java +++ b/Mage/src/mage/abilities/keyword/UndyingAbility.java @@ -14,7 +14,6 @@ import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import org.apache.log4j.Logger; /** * @author Loki diff --git a/Mage/src/mage/game/Game.java b/Mage/src/mage/game/Game.java index 689f545a5f..7e3f9f06a0 100644 --- a/Mage/src/mage/game/Game.java +++ b/Mage/src/mage/game/Game.java @@ -90,6 +90,7 @@ public interface Game extends MageItem, Serializable { UUID getControllerId(UUID objectId); Permanent getPermanent(UUID permanentId); Permanent getPermanentOrLKIBattlefield(UUID permanentId); + Map> getLKI(); Card getCard(UUID cardId); Ability getAbility(UUID abilityId, UUID sourceId); void setZone(UUID objectId, Zone zone); diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index f93b91ced0..c856ca5801 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -2305,6 +2305,11 @@ public abstract class GameImpl implements Game, Serializable { } } + @Override + public Map> getLKI() { + return lki; + } + private void removeCards(Cards cards) { for (UUID card : cards) { removeCard(card);