[AKH] Liliana, Death's Majesty

Refactored the "Becomes a black Zombie in addition to its other colors and types" code to own class file to dedupe code from several cards.
This commit is contained in:
Justin Herlehy 2017-04-08 23:25:43 -07:00
parent 6912e45310
commit 8b1220af66
9 changed files with 206 additions and 265 deletions

View file

@ -33,6 +33,7 @@ import mage.abilities.common.DealtDamageAndDiedTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -94,7 +95,7 @@ class DreadSlaverEffect extends OneShotEffect {
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())) {
ContinuousEffect effect = new DreadSlaverContiniousEffect();
ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
return true;
@ -104,54 +105,3 @@ class DreadSlaverEffect extends OneShotEffect {
}
}
class DreadSlaverContiniousEffect extends ContinuousEffectImpl {
public DreadSlaverContiniousEffect() {
super(Duration.Custom, Outcome.Neutral);
staticText = "That creature is a black Zombie in addition to its other colors and types";
}
public DreadSlaverContiniousEffect(final DreadSlaverContiniousEffect effect) {
super(effect);
}
@Override
public DreadSlaverContiniousEffect copy() {
return new DreadSlaverContiniousEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
creature.getSubtype(game).add("Zombie");
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
creature.getColor(game).setBlack(true);
}
break;
}
return true;
} else {
this.used = true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -29,8 +29,10 @@ package mage.cards.e;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.effects.common.ReturnToLibrarySpellEffect;
import mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -55,7 +57,9 @@ public class EverAfter extends CardImpl {
// to its other colors and types. Put Ever After on the bottom of its owner's library.
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 2, new FilterCreatureCard("creature cards from your graveyard")));
this.getSpellAbility().addEffect(new EverAfterEffect());
Effect effect = new BecomesBlackZombieAdditionEffect();
effect.setText("Each of those creatures is a black Zombie in addition to its other colors and types");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new ReturnToLibrarySpellEffect(false));
}
@ -68,56 +72,3 @@ public class EverAfter extends CardImpl {
return new EverAfter(this);
}
}
class EverAfterEffect extends ContinuousEffectImpl {
public EverAfterEffect() {
super(Duration.Custom, Outcome.Neutral);
staticText = "Each of those creatures is a black Zombie in addition to its other colors and types";
}
public EverAfterEffect(final EverAfterEffect effect) {
super(effect);
}
@Override
public EverAfterEffect copy() {
return new EverAfterEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
List<UUID> targets = source.getTargets().get(0).getTargets();
for (UUID targetId : targets) {
Card card = game.getCard(targetId);
if (card != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
card.getSubtype(game).add("Zombie");
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
card.getColor(game).setBlack(true);
}
break;
}
} else {
this.used = true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -35,6 +35,7 @@ import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -143,7 +144,7 @@ class GraveBetrayalEffect extends OneShotEffect {
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())) {
Permanent creature = game.getPermanent(card.getId());
creature.addCounters(CounterType.P1P1.createInstance(), source, game);
ContinuousEffect effect = new GraveBetrayalContiniousEffect();
ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
effect.setTargetPointer(new FixedTarget(creature.getId()));
game.addEffect(effect, source);
return true;
@ -153,54 +154,3 @@ class GraveBetrayalEffect extends OneShotEffect {
}
}
class GraveBetrayalContiniousEffect extends ContinuousEffectImpl {
public GraveBetrayalContiniousEffect() {
super(Duration.Custom, Outcome.Neutral);
staticText = "That creature is a black Zombie in addition to its other colors and types";
}
public GraveBetrayalContiniousEffect(final GraveBetrayalContiniousEffect effect) {
super(effect);
}
@Override
public GraveBetrayalContiniousEffect copy() {
return new GraveBetrayalContiniousEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
creature.getSubtype(game).add("Zombie");
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
creature.getColor(game).setBlack(true);
}
break;
}
return true;
} else {
this.used = true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.l;
import java.util.UUID;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveControllerEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.permanent.token.ZombieToken;
import mage.target.common.TargetCardInYourGraveyard;
/**
*
* @author JRHerlehy
*/
public class LilianaDeathsMajesty extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("non-Zombie creatures");
static {
filter.add(Predicates.not(new SubtypePredicate("Zombie")));
}
public LilianaDeathsMajesty(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{3}{B}{B}");
this.subtype.add("Liliana");
//Starting Loyalty: 5
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(5));
// +1: Create a 2/2 black Zombie creature token. Put the top two cards of your library into your graveyard.
LoyaltyAbility ability = new LoyaltyAbility(new CreateTokenEffect(new ZombieToken()), 1);
ability.addEffect(new PutTopCardOfLibraryIntoGraveControllerEffect(2));
this.addAbility(ability);
// -3: Return target creature card from your graveyard to the battlefield. That creature is a black Zombie in addition to its other colors and types.
ability = new LoyaltyAbility(new ReturnFromGraveyardToBattlefieldTargetEffect(), -3);
ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from a graveyard")));
ability.addEffect(new BecomesBlackZombieAdditionEffect());
this.addAbility(ability);
// -7: Destroy all non-Zombie creatures.
ability = new LoyaltyAbility(new DestroyAllEffect(filter), -7);
this.addAbility(ability);
}
public LilianaDeathsMajesty(final LilianaDeathsMajesty card) {
super(card);
}
@Override
public LilianaDeathsMajesty copy() {
return new LilianaDeathsMajesty(this);
}
}

View file

@ -35,6 +35,7 @@ import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -123,7 +124,8 @@ class NecromanticSelectionEffect extends OneShotEffect {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
ContinuousEffect effect = new NecromanticSelectionContinuousEffect();
ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
effect.setText("It's a black Zombie in addition to its other colors and types");
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
@ -133,56 +135,3 @@ class NecromanticSelectionEffect extends OneShotEffect {
return false;
}
}
class NecromanticSelectionContinuousEffect extends ContinuousEffectImpl {
public NecromanticSelectionContinuousEffect() {
super(Duration.Custom, Outcome.Neutral);
staticText = "It's a black Zombie in addition to its other colors and types";
}
public NecromanticSelectionContinuousEffect(final NecromanticSelectionContinuousEffect effect) {
super(effect);
}
@Override
public NecromanticSelectionContinuousEffect copy() {
return new NecromanticSelectionContinuousEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!creature.getSubtype(game).contains("Zombie")) {
creature.getSubtype(game).add("Zombie");
}
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
creature.getColor(game).setBlack(true);
}
break;
}
return true;
} else {
this.used = true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -28,6 +28,8 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
@ -56,7 +58,7 @@ public class RiseFromTheGrave extends CardImpl {
// Put target creature card from a graveyard onto the battlefield under your control. That creature is a black Zombie in addition to its other colors and types.
this.getSpellAbility().addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card from a graveyard")));
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
this.getSpellAbility().addEffect(new RiseFromTheGraveEffect());
this.getSpellAbility().addEffect(new BecomesBlackZombieAdditionEffect());
}
public RiseFromTheGrave(final RiseFromTheGrave card) {
@ -68,54 +70,3 @@ public class RiseFromTheGrave extends CardImpl {
return new RiseFromTheGrave(this);
}
}
class RiseFromTheGraveEffect extends ContinuousEffectImpl {
public RiseFromTheGraveEffect() {
super(Duration.Custom, Outcome.Neutral);
staticText = "That creature is a black Zombie in addition to its other colors and types";
}
public RiseFromTheGraveEffect(final RiseFromTheGraveEffect effect) {
super(effect);
}
@Override
public RiseFromTheGraveEffect copy() {
return new RiseFromTheGraveEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
creature.getSubtype(game).add("Zombie");
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
creature.getColor(game).setBlack(true);
}
break;
}
return true;
} else {
this.used = true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -121,6 +121,7 @@ public class Amonkhet extends ExpansionSet {
cards.add(new SetCardInfo("Kefnet's Monument", 231, Rarity.UNCOMMON, mage.cards.k.KefnetsMonument.class));
cards.add(new SetCardInfo("Lay Bare the Heart", 96, Rarity.UNCOMMON, mage.cards.l.LayBareTheHeart.class));
cards.add(new SetCardInfo("Liliana, Death Wielder", 274, Rarity.MYTHIC, mage.cards.l.LilianaDeathWielder.class));
cards.add(new SetCardInfo("Liliana, Death's Majesty", 97, Rarity.MYTHIC, mage.cards.l.LilianaDeathsMajesty.class));
cards.add(new SetCardInfo("Limits of Solidarity", 140, Rarity.UNCOMMON, mage.cards.l.LimitsOfSolidarity.class));
cards.add(new SetCardInfo("Magma Spray", 141, Rarity.COMMON, mage.cards.m.MagmaSpray.class));
cards.add(new SetCardInfo("Miasma Mummy", 100, Rarity.COMMON, mage.cards.m.MiasmaMummy.class));

View file

@ -0,0 +1,93 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author JRHerlehy
* Created on 4/8/17.
*/
public class BecomesBlackZombieAdditionEffect extends ContinuousEffectImpl {
public BecomesBlackZombieAdditionEffect() {
super(Duration.Custom, Outcome.Neutral);
staticText = "That creature is a black Zombie in addition to its other colors and types";
}
public BecomesBlackZombieAdditionEffect(final BecomesBlackZombieAdditionEffect effect) {
super(effect);
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!creature.getSubtype(game).contains("Zombie")) {
creature.getSubtype(game).add("Zombie");
}
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
creature.getColor(game).setBlack(true);
}
break;
}
return true;
} else {
this.used = true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public BecomesBlackZombieAdditionEffect copy() {
return new BecomesBlackZombieAdditionEffect(this);
}
}

View file

@ -45,7 +45,7 @@ public class ZombieToken extends Token {
static {
tokenImageSets.addAll(Arrays.asList("10E", "M10", "M11", "M12", "M13", "M14", "M15", "MBS", "ALA", "ISD", "C14", "C15", "C16", "CNS",
"MMA", "BNG", "KTK", "DTK", "ORI", "OGW", "SOI", "EMN", "EMA", "MM3"));
"MMA", "BNG", "KTK", "DTK", "ORI", "OGW", "SOI", "EMN", "EMA", "MM3", "AKH"));
}
public ZombieToken() {