* Alluring Siren - fixed that it forced to attack any player instead controller (#9939, #9963)

This commit is contained in:
Oleg Agafonov 2023-02-25 16:20:43 +04:00
parent 0fa82ad368
commit 930d18a77d
2 changed files with 50 additions and 7 deletions

View file

@ -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);
}

View file

@ -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();
}
}