* Mikaeus, the Unhallowed - Fixed that the given undying ability did not trigger.

This commit is contained in:
LevelX2 2015-03-22 19:47:46 +01:00
parent b1427f6066
commit 740611119b
10 changed files with 81 additions and 10 deletions

View file

@ -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);

View file

@ -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.
*

View file

@ -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()));

View file

@ -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);
}
}

View file

@ -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;
/**
*

View file

@ -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<MageObjectReference> 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<UUID, MageObject> 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);
}
}
}
}
}

View file

@ -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<UUID, MageObject> 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;
}

View file

@ -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

View file

@ -90,6 +90,7 @@ public interface Game extends MageItem, Serializable {
UUID getControllerId(UUID objectId);
Permanent getPermanent(UUID permanentId);
Permanent getPermanentOrLKIBattlefield(UUID permanentId);
Map<Zone,HashMap<UUID, MageObject>> getLKI();
Card getCard(UUID cardId);
Ability getAbility(UUID abilityId, UUID sourceId);
void setZone(UUID objectId, Zone zone);

View file

@ -2305,6 +2305,11 @@ public abstract class GameImpl implements Game, Serializable {
}
}
@Override
public Map<Zone,HashMap<UUID, MageObject>> getLKI() {
return lki;
}
private void removeCards(Cards cards) {
for (UUID card : cards) {
removeCard(card);