Skip to content

Commit

Permalink
Fixing up
Browse files Browse the repository at this point in the history
  • Loading branch information
kiooeht committed Oct 28, 2018
1 parent 146eb38 commit 41516c6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog ##
#### dev ####
* Enable Exhaustive and Refund variables (The_Evil_Pickle)
* Make Exhaustive and Refund automatic (The_Evil_Pickle)

#### v1.4.0
* Keywords
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/evacipated/cardcrawl/mod/stslib/StSLib.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.evacipated.cardcrawl.mod.stslib;

import basemod.BaseMod;
import basemod.interfaces.*;

import basemod.interfaces.EditCardsSubscriber;
import basemod.interfaces.EditKeywordsSubscriber;
import basemod.interfaces.EditStringsSubscriber;
import basemod.interfaces.PostInitializeSubscriber;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.evacipated.cardcrawl.mod.stslib.variables.ExhaustiveVariable;
Expand All @@ -15,11 +17,8 @@
import com.megacrit.cardcrawl.localization.Keyword;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.localization.RelicStrings;
import com.megacrit.cardcrawl.rooms.AbstractRoom;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

@SpireInitializer
public class StSLib implements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public RefundAction(AbstractCard targetCard, int energyCap)
{
this(targetCard, energyCap, targetCard.energyOnUse);
}

public RefundAction(AbstractCard targetCard, int energyCap, int energyOnUse)
{
this.targetCard = targetCard;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
clz=AbstractCard.class,
method=SpirePatch.CLASS
)
public class RefundFields {
public class RefundFields
{
public static SpireField<Integer> refund = new SpireField<>(() -> 0);
public static SpireField<Integer> baseRefund = new SpireField<>(() -> 0);
public static SpireField<Boolean> isRefundUpgraded = new SpireField<>(() -> false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@
import com.evacipated.cardcrawl.mod.stslib.variables.ExhaustiveVariable;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.red.Corruption;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

@SpirePatch(
cls="com.megacrit.cardcrawl.characters.AbstractPlayer",
clz=AbstractPlayer.class,
method="useCard"
)
public class RefundExhaustivePatch {
public static void Prefix(final AbstractPlayer p, final AbstractCard c, final AbstractMonster monster, final int energyOnUse) {
if (ExhaustiveField.ExhaustiveFields.exhaustive.get(c) > -1) {
ExhaustiveVariable.increment(c);
}
}
public static void Postfix(final AbstractPlayer p, final AbstractCard c, final AbstractMonster monster, final int energyOnUse) {
if (RefundFields.refund.get(c) > 0) {
if (!c.freeToPlayOnce && ((c.costForTurn == -1 && energyOnUse > 0) || c.costForTurn > 0 && (!p.hasPower("Corruption") || c.type != AbstractCard.CardType.SKILL))) {
AbstractDungeon.actionManager.addToBottom(new RefundAction(c, RefundFields.refund.get(c), energyOnUse));
}
}
}
public class RefundExhaustivePatch
{
public static void Prefix(AbstractPlayer p, AbstractCard c, AbstractMonster monster, int energyOnUse)
{
if (ExhaustiveField.ExhaustiveFields.exhaustive.get(c) > -1) {
ExhaustiveVariable.increment(c);
}
}

public static void Postfix(AbstractPlayer p, AbstractCard c, AbstractMonster monster, int energyOnUse)
{
if (RefundFields.refund.get(c) > 0) {
if (!c.freeToPlayOnce
&& ((c.costForTurn == -1 && energyOnUse > 0) || c.costForTurn > 0
&& (!p.hasPower(Corruption.ID)
|| c.type != AbstractCard.CardType.SKILL))) {
AbstractDungeon.actionManager.addToBottom(new RefundAction(c, RefundFields.refund.get(c), energyOnUse));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.evacipated.cardcrawl.mod.stslib.variables;

import com.evacipated.cardcrawl.mod.stslib.fields.cards.AbstractCard.ExhaustiveField;
import basemod.abstracts.DynamicVariable;
import com.evacipated.cardcrawl.mod.stslib.fields.cards.AbstractCard.RefundFields;
import com.evacipated.cardcrawl.mod.stslib.powers.ExhaustiveNegationPower;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;

import basemod.abstracts.DynamicVariable;

public class RefundVariable extends DynamicVariable
{
Expand Down Expand Up @@ -42,14 +38,14 @@ public boolean upgraded(AbstractCard card)

public static void setBaseValue(AbstractCard card, int amount)
{
RefundFields.baseRefund.set(card, amount);
RefundFields.baseRefund.set(card, amount);
RefundFields.refund.set(card, amount);
card.initializeDescription();
}

public static void upgrade(AbstractCard card, int amount)
{
RefundFields.isRefundUpgraded.set(card, true);
RefundFields.isRefundUpgraded.set(card, true);
setBaseValue(card, RefundFields.baseRefund.get(card) + amount);
}
}

0 comments on commit 41516c6

Please sign in to comment.