Some clean up of the lose life framework effects.

This commit is contained in:
LevelX2 2014-03-20 13:42:46 +01:00
parent 46ce31e927
commit 79b319777f
62 changed files with 233 additions and 359 deletions

View file

@ -728,5 +728,5 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private HoverButton commandZone;
private HoverButton enchantPlayerViewZone;
private Map<String, JLabel> manaLabels = new HashMap<String, JLabel>();
private final Map<String, JLabel> manaLabels = new HashMap<>();
}

View file

@ -34,7 +34,7 @@ import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.TargetController;
@ -49,7 +49,7 @@ public class PhyrexianArena extends CardImpl<PhyrexianArena> {
this.expansionSetCode = "APC";
this.color.setBlack(true);
Ability ability = new BeginningOfUpkeepTriggeredAbility(new DrawCardControllerEffect(1), TargetController.YOU, false);
ability.addEffect(new LoseLifeSourceEffect(1));
ability.addEffect(new LoseLifeSourceControllerEffect(1));
this.addAbility(ability);
}

View file

@ -35,7 +35,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -52,7 +52,7 @@ public class PhyrexianGargantua extends CardImpl<PhyrexianGargantua> {
this.power = new MageInt(4);
this.toughness = new MageInt(4);
Ability ability = new EntersBattlefieldTriggeredAbility(new DrawCardControllerEffect(2), false);
ability.addEffect(new LoseLifeSourceEffect(2));
ability.addEffect(new LoseLifeSourceControllerEffect(2));
this.addAbility(ability);
}

View file

@ -31,7 +31,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.cards.CardImpl;
import java.util.UUID;
@ -51,7 +51,7 @@ public class SoulcageFiend extends CardImpl<SoulcageFiend> {
this.toughness = new MageInt(2);
// When Soulcage Fiend dies, each player loses 3 life.
this.addAbility(new DiesTriggeredAbility(new LoseLifePlayersEffect(3)));
this.addAbility(new DiesTriggeredAbility(new LoseLifeAllPlayersEffect(3)));
}
public SoulcageFiend(final SoulcageFiend card) {

View file

@ -36,7 +36,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.RegenerateAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.FlashAbility;
@ -65,7 +65,7 @@ public class BlessingOfLeeches extends CardImpl<BlessingOfLeeches> {
this.addAbility(ability);
// At the beginning of your upkeep, you lose 1 life.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceControllerEffect(1), TargetController.YOU, false));
// {0}: Regenerate enchanted creature.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateAttachedEffect(AttachmentType.AURA),new GenericManaCost(0)));

View file

@ -33,7 +33,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.continious.BoostEnchantedEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.keyword.BestowAbility;
@ -67,7 +67,7 @@ public class HeraldOfTorment extends CardImpl<HeraldOfTorment> {
this.addAbility(FlyingAbility.getInstance());
// At the beginning of your upkeep, you lose 1 life.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceControllerEffect(1), TargetController.YOU, false));
// Enchanted creature gets +3/+3 and has flying.
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3));

View file

@ -32,7 +32,7 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
@ -55,7 +55,7 @@ public class Sanguimancy extends CardImpl<Sanguimancy> {
Effect effect = new DrawCardControllerEffect(blackDevotion);
effect.setText("You draw X cards");
this.getSpellAbility().addEffect(effect);
effect = new LoseLifeSourceEffect(blackDevotion);
effect = new LoseLifeSourceControllerEffect(blackDevotion);
effect.setText("and you lose X life, where X is your devotion to black");
this.getSpellAbility().addEffect(effect);
}

View file

@ -34,7 +34,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.cards.CardImpl;
/**
@ -51,7 +51,7 @@ public class DeathcurseOgre extends CardImpl<DeathcurseOgre> {
this.color.setBlack(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
this.addAbility(new DiesTriggeredAbility(new LoseLifePlayersEffect(3)));
this.addAbility(new DiesTriggeredAbility(new LoseLifeAllPlayersEffect(3)));
}
public DeathcurseOgre (final DeathcurseOgre card) {

View file

@ -31,9 +31,9 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -56,7 +56,9 @@ public class BalefulForce extends CardImpl<BalefulForce> {
// At the beginning of each upkeep, you draw a card and you lose 1 life.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new DrawCardControllerEffect(1), TargetController.ANY, false);
ability.addEffect(new LoseLifeSourceEffect(1));
Effect effect = new LoseLifeSourceControllerEffect(1);
effect.setText("and you lose 1 life");
ability.addEffect(effect);
this.addAbility(ability);
}

View file

@ -107,10 +107,7 @@ class PlayerLosesTheGameTriggeredAbility extends TriggeredAbilityImpl<PlayerLose
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.LOSES) {
return true;
}
return false;
return event.getType() == EventType.LOSES;
}
@Override
@ -138,16 +135,22 @@ class BloodTyrantEffect extends OneShotEffect<BloodTyrantEffect> {
@Override
public boolean apply(Game game, Ability source) {
int counters = 0;
for (Player player : game.getPlayers().values()) {
if (player != null) {
player.loseLife(1, game);
counters++;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.loseLife(1, game) > 0) {
counters++;
}
}
}
Permanent bloodTyrant = game.getPermanent(source.getSourceId());
if (bloodTyrant != null && counters > 0) {
bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), game);
}
return true;
}
Permanent bloodTyrant = game.getPermanent(source.getSourceId());
if (bloodTyrant != null && counters != 0) {
bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), game);
}
return true;
return false;
}
}
}

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
@ -57,9 +57,10 @@ public class Countersquall extends CardImpl<Countersquall> {
this.color.setBlue(true);
this.color.setBlack(true);
// Counter target noncreature spell. Its controller loses 2 life.
this.getSpellAbility().addTarget(new TargetSpell(filter));
this.getSpellAbility().addEffect(new CounterTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(2));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(2));
}
public Countersquall(final Countersquall card) {

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -48,7 +48,7 @@ public class AmbitionsCost extends CardImpl<AmbitionsCost> {
// You draw three cards and you lose 3 life.
this.getSpellAbility().addEffect(new DrawCardControllerEffect(3));
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(3));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(3));
}
public AmbitionsCost(final AmbitionsCost card) {

View file

@ -32,7 +32,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -54,7 +54,7 @@ public class VampiricSpirit extends CardImpl<VampiricSpirit> {
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Vampiric Spirit enters the battlefield, you lose 4 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceEffect(4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceControllerEffect(4)));
}
public VampiricSpirit(final VampiricSpirit card) {

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -48,7 +48,7 @@ public class NightsWhisper extends CardImpl<NightsWhisper> {
// You draw two cards and you lose 2 life.
this.getSpellAbility().addEffect(new DrawCardControllerEffect(2));
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(2));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(2));
}
public NightsWhisper(final NightsWhisper card) {

View file

@ -33,7 +33,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.combat.CantAttackBlockAttachedEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -71,7 +71,7 @@ public class PilloryOfTheSleepless extends CardImpl<PilloryOfTheSleepless> {
// Enchanted creature has "At the beginning of your upkeep, you lose 1 life."
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(
new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false), AttachmentType.AURA)));
new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceControllerEffect(1), TargetController.YOU, false), AttachmentType.AURA)));
}
public PilloryOfTheSleepless(final PilloryOfTheSleepless card) {

View file

@ -32,7 +32,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -53,7 +53,7 @@ public class UnholyFiend extends CardImpl<UnholyFiend> {
this.nightCard = true;
this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new LoseLifeSourceEffect(1), false));
this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new LoseLifeSourceControllerEffect(1), false));
}
public UnholyFiend(final UnholyFiend card) {

View file

@ -28,7 +28,7 @@
package mage.sets.lorwyn;
import java.util.UUID;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -60,7 +60,7 @@ public class Thoughtseize extends CardImpl<Thoughtseize> {
// Target player reveals his or her hand. You choose a nonland card from it. That player discards that card. You lose 2 life.
this.getSpellAbility().addTarget(new TargetPlayer(true));
this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetEffect(filter, TargetController.ANY));
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(2));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(2));
}
public Thoughtseize(final Thoughtseize card) {

View file

@ -33,7 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -52,7 +52,7 @@ public class HowlingBanshee extends CardImpl<HowlingBanshee> {
this.toughness = new MageInt(3);
this.addAbility(FlyingAbility.getInstance());
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifePlayersEffect(3), false));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeAllPlayersEffect(3), false));
}
public HowlingBanshee(final HowlingBanshee card) {

View file

@ -35,7 +35,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.continious.BoostEnchantedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -57,7 +57,7 @@ public class DarkFavor extends CardImpl<DarkFavor> {
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceEffect(1), false));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceControllerEffect(1), false));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 1, Duration.WhileOnBattlefield)));
}

View file

@ -27,29 +27,27 @@
*/
package mage.sets.magic2012;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DiscardEachPlayerEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.abilities.effects.common.SacrificeAllEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetControlledPermanent;
import mage.filter.common.FilterControlledPermanent;
/**
*
* @author nantuko
*/
public class Smallpox extends CardImpl<Smallpox> {
private static final FilterControlledPermanent filterCreature = new FilterControlledCreaturePermanent();
private static final FilterControlledPermanent filterLand = new FilterControlledLandPermanent();
public Smallpox(UUID ownerId) {
super(ownerId, 108, "Smallpox", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{B}{B}");
this.expansionSetCode = "M12";
@ -57,7 +55,16 @@ public class Smallpox extends CardImpl<Smallpox> {
this.color.setBlack(true);
// Each player loses 1 life, discards a card, sacrifices a creature, then sacrifices a land.
this.getSpellAbility().addEffect(new SmallpoxEffect());
this.getSpellAbility().addEffect(new LoseLifeAllPlayersEffect(1));
Effect effect = new DiscardEachPlayerEffect();
effect.setText(", discards a card");
this.getSpellAbility().addEffect(effect);
effect = new SacrificeAllEffect(1, filterCreature);
effect.setText(", sacrifices a creature");
this.getSpellAbility().addEffect(effect);
effect = new SacrificeAllEffect(1, filterLand);
effect.setText(", then sacrifices a land");
this.getSpellAbility().addEffect(effect);
}
public Smallpox(final Smallpox card) {
@ -69,75 +76,3 @@ public class Smallpox extends CardImpl<Smallpox> {
return new Smallpox(this);
}
}
class SmallpoxEffect extends OneShotEffect<SmallpoxEffect> {
private static final FilterPermanent filterCreature = new FilterControlledCreaturePermanent();
private static final FilterPermanent filterLand = new FilterControlledLandPermanent();
SmallpoxEffect() {
super(Outcome.DestroyPermanent);
staticText = "Each player loses 1 life, discards a card, sacrifices a creature, then sacrifices a land";
}
SmallpoxEffect(final SmallpoxEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set <UUID> players = controller.getInRange();
for (UUID playerId : players) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(1, game);
}
}
for (UUID playerId : players) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.discard(1, source, game);
}
}
for (UUID playerId : players) {
Player player = game.getPlayer(playerId);
if (player != null) {
sacrifice(game, source, player, filterCreature);
}
}
for (UUID playerId : players) {
Player player = game.getPlayer(playerId);
if (player != null) {
sacrifice(game, source, player, filterLand);
}
}
return true;
}
return false;
}
@Override
public SmallpoxEffect copy() {
return new SmallpoxEffect(this);
}
private void sacrifice(Game game, Ability source, Player player, FilterPermanent filter) {
Target target = new TargetControlledPermanent(1, 1, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.isInGame()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for ( int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent((UUID)target.getTargets().get(idx));
if ( permanent != null ) {
permanent.sacrifice(source.getSourceId(), game);
}
}
}
}
}

View file

@ -31,8 +31,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -59,7 +58,7 @@ public class DarkProphecy extends CardImpl<DarkProphecy> {
// Whenever a creature you control dies, you draw a card and lose 1 life.
Ability ability = new DiesCreatureTriggeredAbility(new DrawCardControllerEffect(1), false, filter);
ability.addEffect(new LoseLifeSourceEffect(1));
ability.addEffect(new LoseLifeSourceControllerEffect(1));
this.addAbility(ability);
}

View file

@ -34,7 +34,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.cards.CardImpl;
/**
@ -50,7 +50,7 @@ public class CausticHound extends CardImpl<CausticHound> {
this.color.setBlack(true);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
this.addAbility(new DiesTriggeredAbility(new LoseLifePlayersEffect(4)));
this.addAbility(new DiesTriggeredAbility(new LoseLifeAllPlayersEffect(4)));
}
public CausticHound (final CausticHound card) {

View file

@ -34,7 +34,7 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DiscardEachPlayerEffect;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.abilities.effects.common.SacrificeAllEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledCreaturePermanent;
@ -54,7 +54,7 @@ public class DeathCloud extends CardImpl<DeathCloud> {
// Each player loses X life, discards X cards, sacrifices X creatures, then sacrifices X lands.
DynamicValue xValue = new ManacostVariableValue();
this.getSpellAbility().addEffect(new LoseLifePlayersEffect(xValue));
this.getSpellAbility().addEffect(new LoseLifeAllPlayersEffect(xValue));
Effect effect = new DiscardEachPlayerEffect(xValue, false);
effect.setText(", discards X cards");
this.getSpellAbility().addEffect(effect);

View file

@ -35,7 +35,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.TargetController;
@ -53,7 +53,7 @@ public class Bitterblossom extends CardImpl<Bitterblossom> {
this.supertype.add("Tribal");
this.subtype.add("Faerie");
this.color.setBlack(true);
Ability ability = new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false);
Ability ability = new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceControllerEffect(1), TargetController.YOU, false);
ability.addEffect(new CreateTokenEffect(new FaerieToken(), 1));
this.addAbility(ability);
}

View file

@ -38,7 +38,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonType;
@ -70,7 +70,7 @@ public class RathiFiend extends CardImpl<RathiFiend> {
this.toughness = new MageInt(2);
// When Rathi Fiend enters the battlefield, each player loses 3 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifePlayersEffect(3), false));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeAllPlayersEffect(3), false));
// {3}, {T}: Search your library for a Mercenary permanent card with converted mana cost 3 or less and put it onto the battlefield. Then shuffle your library.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)), new TapSourceCost());
ability.addManaCost(new GenericManaCost(3));

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.target.common.TargetArtifactPermanent;
@ -46,10 +46,10 @@ public class GlissasScorn extends CardImpl<GlissasScorn> {
this.expansionSetCode = "NPH";
this.color.setGreen(true);
// Destroy target artifact. Its controller loses 1 life.
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(1));
this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(1));
}
public GlissasScorn(final GlissasScorn card) {

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -54,10 +54,10 @@ public class PsychicBarrier extends CardImpl<PsychicBarrier> {
this.expansionSetCode = "NPH";
this.color.setBlue(true);
// Counter target creature spell. Its controller loses 1 life.
this.getSpellAbility().addTarget(new TargetSpell(filter));
this.getSpellAbility().addEffect(new CounterTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(1));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(1));
}
public PsychicBarrier(final PsychicBarrier card) {

View file

@ -32,7 +32,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.cards.CardImpl;
import mage.target.common.TargetCreaturePermanent;
@ -47,9 +47,11 @@ public class VaporSnag extends CardImpl<VaporSnag> {
super(ownerId, 48, "Vapor Snag", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{U}");
this.expansionSetCode = "NPH";
this.color.setBlue(true);
// Return target creature to its owner's hand. Its controller loses 1 life.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(1));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(1));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(true));
}
public VaporSnag (final VaporSnag card) {

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
@ -58,9 +58,10 @@ public class VictoriousDestruction extends CardImpl<VictoriousDestruction> {
this.color.setRed(true);
// Destroy target artifact or land. Its controller loses 1 life.
this.getSpellAbility().addTarget(new TargetPermanent(filter));
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(1));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(1));
}
public VictoriousDestruction(final VictoriousDestruction card) {

View file

@ -34,7 +34,7 @@ import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.constants.Outcome;
@ -62,7 +62,7 @@ public class ContaminatedBond extends CardImpl<ContaminatedBond> {
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Whenever enchanted creature attacks or blocks, its controller loses 3 life.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeSourceEffect(3)));
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeSourceControllerEffect(3)));
}
public ContaminatedBond(final ContaminatedBond card) {

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -55,7 +55,7 @@ public class FilthyCur extends CardImpl<FilthyCur> {
this.toughness = new MageInt(2);
// Whenever Filthy Cur is dealt damage, you lose that much life.
this.addAbility(new DealtDamageLoseLifeTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeSourceEffect(0), false));
this.addAbility(new DealtDamageLoseLifeTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeSourceControllerEffect(0), false));
}
@ -89,7 +89,7 @@ class DealtDamageLoseLifeTriggeredAbility extends TriggeredAbilityImpl<DealtDama
if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) {
if (event.getTargetId().equals(this.sourceId)) {
this.getEffects().clear();
this.addEffect(new LoseLifeSourceEffect(event.getAmount()));
this.addEffect(new LoseLifeSourceControllerEffect(event.getAmount()));
return true;
}
}

View file

@ -35,7 +35,7 @@ import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.cards.CardImpl;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
@ -66,7 +66,7 @@ public class ShepherdOfRot extends CardImpl<ShepherdOfRot> {
this.toughness = new MageInt(1);
// {tap}: Each player loses 1 life for each Zombie on the battlefield.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseLifePlayersEffect(new PermanentsOnBattlefieldCount(filter), rule), new TapSourceCost()));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseLifeAllPlayersEffect(new PermanentsOnBattlefieldCount(filter), rule), new TapSourceCost()));
}
public ShepherdOfRot(final ShepherdOfRot card) {

View file

@ -33,7 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.DiscardEachPlayerEffect;
import mage.abilities.effects.common.DrawCardAllEffect;
import mage.abilities.effects.common.LoseLifeAllEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.cards.CardImpl;
/**
@ -54,7 +54,7 @@ public class UrzasGuilt extends CardImpl<UrzasGuilt> {
Effect effect = new DiscardEachPlayerEffect(3, false);
effect.setText("then discards three cards");
this.getSpellAbility().addEffect(effect);
effect = new LoseLifeAllEffect(4);
effect = new LoseLifeAllPlayersEffect(4);
effect.setText("then loses 4 life");
this.getSpellAbility().addEffect(effect);
}

View file

@ -31,16 +31,10 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.abilities.keyword.TransmuteAbility;
import mage.cards.CardImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
@ -57,7 +51,7 @@ public class ClutchOfTheUndercity extends CardImpl<ClutchOfTheUndercity> {
// Return target permanent to its owner's hand. Its controller loses 3 life.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
this.getSpellAbility().addEffect(new ClutchOfTheUndercityEffect());
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(3));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// Transmute {1}{U}{B}
this.addAbility(new TransmuteAbility("{1}{U}{B}"));
@ -72,32 +66,3 @@ public class ClutchOfTheUndercity extends CardImpl<ClutchOfTheUndercity> {
return new ClutchOfTheUndercity(this);
}
}
class ClutchOfTheUndercityEffect extends OneShotEffect<ClutchOfTheUndercityEffect> {
ClutchOfTheUndercityEffect() {
super(Outcome.Damage);
staticText = "Its controller loses 3 life";
}
ClutchOfTheUndercityEffect(final ClutchOfTheUndercityEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent p = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (p != null) {
Player player = game.getPlayer(p.getControllerId());
if (player != null) {
player.loseLife(3, game);
return true;
}
}
return false;
}
@Override
public ClutchOfTheUndercityEffect copy() {
return new ClutchOfTheUndercityEffect(this);
}
}

View file

@ -33,7 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.TargetController;
@ -56,7 +56,7 @@ public class Moroii extends CardImpl<Moroii> {
this.addAbility(FlyingAbility.getInstance());
// At the beginning of your upkeep, you lose 1 life.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceEffect(1), TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeSourceControllerEffect(1), TargetController.YOU, false));
}
public Moroii(final Moroii card) {

View file

@ -32,7 +32,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
@ -54,7 +54,7 @@ public class LaunchParty extends CardImpl<LaunchParty> {
// Destroy target creature. Its controller loses 2 life.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(2));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(2));
}
public LaunchParty(final LaunchParty card) {

View file

@ -38,7 +38,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -55,7 +55,7 @@ public class MoriokReplica extends CardImpl<MoriokReplica> {
this.toughness = new MageInt(2);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardControllerEffect(2), new ManaCostsImpl("{1}{B}"));
ability.addCost(new SacrificeSourceCost());
ability.addEffect(new LoseLifeSourceEffect(2));
ability.addEffect(new LoseLifeSourceControllerEffect(2));
this.addAbility(ability);
}

View file

@ -33,7 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -50,7 +50,7 @@ public class NecrogenScudder extends CardImpl<NecrogenScudder> {
this.color.setBlack(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceEffect(3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceControllerEffect(3)));
this.addAbility(FlyingAbility.getInstance());
}

View file

@ -34,7 +34,7 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.cards.CardImpl;
/**
@ -54,7 +54,7 @@ public class SpiteflameWitch extends CardImpl<SpiteflameWitch> {
this.power = new MageInt(2);
this.toughness = new MageInt(1);
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseLifePlayersEffect(1), new ManaCostsImpl("{B}{R}")));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseLifeAllPlayersEffect(1), new ManaCostsImpl("{B}{R}")));
}
public SpiteflameWitch(final SpiteflameWitch card) {

View file

@ -28,11 +28,12 @@
package mage.sets.shardsofalara;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.filter.FilterSpell;
import mage.target.TargetSpell;
@ -51,10 +52,13 @@ public class PunishIgnorance extends CardImpl<PunishIgnorance> {
this.color.setBlue(true);
this.color.setBlack(true);
// Counter target spell. Its controller loses 3 life and you gain 3 life.
this.getSpellAbility().addTarget(new TargetSpell(new FilterSpell()));
this.getSpellAbility().addEffect(new CounterTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(3));
this.getSpellAbility().addEffect(new GainLifeEffect(3));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(3));
Effect effect = new GainLifeEffect(3);
effect.setText("and you gain 3 life");
this.getSpellAbility().addEffect(effect);
}
public PunishIgnorance(final PunishIgnorance card) {

View file

@ -30,7 +30,7 @@ package mage.sets.stronghold;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -52,7 +52,7 @@ public class SerpentWarrior extends CardImpl<SerpentWarrior> {
this.toughness = new MageInt(3);
// When Serpent Warrior enters the battlefield, you lose 3 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceEffect(3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceControllerEffect(3)));
}
public SerpentWarrior(final SerpentWarrior card) {

View file

@ -30,7 +30,7 @@ package mage.sets.tempest;
import java.util.UUID;
import mage.abilities.dynamicvalue.common.TargetConvertedManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -53,7 +53,7 @@ public class Reanimate extends CardImpl<Reanimate> {
// Put target creature card from a graveyard onto the battlefield under your control. You lose life equal to its converted mana cost.
this.getSpellAbility().addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card from a graveyard")));
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
Effect effect = new LoseLifeSourceEffect(new TargetConvertedManaCost());
Effect effect = new LoseLifeSourceControllerEffect(new TargetConvertedManaCost());
effect.setText("You lose life equal to its converted mana cost");
this.getSpellAbility().addEffect(effect);
}

View file

@ -32,7 +32,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.ObjectColor;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
@ -57,7 +57,7 @@ public class RecklessSpite extends CardImpl<RecklessSpite> {
this.color.setBlack(true);
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(2, 2, filter, false));
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(5));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(5));
}
public RecklessSpite(final RecklessSpite card) {

View file

@ -36,7 +36,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.TargetController;
import mage.filter.common.FilterControlledPermanent;
@ -65,7 +65,7 @@ public class GravebornMuse extends CardImpl<GravebornMuse> {
// At the beginning of your upkeep, you draw X cards and you lose X life, where X is the number of Zombies you control.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new DrawCardControllerEffect(new PermanentsOnBattlefieldCount(filter)), TargetController.YOU, false);
ability.addEffect(new LoseLifeSourceEffect(new PermanentsOnBattlefieldCount(filter)));
ability.addEffect(new LoseLifeSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)));
this.addAbility(ability);
}

View file

@ -35,7 +35,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -52,7 +52,7 @@ public class PhyrexianRager extends CardImpl<PhyrexianRager> {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
Ability ability = new EntersBattlefieldTriggeredAbility(new DrawCardControllerEffect(1), false);
ability.addEffect(new LoseLifeSourceEffect(1));
ability.addEffect(new LoseLifeSourceControllerEffect(1));
this.addAbility(ability);
}

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.DamagePlayersEffect;
import mage.abilities.effects.common.LoseLifePlayersEffect;
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -55,7 +55,7 @@ public class BloodTollHarpy extends CardImpl<BloodTollHarpy> {
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Blood-Toll Harpy enters the battlefield, each player loses 1 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifePlayersEffect(1)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeAllPlayersEffect(1)));
}
public BloodTollHarpy(final BloodTollHarpy card) {

View file

@ -28,7 +28,7 @@
package mage.sets.theros;
import java.util.UUID;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.RegenerateTargetEffect;
import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.cards.CardImpl;
@ -53,7 +53,7 @@ public class BoonOfErebos extends CardImpl<BoonOfErebos> {
this.getSpellAbility().addEffect(new BoostTargetEffect(2,0, Duration.EndOfTurn));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(true));
this.getSpellAbility().addEffect(new RegenerateTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(2));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(2));
}
public BoonOfErebos(final BoonOfErebos card) {

View file

@ -30,7 +30,7 @@ package mage.sets.theros;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.ScryEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -53,7 +53,7 @@ public class ReadTheBones extends CardImpl<ReadTheBones> {
Effect effect = new DrawCardControllerEffect(2);
effect.setText("then draw two cards");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(2));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(2));
}
public ReadTheBones(final ReadTheBones card) {

View file

@ -29,7 +29,7 @@ package mage.sets.theros;
import java.util.UUID;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -50,7 +50,7 @@ public class SipOfHemlock extends CardImpl<SipOfHemlock> {
// Destroy target creature. Its controller loses 2 life.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(true));
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(2));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(2));
}
public SipOfHemlock(final SipOfHemlock card) {

View file

@ -33,7 +33,7 @@ import mage.constants.Rarity;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
/**
@ -49,7 +49,7 @@ public class DelusionsOfMediocrity extends CardImpl<DelusionsOfMediocrity> {
//When Delusions of Mediocrity enters the battlefield, you gain 10 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(10), false));
//When Delusions of Mediocrity leaves the battlefield, you lose 10 life.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new LoseLifeSourceEffect(10), false));
this.addAbility(new LeavesBattlefieldTriggeredAbility(new LoseLifeSourceControllerEffect(10), false));
}
public DelusionsOfMediocrity(final DelusionsOfMediocrity card) {

View file

@ -33,7 +33,7 @@ import mage.constants.Rarity;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
@ -63,7 +63,7 @@ public class Eviscerator extends CardImpl<Eviscerator> {
// Protection from white
this.addAbility(new ProtectionAbility(filter));
// When Eviscerator enters the battlefield, you lose 5 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceEffect(5)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LoseLifeSourceControllerEffect(5)));
}
public Eviscerator(final Eviscerator card) {

View file

@ -32,7 +32,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.BecomesTargetTriggeredAbility;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -54,7 +54,7 @@ public class TetheredSkirge extends CardImpl<TetheredSkirge> {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever Tethered Skirge becomes the target of a spell or ability, you lose 1 life.
this.addAbility(new BecomesTargetTriggeredAbility(new LoseLifeSourceEffect(1)));
this.addAbility(new BecomesTargetTriggeredAbility(new LoseLifeSourceControllerEffect(1)));
}
public TetheredSkirge(final TetheredSkirge card) {

View file

@ -28,7 +28,7 @@
package mage.sets.visions;
import java.util.UUID;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOnLibraryEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -49,7 +49,7 @@ public class VampiricTutor extends CardImpl<VampiricTutor> {
// Search your library for a card, then shuffle your library and put that card on top of it. You lose 2 life.
this.getSpellAbility().addEffect(new SearchLibraryPutOnLibraryEffect(new TargetCardInLibrary()));
this.getSpellAbility().addEffect(new LoseLifeSourceEffect(2));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(2));
}
public VampiricTutor(final VampiricTutor card) {

View file

@ -32,7 +32,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.ObjectColor;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
@ -57,9 +57,10 @@ public class HideousEnd extends CardImpl<HideousEnd> {
this.color.setBlack(true);
// Destroy target nonblack creature. Its controller loses 2 life.
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new LoseLifeControllerEffect(2));
this.getSpellAbility().addEffect(new LoseLifeTargetControllerEffect(2));
}
public HideousEnd(final HideousEnd card) {

View file

@ -36,7 +36,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.TenOrLessLifeCondition;
import mage.abilities.condition.InvertCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.TargetController;
@ -57,7 +57,7 @@ public class VampireLacerator extends CardImpl<VampireLacerator> {
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new ConditionalOneShotEffect(
new LoseLifeSourceEffect(1),
new LoseLifeSourceControllerEffect(1),
new InvertCondition( new TenOrLessLifeCondition(TenOrLessLifeCondition.CheckType.AN_OPPONENT) ),
"you lose 1 life unless an opponent has 10 or less life"), TargetController.YOU, false));
}

View file

@ -43,7 +43,6 @@ public class HideousEndTest extends CardTestPlayerBase {
}
@Test
@Ignore
public void testWithPossibleProtection() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Zone.BATTLEFIELD, playerA, "Swamp");
@ -52,13 +51,17 @@ public class HideousEndTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Plains");
addCard(Zone.BATTLEFIELD, playerB, "Plains");
addCard(Zone.BATTLEFIELD, playerB, "Copper Myr");
// Target artifact or creature you control gains protection from artifacts or from the color of your choice until end of turn.
addCard(Zone.HAND, playerB, "Apostle's Blessing");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hideous End", "Copper Myr");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Apostle's Blessing", "Copper Myr");
setChoice(playerB, "Black");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Hideous End", 1);
assertPermanentCount(playerB, "Copper Myr", 1);
assertLife(playerB, 20);
}

View file

@ -53,6 +53,7 @@ import mage.game.Game;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> extends EffectImpl<T> implements ContinuousEffect<T> {
@ -63,8 +64,8 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
protected boolean used = false;
protected boolean discarded = false; // for manual effect discard
protected boolean affectedObjectsSet = false;
protected List<UUID> objects = new ArrayList<UUID>();
protected Map<UUID, Integer> metadata = new HashMap<UUID, Integer>();
protected List<UUID> objects = new ArrayList<>();
protected Map<UUID, Integer> metadata = new HashMap<>();
public ContinuousEffectImpl(Duration duration, Outcome outcome) {
super(outcome);

View file

@ -1,78 +0,0 @@
/*
* Copyright 2011 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;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class LoseLifeAllEffect extends OneShotEffect<LoseLifeAllEffect> {
private DynamicValue amount;
public LoseLifeAllEffect(int amount) {
this(new StaticValue(amount));
}
public LoseLifeAllEffect(DynamicValue amount) {
super(Outcome.Damage);
this.amount = amount;
staticText = "Each player loses " + amount + " life";
}
public LoseLifeAllEffect(final LoseLifeAllEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(amount.calculate(game, source), game);
}
}
return true;
}
@Override
public LoseLifeAllEffect copy() {
return new LoseLifeAllEffect(this);
}
}

View file

@ -41,48 +41,52 @@ import mage.players.Player;
*
* @author BetaSteward_at_googlemail.com
*/
public class LoseLifePlayersEffect extends OneShotEffect<LoseLifePlayersEffect> {
public class LoseLifeAllPlayersEffect extends OneShotEffect<LoseLifeAllPlayersEffect> {
private DynamicValue amount;
String text;
private final DynamicValue amount;
public LoseLifePlayersEffect(int amount) {
super(Outcome.Damage);
this.amount = new StaticValue(amount);
staticText = "each player loses " + amount + " life";
public LoseLifeAllPlayersEffect(int amount) {
this(new StaticValue(amount));
}
public LoseLifePlayersEffect(DynamicValue amount) {
public LoseLifeAllPlayersEffect(DynamicValue amount) {
super(Outcome.Damage);
this.amount = amount;
staticText = "each player loses " + amount + " life";
staticText = setText();
}
public LoseLifePlayersEffect(DynamicValue amount, String text) {
public LoseLifeAllPlayersEffect(DynamicValue amount, String text) {
super(Outcome.Damage);
this.amount = amount;
staticText = text;
}
public LoseLifePlayersEffect(final LoseLifePlayersEffect effect) {
public LoseLifeAllPlayersEffect(final LoseLifeAllPlayersEffect effect) {
super(effect);
this.amount = effect.amount;
this.text = effect.text;
}
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null)
if (player != null) {
player.loseLife(amount.calculate(game, source), game);
}
}
return true;
}
@Override
public LoseLifePlayersEffect copy() {
return new LoseLifePlayersEffect(this);
public LoseLifeAllPlayersEffect copy() {
return new LoseLifeAllPlayersEffect(this);
}
private String setText() {
StringBuilder sb = new StringBuilder("each player loses ");
sb.append(amount);
sb.append(" life");
return sb.toString();
}
}

View file

@ -40,28 +40,28 @@ import mage.players.Player;
*
* @author BetaSteward_at_googlemail.com
*/
public class LoseLifeSourceEffect extends OneShotEffect<LoseLifeSourceEffect> {
public class LoseLifeSourceControllerEffect extends OneShotEffect<LoseLifeSourceControllerEffect> {
protected DynamicValue amount;
public LoseLifeSourceEffect(int amount) {
public LoseLifeSourceControllerEffect(int amount) {
this(new StaticValue(amount));
}
public LoseLifeSourceEffect(DynamicValue amount) {
public LoseLifeSourceControllerEffect(DynamicValue amount) {
super(Outcome.LoseLife);
this.amount = amount;
setText();
}
public LoseLifeSourceEffect(final LoseLifeSourceEffect effect) {
public LoseLifeSourceControllerEffect(final LoseLifeSourceControllerEffect effect) {
super(effect);
this.amount = effect.amount.copy();
}
@Override
public LoseLifeSourceEffect copy() {
return new LoseLifeSourceEffect(this);
public LoseLifeSourceControllerEffect copy() {
return new LoseLifeSourceControllerEffect(this);
}
@Override

View file

@ -42,24 +42,24 @@ import mage.players.Player;
*
* @author North
*/
public class LoseLifeControllerEffect extends OneShotEffect<LoseLifeControllerEffect> {
public class LoseLifeTargetControllerEffect extends OneShotEffect<LoseLifeTargetControllerEffect> {
protected int amount;
public LoseLifeControllerEffect(int amount) {
public LoseLifeTargetControllerEffect(int amount) {
super(Outcome.Damage);
this.amount = amount;
staticText = "Its controller loses " + amount + " life";
}
public LoseLifeControllerEffect(final LoseLifeControllerEffect effect) {
public LoseLifeTargetControllerEffect(final LoseLifeTargetControllerEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public LoseLifeControllerEffect copy() {
return new LoseLifeControllerEffect(this);
public LoseLifeTargetControllerEffect copy() {
return new LoseLifeTargetControllerEffect(this);
}
@Override

View file

@ -28,6 +28,9 @@
package mage.abilities.effects.common.continious;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
@ -61,15 +64,43 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl<SwitchPo
public SwitchPowerToughnessAllEffect copy() {
return new SwitchPowerToughnessAllEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
this.objects.add(creature.getId());
}
}
}
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
int power = creature.getPower().getValue();
creature.getPower().setValue(creature.getToughness().getValue());
creature.getToughness().setValue(power);
if (this.affectedObjectsSet) {
Set<UUID> toDelete = new HashSet<>();
for (UUID creatureId: objects) {
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
int power = creature.getPower().getValue();
creature.getPower().setValue(creature.getToughness().getValue());
creature.getToughness().setValue(power);
} else {
toDelete.add(creatureId);
}
}
this.objects.removeAll(toDelete);
} else {
for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
int power = creature.getPower().getValue();
creature.getPower().setValue(creature.getToughness().getValue());
creature.getToughness().setValue(power);
}
}
return true;
}