mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
- Fixed #8839 and added test for it.
This commit is contained in:
parent
77b2c932d0
commit
b279d4b318
3 changed files with 83 additions and 6 deletions
|
@ -15,6 +15,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.game.stack.StackAbility;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
@ -58,16 +59,25 @@ class StrictProctorTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ABILITY_TRIGGERED;
|
||||
return event.getType() == GameEvent.EventType.TRIGGERED_ABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
GameEvent triggeringEvent = (GameEvent) game.getState().getValue(event.getId().toString());
|
||||
if (triggeringEvent == null || triggeringEvent.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
// retrieve the event that led to the trigger triggering
|
||||
// verify that it is a ETB event
|
||||
StackAbility stackAbilityOfTriggeredAbility = (StackAbility) game.getObject(event.getTargetId());
|
||||
if (stackAbilityOfTriggeredAbility == null
|
||||
|| stackAbilityOfTriggeredAbility.getSourceId() == null) {
|
||||
return false;
|
||||
}
|
||||
getEffects().setTargetPointer(new FixedTarget(triggeringEvent.getTargetId(), game));
|
||||
GameEvent triggeringEvent = (GameEvent) game.getState().getValue("triggeringEvent" + stackAbilityOfTriggeredAbility.getSourceId());
|
||||
if (triggeringEvent == null
|
||||
|| triggeringEvent.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
return false;
|
||||
}
|
||||
// set the target to the ability that gets triggered from the enter the battlefield trigger
|
||||
getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,7 +88,7 @@ class StrictProctorTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a permanent entering the battlefield causes a triggered ability to trigger, " +
|
||||
"counter that ability unless its controller pays {2}.";
|
||||
return "Whenever a permanent entering the battlefield causes a triggered ability to trigger, "
|
||||
+ "counter that ability unless its controller pays {2}.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.mage.test.cards.triggers;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class StrictProctorTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testStrictProctorPaid() {
|
||||
setStrictChooseMode(true);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
// Whenever a permanent entering the battlefield causes a triggered ability to
|
||||
// trigger, counter that ability unless its controller pays {2}.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Strict Proctor", 1);
|
||||
// Whenever a land enters the battlefield under your control, you gain 3 life.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Primeval Bounty", 1);
|
||||
// land to play for trigger
|
||||
addCard(Zone.HAND, playerA, "Swamp", 1);
|
||||
|
||||
playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swamp"); // play land
|
||||
setChoice(playerA, "Yes"); // pay the {2} mana cost to prevent the countering of the trigger
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 23); // player gains the 3 life
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrictProctorNotPaid() {
|
||||
setStrictChooseMode(true);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
// Whenever a permanent entering the battlefield causes a triggered ability to
|
||||
// trigger, counter that ability unless its controller pays {2}.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Strict Proctor", 1);
|
||||
// Whenever a land enters the battlefield under your control, you gain 3 life.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Primeval Bounty", 1);
|
||||
// land to play for trigger
|
||||
addCard(Zone.HAND, playerA, "Swamp", 1);
|
||||
|
||||
playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swamp"); // play land
|
||||
setChoice(playerA, "No"); // do not pay the {2} mana cost to prevent the countering of the trigger
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 20); // player does not gain the 3 life
|
||||
|
||||
}
|
||||
}
|
|
@ -93,6 +93,9 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
|
||||
if (ability.checkTrigger(event, game) && ability.checkTriggeredAlready(game) && ability.checkUsedAlready(game)) {
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability, event);
|
||||
// store the event that led to the triggered event (Strict Proctor)
|
||||
// numberOfTriggerers event is only checked in replacement effects
|
||||
game.getState().setValue("triggeringEvent" + ability.getSourceId(), event);
|
||||
if (!game.replaceEvent(numberOfTriggersEvent)) {
|
||||
for (int i = 0; i < numberOfTriggersEvent.getAmount(); i++) {
|
||||
ability.trigger(game, ability.getControllerId(), event);
|
||||
|
|
Loading…
Reference in a new issue