From cfc92a54f0f3bb7654ace8b498d889c32e4c852e Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Mon, 28 Nov 2022 09:08:09 +0100 Subject: [PATCH] Fix zone choosing when searching --- .../src/main/java/forge/ai/ability/EffectAi.java | 8 ++++---- .../game/ability/effects/ChangeZoneEffect.java | 13 ++++++++++++- forge-gui/res/cardsfolder/r/runeforge_champion.txt | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index a330e4c36b7..09b4f2ed1ba 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -216,8 +216,9 @@ public class EffectAi extends SpellAbilityAi { } else if (logic.equals("Fight")) { return FightAi.canFightAi(ai, sa, 0, 0); } else if (logic.equals("Pump")) { - List options = ai.getCreaturesInPlay(); - if (phase.isPlayerTurn(ai) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) && !options.isEmpty()) { + CardCollection options = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), sa.getTargetRestrictions().getValidTgts(), ai, sa.getHostCard(), sa); + options = CardLists.getTargetableCards(options, sa); + if (!options.isEmpty() && phase.isPlayerTurn(ai) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) { sa.getTargets().add(ComputerUtilCard.getBestCreatureAI(options)); return true; } @@ -239,8 +240,7 @@ public class EffectAi extends SpellAbilityAi { } return true; } else if (logic.equals("ReplaySpell")) { - CardCollection list = new CardCollection(game.getCardsIn(ZoneType.Graveyard)); - list = CardLists.getValidCards(list, sa.getTargetRestrictions().getValidTgts(), ai, sa.getHostCard(), sa); + CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Graveyard), sa.getTargetRestrictions().getValidTgts(), ai, sa.getHostCard(), sa); if (!ComputerUtil.targetPlayableSpellCard(ai, list, sa, false, false)) { return false; } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 5c7876e2dbe..1dddf25c4eb 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -941,7 +941,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect { } ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination")); - if (sa.hasParam("OriginChoice")) { + if (sa.hasParam("OriginAlternative")) { // Currently only used for Mishra, but may be used by other things // Improve how this message reacts for other cards final List alt = ZoneType.listValueOf(sa.getParam("OriginAlternative")); @@ -952,6 +952,17 @@ public class ChangeZoneEffect extends SpellAbilityEffect { sb.append(altFetchList.size()).append(" " + Localizer.getInstance().getMessage("lblCardMatchSearchingTypeInAlternateZones")); if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneFromAltSource, sb.toString(), null)) { + origin.clear(); + } + while (!alt.isEmpty() && origin.size() + alt.size() != 1) { + String prompt = Localizer.getInstance().getMessage("lblSearchPlayerZoneConfirm", "{player's}", alt.get(0).getTranslatedName().toLowerCase()); + prompt = MessageUtil.formatMessage(prompt , decider, player); + if (decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneFromAltSource, prompt, null)) { + origin.add(alt.get(0)); + } + alt.remove(0); + } + if (origin.isEmpty()) { origin = alt; } } diff --git a/forge-gui/res/cardsfolder/r/runeforge_champion.txt b/forge-gui/res/cardsfolder/r/runeforge_champion.txt index ba3ca8d5fb9..ef724880135 100644 --- a/forge-gui/res/cardsfolder/r/runeforge_champion.txt +++ b/forge-gui/res/cardsfolder/r/runeforge_champion.txt @@ -4,6 +4,6 @@ Types:Creature Dwarf Warrior PT:2/3 S:Mode$ Continuous | Affected$ Card.Rune+YouCtrl | AddKeyword$ Alternative Cost:1 | AffectedZone$ Hand,Graveyard,Exile,Library,Command | Description$ You may pay {1} rather than pay the mana cost for Rune spells you cast. T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigChange | OptionalDecider$ You | TriggerDescription$ When CARDNAME enters the battlefield, you may search your library and/or graveyard for a Rune card, reveal it, and put it into your hand. If you search your library this way, shuffle. -SVar:TrigChange:DB$ ChangeZone | Origin$ Library | OriginChoice$ True | OriginAlternative$ Graveyard | AlternativeMessage$ Would you like to search your library with this ability? If you do, your library will be shuffled. | Destination$ Hand | ChangeType$ Rune | ChangeNum$ 1 +SVar:TrigChange:DB$ ChangeZone | Origin$ Library | OriginAlternative$ Graveyard | AlternativeMessage$ Would you like to search your library with this ability? If you do, your library will be shuffled. | Destination$ Hand | ChangeType$ Rune.YouOwn | ChangeNum$ 1 DeckNeeds:Type$Rune Oracle:When Runeforge Champion enters the battlefield, you may search your library and/or graveyard for a Rune card, reveal it, and put it into your hand. If you search your library this way, shuffle.\nYou may pay {1} rather than pay the mana cost for Rune spells you cast.