Skip to content

Commit

Permalink
Fix up assorted memory bugs noted in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbjorge committed Oct 13, 2019
1 parent c9ed6b4 commit 04e185f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void update() {

masterCard.baseDamage += damageIncrease;
masterCard.superFlash();
masterCard.applyPowers();

for (AbstractCard instance : GetAllInBattleInstances.get(cardUuid)) {
instance.baseDamage += damageIncrease;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ private int calculateStrengthToAdd() {
@Override
public void onInitialApplication() {
this.strengthAdded = calculateStrengthToAdd();
AbstractDungeon.actionManager.addToBottom(
new ApplyPowerAction(owner, source, new StrengthPower(owner, this.strengthAdded), this.strengthAdded));
if (this.strengthAdded > 0) {
AbstractDungeon.actionManager.addToBottom(
new ApplyPowerAction(owner, source, new StrengthPower(owner, this.strengthAdded), this.strengthAdded));
}
}

@Override
public void onRemove() {
if (!isClarified) {
if (isClarified || this.strengthAdded <= 0) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ public GluttonyMemoryPower(final AbstractCreature owner, final AbstractCreature
updateDescription();
}

@Override
public void onAttack(DamageInfo damageInfo, int damage, AbstractCreature target) {
this.onInflictDamage(damageInfo, damage, target);
}

@Override
public void onInflictDamage(DamageInfo damageInfo, int damage, AbstractCreature target) {
if (target.isPlayer || target.isDead || target.isDying || target.halfDead || target.hasPower(MinionPower.POWER_ID)) {
return;
}

if (damage > target.currentHealth) {
if (damage >= target.currentHealth) {
JorbsMod.logger.info("Gluttony: gaining max hp");
AbstractDungeon.player.increaseMaxHp(MAX_HP_PER_KILL, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.MinionPower;
import stsjorbsmod.JorbsMod;
import stsjorbsmod.actions.PermanentlyUpgradeRandomCardAction;
import stsjorbsmod.util.TextureLoader;

import static stsjorbsmod.JorbsMod.makePowerPath;
Expand All @@ -37,13 +36,18 @@ public GreedMemoryPower(final AbstractCreature owner, final AbstractCreature sou
updateDescription();
}

@Override
public void onAttack(DamageInfo damageInfo, int damage, AbstractCreature target) {
this.onInflictDamage(damageInfo, damage, target);
}

@Override
public void onInflictDamage(DamageInfo damageInfo, int damage, AbstractCreature target) {
if (target.isPlayer || target.isDead || target.isDying || target.halfDead || target.hasPower(MinionPower.POWER_ID)) {
return;
}

if (damage > target.currentHealth) {
if (damage >= target.currentHealth) {
JorbsMod.logger.info("Greed: gaining gold");
AbstractDungeon.player.gainGold(GOLD_PER_KILL);
}
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/stsjorbsmod/powers/memories/PrideMemoryPower.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import basemod.interfaces.CloneablePowerInterface;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.UpgradeRandomCardAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.CardGroup;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.WeakPower;
import stsjorbsmod.JorbsMod;
import stsjorbsmod.actions.PermanentlyUpgradeRandomCardAction;
import stsjorbsmod.util.TextureLoader;

import static stsjorbsmod.JorbsMod.makePowerPath;
Expand All @@ -39,7 +36,18 @@ public PrideMemoryPower(final AbstractCreature owner, final AbstractCreature sou

@Override
public void onVictory() {
AbstractDungeon.actionManager.addToBottom(new PermanentlyUpgradeRandomCardAction());
CardGroup masterDeckCandidates = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED);
for (AbstractCard c : AbstractDungeon.player.masterDeck.group) {
if (c.canUpgrade()) {
masterDeckCandidates.addToBottom(c);
}
}

if (!masterDeckCandidates.isEmpty()) {
AbstractCard masterDeckCard = masterDeckCandidates.getRandomCard(AbstractDungeon.cardRandomRng);
masterDeckCard.upgrade();
masterDeckCard.superFlash();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ public WrathMemoryPower(final AbstractCreature owner, final AbstractCreature sou

@Override
public void onPlayCard(AbstractCard card, AbstractMonster target) {
if (target.hasPower(MinionPower.POWER_ID)) {
if (card.type != AbstractCard.CardType.ATTACK || target.hasPower(MinionPower.POWER_ID)) {
return;
}

if (target.isDead || target.isDying || target.halfDead) {
card.calculateCardDamage(target);
if (card.damage >= target.currentHealth) {
JorbsMod.logger.info("Wrath: increasing damage");
AbstractDungeon.actionManager.addToTop(
new PermanentlyIncreaseCardDamageAction(card.uuid, DAMAGE_INCREASE_PER_KILL));
Expand Down

0 comments on commit 04e185f

Please sign in to comment.