mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
Fixed Panharmonicon triggering for non-permanents.
This commit is contained in:
parent
da9fd5875c
commit
ab352100f1
4 changed files with 37 additions and 4 deletions
|
@ -92,11 +92,20 @@ class PanharmoniconEffect extends ReplacementEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event instanceof NumberOfTriggersEvent) {
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = (NumberOfTriggersEvent) event;
|
||||
// Only triggers of the controller of Panharmonicon
|
||||
if (source.getControllerId().equals(event.getPlayerId())) {
|
||||
GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent();
|
||||
// Only EtB triggers
|
||||
if (sourceEvent.getType() == EventType.ENTERS_THE_BATTLEFIELD && sourceEvent instanceof EntersTheBattlefieldEvent) {
|
||||
EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) sourceEvent;
|
||||
return entersTheBattlefieldEvent.getTarget().getCardType().contains(CardType.ARTIFACT) || entersTheBattlefieldEvent.getTarget().getCardType().contains(CardType.CREATURE);
|
||||
// Only for entering artifacts or creatures
|
||||
if (entersTheBattlefieldEvent.getTarget().getCardType().contains(CardType.ARTIFACT)
|
||||
|| entersTheBattlefieldEvent.getTarget().getCardType().contains(CardType.CREATURE)) {
|
||||
// Only for triggers of permanents
|
||||
if (game.getPermanent(numberOfTriggersEvent.getSourceId()) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,4 +102,28 @@ public class PanharmoniconTest extends CardTestPlayerBase {
|
|||
|
||||
assertLife(playerA, 22);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that Panharmonicon doesn't add to non-permanents triggers.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDoesntAddNonPermanentsTriggers() {
|
||||
// If an artifact or creature entering the battlefield causes a triggered ability of a permanent you control to trigger, that ability triggers an additional time.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Panharmonicon");
|
||||
// When a Dragon enters the battlefield, you may return Bladewing's Thrall from your graveyard to the battlefield.
|
||||
addCard(Zone.GRAVEYARD, playerA, "Bladewing's Thrall");
|
||||
// A 4/4 vanilla dragon
|
||||
addCard(Zone.HAND, playerA, "Scion of Ugin");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Scion of Ugin");
|
||||
setChoice(playerA, "No"); // Return Bladewing's Thrall from your graveyard to the battlefield?
|
||||
setChoice(playerA, "Yes"); // Should not get run since there is only one trigger.
|
||||
|
||||
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Bladewing's Thrall", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
}
|
||||
|
||||
if (ability.checkTrigger(event, game)) {
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability.getControllerId(), event);
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability.getControllerId(), ability.getSourceId(), event);
|
||||
if (!game.replaceEvent(numberOfTriggersEvent)) {
|
||||
for (int i = 0; i < numberOfTriggersEvent.getAmount(); i++) {
|
||||
ability.trigger(game, ability.getControllerId());
|
||||
|
|
|
@ -38,8 +38,8 @@ public class NumberOfTriggersEvent extends GameEvent {
|
|||
|
||||
private final GameEvent sourceEvent;
|
||||
|
||||
public NumberOfTriggersEvent(UUID controllerOfAbilityId, GameEvent sourceEvent) {
|
||||
super(EventType.NUMBER_OF_TRIGGERS, null, null, controllerOfAbilityId);
|
||||
public NumberOfTriggersEvent(UUID controllerOfAbilityId, UUID sourceOfTrigger, GameEvent sourceEvent) {
|
||||
super(EventType.NUMBER_OF_TRIGGERS, null, sourceOfTrigger, controllerOfAbilityId);
|
||||
this.sourceEvent = sourceEvent;
|
||||
this.amount = 1; // Number of times to trigger. Panharmonicon can change this.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue