fix #13425 (ninjutsu ability), add test

This commit is contained in:
xenohedron 2025-03-15 17:36:46 -04:00
parent e373c82b0a
commit bf8c8c4e99
2 changed files with 67 additions and 6 deletions

View file

@ -54,7 +54,7 @@ public class NinjutsuAbility extends ActivatedAbilityImpl {
}
public NinjutsuAbility(Cost cost, boolean commander) {
super(commander ? Zone.ALL : Zone.HAND, new NinjutsuEffect(), cost);
super(commander ? Zone.ALL : Zone.HAND, new NinjutsuEffect(commander), cost);
this.addCost(new RevealNinjutsuCardCost(commander));
this.addCost(new ReturnAttackerToHandTargetCost());
this.commander = commander;
@ -84,14 +84,18 @@ public class NinjutsuAbility extends ActivatedAbilityImpl {
class NinjutsuEffect extends OneShotEffect {
public NinjutsuEffect() {
private final boolean commander;
NinjutsuEffect(boolean commander) {
super(Outcome.PutCreatureInPlay);
this.commander = commander;
this.staticText = "Put this card onto the battlefield "
+ "from your hand tapped and attacking";
}
protected NinjutsuEffect(final NinjutsuEffect effect) {
private NinjutsuEffect(final NinjutsuEffect effect) {
super(effect);
this.commander = effect.commander;
}
@Override
@ -102,11 +106,12 @@ class NinjutsuEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
Card card = game.getCard(source.getSourceId());
if (controller == null || card == null) {
return false;
}
Card card = game.getCard(source.getSourceId());
if (card != null) {
Zone cardZone = game.getState().getZone(card.getId());
if (cardZone == Zone.HAND || (commander && cardZone == Zone.COMMAND)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
@ -144,6 +149,7 @@ class ReturnAttackerToHandTargetCost extends CostImpl {
public ReturnAttackerToHandTargetCost(ReturnAttackerToHandTargetCost cost) {
super(cost);
this.defendingPlayerId = cost.defendingPlayerId;
}
@Override