GameAction: better handle etb counter + doubler + same time

This commit is contained in:
Hans Mackowiak
2022-06-18 10:19:22 +02:00
parent 49462192f1
commit 41197902ab
5 changed files with 131 additions and 2 deletions

View File

@@ -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
checkStaticAbilities();

View File

@@ -122,8 +122,12 @@ public class GameEntityCounterTable extends ForwardingTable<Optional<Player>, Ga
game.getTriggerHandler().runTrigger(TriggerType.CounterAddedAll, runParams, false);
}
@SuppressWarnings("unchecked")
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()) {
return;
}
@@ -135,6 +139,10 @@ public class GameEntityCounterTable extends ForwardingTable<Optional<Player>, Ga
repParams.put(AbilityKey.Cause, cause);
repParams.put(AbilityKey.EffectOnly, effect);
repParams.put(AbilityKey.CounterMap, values);
repParams.put(AbilityKey.ETB, etb);
if (params != null) {
repParams.putAll(params);
}
switch (game.getReplacementHandler().run(ReplacementType.AddCounter, repParams)) {
case NotReplaced:

View File

@@ -67,6 +67,7 @@ public enum AbilityKey {
Explorer("Explorer"),
ExtraTurn("ExtraTurn"),
Event("Event"),
ETB("ETB"),
Fighter("Fighter"),
Fighters("Fighters"),
FirstTime("FirstTime"),

View File

@@ -8,9 +8,11 @@ import com.google.common.base.Optional;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.card.CardCollectionView;
import forge.game.card.CounterType;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.game.zone.ZoneType;
/**
* TODO: Write javadoc for this type.
@@ -58,6 +60,23 @@ public class ReplaceAddCounter extends ReplacementEffect {
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;
}