From 930d18a77d67f93efcf6a900ff93c4807fa68b04 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 25 Feb 2023 16:20:43 +0400 Subject: [PATCH] * Alluring Siren - fixed that it forced to attack any player instead controller (#9939, #9963) --- Mage.Sets/src/mage/cards/a/AlluringSiren.java | 4 +- .../combat/AttacksIfAbleTargetEffect.java | 53 ++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AlluringSiren.java b/Mage.Sets/src/mage/cards/a/AlluringSiren.java index c8b658087e..3af2de7fe6 100644 --- a/Mage.Sets/src/mage/cards/a/AlluringSiren.java +++ b/Mage.Sets/src/mage/cards/a/AlluringSiren.java @@ -26,7 +26,9 @@ public final class AlluringSiren extends CardImpl { this.subtype.add(SubType.SIREN); this.power = new MageInt(1); this.toughness = new MageInt(1); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AttacksIfAbleTargetEffect(Duration.EndOfTurn), new TapSourceCost()); + + // {T}: Target creature an opponent controls attacks you this turn if able. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AttacksIfAbleTargetEffect(Duration.EndOfTurn, TargetController.YOU), new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE)); this.addAbility(ability); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleTargetEffect.java index 848619ecd8..64957dca54 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleTargetEffect.java @@ -5,21 +5,39 @@ import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.RequirementEffect; import mage.constants.Duration; +import mage.constants.TargetController; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.EnumSet; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public class AttacksIfAbleTargetEffect extends RequirementEffect { + TargetController mustAttacks; + public AttacksIfAbleTargetEffect(Duration duration) { + this(duration, TargetController.ANY); + } + + public AttacksIfAbleTargetEffect(Duration duration, TargetController mustAttacks) { super(duration); + this.mustAttacks = mustAttacks; + + if (!EnumSet.of( + TargetController.YOU, + TargetController.ANY + ).contains(this.mustAttacks)) { + throw new IllegalArgumentException("Unsupported type in mustAttacks"); + } } public AttacksIfAbleTargetEffect(final AttacksIfAbleTargetEffect effect) { super(effect); + this.mustAttacks = effect.mustAttacks; } @Override @@ -37,6 +55,17 @@ public class AttacksIfAbleTargetEffect extends RequirementEffect { return true; } + @Override + public UUID mustAttackDefender(Ability source, Game game) { + switch (this.mustAttacks) { + case YOU: + return source.getControllerId(); + case ANY: + default: + return null; + } + } + @Override public boolean mustBlock(Game game) { return false; @@ -47,11 +76,23 @@ public class AttacksIfAbleTargetEffect extends RequirementEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } - if (this.duration == Duration.EndOfTurn) { - return "target " + mode.getTargets().get(0).getTargetName() + " attacks this turn if able"; - } else { - return "target " + mode.getTargets().get(0).getTargetName() + " attacks each combat if able"; + StringBuilder sb = new StringBuilder(); + sb.append("target "); + sb.append(mode.getTargets().get(0).getTargetName()); + switch (this.mustAttacks) { + case YOU: + sb.append(" attacks you"); + break; + case ANY: + default: + sb.append(" attacks"); + break; } + if (this.duration == Duration.EndOfTurn) { + sb.append(" this turn if able"); + } else { + sb.append(" each combat if able"); + } + return sb.toString(); } - }