diff --git a/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java b/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java index 458863110c..26fa79b5ad 100644 --- a/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java +++ b/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java @@ -35,8 +35,9 @@ import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; -import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -51,6 +52,7 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.targetpointer.FixedTarget; import mage.util.CardUtil; /** @@ -85,9 +87,9 @@ public class DauntlessBodyguard extends CardImpl { } class DauntlessBodyguardChooseCreatureEffect extends OneShotEffect { - + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature you control"); - + static { filter.add(new AnotherPredicate()); } @@ -127,12 +129,10 @@ class DauntlessBodyguardChooseCreatureEffect extends OneShotEffect { } } -class DauntlessBodyguardGainAbilityEffect extends GainAbilityTargetEffect { - - private MageObjectReference mor; +class DauntlessBodyguardGainAbilityEffect extends OneShotEffect { public DauntlessBodyguardGainAbilityEffect() { - super(IndestructibleAbility.getInstance(), Duration.EndOfTurn); + super(Outcome.AddAbility); this.staticText = "The chosen creature gains indestructible until end of turn"; } @@ -147,17 +147,17 @@ class DauntlessBodyguardGainAbilityEffect extends GainAbilityTargetEffect { @Override public boolean apply(Game game, Ability source) { - if (mor == null) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - if (sourcePermanent != null) { - mor = (MageObjectReference) game.getState().getValue(sourcePermanent.getId() + "_chosenCreature"); - } + MageObjectReference mor; + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (sourcePermanent == null) { + return false; } - if (mor != null) { - Permanent permanent = mor.getPermanent(game); - if (permanent != null) { - permanent.addAbility(ability, source.getSourceId(), game, false); - } + mor = (MageObjectReference) game.getState().getValue(sourcePermanent.getId() + "_chosenCreature"); + Permanent chosenPermanent = mor.getPermanent(game); + if (chosenPermanent != null) { + ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn); + effect.setTargetPointer(new FixedTarget(chosenPermanent, game)); + game.addEffect(effect, source); } return true; } diff --git a/Mage.Sets/src/mage/cards/k/KarplusanHound.java b/Mage.Sets/src/mage/cards/k/KarplusanHound.java index ab463771b8..917f3937e3 100644 --- a/Mage.Sets/src/mage/cards/k/KarplusanHound.java +++ b/Mage.Sets/src/mage/cards/k/KarplusanHound.java @@ -33,13 +33,14 @@ import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.decorator.ConditionalTriggeredAbility; -import mage.abilities.effects.common.DamageEverythingEffect; +import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterPlaneswalkerPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.target.common.TargetAnyTarget; /** * @@ -56,9 +57,13 @@ public class KarplusanHound extends CardImpl { FilterPlaneswalkerPermanent filter = new FilterPlaneswalkerPermanent("a Chandra planeswalker"); filter.add(new SubtypePredicate(SubType.CHANDRA)); // Whenever Karplusan Hound attacks, if you control a Chandra planeswalker, this creature deals 2 damage to any target. - Ability ability = new ConditionalTriggeredAbility(new AttacksTriggeredAbility(new DamageEverythingEffect(2), false), new PermanentsOnTheBattlefieldCondition(filter), - "if you control a Chandra planeswalker, this creature deals 2 damage to any target"); - + Ability ability = new ConditionalTriggeredAbility( + new AttacksTriggeredAbility(new DamageTargetEffect(2), false), + new PermanentsOnTheBattlefieldCondition(filter), + "if you control a Chandra planeswalker, " + + "this creature deals 2 damage to any target" + ); + ability.addTarget(new TargetAnyTarget()); this.addAbility(ability); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java index 502b70186b..f408e17033 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java @@ -31,8 +31,6 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; -import mage.filter.FilterPermanent; -import mage.filter.StaticFilters; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; @@ -46,6 +44,11 @@ import mage.util.CardUtil; */ public class UntapLandsEffect extends OneShotEffect { + private static final FilterLandPermanent filter = new FilterLandPermanent("untapped lands"); + + static { + filter.add(new TappedPredicate()); + } private final int amount; private final boolean upTo; @@ -70,15 +73,12 @@ public class UntapLandsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - TargetLandPermanent target = new TargetLandPermanent(upTo ? 0 : amount, amount, StaticFilters.FILTER_LAND, true); + int tappedLands = game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game).size(); + TargetLandPermanent target = new TargetLandPermanent(upTo ? 0 : Math.min(tappedLands, amount), amount, filter, true); if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { // UI Shortcut: Check if any lands are already tapped. If there are equal/fewer than amount, give the option to add those in to be untapped now. - FilterPermanent filter = new FilterLandPermanent(); - filter.add(new TappedPredicate()); - int tappedLands = game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game).size(); - - if (tappedLands <= amount) { + if (tappedLands <= amount && upTo) { if (controller.chooseUse(outcome, "Include your tapped lands to untap?", source, game)) { for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) { target.addTarget(land.getId(), source, game); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 0e1136188e..307fc1d527 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2226,7 +2226,7 @@ public abstract class PlayerImpl implements Player, Serializable { Player opponent = game.getPlayer(opponentId); if (opponent != null && !opponent.hasLost()) { logger.debug("player won -> calling opponent lost: " + this.getName() + " opponent: " + opponent.getName()); - opponent.lost(game); + opponent.lostForced(game); } } // if no more opponents alive, you win and the game ends