Skip to content

Commit

Permalink
OnLoseBlock hook for powers and relics
Browse files Browse the repository at this point in the history
  • Loading branch information
kiooeht committed Nov 29, 2018
1 parent 8755429 commit 83bfcd3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* Powers
* `HealthBarRenderPower`
* `OnLoseTempHpPower`
* `OnLoseBlockPower`
* Relics
* `OnLoseTempHpRelic`
* `OnLoseBlockRelic`

#### v1.8.1 ####
* Fix stun having incorrect intents the next turn
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.evacipated.cardcrawl.mod.stslib.patches.bothInterfaces;

import com.evacipated.cardcrawl.mod.stslib.powers.interfaces.OnLoseBlockPower;
import com.evacipated.cardcrawl.mod.stslib.relics.OnLoseBlockRelic;
import com.evacipated.cardcrawl.modthespire.lib.ByRef;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.evacipated.cardcrawl.modthespire.lib.SpireReturn;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.relics.AbstractRelic;

@SpirePatch(
clz=AbstractCreature.class,
method="decrementBlock"
)
public class OnLoseBlockPatch
{
public static SpireReturn<Integer> Prefix(AbstractCreature __instance, DamageInfo info, @ByRef int[] damageAmount)
{
for (AbstractPower power : __instance.powers) {
if (power instanceof OnLoseBlockPower) {
damageAmount[0] = ((OnLoseBlockPower) power).onLoseBlock(info, damageAmount[0]);
}
}
if (__instance.isPlayer) {
for (AbstractRelic relic : AbstractDungeon.player.relics) {
if (relic instanceof OnLoseBlockRelic) {
damageAmount[0] = ((OnLoseBlockRelic) relic).onLoseBlock(info, damageAmount[0]);
}
}
}

return SpireReturn.Continue();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.evacipated.cardcrawl.mod.stslib.patches.relicInterfaces;
package com.evacipated.cardcrawl.mod.stslib.patches.bothInterfaces;

import com.badlogic.gdx.Gdx;
import com.evacipated.cardcrawl.mod.stslib.powers.interfaces.OnReceivePowerPower;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.evacipated.cardcrawl.mod.stslib.powers.interfaces;

import com.megacrit.cardcrawl.cards.DamageInfo;

public interface OnLoseBlockPower
{
int onLoseBlock(DamageInfo info, int damageAmount);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.evacipated.cardcrawl.mod.stslib.relics;

import com.megacrit.cardcrawl.cards.DamageInfo;

public interface OnLoseBlockRelic
{
int onLoseBlock(DamageInfo info, int damageAmount);
}

0 comments on commit 83bfcd3

Please sign in to comment.