Designation - fixed not working abilities like Monarch and Initiative (#10334, #10338);

This commit is contained in:
Oleg Agafonov 2023-05-12 18:00:52 +04:00
parent b860253624
commit 6d4e353867
3 changed files with 33 additions and 6 deletions

View file

@ -29,6 +29,7 @@ public final class ProdigalPyromancer extends CardImpl {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// {T} : Prodigal Pyromancer deals 1 damage to any target.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost());
ability.addTarget(new TargetAnyTarget());
this.addAbility(ability);

View file

@ -9,17 +9,18 @@ import mage.game.Game;
import mage.game.GameException;
import mage.game.mulligan.MulliganType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestMultiPlayerBaseWithRangeAll;
import org.mage.test.serverside.base.CardTestMultiPlayerBase;
import java.io.FileNotFoundException;
/**
* @author JayDi85
*/
public class MonarchTest extends CardTestMultiPlayerBaseWithRangeAll {
public class MonarchTest extends CardTestMultiPlayerBase {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
// reason: must use MultiplayerAttackOption.MULTIPLE
Game game = new FreeForAll(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 20);
// Player order: A -> D -> C -> B
playerA = createPlayer(game, "PlayerA");
@ -93,4 +94,31 @@ public class MonarchTest extends CardTestMultiPlayerBaseWithRangeAll {
setStopAt(3 + 4, PhaseStep.END_TURN);
execute();
}
@Test
public void test_MonarchByDies() {
// Player order: A -> D -> C -> B
addCustomEffect_TargetDamage(playerA, 100);
// When Thorn of the Black Rose enters the battlefield, you become the monarch.
addCard(Zone.HAND, playerA, "Thorn of the Black Rose", 1); // {3}{B}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
// A as monarch
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Thorn of the Black Rose");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkMonarch("monarch to A", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerA);
// kill itself, so monarch goes to next - player D
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "target damage 100", playerA);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkMonarch("monarch to D", 2, PhaseStep.POSTCOMBAT_MAIN, playerD, playerD);
setStrictChooseMode(true);
setStopAt(2, PhaseStep.END_TURN);
execute();
assertLostTheGame(playerA);
}
}

View file

@ -35,7 +35,6 @@ public abstract class Designation extends MageObjectImpl {
private boolean copy;
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
private Abilities<Ability> abilites = new AbilitiesImpl<>();
public Designation(DesignationType designationType) {
this(designationType, true);
@ -56,7 +55,6 @@ public abstract class Designation extends MageObjectImpl {
this.frameStyle = designation.frameStyle;
this.copy = designation.copy;
this.copyFrom = (designation.copyFrom != null ? designation.copyFrom.copy() : null);
this.abilites = designation.abilites.copy();
}
@Override
@ -80,8 +78,8 @@ public abstract class Designation extends MageObjectImpl {
public void addAbility(Ability ability) {
ability.setSourceId(this.objectId);
abilites.add(ability);
abilites.addAll(ability.getSubAbilities());
this.abilities.add(ability);
this.abilities.addAll(ability.getSubAbilities());
}
@Override