diff --git a/Mage.Sets/src/mage/cards/a/AggressiveInstinct.java b/Mage.Sets/src/mage/cards/a/AggressiveInstinct.java index 7bc7d8fe4d..793bf6b499 100644 --- a/Mage.Sets/src/mage/cards/a/AggressiveInstinct.java +++ b/Mage.Sets/src/mage/cards/a/AggressiveInstinct.java @@ -1,7 +1,6 @@ package mage.cards.a; -import java.util.UUID; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -10,8 +9,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class AggressiveInstinct extends CardImpl { @@ -26,7 +26,7 @@ public final class AggressiveInstinct extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}"); // Target creature you control deals damage equal to its power to target creature you don't control. - this.getSpellAbility().addEffect(new DamageWithPowerTargetEffect()); + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); } diff --git a/Mage.Sets/src/mage/cards/a/Ambuscade.java b/Mage.Sets/src/mage/cards/a/Ambuscade.java index bfeedd4abc..fe76f0616b 100644 --- a/Mage.Sets/src/mage/cards/a/Ambuscade.java +++ b/Mage.Sets/src/mage/cards/a/Ambuscade.java @@ -1,9 +1,7 @@ - package mage.cards.a; -import java.util.UUID; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -14,8 +12,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author ciaccona007 */ public final class Ambuscade extends CardImpl { @@ -31,14 +30,12 @@ public final class Ambuscade extends CardImpl { // Target creature you control gets +1/+0 until end of turn. Effect effect = new BoostTargetEffect(1, 0, Duration.EndOfTurn); - this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); // It deals damage equal to its power to target creature you don't control. - effect = new DamageWithPowerTargetEffect(); - effect.setText("It deals damage equal to its power to target creature you don't control"); - this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect("It")); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); // second target for effect } public Ambuscade(final Ambuscade card) { diff --git a/Mage.Sets/src/mage/cards/c/ClearShot.java b/Mage.Sets/src/mage/cards/c/ClearShot.java index 9b437d0a9b..dd91a12153 100644 --- a/Mage.Sets/src/mage/cards/c/ClearShot.java +++ b/Mage.Sets/src/mage/cards/c/ClearShot.java @@ -1,9 +1,7 @@ - package mage.cards.c; -import java.util.UUID; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -14,8 +12,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class ClearShot extends CardImpl { @@ -35,10 +34,9 @@ public final class ClearShot extends CardImpl { this.getSpellAbility().addEffect(effect); // It deals damage equal to its power to target creature you don't control. - effect = new DamageWithPowerTargetEffect(); - effect.setText("It deals damage equal to its power to target creature you don't control"); - this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect("It")); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); // second target + } public ClearShot(final ClearShot card) { diff --git a/Mage.Sets/src/mage/cards/d/DomrisAmbush.java b/Mage.Sets/src/mage/cards/d/DomrisAmbush.java index aa6ece0e25..f1c177cb97 100644 --- a/Mage.Sets/src/mage/cards/d/DomrisAmbush.java +++ b/Mage.Sets/src/mage/cards/d/DomrisAmbush.java @@ -2,7 +2,8 @@ package mage.cards.d; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -33,9 +34,12 @@ public final class DomrisAmbush extends CardImpl { public DomrisAmbush(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}{G}"); - // Put a +1/+1 counter on target creature you control. Then that creature deals damage equal to its power to target creature or planeswalker you don't control. - this.getSpellAbility().addEffect(new DomrisAmbushEffect()); + // Put a +1/+1 counter on target creature you control. + this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance())); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); + + // Then that creature deals damage equal to its power to target creature or planeswalker you don't control. + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect("that creature").concatBy("Then")); this.getSpellAbility().addTarget(new TargetPermanent(filter)); } @@ -75,6 +79,6 @@ class DomrisAmbushEffect extends OneShotEffect { } permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.applyEffects(); - return new DamageWithPowerTargetEffect().apply(game, source); + return new DamageWithPowerFromOneToAnotherTargetEffect().apply(game, source); } } diff --git a/Mage.Sets/src/mage/cards/n/NaturesWay.java b/Mage.Sets/src/mage/cards/n/NaturesWay.java index 3f76b3167d..3264e7d521 100644 --- a/Mage.Sets/src/mage/cards/n/NaturesWay.java +++ b/Mage.Sets/src/mage/cards/n/NaturesWay.java @@ -1,9 +1,6 @@ - package mage.cards.n; -import java.util.UUID; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.VigilanceAbility; @@ -16,8 +13,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class NaturesWay extends CardImpl { @@ -32,19 +30,15 @@ public final class NaturesWay extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}"); // Target creature you control gains vigilance and trample until end of turn. - Effect effect = new GainAbilityTargetEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn); - effect.setText("Target creature you control gains vigilance"); - this.getSpellAbility().addEffect(effect); - effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); - effect.setText("and trample until end of turn"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn) + .setText("Target creature you control gains vigilance")); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn) + .setText("and trample until end of turn")); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); // It deals damage equal to its power to target creature you don't control. - effect = new DamageWithPowerTargetEffect(); - effect.setText("It deals damage equal to its power to target creature you don't control"); - this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect("It")); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); // second target } public NaturesWay(final NaturesWay card) { diff --git a/Mage.Sets/src/mage/cards/r/RabidBite.java b/Mage.Sets/src/mage/cards/r/RabidBite.java index a954933519..1b9526dc8a 100644 --- a/Mage.Sets/src/mage/cards/r/RabidBite.java +++ b/Mage.Sets/src/mage/cards/r/RabidBite.java @@ -1,8 +1,6 @@ - package mage.cards.r; -import java.util.UUID; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -11,8 +9,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author fireshoes */ public final class RabidBite extends CardImpl { @@ -27,9 +26,9 @@ public final class RabidBite extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}"); // Target creature you control deals damage equal to its power to target creature you don't control. + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); - this.getSpellAbility().addEffect(new DamageWithPowerTargetEffect()); } public RabidBite(final RabidBite card) { diff --git a/Mage.Sets/src/mage/cards/s/StalkingVengeance.java b/Mage.Sets/src/mage/cards/s/StalkingVengeance.java index f3d6d921dd..a96d2e9e38 100644 --- a/Mage.Sets/src/mage/cards/s/StalkingVengeance.java +++ b/Mage.Sets/src/mage/cards/s/StalkingVengeance.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesCreatureTriggeredAbility; @@ -9,19 +7,16 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetPlayerOrPlaneswalker; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class StalkingVengeance extends CardImpl { @@ -42,7 +37,8 @@ public final class StalkingVengeance extends CardImpl { // Haste this.addAbility(HasteAbility.getInstance()); - // Whenever another creature you control dies, it deals damage equal to its power to target player. + + // Whenever another creature you control dies, it deals damage equal to its power to target player or planeswalker. Ability ability = new DiesCreatureTriggeredAbility(new StalkingVengeanceDamageEffect(), false, filter, true); ability.addTarget(new TargetPlayerOrPlaneswalker()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/t/TailSlash.java b/Mage.Sets/src/mage/cards/t/TailSlash.java index de60057055..69d5dbbe3c 100644 --- a/Mage.Sets/src/mage/cards/t/TailSlash.java +++ b/Mage.Sets/src/mage/cards/t/TailSlash.java @@ -1,8 +1,6 @@ - package mage.cards.t; -import java.util.UUID; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -11,8 +9,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class TailSlash extends CardImpl { @@ -27,9 +26,9 @@ public final class TailSlash extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{R}"); // Target creature you control deals damage equal to its power to target creature you don't control. + this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); - this.getSpellAbility().addEffect(new DamageWithPowerTargetEffect()); } public TailSlash(final TailSlash card) { diff --git a/Mage.Sets/src/mage/cards/t/ThrashThreat.java b/Mage.Sets/src/mage/cards/t/ThrashThreat.java index 301788e9d7..068c43b5aa 100644 --- a/Mage.Sets/src/mage/cards/t/ThrashThreat.java +++ b/Mage.Sets/src/mage/cards/t/ThrashThreat.java @@ -1,7 +1,7 @@ package mage.cards.t; import mage.abilities.effects.common.CreateTokenEffect; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.cards.CardSetInfo; import mage.cards.SplitCard; import mage.constants.CardType; @@ -32,11 +32,7 @@ public final class ThrashThreat extends SplitCard { // Thrash // Target creature you control deals damage equal to its power to target creature or planeswalker you don't control. - this.getLeftHalfCard().getSpellAbility().addEffect( - new DamageWithPowerTargetEffect() - .setText("Target creature you control deals damage equal to its power " + - "to target creature or planeswalker you don't control.") - ); + this.getLeftHalfCard().getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect()); this.getLeftHalfCard().getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getLeftHalfCard().getSpellAbility().addTarget(new TargetPermanent(filter)); diff --git a/Mage.Sets/src/mage/cards/v/VivienArkbowRanger.java b/Mage.Sets/src/mage/cards/v/VivienArkbowRanger.java index 8701980a5a..e1c24f89b5 100644 --- a/Mage.Sets/src/mage/cards/v/VivienArkbowRanger.java +++ b/Mage.Sets/src/mage/cards/v/VivienArkbowRanger.java @@ -3,7 +3,7 @@ package mage.cards.v; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.abilities.effects.common.WishEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.effects.common.counter.DistributeCountersEffect; @@ -16,13 +16,13 @@ import mage.constants.SubType; import mage.constants.SuperType; import mage.counters.CounterType; import mage.filter.StaticFilters; +import mage.game.Game; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreatureOrPlaneswalker; import mage.target.common.TargetCreaturePermanentAmount; +import mage.target.targetadjustment.TargetAdjuster; import java.util.UUID; -import mage.game.Game; -import mage.target.targetadjustment.TargetAdjuster; /** * @author TheElk801 @@ -45,17 +45,14 @@ public final class VivienArkbowRanger extends CardImpl { )); TargetCreaturePermanentAmount target = new TargetCreaturePermanentAmount(2); target.setMinNumberOfTargets(0); - target.setMaxNumberOfTargets(2); + target.setMaxNumberOfTargets(2); ability.addTarget(target); - - // ability.setTargetAdjuster(VivienArkbowRangerAdjuster.instance); + + // ability.setTargetAdjuster(VivienArkbowRangerAdjuster.instance); this.addAbility(ability); // −3: Target creature you control deals damage equal to its power to target creature or planeswalker. - ability = new LoyaltyAbility( - new DamageWithPowerTargetEffect().setText("Target creature you control deals damage " - + "equal to its power to target creature or planeswalker."), -3 - ); + ability = new LoyaltyAbility(new DamageWithPowerFromOneToAnotherTargetEffect(), -3); ability.addTarget(new TargetControlledCreaturePermanent()); ability.addTarget(new TargetCreatureOrPlaneswalker()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/v/VivienOfTheArkbow.java b/Mage.Sets/src/mage/cards/v/VivienOfTheArkbow.java index 3fd71469cb..82b52a429e 100644 --- a/Mage.Sets/src/mage/cards/v/VivienOfTheArkbow.java +++ b/Mage.Sets/src/mage/cards/v/VivienOfTheArkbow.java @@ -1,29 +1,25 @@ package mage.cards.v; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; -import mage.abilities.effects.common.DamageWithPowerTargetEffect; +import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; import mage.abilities.effects.common.continuous.BoostControlledEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.keyword.TrampleAbility; -import mage.constants.SubType; -import mage.constants.SuperType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.TargetController; +import mage.constants.*; import mage.counters.CounterType; import mage.filter.StaticFilters; import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class VivienOfTheArkbow extends CardImpl { @@ -47,7 +43,7 @@ public final class VivienOfTheArkbow extends CardImpl { this.addAbility(ability); // −3: Target creature you control deals damage equal to its power to target creature you don't control. - ability = new LoyaltyAbility(new DamageWithPowerTargetEffect(), -3); + ability = new LoyaltyAbility(new DamageWithPowerFromOneToAnotherTargetEffect(), -3); ability.addTarget(new TargetControlledCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index e4469a4d9e..30ac7356aa 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -921,7 +921,12 @@ public class VerifyCardDataTest { CardSetInfo testSet = new CardSetInfo(cardName, "test", "123", Rarity.COMMON); CardInfo cardInfo = CardRepository.instance.findCard(cardName); Card card = CardImpl.createCard(cardInfo.getClassName(), testSet); - card.getRules().stream().forEach(System.out::println); + System.out.println(card.getName()); + if (card instanceof SplitCard) { + card.getAbilities().getRules(card.getName()).stream().forEach(System.out::println); + } else { + card.getRules().stream().forEach(System.out::println); + } } private void checkWrongAbilitiesText(Card card, JsonCard ref) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerFromOneToAnotherTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerFromOneToAnotherTargetEffect.java new file mode 100644 index 0000000000..d9441ac11a --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerFromOneToAnotherTargetEffect.java @@ -0,0 +1,73 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * @author JayDi85 + */ +public class DamageWithPowerFromOneToAnotherTargetEffect extends OneShotEffect { + + String firstTargetName; + + public DamageWithPowerFromOneToAnotherTargetEffect() { + this((String) null); + } + + public DamageWithPowerFromOneToAnotherTargetEffect(String firstTargetName) { + super(Outcome.Damage); + this.firstTargetName = firstTargetName; + } + + public DamageWithPowerFromOneToAnotherTargetEffect(final DamageWithPowerFromOneToAnotherTargetEffect effect) { + super(effect); + this.firstTargetName = effect.firstTargetName; + } + + @Override + public boolean apply(Game game, Ability source) { + if (source.getTargets().size() != 2) { + throw new IllegalStateException("It must have two targets, but found " + source.getTargets().size()); + } + + Permanent myPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent anotherPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); + Player anotherPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget()); + + if (myPermanent != null && anotherPermanent != null) { + anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true); + return true; + } else if (myPermanent != null && anotherPlayer != null) { + anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true); + return true; + } + return false; + } + + @Override + public DamageWithPowerFromOneToAnotherTargetEffect copy() { + return new DamageWithPowerFromOneToAnotherTargetEffect(this); + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + + if (mode.getTargets().size() != 2) { + throw new IllegalStateException("It must have two targets, but found " + mode.getTargets().size()); + } + + // Target creature you control deals damage equal to its power to target creature you don't control + String sb = (this.firstTargetName != null ? this.firstTargetName : "Target " + mode.getTargets().get(0).getTargetName()) + + " deals damage equal to its power to target " + + mode.getTargets().get(1).getTargetName(); + return sb; + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerFromSourceToAnotherTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerFromSourceToAnotherTargetEffect.java new file mode 100644 index 0000000000..1e9b2ccde8 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerFromSourceToAnotherTargetEffect.java @@ -0,0 +1,70 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * @author JayDi85 + */ +public class DamageWithPowerFromSourceToAnotherTargetEffect extends OneShotEffect { + + String sourceTargetName; + + public DamageWithPowerFromSourceToAnotherTargetEffect() { + this("It"); + } + + public DamageWithPowerFromSourceToAnotherTargetEffect(String sourceTargetName) { + super(Outcome.Damage); + this.sourceTargetName = sourceTargetName; + } + + public DamageWithPowerFromSourceToAnotherTargetEffect(final DamageWithPowerFromSourceToAnotherTargetEffect effect) { + super(effect); + this.sourceTargetName = effect.sourceTargetName; + } + + @Override + public boolean apply(Game game, Ability source) { + if (source.getTargets().size() != 1) { + throw new IllegalStateException("It must have one target, but found " + source.getTargets().size()); + } + + Permanent myPermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + Permanent anotherPermanent = game.getPermanent(source.getTargets().get(0).getFirstTarget()); + Player anotherPlayer = game.getPlayer(source.getTargets().get(0).getFirstTarget()); + + if (myPermanent != null && anotherPermanent != null) { + anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true); + return true; + } else if (myPermanent != null && anotherPlayer != null) { + anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true); + return true; + } + return false; + } + + @Override + public DamageWithPowerFromSourceToAnotherTargetEffect copy() { + return new DamageWithPowerFromSourceToAnotherTargetEffect(this); + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + + if (mode.getTargets().size() != 1) { + throw new IllegalStateException("It must have one targets, but found " + mode.getTargets().size()); + } + + // It deals damage equal to its power to target creature you don't control + return this.sourceTargetName + " deals damage equal to its power to target " + mode.getTargets().get(0).getTargetName(); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerTargetEffect.java deleted file mode 100644 index 00fcd5af85..0000000000 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageWithPowerTargetEffect.java +++ /dev/null @@ -1,45 +0,0 @@ - -package mage.abilities.effects.common; - -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.constants.Outcome; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; - -/** - * - * @author Styxo - */ -public class DamageWithPowerTargetEffect extends OneShotEffect { - - public DamageWithPowerTargetEffect() { - super(Outcome.Damage); - staticText = "Target creature you control deals damage equal to its power to target creature you don't control"; - } - - public DamageWithPowerTargetEffect(final DamageWithPowerTargetEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Permanent controlledCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); - Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (controller != null) { - if (targetCreature != null && controlledCreature != null) { - targetCreature.damage(controlledCreature.getPower().getValue(), controlledCreature.getId(), game, false, true); - } - return true; - } - return false; - } - - @Override - public DamageWithPowerTargetEffect copy() { - return new DamageWithPowerTargetEffect(this); - } - -} diff --git a/Mage/src/main/java/mage/game/draft/RateCard.java b/Mage/src/main/java/mage/game/draft/RateCard.java index fa64ec8778..87676a9210 100644 --- a/Mage/src/main/java/mage/game/draft/RateCard.java +++ b/Mage/src/main/java/mage/game/draft/RateCard.java @@ -144,7 +144,9 @@ public final class RateCard { return 1; } } - if (effect instanceof FightTargetsEffect || effect instanceof DamageWithPowerTargetEffect) { + if (effect instanceof FightTargetsEffect + || effect instanceof DamageWithPowerFromOneToAnotherTargetEffect + || effect instanceof DamageWithPowerFromSourceToAnotherTargetEffect) { return 1; } if (effect.getOutcome() == Outcome.Damage || effect instanceof DamageTargetEffect) {