Skip to content

Commit e323890

Browse files
wang429dbjorge
authored andcommitted
Fragile mind nloths gift (#206)
* 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
1 parent ff1b820 commit e323890

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package stsjorbsmod.patches;
2+
3+
import com.evacipated.cardcrawl.modthespire.lib.*;
4+
import com.megacrit.cardcrawl.characters.AbstractPlayer;
5+
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
6+
import com.megacrit.cardcrawl.events.AbstractEvent;
7+
import com.megacrit.cardcrawl.events.shrines.Nloth;
8+
import com.megacrit.cardcrawl.random.Random;
9+
import com.megacrit.cardcrawl.relics.AbstractRelic;
10+
import javassist.CannotCompileException;
11+
import javassist.CtBehavior;
12+
import javassist.expr.ExprEditor;
13+
import javassist.expr.FieldAccess;
14+
import javassist.expr.MethodCall;
15+
import stsjorbsmod.JorbsMod;
16+
import stsjorbsmod.relics.FragileMindRelic;
17+
18+
import java.util.ArrayList;
19+
20+
public class NlothsGiftPatch {
21+
22+
/**
23+
* This is called only by edited expressions in the main game. See the following SpirePatch.
24+
*
25+
* @param playerRelics ArrayList of AbstractRelic. This exactly matches the return type
26+
* @return ArrayList of AbstractRelics. This exactly matches the parameter type
27+
*/
28+
public static ArrayList<AbstractRelic> clonePlayerRelicsWithoutFragileMind(ArrayList<AbstractRelic> playerRelics) {
29+
ArrayList<AbstractRelic> relics = new ArrayList<>(playerRelics.size());
30+
playerRelics.forEach(r -> {
31+
if (!FragileMindRelic.ID.equals(r.relicId)) {
32+
relics.add(r);
33+
}
34+
});
35+
return relics;
36+
}
37+
38+
public static class ClonePlayerRelicsWithoutFragileMind extends ExprEditor {
39+
@Override
40+
public void edit(FieldAccess fieldAccess) throws CannotCompileException {
41+
if (fieldAccess.getClassName().equals(AbstractPlayer.class.getName())
42+
&& fieldAccess.getFieldName().equals("relics")) {
43+
fieldAccess.replace("{ $_ = (" + NlothsGiftPatch.class.getName() + ".clonePlayerRelicsWithoutFragileMind($proceed())); }");
44+
}
45+
}
46+
}
47+
48+
@SpirePatch(clz = AbstractDungeon.class, method = "getShrine")
49+
public static class AbstractDungeon_getShrine_NlothCheck {
50+
public static ExprEditor Instrument() {
51+
return new ClonePlayerRelicsWithoutFragileMind();
52+
}
53+
}
54+
55+
@SpirePatch(clz = Nloth.class, method = SpirePatch.CONSTRUCTOR)
56+
public static class Nloth_ctor_RemoveFragileMind {
57+
/**
58+
* Removes FragileMindRelic from the list of relics for N'loth to request.
59+
*/
60+
public static ExprEditor Instrument() {
61+
return new ClonePlayerRelicsWithoutFragileMind();
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)