WHO: Two Streams Facility (#4495)

* WHO: Two Streams Facility

* add TempRemember to ChooseGenericEffect

* remove RepeatEach from more GenericChoice cards

* tidy Archangel of Strife
This commit is contained in:
Northmoc
2024-01-16 11:01:18 -05:00
committed by GitHub
parent 9431f7fc70
commit b8cf172255
17 changed files with 101 additions and 65 deletions

View File

@@ -3,13 +3,18 @@ package forge.game.ability.effects;
import java.util.List;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.card.CardDamageMap;
import forge.game.card.CardZoneTable;
import forge.game.cost.Cost;
import forge.game.event.GameEventCardModeChosen;
import forge.game.Game;
import forge.game.GameEntityCounterTable;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.util.Aggregates;
@@ -30,6 +35,7 @@ public class ChooseGenericEffect extends SpellAbilityEffect {
@Override
public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard();
final Game game = host.getGame();
final List<SpellAbility> abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices"));
if (sa.hasParam("NumRandomChoices")) {
@@ -38,8 +44,20 @@ public class ChooseGenericEffect extends SpellAbilityEffect {
Aggregates.removeRandom(abilities);
}
}
// TODO Can this be simplified somehow to avoid needing a dedicated fallback ability?
final SpellAbility fallback = sa.getAdditionalAbility("FallbackAbility");
final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("ChoiceAmount", "1"), sa);
final boolean tempRem = sa.hasParam("TempRemember");
final boolean changeZoneTable = sa.hasParam("ChangeZoneTable");
final boolean damageMap = sa.hasParam("DamageMap");
if (damageMap) {
sa.setDamageMap(new CardDamageMap());
sa.setPreventMap(new CardDamageMap());
sa.setCounterTable(new GameEntityCounterTable());
}
if (changeZoneTable) sa.setChangeZoneTable(new CardZoneTable());
for (Player p : getDefinedPlayersOrTargeted(sa)) {
if (!p.isInGame()) {
@@ -84,30 +102,46 @@ public class ChooseGenericEffect extends SpellAbilityEffect {
chosenSAs = p.getController().chooseSpellAbilitiesForEffect(abilities, sa, prompt, amount, ImmutableMap.of());
}
List<Object> oldRem = Lists.newArrayList(Iterables.filter(host.getRemembered(), Player.class));
if (tempRem) {
host.removeRemembered(oldRem);
host.addRemembered(p); // currently we only ever need the Chooser, may need more support later
}
if (!chosenSAs.isEmpty()) {
for (SpellAbility chosenSA : chosenSAs) {
String chosenValue = chosenSA.getDescription();
if (sa.hasParam("ShowChoice")) {
boolean dontNotifySelf = sa.getParam("ShowChoice").equals("ExceptSelf");
p.getGame().getAction().notifyOfValue(sa, p, chosenValue, dontNotifySelf ? p : null);
game.getAction().notifyOfValue(sa, p, chosenValue, dontNotifySelf ? p : null);
}
if (sa.hasParam("SetChosenMode")) {
sa.getHostCard().setChosenMode(chosenValue);
}
p.getGame().fireEvent(new GameEventCardModeChosen(p, host.getName(), chosenValue,
game.fireEvent(new GameEventCardModeChosen(p, host.getName(), chosenValue,
sa.hasParam("ShowChoice"), random));
AbilityUtils.resolve(chosenSA);
}
} else {
// no choices are valid, e.g. maybe all Unless costs are unpayable
if (fallback != null) {
p.getGame().fireEvent(new GameEventCardModeChosen(p, host.getName(), fallback.getDescription(),
game.fireEvent(new GameEventCardModeChosen(p, host.getName(), fallback.getDescription(),
sa.hasParam("ShowChoice"), random));
AbilityUtils.resolve(fallback);
} else if (!random) {
System.err.println("Warning: all Unless costs were unpayable for " + host.getName() +", but it had no FallbackAbility defined. Doing nothing (this is most likely incorrect behavior).");
}
}
if (tempRem) {
host.removeRemembered(p);
host.addRemembered(oldRem);
}
}
if (damageMap) game.getAction().dealDamage(false, sa.getDamageMap(), sa.getPreventMap(),
sa.getCounterTable(), sa);
if (changeZoneTable) {
sa.getChangeZoneTable().triggerChangesZoneAll(game, sa);
sa.setChangeZoneTable(null);
}
}

View File

@@ -441,7 +441,9 @@ public class PumpEffect extends SpellAbilityEffect {
}
if (sa.hasParam("ClearNotedCardsFor")) {
for (Player p : tgtPlayers) {
p.clearNotesForName(sa.getParam("ClearNotedCardsFor"));
for (String s : sa.getParam("ClearNotedCardsFor").split(",")) {
p.clearNotesForName(s);
}
}
}