Implemented card: Kaervek's Purge

Updated: Builder's Bane
This commit is contained in:
Sinsedrix 2018-03-18 21:55:43 +01:00
parent b073ce1c42
commit 54a96a7f4a
3 changed files with 127 additions and 3 deletions

View file

@ -101,9 +101,13 @@ class BuildersBaneEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(targetID);
if (permanent != null) {
if (permanent.destroy(source.getSourceId(), game, false)) {
if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
destroyedArtifactPerPlayer.merge(permanent.getControllerId(), 1, Integer::sum);
game.applyEffects();
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
// A replacement effect has moved the card to another zone as grvayard
continue;
}
destroyedArtifactPerPlayer.merge(permanent.getControllerId(), 1, Integer::sum);
}
}
}
@ -111,7 +115,7 @@ class BuildersBaneEffect extends OneShotEffect {
// Builder's Bane deals damage to each player equal to the number of artifacts he or she controlled put into a graveyard this way.
for (Map.Entry<UUID, Integer> entry : destroyedArtifactPerPlayer.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if(player != null) {
if (player != null) {
player.damage(entry.getValue(), source.getSourceId(), game, false, true);
}
}

View file

@ -0,0 +1,119 @@
/*
* 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.k;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author sinsedrix
*/
public class KaerveksPurge extends CardImpl {
public KaerveksPurge(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}{R}");
// Destroy target creature with converted mana cost X. If that creature dies this way, Kaervek's Purge deals damage equal to the creature's power to the creature's controller.
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature with converted mana cost X")));
this.getSpellAbility().addEffect(new KaerveksPurgeEffect());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost X");
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetCreaturePermanent(filter));
}
}
public KaerveksPurge(final KaerveksPurge card) {
super(card);
}
@Override
public KaerveksPurge copy() {
return new KaerveksPurge(this);
}
}
class KaerveksPurgeEffect extends OneShotEffect {
public KaerveksPurgeEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "Destroy target creature with converted mana cost X. If that creature dies this way, {this} deals damage equal to the creature's power to the creature's controller";
}
public KaerveksPurgeEffect(final KaerveksPurgeEffect effect) {
super(effect);
}
@Override
public KaerveksPurgeEffect copy() {
return new KaerveksPurgeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
// Destroy target creature with converted mana cost X.
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null && targetCreature.destroy(source.getSourceId(), game, false)) {
game.applyEffects();
if (targetCreature.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(targetCreature.getId())
&& !game.getState().getZone(targetCreature.getId()).equals(Zone.GRAVEYARD)) {
// A replacement effect has moved the card to another zone as graveyard
return true;
}
// If that creature dies this way, Kaervek's Purge deals damage equal to the creature's power to the creature's controller
Player creatureController = game.getPlayer(targetCreature.getControllerId());
int power = targetCreature.getPower().getValue();
if (creatureController != null) {
creatureController.damage(power, source.getSourceId(), game, false, true);
}
}
return true;
}
}

View file

@ -190,6 +190,7 @@ public class Mirage extends ExpansionSet {
cards.add(new SetCardInfo("Jungle Troll", 329, Rarity.UNCOMMON, mage.cards.j.JungleTroll.class));
cards.add(new SetCardInfo("Jungle Wurm", 122, Rarity.COMMON, mage.cards.j.JungleWurm.class));
cards.add(new SetCardInfo("Kaervek's Hex", 28, Rarity.UNCOMMON, mage.cards.k.KaerveksHex.class));
cards.add(new SetCardInfo("Kaervek's Purge", 330, Rarity.UNCOMMON, mage.cards.k.KaerveksPurge.class));
cards.add(new SetCardInfo("Kaervek's Torch", 185, Rarity.COMMON, mage.cards.k.KaerveksTorch.class));
cards.add(new SetCardInfo("Karoo Meerkat", 123, Rarity.UNCOMMON, mage.cards.k.KarooMeerkat.class));
cards.add(new SetCardInfo("Kukemssa Pirates", 71, Rarity.RARE, mage.cards.k.KukemssaPirates.class));