From 6fa613d47c795b0edbb0a792355600bf6fa16f56 Mon Sep 17 00:00:00 2001 From: ForgottenArbiter <43520548+ForgottenArbiter@users.noreply.github.com> Date: Sun, 9 Feb 2020 23:01:10 -0600 Subject: [PATCH] Improve compatibility with BaseMod and character mods --- README.md | 2 +- pom.xml | 2 +- src/main/java/seedsearch/SeedRunner.java | 10 ++++++++++ .../java/seedsearch/patches/BaseModPatch.java | 16 ++++++++++++++++ .../java/seedsearch/patches/StartSearch.java | 6 ++++-- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 src/main/java/seedsearch/patches/BaseModPatch.java diff --git a/README.md b/README.md index 1d8821f..90eae8c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A mod that searches through Slay the Spire seeds. * Slay the Spire * ModTheSpire (https://github.com/kiooeht/ModTheSpire) -Note: Use of other mods, including BaseMod, with SeedSearch is not recommended and will likely fail. +Note: Because it runs a headless version of Slay the Spire and has no access to graphics, SeedSearch is not designed for compatibility with all other mods, and has no mod requirements. Also, any mod can change the outcome of seeds, so you should not use any mods, including BaseMod, with SeedSearch when searching for seeds to use in unmodded gameplay. Still, some character mods, such as Thorton and Jorbs Mod, have been found to work (or at least not crash/hang) with SeedSearch. ## Setup and Usage diff --git a/pom.xml b/pom.xml index c9c837c..3d81a2b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ seedsearch SeedSearch - 1.0.0 + 1.1.0 jar SeedSearch Finds seeds with desired properties diff --git a/src/main/java/seedsearch/SeedRunner.java b/src/main/java/seedsearch/SeedRunner.java index f4ea71a..8ad1f62 100644 --- a/src/main/java/seedsearch/SeedRunner.java +++ b/src/main/java/seedsearch/SeedRunner.java @@ -33,6 +33,7 @@ import com.megacrit.cardcrawl.shop.ShopScreen; import com.megacrit.cardcrawl.shop.StorePotion; import com.megacrit.cardcrawl.shop.StoreRelic; +import com.megacrit.cardcrawl.vfx.AbstractGameEffect; import seedsearch.patches.AbstractRoomPatch; import seedsearch.patches.CardRewardScreenPatch; import seedsearch.patches.EventHelperPatch; @@ -67,6 +68,7 @@ public SeedRunner(SearchSettings settings) { this.settings = settings; AbstractDungeon.fadeColor = Settings.SHADOW_COLOR; CharacterManager characterManager = new CharacterManager(); + CardCrawlGame.characterManager = characterManager; characterManager.setChosenCharacter(settings.playerClass); currentSeed = settings.startSeed; AbstractDungeon.ascensionLevel = settings.ascensionLevel; @@ -503,6 +505,9 @@ private void runPath(ArrayList path) { } } AbstractDungeon.currMapNode = node; + if (AbstractDungeon.getCurrRoom().phase == AbstractRoom.RoomPhase.COMBAT) { + AbstractDungeon.getCurrRoom().phase = AbstractRoom.RoomPhase.COMPLETE; + } switch(result) { case EVENT: Random eventRngDuplicate = new Random(Settings.seed, AbstractDungeon.eventRng.counter); @@ -544,12 +549,16 @@ private void runPath(ArrayList path) { break; case TREASURE: AbstractChest chest = AbstractDungeon.getRandomChest(); + ShowCardAndObtainEffectPatch.resetCards(); chest.open(false); addGoldReward(combatGold); Reward treasureRelicReward = new Reward(AbstractDungeon.floorNum); for(AbstractRelic treasureRelic : combatRelics) { awardRelic(treasureRelic, treasureRelicReward); } + for (AbstractCard card : ShowCardAndObtainEffectPatch.obtainedCards) { + addInvoluntaryCardReward(card, treasureRelicReward); + } seedResult.addAllCardRewards(combatCardRewards); seedResult.addMiscReward(treasureRelicReward); break; @@ -909,6 +918,7 @@ private void getBossRewards() { AbstractDungeon.floorNum += 1; AbstractDungeon.currMapNode = new MapRoomNode(-1, 15); AbstractDungeon.currMapNode.room = new MonsterRoomBoss(); + AbstractDungeon.currMapNode.room.phase = AbstractRoom.RoomPhase.COMPLETE; if (AbstractDungeon.ascensionLevel == 20 && currentAct == 2) { seedResult.registerBossCombat(AbstractDungeon.bossList.get(1)); AbstractDungeon.floorNum += 1; diff --git a/src/main/java/seedsearch/patches/BaseModPatch.java b/src/main/java/seedsearch/patches/BaseModPatch.java new file mode 100644 index 0000000..07374b8 --- /dev/null +++ b/src/main/java/seedsearch/patches/BaseModPatch.java @@ -0,0 +1,16 @@ +package seedsearch.patches; + +import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; + +@SpirePatch( + cls="basemod.BaseMod", + method="setupAnimationGfx", + optional=true +) +public class BaseModPatch { + + public static void Replace() { + // Do nothing + } + +} diff --git a/src/main/java/seedsearch/patches/StartSearch.java b/src/main/java/seedsearch/patches/StartSearch.java index 9762866..a027289 100644 --- a/src/main/java/seedsearch/patches/StartSearch.java +++ b/src/main/java/seedsearch/patches/StartSearch.java @@ -4,6 +4,7 @@ import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; import com.megacrit.cardcrawl.core.CardCrawlGame; import com.megacrit.cardcrawl.core.Settings; +import com.megacrit.cardcrawl.helpers.GameTips; import com.megacrit.cardcrawl.helpers.ImageMaster; import com.megacrit.cardcrawl.screens.DisplayOption; import javassist.CannotCompileException; @@ -38,7 +39,8 @@ public static ExprEditor Instrument() { return new ExprEditor() { public void edit(NewExpr m) throws CannotCompileException { if (m.getClassName().equals("com.badlogic.gdx.graphics.g2d.SpriteBatch") - || m.getClassName().equals("com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch")) { + || m.getClassName().equals("com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch") + || m.getClassName().equals(GameTips.class.getName())) { m.replace("{$_ = $0;}"); } } @@ -47,7 +49,7 @@ public void edit(NewExpr m) throws CannotCompileException { private static class Locator extends SpireInsertLocator { public int[] Locate(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { - Matcher matcher = new Matcher.FieldAccessMatcher(CardCrawlGame.class, "tips"); + Matcher matcher = new Matcher.FieldAccessMatcher(CardCrawlGame.class, "splashScreen"); return LineFinder.findInOrder(ctMethodToPatch, new ArrayList(), matcher); } }