diff --git a/Mage.Sets/src/mage/cards/a/AliFromCairo.java b/Mage.Sets/src/mage/cards/a/AliFromCairo.java index 40e23e1f1b7..cc243fb0572 100644 --- a/Mage.Sets/src/mage/cards/a/AliFromCairo.java +++ b/Mage.Sets/src/mage/cards/a/AliFromCairo.java @@ -113,7 +113,7 @@ class AliFromCairoReplacementEffect extends ReplacementEffectImpl { game.fireEvent(event); if (controller != null) { - controller.setLife(1, game); + controller.setLife(1, game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/ArbiterOfKnollridge.java b/Mage.Sets/src/mage/cards/a/ArbiterOfKnollridge.java index 2265d8ad929..e086a5654cb 100644 --- a/Mage.Sets/src/mage/cards/a/ArbiterOfKnollridge.java +++ b/Mage.Sets/src/mage/cards/a/ArbiterOfKnollridge.java @@ -97,7 +97,7 @@ class ArbiterOfKnollridgeEffect extends OneShotEffect { for (UUID pid : playerList) { Player p = game.getPlayer(pid); if (p != null) { - p.setLife(maxLife, game); + p.setLife(maxLife, game, source); } } return true; diff --git a/Mage.Sets/src/mage/cards/a/AxisOfMortality.java b/Mage.Sets/src/mage/cards/a/AxisOfMortality.java index 8470ebf8435..44e5f51871d 100644 --- a/Mage.Sets/src/mage/cards/a/AxisOfMortality.java +++ b/Mage.Sets/src/mage/cards/a/AxisOfMortality.java @@ -107,8 +107,8 @@ class AxisOfMortalityEffect extends OneShotEffect { return false; } - player1.setLife(lifePlayer2, game); - player2.setLife(lifePlayer1, game); + player1.setLife(lifePlayer2, game, source); + player2.setLife(lifePlayer1, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/d/DarthTyranus.java b/Mage.Sets/src/mage/cards/d/DarthTyranus.java index 98a6a34dbae..1a8a2ac281e 100644 --- a/Mage.Sets/src/mage/cards/d/DarthTyranus.java +++ b/Mage.Sets/src/mage/cards/d/DarthTyranus.java @@ -107,8 +107,8 @@ class DarthTyranusEffect extends OneShotEffect { Player player1 = game.getPlayer(targetPointer.getTargets(game, source).get(0)); Player player2 = game.getPlayer(targetPointer.getTargets(game, source).get(1)); if (player1 != null && player2 != null) { - player1.setLife(5, game); - player1.setLife(30, game); + player1.setLife(5, game, source); + player1.setLife(30, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/e/ElderscaleWurm.java b/Mage.Sets/src/mage/cards/e/ElderscaleWurm.java index 54c2fe1b3ba..a3cdac4b25e 100644 --- a/Mage.Sets/src/mage/cards/e/ElderscaleWurm.java +++ b/Mage.Sets/src/mage/cards/e/ElderscaleWurm.java @@ -94,7 +94,7 @@ class ElderscaleWurmSetLifeEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null && player.getLife() < 7) { - player.setLife(7, game); + player.setLife(7, game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/e/EternityVessel.java b/Mage.Sets/src/mage/cards/e/EternityVessel.java index 17a29203802..88c1259dc9f 100644 --- a/Mage.Sets/src/mage/cards/e/EternityVessel.java +++ b/Mage.Sets/src/mage/cards/e/EternityVessel.java @@ -116,7 +116,7 @@ class EternityVesselEffect2 extends OneShotEffect { Permanent vessel = game.getPermanent(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (vessel != null && controller != null) { - controller.setLife(vessel.getCounters(game).getCount(CounterType.CHARGE), game); + controller.setLife(vessel.getCounters(game).getCount(CounterType.CHARGE), game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/e/EvraHalcyonWitness.java b/Mage.Sets/src/mage/cards/e/EvraHalcyonWitness.java index 99545b678a3..7ac74b44aa4 100644 --- a/Mage.Sets/src/mage/cards/e/EvraHalcyonWitness.java +++ b/Mage.Sets/src/mage/cards/e/EvraHalcyonWitness.java @@ -107,7 +107,7 @@ class EvraHalcyonWitnessEffect extends OneShotEffect { if (life > amount && !player.isCanLoseLife()) { return false; } - player.setLife(amount, game); + player.setLife(amount, game, source); game.addEffect(new SetPowerToughnessSourceEffect(life, Integer.MIN_VALUE, Duration.Custom, SubLayer.SetPT_7b), source); return true; } diff --git a/Mage.Sets/src/mage/cards/e/ExquisiteArchangel.java b/Mage.Sets/src/mage/cards/e/ExquisiteArchangel.java index b2953410aea..6ae070f4b24 100644 --- a/Mage.Sets/src/mage/cards/e/ExquisiteArchangel.java +++ b/Mage.Sets/src/mage/cards/e/ExquisiteArchangel.java @@ -104,7 +104,7 @@ class ExquisiteArchangelEffect extends ReplacementEffectImpl { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null) { new ExileSourceEffect().apply(game, source); - player.setLife(game.getLife(), game); + player.setLife(game.getLife(), game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java b/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java index f41b3332f6e..b38ba19bd95 100644 --- a/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java +++ b/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java @@ -34,25 +34,16 @@ import mage.MageObject; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.common.GainLifeControllerTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.common.SimpleTriggeredAbility; -import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.DoIfCostPaid; -import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.keyword.LifelinkAbility; import mage.cards.Card; -import mage.cards.GainAbilitySpellsEffect; -import mage.cards.a.AgelessEntityEffect; -import mage.cards.s.SpiritualFocusDrawCardEffect; import mage.constants.*; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.filter.FilterObject; -import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.ColorPredicate; @@ -107,6 +98,7 @@ class FiresongAndSunspeakerTriggeredAbility extends TriggeredAbilityImpl { public FiresongAndSunspeakerTriggeredAbility() { super(Zone.BATTLEFIELD, new DamageTargetEffect(3), false); + this.addTarget(new TargetCreatureOrPlayer()); } public FiresongAndSunspeakerTriggeredAbility(final FiresongAndSunspeakerTriggeredAbility ability) { @@ -124,7 +116,7 @@ class FiresongAndSunspeakerTriggeredAbility extends TriggeredAbilityImpl { } @Override - public boolean applies(GameEvent event, Game game) { + public boolean checkTrigger(GameEvent event, Game game) { MageObject object = game.getObject(event.getSourceId()); if (object != null && object instanceof Spell) { if (object.getColor(game).equals(ObjectColor.WHITE) @@ -170,26 +162,6 @@ class GainAbilitySpellsEffect extends ContinuousEffectImpl { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (player != null && permanent != null) { - for (Card card : game.getExile().getAllCards(game)) { - if (card.getOwnerId().equals(source.getControllerId()) && filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } - for (Card card : player.getLibrary().getCards(game)) { - if (filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } - for (Card card : player.getHand().getCards(game)) { - if (filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } - for (Card card : player.getGraveyard().getCards(game)) { - if (filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } for (StackObject stackObject : game.getStack()) { if (stackObject.getControllerId().equals(source.getControllerId())) { Card card = game.getCard(stackObject.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/g/GameOfChaos.java b/Mage.Sets/src/mage/cards/g/GameOfChaos.java index fedcee99b2e..0a9de43fcb0 100644 --- a/Mage.Sets/src/mage/cards/g/GameOfChaos.java +++ b/Mage.Sets/src/mage/cards/g/GameOfChaos.java @@ -45,7 +45,7 @@ import mage.target.common.TargetOpponent; public class GameOfChaos extends CardImpl { public GameOfChaos(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{R}{R}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}{R}{R}"); // Flip a coin. // If you win the flip, you gain 1 life and target opponent loses 1 life, and you decide whether to flip again. @@ -66,51 +66,52 @@ public class GameOfChaos extends CardImpl { } class GameOfChaosEffect extends OneShotEffect { - + public GameOfChaosEffect() { super(Outcome.Detriment); this.staticText = "Flip a coin. If you win the flip, you gain 1 life and target opponent loses 1 life, and you decide whether to flip again. If you lose the flip, you lose 1 life and that opponent gains 1 life, and that player decides whether to flip again. Double the life stakes with each flip."; } - + public GameOfChaosEffect(final GameOfChaosEffect effect) { super(effect); } - + @Override public GameOfChaosEffect copy() { return new GameOfChaosEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source)); - + if (you != null && targetOpponent != null) { - + boolean continueFlipping = true; boolean youWonFlip = you.flipCoin(game); // controller flips first boolean youWonLastFlip = false; // tracks if you won the flip last, negation of it means opponent won last int lifeAmount = 1; // starts stakes with 1 life - - while (continueFlipping) { + + while (continueFlipping) { if (youWonFlip) { // flipper of coin wins, flipper gain 1 and non-flipper loses 1 - handleLifeChangesFromFlip(game, you, targetOpponent, lifeAmount); + handleLifeChangesFromFlip(game, you, targetOpponent, lifeAmount, source); if (!cannotContinueFlipping(you, targetOpponent)) { continueFlipping = you.chooseUse(outcome, "You gained " + lifeAmount + " life! Flip again for double the life stakes?", source, game); youWonLastFlip = true; } } else { // non-flipper wins, flipper lose 1 and non-flipper gains 1 - handleLifeChangesFromFlip(game, targetOpponent, you, lifeAmount); + handleLifeChangesFromFlip(game, targetOpponent, you, lifeAmount, source); if (!cannotContinueFlipping(you, targetOpponent)) { continueFlipping = targetOpponent.chooseUse(outcome, "You gained " + lifeAmount + " life! Flip again for double the life stakes?", source, game); youWonLastFlip = false; } } - - if (cannotContinueFlipping(you, targetOpponent)) + + if (cannotContinueFlipping(you, targetOpponent)) { continueFlipping = false; - + } + if (continueFlipping) { lifeAmount *= 2; // double the life each time youWonFlip = youWonLastFlip ? you.flipCoin(game) : !targetOpponent.flipCoin(game); // negate the opponent's results for proper evaluation of if you won in next iteration @@ -121,13 +122,13 @@ class GameOfChaosEffect extends OneShotEffect { } return false; } - - private void handleLifeChangesFromFlip(Game game, Player playerGainingLife, Player playerLosingLife, int lifeAmount) { + + private void handleLifeChangesFromFlip(Game game, Player playerGainingLife, Player playerLosingLife, int lifeAmount, Ability source) { playerGainingLife.gainLife(lifeAmount, game, source); playerLosingLife.loseLife(lifeAmount, game, false); } - + private boolean cannotContinueFlipping(Player you, Player opponent) { - return (!you.canRespond() || !opponent.canRespond() || (you.canLoseByZeroOrLessLife() && you.getLife() <= 0) || (opponent.canLoseByZeroOrLessLife() && opponent.getLife() <= 0)); + return (!you.canRespond() || !opponent.canRespond() || (you.canLoseByZeroOrLessLife() && you.getLife() <= 0) || (opponent.canLoseByZeroOrLessLife() && opponent.getLife() <= 0)); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/l/LichsMirror.java b/Mage.Sets/src/mage/cards/l/LichsMirror.java index 933d05d7e17..7aea9ed443a 100644 --- a/Mage.Sets/src/mage/cards/l/LichsMirror.java +++ b/Mage.Sets/src/mage/cards/l/LichsMirror.java @@ -113,7 +113,7 @@ class LichsMirrorEffect extends ReplacementEffectImpl { player.drawCards(7, game); - player.setLife(20, game); + player.setLife(20, game, source); } return true; } diff --git a/Mage.Sets/src/mage/cards/m/MagisterSphinx.java b/Mage.Sets/src/mage/cards/m/MagisterSphinx.java index 3f588ddb74d..0288bfd068c 100644 --- a/Mage.Sets/src/mage/cards/m/MagisterSphinx.java +++ b/Mage.Sets/src/mage/cards/m/MagisterSphinx.java @@ -90,7 +90,7 @@ class MagisterSphinxEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer != null) { - targetPlayer.setLife(10, game); + targetPlayer.setLife(10, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java b/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java index 782e70b6e7f..8b903162000 100644 --- a/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java +++ b/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java @@ -150,7 +150,7 @@ class MasterOfCrueltiesEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player defendingPlayer = game.getPlayer(game.getCombat().getDefenderId(source.getSourceId())); if (defendingPlayer != null) { - defendingPlayer.setLife(1, game); + defendingPlayer.setLife(1, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/o/OketrasLastMercy.java b/Mage.Sets/src/mage/cards/o/OketrasLastMercy.java index 82d0e97a879..39a15267d35 100644 --- a/Mage.Sets/src/mage/cards/o/OketrasLastMercy.java +++ b/Mage.Sets/src/mage/cards/o/OketrasLastMercy.java @@ -87,7 +87,7 @@ class OketrasLastMercyEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - controller.setLife(game.getLife(), game); + controller.setLife(game.getLife(), game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/p/PsychicTransfer.java b/Mage.Sets/src/mage/cards/p/PsychicTransfer.java index 08b24fd1dc7..fefebf1a27b 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicTransfer.java +++ b/Mage.Sets/src/mage/cards/p/PsychicTransfer.java @@ -105,8 +105,8 @@ class PsychicTransferEffect extends OneShotEffect return false; } - sourcePlayer.setLife(lifePlayer2, game); - targetPlayer.setLife(lifePlayer1, game); + sourcePlayer.setLife(lifePlayer2, game, source); + targetPlayer.setLife(lifePlayer1, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/r/RepayInKind.java b/Mage.Sets/src/mage/cards/r/RepayInKind.java index 7f0456525a1..402f7575c7d 100644 --- a/Mage.Sets/src/mage/cards/r/RepayInKind.java +++ b/Mage.Sets/src/mage/cards/r/RepayInKind.java @@ -84,7 +84,7 @@ class RepayInKindEffect extends OneShotEffect { } for (Player playerId : game.getPlayers().values()) { if (playerId != null) { - playerId.setLife(lowestLife, game); + playerId.setLife(lowestLife, game, source); } } return true; diff --git a/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java b/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java index 0dc7b688590..48c150de2ad 100644 --- a/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java +++ b/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java @@ -93,7 +93,7 @@ class ResoluteArchangelEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - controller.setLife(game.getLife(), game); + controller.setLife(game.getLife(), game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/r/ReverseTheSands.java b/Mage.Sets/src/mage/cards/r/ReverseTheSands.java index 8c1a2a1ddf1..bd9554ae7e2 100644 --- a/Mage.Sets/src/mage/cards/r/ReverseTheSands.java +++ b/Mage.Sets/src/mage/cards/r/ReverseTheSands.java @@ -110,7 +110,7 @@ class ReverseTheSandsEffect extends OneShotEffect { if (index > 0) { String lifeString = selectedChoice.substring(0, index); int life = Integer.parseInt(lifeString); - player.setLife(life, game); + player.setLife(life, game, source); choices.remove(selectedChoice); game.informPlayers(new StringBuilder("Player ").append(player.getLogName()).append(" life set to ").append(life).toString()); } diff --git a/Mage.Sets/src/mage/cards/s/ShamanOfForgottenWays.java b/Mage.Sets/src/mage/cards/s/ShamanOfForgottenWays.java index e9e6c2d9636..0cd803a7c42 100644 --- a/Mage.Sets/src/mage/cards/s/ShamanOfForgottenWays.java +++ b/Mage.Sets/src/mage/cards/s/ShamanOfForgottenWays.java @@ -147,7 +147,7 @@ class ShamanOfForgottenWaysEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null){ int numberCreatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size(); - player.setLife(numberCreatures, game); + player.setLife(numberCreatures, game, source); } } return true; diff --git a/Mage.Sets/src/mage/cards/s/SorinMarkov.java b/Mage.Sets/src/mage/cards/s/SorinMarkov.java index da0dcfee524..9865669c3e7 100644 --- a/Mage.Sets/src/mage/cards/s/SorinMarkov.java +++ b/Mage.Sets/src/mage/cards/s/SorinMarkov.java @@ -102,7 +102,7 @@ class SorinMarkovEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - player.setLife(10, game); + player.setLife(10, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/s/SoulConduit.java b/Mage.Sets/src/mage/cards/s/SoulConduit.java index 9fbf7f21ff2..8618bae5fad 100644 --- a/Mage.Sets/src/mage/cards/s/SoulConduit.java +++ b/Mage.Sets/src/mage/cards/s/SoulConduit.java @@ -109,8 +109,8 @@ class SoulConduitEffect extends OneShotEffect { return false; } - player1.setLife(lifePlayer2, game); - player2.setLife(lifePlayer1, game); + player1.setLife(lifePlayer2, game, source); + player2.setLife(lifePlayer1, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java b/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java index 16435ea6f46..0e2f1fbea91 100644 --- a/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java +++ b/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java @@ -73,7 +73,7 @@ public class SoulfireGrandMaster extends CardImpl { } public SoulfireGrandMaster(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.MONK); this.power = new MageInt(2); @@ -130,26 +130,6 @@ class GainAbilitySpellsEffect extends ContinuousEffectImpl { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (player != null && permanent != null) { - for (Card card : game.getExile().getAllCards(game)) { - if (card.getOwnerId().equals(source.getControllerId()) && filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } - for (Card card : player.getLibrary().getCards(game)) { - if (filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } - for (Card card : player.getHand().getCards(game)) { - if (filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } - for (Card card : player.getGraveyard().getCards(game)) { - if (filter.match(card, game)) { - game.getState().addOtherAbility(card, ability); - } - } for (StackObject stackObject : game.getStack()) { if (stackObject.getControllerId().equals(source.getControllerId())) { Card card = game.getCard(stackObject.getSourceId()); @@ -225,7 +205,8 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect public boolean applies(GameEvent event, Ability source, Game game) { //Something hit the stack from the hand, see if its a spell with this ability. ZoneChangeEvent zEvent = (ZoneChangeEvent) event; - if (spellId == null && // because this effect works only once, spellId has to be null here + if (spellId == null + && // because this effect works only once, spellId has to be null here zEvent.getFromZone() == Zone.HAND && zEvent.getToZone() == Zone.STACK && event.getPlayerId().equals(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/t/TorgaarFamineIncarnate.java b/Mage.Sets/src/mage/cards/t/TorgaarFamineIncarnate.java index 61d25588391..7f68af91bbf 100644 --- a/Mage.Sets/src/mage/cards/t/TorgaarFamineIncarnate.java +++ b/Mage.Sets/src/mage/cards/t/TorgaarFamineIncarnate.java @@ -160,7 +160,7 @@ class TorgaarFamineIncarnateEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { int startingLifeTotal = game.getLife(); - targetPlayer.setLife(startingLifeTotal / 2, game); + targetPlayer.setLife(startingLifeTotal / 2, game, source); } return true; } diff --git a/Mage.Sets/src/mage/cards/t/TouchOfTheEternal.java b/Mage.Sets/src/mage/cards/t/TouchOfTheEternal.java index 14ba9487840..081ef437e1c 100644 --- a/Mage.Sets/src/mage/cards/t/TouchOfTheEternal.java +++ b/Mage.Sets/src/mage/cards/t/TouchOfTheEternal.java @@ -84,7 +84,7 @@ class TouchOfTheEternalEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); int permanentsInPlay = game.getBattlefield().countAll(filter, source.getControllerId(), game); if (player != null) { - player.setLife(permanentsInPlay, game); + player.setLife(permanentsInPlay, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/t/TreeOfPerdition.java b/Mage.Sets/src/mage/cards/t/TreeOfPerdition.java index 640ae40c31c..10607139cda 100644 --- a/Mage.Sets/src/mage/cards/t/TreeOfPerdition.java +++ b/Mage.Sets/src/mage/cards/t/TreeOfPerdition.java @@ -104,7 +104,7 @@ class TreeOfPerditionEffect extends OneShotEffect { if (life > amount && !opponent.isCanLoseLife()) { return false; } - opponent.setLife(amount, game); + opponent.setLife(amount, game, source); perm.getToughness().modifyBaseValue(life); // game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.Custom, SubLayer.SetPT_7b), source); return true; diff --git a/Mage.Sets/src/mage/cards/t/TreeOfRedemption.java b/Mage.Sets/src/mage/cards/t/TreeOfRedemption.java index cd2322bd200..1d40b9094df 100644 --- a/Mage.Sets/src/mage/cards/t/TreeOfRedemption.java +++ b/Mage.Sets/src/mage/cards/t/TreeOfRedemption.java @@ -104,7 +104,7 @@ class TreeOfRedemptionEffect extends OneShotEffect { if (life > amount && !player.isCanLoseLife()) { return false; } - player.setLife(amount, game); + player.setLife(amount, game, source); game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.Custom, SubLayer.SetPT_7b), source); return true; } diff --git a/Mage.Sets/src/mage/cards/v/VraskaRelicSeeker.java b/Mage.Sets/src/mage/cards/v/VraskaRelicSeeker.java index 0ca53b9549e..dabfc8e09ff 100644 --- a/Mage.Sets/src/mage/cards/v/VraskaRelicSeeker.java +++ b/Mage.Sets/src/mage/cards/v/VraskaRelicSeeker.java @@ -129,7 +129,7 @@ class VraskaRelicSeekerLifeTotalEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - player.setLife(1, game); + player.setLife(1, game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/w/Worldfire.java b/Mage.Sets/src/mage/cards/w/Worldfire.java index 40a0c987c2f..1823dd1856f 100644 --- a/Mage.Sets/src/mage/cards/w/Worldfire.java +++ b/Mage.Sets/src/mage/cards/w/Worldfire.java @@ -101,7 +101,7 @@ class WorldfireEffect extends OneShotEffect { c.moveToExile(null, null, source.getSourceId(), game); } } - player.setLife(1, game); + player.setLife(1, game, source); } } return true; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/vis/BroodOfCockroachesTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/vis/BroodOfCockroachesTest.java index d4133f297a8..95d3140bdcc 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/vis/BroodOfCockroachesTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/vis/BroodOfCockroachesTest.java @@ -1,5 +1,6 @@ package org.mage.test.cards.single.vis; +import java.util.UUID; import mage.game.permanent.Permanent; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -19,7 +20,7 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { @Test public void should_display_correct_text() { - String expectedText = "When {this} dies, at the beginning of the next end step, you lose 1 life and return Brood of Cockroaches to your hand."; + String expectedText = "When {this} dies, at the beginning of the next end step, you lose 1 life and return Brood of Cockroaches to your hand."; playerA_casts_Brood_of_Cockroaches_at_precombat_main_phase(); @@ -33,7 +34,7 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { @Test public void should_reduce_life_of_playerA_by_1_at_the_beginning_of_the_next_end_step() { - playerA.setLife(ANY_LIFE_TOTAL, currentGame); + playerA.setLife(ANY_LIFE_TOTAL, currentGame, UUID.randomUUID()); playerA_casts_Brood_of_Cockroaches_at_precombat_main_phase(); @@ -47,7 +48,7 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { @Test public void should_not_reduce_life_of_playerA_by_1_at_post_combat_main_step() { - playerA.setLife(ANY_LIFE_TOTAL, currentGame); + playerA.setLife(ANY_LIFE_TOTAL, currentGame, UUID.randomUUID()); playerA_casts_Brood_of_Cockroaches_at_precombat_main_phase(); @@ -56,12 +57,12 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { setStopAt(TURN_1, PRECOMBAT_MAIN); execute(); - assertLife(playerA, ANY_LIFE_TOTAL ); + assertLife(playerA, ANY_LIFE_TOTAL); } @Test public void should_return_Brood_of_Cockroaches_to_playerA_hand_end_of_turn() { - playerA.setLife(ANY_LIFE_TOTAL, currentGame); + playerA.setLife(ANY_LIFE_TOTAL, currentGame, UUID.randomUUID()); playerA_casts_Brood_of_Cockroaches_at_precombat_main_phase(); @@ -75,7 +76,7 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { @Test public void should_not_return_Brood_of_Cockroaches_to_playerA_at_post_combat_step() { - playerA.setLife(ANY_LIFE_TOTAL, currentGame); + playerA.setLife(ANY_LIFE_TOTAL, currentGame, UUID.randomUUID()); playerA_casts_Brood_of_Cockroaches_at_precombat_main_phase(); @@ -87,7 +88,6 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { assertHandCount(playerA, BROOD_OF_COCKROACHES, 0); } - private void brood_of_cockroaches_diesat_precombat_main_phase() { addCard(BATTLEFIELD, playerB, "Mountain", 1); addCard(HAND, playerB, SHOCK, 1); @@ -100,5 +100,4 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase { castSpell(TURN_1, PRECOMBAT_MAIN, playerA, BROOD_OF_COCKROACHES); } - } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 31a2346b8ae..d8fe776a6b2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -1547,8 +1547,13 @@ public class TestPlayer implements Player { } @Override - public void setLife(int life, Game game) { - computerPlayer.setLife(life, game); + public void setLife(int life, Game game, UUID sourceId) { + computerPlayer.setLife(life, game, sourceId); + } + + @Override + public void setLife(int life, Game game, Ability source) { + computerPlayer.setLife(life, game, source); } @Override @@ -1593,7 +1598,12 @@ public class TestPlayer implements Player { @Override public int gainLife(int amount, Game game, Ability source) { - return computerPlayer.gainLife(amount, game); + return computerPlayer.gainLife(amount, game, source); + } + + @Override + public int gainLife(int amount, Game game, UUID sourceId) { + return computerPlayer.gainLife(amount, game, sourceId); } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java index ab572ff6795..354b9a88ac6 100644 --- a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java +++ b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java @@ -140,7 +140,12 @@ public class PlayerStub implements Player { } @Override - public void setLife(int life, Game game) { + public void setLife(int life, Game game, Ability source) { + + } + + @Override + public void setLife(int life, Game game, UUID sourceId) { } @@ -154,6 +159,11 @@ public class PlayerStub implements Player { return 0; } + @Override + public int gainLife(int amount, Game game, UUID sourceId) { + return 0; + } + @Override public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable) { return 0; diff --git a/Mage/src/main/java/mage/abilities/costs/common/GainLifeOpponentCost.java b/Mage/src/main/java/mage/abilities/costs/common/GainLifeOpponentCost.java index 98593815f82..2ff1e0a962f 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/GainLifeOpponentCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/GainLifeOpponentCost.java @@ -67,7 +67,7 @@ public class GainLifeOpponentCost extends CostImpl { if (controller.chooseTarget(Outcome.Detriment, target, ability, game)) { Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { - opponent.gainLife(amount, game, source); + opponent.gainLife(amount, game, sourceId); paid = true; } diff --git a/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java b/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java index f24c852c69d..5399765b0f4 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java @@ -78,7 +78,7 @@ public class GainLifePlayersCost extends CostImpl { if (!playerId.equals(controllerId)) { Player player = game.getPlayer(playerId); if (player != null) { - player.gainLife(amount, game, source); + player.gainLife(amount, game, sourceId); } } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExchangeLifeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExchangeLifeTargetEffect.java index 5342c01cc55..a9a8d151055 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExchangeLifeTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExchangeLifeTargetEffect.java @@ -77,8 +77,8 @@ public class ExchangeLifeTargetEffect extends OneShotEffect { return false; } - controller.setLife(lifePlayer, game); - player.setLife(lifeController, game); + controller.setLife(lifePlayer, game, source); + player.setLife(lifeController, game, source); return true; } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java index 4e6b4f8d338..fa7befc9179 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java @@ -62,7 +62,7 @@ public class SetPlayerLifeAllEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - player.setLife(amount.calculate(game, source, this), game); + player.setLife(amount.calculate(game, source, this), game, source); } } break; @@ -70,7 +70,7 @@ public class SetPlayerLifeAllEffect extends OneShotEffect { for (UUID playerId : game.getOpponents(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { - player.setLife(amount.calculate(game, source, this), game); + player.setLife(amount.calculate(game, source, this), game, source); } } break; diff --git a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeSourceEffect.java index ab15b8d8536..54db0d0d56a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeSourceEffect.java @@ -45,7 +45,7 @@ public class SetPlayerLifeSourceEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - player.setLife(amount.calculate(game, source, this), game); + player.setLife(amount.calculate(game, source, this), game, source); return true; } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeTargetEffect.java index f38181d11e9..8f05f221f1e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeTargetEffect.java @@ -67,7 +67,7 @@ public class SetPlayerLifeTargetEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - player.setLife(amount.calculate(game, source, this), game); + player.setLife(amount.calculate(game, source, this), game, source); return true; } return false; diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index c72ddb6fadb..86cc1bd201d 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1565,14 +1565,14 @@ public abstract class GameImpl implements Game, Serializable { } state.addCommandObject(newPlane); informPlayers("You have planeswalked to " + newPlane.getLogName()); - + // Fire off the planeswalked event GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), null, newPlane.getId(), 0, true); if (!replaceEvent(event)) { GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), null, newPlane.getId(), 0, true); fireEvent(ge); } - + return true; } @@ -2821,7 +2821,7 @@ public abstract class GameImpl implements Game, Serializable { if (s.length == 2) { try { Integer amount = Integer.parseInt(s[1]); - player.setLife(amount, this); + player.setLife(amount, this, ownerId); logger.info("Setting player's life: "); } catch (NumberFormatException e) { logger.fatal("error setting life", e); diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 806980a1ad2..117dd2b88b5 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -785,7 +785,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { if (source != null && sourceAbilities != null) { if (sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) { Player player = game.getPlayer(sourceControllerId); - player.gainLife(damageDone, game, source); + player.gainLife(damageDone, game, sourceId); } if (sourceAbilities.containsKey(DeathtouchAbility.getInstance().getId())) { deathtouched = true; @@ -946,8 +946,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } } - - if (abilities.containsKey(HexproofFromBlackAbility.getInstance().getId()) ) { + if (abilities.containsKey(HexproofFromBlackAbility.getInstance().getId())) { if (game.getPlayer(this.getControllerId()).hasOpponent(sourceControllerId, game) && !game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.HEXPROOF, sourceControllerId, game) && source.getColor(game).isBlack()) { @@ -955,7 +954,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } } - if (abilities.containsKey(HexproofFromWhiteAbility.getInstance().getId()) ) { + if (abilities.containsKey(HexproofFromWhiteAbility.getInstance().getId())) { if (game.getPlayer(this.getControllerId()).hasOpponent(sourceControllerId, game) && !game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.HEXPROOF, sourceControllerId, game) && source.getColor(game).isWhite()) { diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index b40beb092ce..83d698dafba 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -112,7 +112,9 @@ public interface Player extends MageItem, Copyable { void initLife(int life); - void setLife(int life, Game game); + void setLife(int life, Game game, Ability source); + + void setLife(int life, Game game, UUID sourceId); /** * @@ -125,6 +127,8 @@ public interface Player extends MageItem, Copyable { int gainLife(int amount, Game game, Ability source); + int gainLife(int amount, Game game, UUID sourceId); + int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable); int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List appliedEffects); @@ -427,6 +431,7 @@ public interface Player extends MageItem, Copyable { PlanarDieRoll rollPlanarDie(Game game); PlanarDieRoll rollPlanarDie(Game game, ArrayList appliedEffects); + PlanarDieRoll rollPlanarDie(Game game, ArrayList appliedEffects, int numberChaosSides, int numberPlanarSides); @Deprecated diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 56e8831b2e2..dbd55c6c2f1 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -31,6 +31,7 @@ import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; +import static jdk.nashorn.internal.objects.NativeRegExp.source; import mage.ConditionalMana; import mage.MageObject; import mage.Mana; @@ -439,7 +440,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.canLoseLife = true; this.topCardRevealed = false; this.payManaMode = false; - this.setLife(game.getLife(), game); + this.setLife(game.getLife(), game, UUID.randomUUID()); this.setReachedNextTurnAfterLeaving(false); this.castSourceIdWithAlternateMana = null; @@ -1741,10 +1742,15 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public void setLife(int life, Game game) { + public void setLife(int life, Game game, Ability source) { + setLife(life, game, source.getSourceId()); + } + + @Override + public void setLife(int life, Game game, UUID sourceId) { // rule 118.5 if (life > this.life) { - gainLife(life - this.life, game, source); + gainLife(life - this.life, game, sourceId); } else if (life < this.life) { loseLife(this.life - life, game, false); } @@ -1808,6 +1814,10 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public int gainLife(int amount, Game game, Ability source) { + return gainLife(amount, game, source.getSourceId()); + } + + public int gainLife(int amount, Game game, UUID sourceId) { if (!canGainLife || amount == 0) { return 0; } @@ -1820,7 +1830,7 @@ public abstract class PlayerImpl implements Player, Serializable { if (!game.isSimulation()) { game.informPlayers(this.getLogName() + " gains " + event.getAmount() + " life"); } - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.GAINED_LIFE, playerId, source.getSourceId(), playerId, event.getAmount())); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.GAINED_LIFE, playerId, sourceId, playerId, event.getAmount())); return event.getAmount(); } return 0; @@ -1879,7 +1889,7 @@ public abstract class PlayerImpl implements Player, Serializable { } if (sourceAbilities != null && sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) { Player player = game.getPlayer(sourceControllerId); - player.gainLife(actualDamage, game, source); + player.gainLife(actualDamage, game, sourceId); } // Unstable ability - Earl of Squirrel if (sourceAbilities != null && sourceAbilities.containsKey(SquirrellinkAbility.getInstance().getId())) {