From ae6f937f35f360e742e0ada0cc2cc27ae7cd306c Mon Sep 17 00:00:00 2001 From: tool4ever Date: Tue, 14 Jan 2025 18:14:33 +0100 Subject: [PATCH] Misc cleanup (#6767) * Restore identical checkstyle until it can be cleaned up --- .../src/main/java/forge/ai/AiController.java | 54 +++++++++---------- .../main/java/forge/ai/AiDeckStatistics.java | 1 - .../main/java/forge/ai/ComputerUtilCard.java | 1 + .../game/ability/effects/DigUntilEffect.java | 6 +-- .../StaticAbilityContinuous.java | 4 +- forge-gui/COMPILE.txt | 8 --- .../res/cardsfolder/c/calibrated_blast.txt | 2 +- forge-gui/res/cardsfolder/c/crabomination.txt | 2 +- .../j/judith_carnage_connoisseur.txt | 2 +- .../p/parnesse_the_subtle_brush.txt | 6 +-- .../res/cardsfolder/t/the_twelfth_doctor.txt | 2 +- 11 files changed, 39 insertions(+), 49 deletions(-) delete mode 100644 forge-gui/COMPILE.txt diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index a3f8900b085..fc9d48d0e32 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -30,7 +30,6 @@ import forge.card.CardType; import forge.card.MagicColor; import forge.card.mana.ManaAtom; import forge.card.mana.ManaCost; -import forge.card.mana.ManaCostShard; import forge.deck.Deck; import forge.deck.DeckSection; import forge.game.*; @@ -500,6 +499,8 @@ public class AiController { return null; } + landList = ComputerUtilCard.dedupeCards(landList); + CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.NON_LANDS); // Some considerations for Momir/MoJhoSto @@ -542,15 +543,12 @@ public class AiController { // try to skip lands that enter the battlefield tapped if we might want to play something this turn if (!nonLandsInHand.isEmpty()) { - // get the tapped and non-tapped lands - CardCollection tappedLands = new CardCollection(); CardCollection nonTappedLands = new CardCollection(); for (Card land : landList) { // check replacement effects if land would enter tapped or not final Map repParams = AbilityKey.mapFromAffected(land); repParams.put(AbilityKey.Origin, land.getZone().getZoneType()); repParams.put(AbilityKey.Destination, ZoneType.Battlefield); - repParams.put(AbilityKey.Source, land); // add Params for AddCounter Replacements GameEntityCounterTable table = new GameEntityCounterTable(); @@ -581,35 +579,36 @@ public class AiController { // if we have the choice, see if we can play an untapped land if (!nonTappedLands.isEmpty()) { - // get the costs of the nonland cards in hand and the mana we have available. - // If adding one won't make something new castable, then pick a tapland. - int max_inc = 0; - for (Card c : nonTappedLands) { - max_inc = max(max_inc, c.getMaxManaProduced()); - } // If we have a lot of mana, prefer untapped lands. // We're either topdecking or have drawn enough the tempo no longer matters. int mana_available = getAvailableManaEstimate(player); if (mana_available > 6) { landList = nonTappedLands; - } - // check for lands with no mana abilities - else if (max_inc > 0) { - boolean found = false; - for (Card c : nonLandsInHand) { - // TODO make this work better with split cards and Monocolored Hybrid - ManaCost cost = c.getManaCost(); - // check for incremental cmc - // check for X cost spells - if (cost.getCMC() == max_inc + mana_available || - (cost.getShardCount(ManaCostShard.X) > 0 && cost.getCMC() >= mana_available)) { - found = true; - break; - } + } else { + // get the costs of the nonland cards in hand and the mana we have available. + // If adding one won't make something new castable, then pick a tapland. + int max_inc = 0; + for (Card c : nonTappedLands) { + max_inc = max(max_inc, c.getMaxManaProduced()); } + // check for lands with no mana abilities + if (max_inc > 0) { + boolean found = false; + for (Card c : nonLandsInHand) { + // TODO make this work better with split cards and Monocolored Hybrid + ManaCost cost = c.getManaCost(); + // check for incremental cmc + // check for X cost spells + if ((cost.getCMC() - mana_available) * (cost.getCMC() - mana_available - max_inc - 1) < 0 || + (cost.countX() > 0 && cost.getCMC() >= mana_available)) { + found = true; + break; + } + } - if (found) { - landList = nonTappedLands; + if (found) { + landList = nonTappedLands; + } } } } @@ -719,7 +718,8 @@ public class AiController { return score; })); - return toReturn; } + return toReturn; + } // if return true, go to next phase private SpellAbility chooseCounterSpell(final List possibleCounters) { diff --git a/forge-ai/src/main/java/forge/ai/AiDeckStatistics.java b/forge-ai/src/main/java/forge/ai/AiDeckStatistics.java index b7ac1be0d85..bd14b4fce7e 100644 --- a/forge-ai/src/main/java/forge/ai/AiDeckStatistics.java +++ b/forge-ai/src/main/java/forge/ai/AiDeckStatistics.java @@ -120,7 +120,6 @@ public class AiDeckStatistics { } return fromDeck(deck, player); - } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 93fd0126879..2aec47810d3 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -2079,6 +2079,7 @@ public class ComputerUtilCard { return false; } + // use this function to skip expensive calculations on identical cards public static CardCollection dedupeCards(CardCollection cc) { if (cc.size() <= 1) { return cc; diff --git a/forge-game/src/main/java/forge/game/ability/effects/DigUntilEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DigUntilEffect.java index a7af28dfb69..5c28cad776b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DigUntilEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DigUntilEffect.java @@ -277,11 +277,7 @@ public class DigUntilEffect extends SpellAbilityEffect { } // Allow ordering the rest of the revealed cards - if (finalDest.isKnown() && revealed.size() >= 2) { - revealed = (CardCollection)p.getController().orderMoveToZoneList(revealed, finalDest, sa); - } - if (finalDest == ZoneType.Library && !shuffle - && !sa.hasParam("RevealRandomOrder") && revealed.size() >= 2) { + if ((finalDest.isKnown() || (finalDest == ZoneType.Library && !shuffle && !sa.hasParam("RevealRandomOrder"))) && revealed.size() >= 2) { revealed = (CardCollection)p.getController().orderMoveToZoneList(revealed, finalDest, sa); } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 677307b32cb..d50a5d8f721 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -842,7 +842,9 @@ public final class StaticAbilityContinuous { for (Card c : cards) { for (final Trigger trig : c.getTriggers()) { final Trigger newTrigger = affectedCard.addTriggerForStaticAbility(trig, stAb); - newTrigger.removeParam("Secondary"); + if (newTrigger.getKeyword() != null) { + newTrigger.removeParam("Secondary"); + } addedTrigger.add(newTrigger); } } diff --git a/forge-gui/COMPILE.txt b/forge-gui/COMPILE.txt deleted file mode 100644 index b2d60e52ea4..00000000000 --- a/forge-gui/COMPILE.txt +++ /dev/null @@ -1,8 +0,0 @@ -This file contains the current build notes for Forge. - --- Compiling Forge for Android: Pre-requisites -- -When compiling Forge for Android, make sure the following prerequisites are met: -Java 17, either Oracle or OpenJDK. -Android SDK 35 -Android Build-Tools 35.0.0 (this is important, build-tools 33 and below do not work with Java 17) -Proguard 7.6.0 (proguard.jar included under "forge-gui-android/tools"). diff --git a/forge-gui/res/cardsfolder/c/calibrated_blast.txt b/forge-gui/res/cardsfolder/c/calibrated_blast.txt index d58319eec9c..dc23da17c75 100644 --- a/forge-gui/res/cardsfolder/c/calibrated_blast.txt +++ b/forge-gui/res/cardsfolder/c/calibrated_blast.txt @@ -1,7 +1,7 @@ Name:Calibrated Blast ManaCost:2 R Types:Instant -A:SP$ DigUntil | Valid$ Card.nonLand | ValidDescription$ nonland | RevealedDestination$ Library | RevealedLibraryPosition$ -1 | RevealRandomOrder$ True | RememberFound$ True | SubAbility$ DBImmediateTrigger | StackDescription$ Reveal cards from the top of your library until you reveal a nonland card. Put the revealed cards on the bottom of your library in a random order. | SpellDescription$ Reveal cards from the top of your library until you reveal a nonland card. Put the revealed cards on the bottom of your library in a random order. +A:SP$ DigUntil | Valid$ Card.nonLand | ValidDescription$ nonland | RevealedDestination$ Library | RevealedLibraryPosition$ -1 | RevealRandomOrder$ True | RememberFound$ True | SubAbility$ DBImmediateTrigger | StackDescription$ SpellDescription | SpellDescription$ Reveal cards from the top of your library until you reveal a nonland card. Put the revealed cards on the bottom of your library in a random order. SVar:DBImmediateTrigger:DB$ ImmediateTrigger | ConditionDefined$ Remembered | ConditionPresent$ Card.nonLand | Execute$ TrigDamage | SpellDescription$ When you reveal a nonland card this way, CARDNAME deals damage equal to that card's mana value to any target. SVar:TrigDamage:DB$ DealDamage | ValidTgts$ Any | NumDmg$ X | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True diff --git a/forge-gui/res/cardsfolder/c/crabomination.txt b/forge-gui/res/cardsfolder/c/crabomination.txt index 87c515137e3..8a843e0bee2 100644 --- a/forge-gui/res/cardsfolder/c/crabomination.txt +++ b/forge-gui/res/cardsfolder/c/crabomination.txt @@ -4,7 +4,7 @@ Types:Creature Crab Demon PT:5/5 K:Emerge:5 B B:Artifact T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ ExileTop | TriggerDescription$ When CARDNAME enters, target opponent exiles the top card of their library, a card at random from their graveyard, and a card at random from their hand. You may cast a spell from among cards exiled this way without paying its mana cost. -SVar:ExileTop:DB$ Dig | ValidTgts$ Opponent | DigNum$ 1 | ChangeNum$ All | DestinationZone$ Exile | SubAbility$ RandomGraveyard +SVar:ExileTop:DB$ Dig | ValidTgts$ Opponent | DigNum$ 1 | ChangeNum$ All | DestinationZone$ Exile | RememberChanged$ True | SubAbility$ RandomGraveyard SVar:RandomGraveyard:DB$ ChangeZone | Origin$ Graveyard | Destination$ Exile | DefinedPlayer$ Targeted | Mandatory$ True | ChangeNum$ 1 | Hidden$ True | IsCurse$ True | AtRandom$ True | RememberChanged$ True | SubAbility$ RandomHand SVar:RandomHand:DB$ ChangeZone | Origin$ Hand | Destination$ Exile | DefinedPlayer$ Targeted | Mandatory$ True | ChangeNum$ 1 | Hidden$ True | IsCurse$ True | AtRandom$ True | RememberChanged$ True | SubAbility$ CastOneExiled SVar:CastOneExiled:DB$ Play | Valid$ Card.IsRemembered | ValidSA$ Spell | ValidZone$ Exile | Amount$ 1 | Optional$ True | WithoutManaCost$ True | SubAbility$ DBCleanup diff --git a/forge-gui/res/cardsfolder/j/judith_carnage_connoisseur.txt b/forge-gui/res/cardsfolder/j/judith_carnage_connoisseur.txt index 700ad7d308f..6cff81e0090 100644 --- a/forge-gui/res/cardsfolder/j/judith_carnage_connoisseur.txt +++ b/forge-gui/res/cardsfolder/j/judith_carnage_connoisseur.txt @@ -2,7 +2,7 @@ Name:Judith, Carnage Connoisseur ManaCost:3 B R Types:Legendary Creature Human Shaman PT:3/4 -T:Mode$ SpellCast | TriggerZones$ Battlefield | ValidCard$ Instant,Sorcery | ValidActivatingPlayer$ You | NoResolvingCheck$ True | Execute$ TrigCharm | TriggerDescription$ Whenever you cast an instant or sorcery spell, ABILITY +T:Mode$ SpellCast | TriggerZones$ Battlefield | ValidCard$ Instant,Sorcery | ValidActivatingPlayer$ You | Execute$ TrigCharm | TriggerDescription$ Whenever you cast an instant or sorcery spell, ABILITY SVar:TrigCharm:DB$ Charm | Choices$ DBPump,DBToken SVar:DBPump:DB$ Pump | Defined$ TriggeredCard | KW$ Deathtouch & Lifelink | PumpZone$ Stack | SpellDescription$ That spell gains deathtouch and lifelink. SVar:DBToken:DB$ Token | TokenAmount$ 1 | TokenScript$ r_2_2_imp_burn_opp | TokenOwner$ You | SpellDescription$ Create a 2/2 red Imp creature token with "When this creature dies, it deals 2 damage to each opponent." diff --git a/forge-gui/res/cardsfolder/p/parnesse_the_subtle_brush.txt b/forge-gui/res/cardsfolder/p/parnesse_the_subtle_brush.txt index 96ac64d310c..71cf047f8bf 100644 --- a/forge-gui/res/cardsfolder/p/parnesse_the_subtle_brush.txt +++ b/forge-gui/res/cardsfolder/p/parnesse_the_subtle_brush.txt @@ -4,8 +4,8 @@ Types:Legendary Creature Vampire Wizard PT:4/4 T:Mode$ BecomesTarget | ValidTarget$ You,Permanent.YouCtrl+inZoneBattlefield | ValidSource$ SpellAbility.OppCtrl | TriggerZones$ Battlefield | Execute$ TrigCounter | TriggerDescription$ Whenever you or a permanent you control becomes the target of a spell or ability an opponent controls, counter that spell or ability unless that player pays 4 life. SVar:TrigCounter:DB$ Counter | Defined$ TriggeredSourceSA | UnlessCost$ PayLife<4> | UnlessPayer$ TriggeredSourceSAController -T:Mode$ SpellCopy | ValidActivatingPlayer$ You | NoResolvingCheck$ True | TriggerZones$ Battlefield | Execute$ TrigTarget | TriggerDescription$ Whenever you copy a spell, up to one target opponent may also copy that spell. They may choose new targets for that copy. -SVar:TrigTarget:DB$ Pump | ValidTgts$ Opponent | SubAbility$ DBCopy -SVar:DBCopy:DB$ CopySpellAbility | TargetMin$ 0 | TargetMax$ 1 | Defined$ TriggeredSpellAbility | AILogic$ Always | Controller$ Targeted | Optional$ True | MayChooseTarget$ True +T:Mode$ SpellCopy | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigTarget | TriggerDescription$ Whenever you copy a spell, up to one target opponent may also copy that spell. They may choose new targets for that copy. +SVar:TrigTarget:DB$ Pump | ValidTgts$ Opponent | TargetMin$ 0 | TargetMax$ 1 | SubAbility$ DBCopy +SVar:DBCopy:DB$ CopySpellAbility | Defined$ TriggeredSpellAbility | AILogic$ Always | Controller$ Targeted | Optional$ True | MayChooseTarget$ True AI:RemoveDeck:Random Oracle:Whenever you or a permanent you control becomes the target of a spell or ability an opponent controls, counter that spell or ability unless that player pays 4 life.\nWhenever you copy a spell, up to one target opponent may also copy that spell. They may choose new targets for that copy. diff --git a/forge-gui/res/cardsfolder/t/the_twelfth_doctor.txt b/forge-gui/res/cardsfolder/t/the_twelfth_doctor.txt index 30e4b29325f..37e0e6e9f90 100644 --- a/forge-gui/res/cardsfolder/t/the_twelfth_doctor.txt +++ b/forge-gui/res/cardsfolder/t/the_twelfth_doctor.txt @@ -4,7 +4,7 @@ Types:Legendary Creature Time Lord Doctor PT:4/4 S:Mode$ Continuous | Affected$ Card.YouCtrl+!wasCastFromYourHand | AffectedZone$ Stack | CheckSVar$ X | SVarCompare$ EQ0 | AddKeyword$ Demonstrate | Description$ The first spell you cast from anywhere other than your hand each turn has demonstrate. (When you cast that spell, you may copy it. If you do, choose an opponent to also copy it. A copy of a permanent spell becomes a token.) SVar:X:Count$ThisTurnCast_Card.YouCtrl+!wasCastFromYourHand -T:Mode$ SpellCopy | ValidActivatingPlayer$ You | NoResolvingCheck$ True | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever you copy a spell, put a +1/+1 counter on CARDNAME. +T:Mode$ SpellCopy | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever you copy a spell, put a +1/+1 counter on CARDNAME. SVar:TrigPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1 DeckHas:Ability$Counters Oracle:The first spell you cast from anywhere other than your hand each turn has demonstrate. (When you cast that spell, you may copy it. If you do, choose an opponent to also copy it. A copy of a permanent spell becomes a token.)\nWhenever you copy a spell, put a +1/+1 counter on The Twelfth Doctor.