fix and test [CMM] Narci, Fable Singer

This commit is contained in:
Susucre 2024-06-30 14:50:35 +02:00
parent 2709614508
commit 5016a57397
2 changed files with 48 additions and 11 deletions

View file

@ -1,7 +1,6 @@
package mage.cards.n; package mage.cards.n;
import mage.MageInt; import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.FinalChapterAbilityResolvesTriggeredAbility; import mage.abilities.common.FinalChapterAbilityResolvesTriggeredAbility;
import mage.abilities.common.SacrificePermanentTriggeredAbility; import mage.abilities.common.SacrificePermanentTriggeredAbility;
@ -18,7 +17,7 @@ import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.target.targetpointer.FixedTarget; import mage.game.permanent.Permanent;
import java.util.UUID; import java.util.UUID;
@ -41,13 +40,13 @@ public final class NarciFableSinger extends CardImpl {
// Whenever you sacrifice an enchantment, draw a card. // Whenever you sacrifice an enchantment, draw a card.
this.addAbility(new SacrificePermanentTriggeredAbility( this.addAbility(new SacrificePermanentTriggeredAbility(
new DrawCardSourceControllerEffect(1), new DrawCardSourceControllerEffect(1),
StaticFilters.FILTER_PERMANENT_ENCHANTMENT StaticFilters.FILTER_PERMANENT_ENCHANTMENT
)); ));
// Whenever the final chapter ability of a Saga you control resolves, each opponent loses X life and you gain X life, where X is that Saga's mana value. // Whenever the final chapter ability of a Saga you control resolves, each opponent loses X life and you gain X life, where X is that Saga's mana value.
this.addAbility(new FinalChapterAbilityResolvesTriggeredAbility( this.addAbility(new FinalChapterAbilityResolvesTriggeredAbility(
new NarciFableSingerEffect(), true new NarciFableSingerEffect(), true
)); ));
} }
@ -79,12 +78,7 @@ class NarciFableSingerEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
FixedTarget fixedTarget = getTargetPointer().getFirstAsFixedTarget(game, source); Permanent saga = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (fixedTarget == null) {
return false;
}
MageObject saga = game.getObject(fixedTarget.getTarget());
if (saga == null) { if (saga == null) {
return false; return false;
} }

View file

@ -0,0 +1,43 @@
package org.mage.test.cards.single.cmm;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class NarciFableSingerTest extends CardTestPlayerBase {
/**
* {@link mage.cards.n.NarciFableSinger Narci, Fable Singer} {1}{W}{B}{G}
* Legendary Creature Human Bard
* Lifelink
* Whenever you sacrifice an enchantment, draw a card.
* Whenever the final chapter ability of a Saga you control resolves, each opponent loses X life and you gain X life, where X is that Sagas mana value.
* 3/3
*/
private static final String narci = "Narci, Fable Singer";
@Test
public void test_Simple() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, narci);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
addCard(Zone.HAND, playerA, "History of Benalia");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "History of Benalia");
setChoice(playerA, "Whenever you sacrifice an enchantment, draw a card."); // stack both triggers
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, "History of Benalia", 1);
assertHandCount(playerA, 3); // 2 from draw step, 1 from Narci
assertLife(playerA, 20 + 3);
assertLife(playerB, 20 - 3);
}
}