mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
GameAction: better handle etb counter + doubler + same time
This commit is contained in:
@@ -591,7 +591,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table.replaceCounterEffect(game, null, true);
|
table.replaceCounterEffect(game, null, true, true, params);
|
||||||
|
|
||||||
// Need to apply any static effects to produce correct triggers
|
// Need to apply any static effects to produce correct triggers
|
||||||
checkStaticAbilities();
|
checkStaticAbilities();
|
||||||
|
|||||||
@@ -122,8 +122,12 @@ public class GameEntityCounterTable extends ForwardingTable<Optional<Player>, Ga
|
|||||||
game.getTriggerHandler().runTrigger(TriggerType.CounterAddedAll, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.CounterAddedAll, runParams, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void replaceCounterEffect(final Game game, final SpellAbility cause, final boolean effect) {
|
public void replaceCounterEffect(final Game game, final SpellAbility cause, final boolean effect) {
|
||||||
|
replaceCounterEffect(game, cause, effect, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void replaceCounterEffect(final Game game, final SpellAbility cause, final boolean effect, final boolean etb, Map<AbilityKey, Object> params) {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -135,6 +139,10 @@ public class GameEntityCounterTable extends ForwardingTable<Optional<Player>, Ga
|
|||||||
repParams.put(AbilityKey.Cause, cause);
|
repParams.put(AbilityKey.Cause, cause);
|
||||||
repParams.put(AbilityKey.EffectOnly, effect);
|
repParams.put(AbilityKey.EffectOnly, effect);
|
||||||
repParams.put(AbilityKey.CounterMap, values);
|
repParams.put(AbilityKey.CounterMap, values);
|
||||||
|
repParams.put(AbilityKey.ETB, etb);
|
||||||
|
if (params != null) {
|
||||||
|
repParams.putAll(params);
|
||||||
|
}
|
||||||
|
|
||||||
switch (game.getReplacementHandler().run(ReplacementType.AddCounter, repParams)) {
|
switch (game.getReplacementHandler().run(ReplacementType.AddCounter, repParams)) {
|
||||||
case NotReplaced:
|
case NotReplaced:
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public enum AbilityKey {
|
|||||||
Explorer("Explorer"),
|
Explorer("Explorer"),
|
||||||
ExtraTurn("ExtraTurn"),
|
ExtraTurn("ExtraTurn"),
|
||||||
Event("Event"),
|
Event("Event"),
|
||||||
|
ETB("ETB"),
|
||||||
Fighter("Fighter"),
|
Fighter("Fighter"),
|
||||||
Fighters("Fighters"),
|
Fighters("Fighters"),
|
||||||
FirstTime("FirstTime"),
|
FirstTime("FirstTime"),
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import com.google.common.base.Optional;
|
|||||||
|
|
||||||
import forge.game.ability.AbilityKey;
|
import forge.game.ability.AbilityKey;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.card.CardCollectionView;
|
||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -58,6 +60,23 @@ public class ReplaceAddCounter extends ReplacementEffect {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runParams.containsKey(AbilityKey.ETB)) {
|
||||||
|
// if Card does affect something other than itself
|
||||||
|
if (!getParam("ValidCard").equals("Card.Self")) {
|
||||||
|
// and it self is entering, skip
|
||||||
|
if (getHostCard().equals(runParams.get(AbilityKey.Affected))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// and it wasn't already on the field, skip
|
||||||
|
if (getActiveZone().contains(ZoneType.Battlefield) && runParams.containsKey(AbilityKey.LastStateBattlefield)) {
|
||||||
|
CardCollectionView lastBattlefield = (CardCollectionView) runParams.get(AbilityKey.LastStateBattlefield);
|
||||||
|
if (!lastBattlefield.contains(getHostCard())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2394,4 +2394,105 @@ public class GameSimulationTest extends SimulationTest {
|
|||||||
AssertJUnit.assertEquals(20, simGame.getPlayers().get(0).getLife());
|
AssertJUnit.assertEquals(20, simGame.getPlayers().get(0).getLife());
|
||||||
AssertJUnit.assertEquals(2, simGame.getPlayers().get(1).getLife());
|
AssertJUnit.assertEquals(2, simGame.getPlayers().get(1).getLife());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testETBCounterMowu() {
|
||||||
|
Game game = initAndCreateGame();
|
||||||
|
Player p = game.getPlayers().get(0);
|
||||||
|
//Player p2 = game.getPlayers().get(1);
|
||||||
|
|
||||||
|
String grumName = "Grumgully, the Generous";
|
||||||
|
String mowuName = "Mowu, Loyal Companion";
|
||||||
|
|
||||||
|
addCard(grumName, p);
|
||||||
|
Card mowu = addCardToZone(mowuName, p, ZoneType.Hand);
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; ++i) {
|
||||||
|
addCard("Forest", p);
|
||||||
|
}
|
||||||
|
SpellAbility mowuSA = mowu.getFirstSpellAbility();
|
||||||
|
|
||||||
|
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||||
|
game.getAction().checkStateEffects(true);
|
||||||
|
|
||||||
|
GameSimulator sim = createSimulator(game, p);
|
||||||
|
sim.simulateSpellAbility(mowuSA);
|
||||||
|
Game simGame = sim.getSimulatedGameState();
|
||||||
|
|
||||||
|
Card simMowu = findCardWithName(simGame, mowuName);
|
||||||
|
|
||||||
|
AssertJUnit.assertNotNull(simMowu);
|
||||||
|
AssertJUnit.assertEquals(2, simMowu.getCounters(CounterEnumType.P1P1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testETBCounterCorpsejack() {
|
||||||
|
Game game = initAndCreateGame();
|
||||||
|
Player p = game.getPlayers().get(0);
|
||||||
|
//Player p2 = game.getPlayers().get(1);
|
||||||
|
|
||||||
|
String grumName = "Grumgully, the Generous";
|
||||||
|
String corpsejackName = "Corpsejack Menace";
|
||||||
|
|
||||||
|
addCard(grumName, p);
|
||||||
|
Card corpsejack = addCardToZone(corpsejackName, p, ZoneType.Hand);
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; ++i) {
|
||||||
|
addCard("Forest", p);
|
||||||
|
addCard("Swamp", p);
|
||||||
|
}
|
||||||
|
SpellAbility corpsejackSA = corpsejack.getFirstSpellAbility();
|
||||||
|
|
||||||
|
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||||
|
game.getAction().checkStateEffects(true);
|
||||||
|
|
||||||
|
GameSimulator sim = createSimulator(game, p);
|
||||||
|
sim.simulateSpellAbility(corpsejackSA);
|
||||||
|
Game simGame = sim.getSimulatedGameState();
|
||||||
|
|
||||||
|
Card simCorpsejack = findCardWithName(simGame, corpsejackName);
|
||||||
|
|
||||||
|
AssertJUnit.assertNotNull(simCorpsejack);
|
||||||
|
AssertJUnit.assertEquals(1, simCorpsejack.getCounters(CounterEnumType.P1P1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testETBCounterCorpsejackMentor() {
|
||||||
|
Game game = initAndCreateGame();
|
||||||
|
Player p = game.getPlayers().get(0);
|
||||||
|
//Player p2 = game.getPlayers().get(1);
|
||||||
|
|
||||||
|
String grumName = "Grumgully, the Generous";
|
||||||
|
String corpsejackName = "Corpsejack Menace";
|
||||||
|
String mentorName = "Conclave Mentor";
|
||||||
|
String everAfterName = "Ever After";
|
||||||
|
|
||||||
|
addCard(grumName, p);
|
||||||
|
Card corpsejack = addCardToZone(corpsejackName, p, ZoneType.Graveyard);
|
||||||
|
Card mentor = addCardToZone(mentorName, p, ZoneType.Graveyard);
|
||||||
|
|
||||||
|
Card everAfter = addCardToZone(everAfterName, p, ZoneType.Hand);
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; ++i) {
|
||||||
|
addCard("Swamp", p);
|
||||||
|
}
|
||||||
|
SpellAbility everSA = everAfter.getFirstSpellAbility();
|
||||||
|
everSA.getTargets().add(corpsejack);
|
||||||
|
everSA.getTargets().add(mentor);
|
||||||
|
|
||||||
|
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||||
|
game.getAction().checkStateEffects(true);
|
||||||
|
|
||||||
|
GameSimulator sim = createSimulator(game, p);
|
||||||
|
sim.simulateSpellAbility(everSA);
|
||||||
|
Game simGame = sim.getSimulatedGameState();
|
||||||
|
|
||||||
|
Card simCorpsejack = findCardWithName(simGame, corpsejackName);
|
||||||
|
Card simMentor = findCardWithName(simGame, mentorName);
|
||||||
|
|
||||||
|
AssertJUnit.assertNotNull(simCorpsejack);
|
||||||
|
AssertJUnit.assertEquals(1, simCorpsejack.getCounters(CounterEnumType.P1P1));
|
||||||
|
AssertJUnit.assertNotNull(simMentor);
|
||||||
|
AssertJUnit.assertEquals(1, simMentor.getCounters(CounterEnumType.P1P1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user