From bbf7a2597986a8276af68defaa1caa60280f9376 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Mon, 6 Oct 2025 20:50:28 +0200 Subject: [PATCH] Refactor UnlockedDoors using PlayerProperty --- .../java/forge/game/ability/AbilityUtils.java | 29 +++---------------- .../c/central_elevator_promising_stairs.txt | 2 +- .../res/cardsfolder/r/rampaging_soulrager.txt | 2 +- .../s/smoky_lounge_misty_salon.txt | 2 +- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 5738433e1c2..2f8d310fcc7 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -2543,34 +2543,13 @@ public class AbilityUtils { return doXMath(CardLists.getValidCardCount(game.getLeftGraveyardThisTurn(), validFilter, player, c, ctb), expr, c, ctb); } - // Count$UnlockedDoors - if (sq[0].startsWith("UnlockedDoors")) { - final String[] workingCopy = l[0].split(" ", 2); - final String validFilter = workingCopy[1]; - - int unlocked = 0; - for (Card doorCard : CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), validFilter, player, c, ctb)) { - unlocked += doorCard.getUnlockedRooms().size(); - } - - return doXMath(unlocked, expr, c, ctb); + if (sq[0].equals("UnlockedDoors")) { + return doXMath(player.getUnlockedDoors().size(), expr, c, ctb); } - // Count$DistinctUnlockedDoors // Counts the distinct names of unlocked doors. Used for the "Promising Stairs" - if (sq[0].startsWith("DistinctUnlockedDoors")) { - final String[] workingCopy = l[0].split(" ", 2); - final String validFilter = workingCopy[1]; - - Set viewedNames = new HashSet<>(); - for (Card doorCard : CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), validFilter, player, c, ctb)) { - for(CardStateName stateName : doorCard.getUnlockedRooms()) { - viewedNames.add(doorCard.getState(stateName).getName()); - } - } - int distinctUnlocked = viewedNames.size(); - - return doXMath(distinctUnlocked, expr, c, ctb); + if (sq[0].equals("DistinctUnlockedDoors")) { + return doXMath(Sets.newHashSet(player.getUnlockedDoors()).size(), expr, c, ctb); } // Manapool diff --git a/forge-gui/res/cardsfolder/c/central_elevator_promising_stairs.txt b/forge-gui/res/cardsfolder/c/central_elevator_promising_stairs.txt index 26ca18797da..751dcb0cc7a 100644 --- a/forge-gui/res/cardsfolder/c/central_elevator_promising_stairs.txt +++ b/forge-gui/res/cardsfolder/c/central_elevator_promising_stairs.txt @@ -14,5 +14,5 @@ Types:Enchantment Room T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigSurveil | TriggerDescription$ At the beginning of your upkeep, surveil 1. You win the game if there are eight or more different names among unlocked doors of Rooms you control. SVar:TrigSurveil:DB$ Surveil | SubAbility$ DBWin SVar:DBWin:DB$ WinsGame | Defined$ You | ConditionCheckSVar$ RoomsUnlocked | ConditionSVarCompare$ GE8 -SVar:RoomsUnlocked:Count$DistinctUnlockedDoors Card.Room+YouCtrl +SVar:RoomsUnlocked:Count$DistinctUnlockedDoors Oracle:At the beginning of your upkeep, surveil 1. You win the game if there are eight or more different names among unlocked doors of Rooms you control. diff --git a/forge-gui/res/cardsfolder/r/rampaging_soulrager.txt b/forge-gui/res/cardsfolder/r/rampaging_soulrager.txt index af9fc947061..86f35bb255f 100644 --- a/forge-gui/res/cardsfolder/r/rampaging_soulrager.txt +++ b/forge-gui/res/cardsfolder/r/rampaging_soulrager.txt @@ -3,5 +3,5 @@ ManaCost:2 R Types:Creature Spirit PT:1/4 S:Mode$ Continuous | Affected$ Card.Self | AddPower$ 3 | CheckSVar$ X | SVarCompare$ GE2 | Description$ CARDNAME gets +3/+0 as long as there are two or more unlocked doors among Rooms you control. -SVar:X:Count$UnlockedDoors Card.Room+YouCtrl +SVar:X:Count$UnlockedDoors Oracle:Rampaging Soulrager gets +3/+0 as long as there are two or more unlocked doors among Rooms you control. diff --git a/forge-gui/res/cardsfolder/s/smoky_lounge_misty_salon.txt b/forge-gui/res/cardsfolder/s/smoky_lounge_misty_salon.txt index 831b569d199..0f2b8e92648 100644 --- a/forge-gui/res/cardsfolder/s/smoky_lounge_misty_salon.txt +++ b/forge-gui/res/cardsfolder/s/smoky_lounge_misty_salon.txt @@ -13,5 +13,5 @@ ManaCost:3 U Types:Enchantment Room T:Mode$ UnlockDoor | ValidPlayer$ You | ValidCard$ Card.Self | ThisDoor$ True | Execute$ TrigToken | TriggerDescription$ When you unlock this door, create an X/X blue Spirit creature token with flying, where X is the number of unlocked doors among Rooms you control. SVar:TrigToken:DB$ Token | TokenAmount$ 1 | TokenScript$ u_x_x_spirit_flying | TokenPower$ X | TokenToughness$ X | TokenOwner$ You -SVar:X:Count$UnlockedDoors Card.Room+YouCtrl +SVar:X:Count$UnlockedDoors Oracle:(You may cast either half. That door unlocks on the battlefield. As a sorcery, you may pay the mana cost of a locked door to unlock it.)\nWhen you unlock this door, create an X/X blue Spirit creature token with flying, where X is the number of unlocked doors among Rooms you control.