-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* N'loth should now both never trigger if the Wanderer only has starting two relics and never request Fragile Mind if the event triggers * reformat * rename a patch * some updates to make redo some of the instrumentation * oops * cleanup * test patch * remove test patch after verification
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package stsjorbsmod.patches; | ||
|
||
import com.evacipated.cardcrawl.modthespire.lib.*; | ||
import com.megacrit.cardcrawl.characters.AbstractPlayer; | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon; | ||
import com.megacrit.cardcrawl.events.AbstractEvent; | ||
import com.megacrit.cardcrawl.events.shrines.Nloth; | ||
import com.megacrit.cardcrawl.random.Random; | ||
import com.megacrit.cardcrawl.relics.AbstractRelic; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
import javassist.expr.ExprEditor; | ||
import javassist.expr.FieldAccess; | ||
import javassist.expr.MethodCall; | ||
import stsjorbsmod.JorbsMod; | ||
import stsjorbsmod.relics.FragileMindRelic; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class NlothsGiftPatch { | ||
|
||
/** | ||
* This is called only by edited expressions in the main game. See the following SpirePatch. | ||
* | ||
* @param playerRelics ArrayList of AbstractRelic. This exactly matches the return type | ||
* @return ArrayList of AbstractRelics. This exactly matches the parameter type | ||
*/ | ||
public static ArrayList<AbstractRelic> clonePlayerRelicsWithoutFragileMind(ArrayList<AbstractRelic> playerRelics) { | ||
ArrayList<AbstractRelic> relics = new ArrayList<>(playerRelics.size()); | ||
playerRelics.forEach(r -> { | ||
if (!FragileMindRelic.ID.equals(r.relicId)) { | ||
relics.add(r); | ||
} | ||
}); | ||
return relics; | ||
} | ||
|
||
public static class ClonePlayerRelicsWithoutFragileMind extends ExprEditor { | ||
@Override | ||
public void edit(FieldAccess fieldAccess) throws CannotCompileException { | ||
if (fieldAccess.getClassName().equals(AbstractPlayer.class.getName()) | ||
&& fieldAccess.getFieldName().equals("relics")) { | ||
fieldAccess.replace("{ $_ = (" + NlothsGiftPatch.class.getName() + ".clonePlayerRelicsWithoutFragileMind($proceed())); }"); | ||
} | ||
} | ||
} | ||
|
||
@SpirePatch(clz = AbstractDungeon.class, method = "getShrine") | ||
public static class AbstractDungeon_getShrine_NlothCheck { | ||
public static ExprEditor Instrument() { | ||
return new ClonePlayerRelicsWithoutFragileMind(); | ||
} | ||
} | ||
|
||
@SpirePatch(clz = Nloth.class, method = SpirePatch.CONSTRUCTOR) | ||
public static class Nloth_ctor_RemoveFragileMind { | ||
/** | ||
* Removes FragileMindRelic from the list of relics for N'loth to request. | ||
*/ | ||
public static ExprEditor Instrument() { | ||
return new ClonePlayerRelicsWithoutFragileMind(); | ||
} | ||
} | ||
} |