Skip to content

Commit

Permalink
Fix stun having incorrect intents the next turn
Browse files Browse the repository at this point in the history
The turn after a stun, intents would no longer react to things like Strength on the next turn
  • Loading branch information
kiooeht committed Nov 26, 2018
1 parent ac5b55a commit 70047a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog ##
#### dev ####
* Fix stun having incorrect intents the next turn

#### v1.8.0 ####
* Relics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.monsters.EnemyMoveInfo;
import com.megacrit.cardcrawl.powers.AbstractPower;

import java.lang.reflect.Field;

public class StunMonsterPower extends AbstractPower
{
public static final String POWER_ID = "stslib:Stunned";
Expand All @@ -17,6 +20,7 @@ public class StunMonsterPower extends AbstractPower

private byte moveByte;
private AbstractMonster.Intent moveIntent;
private EnemyMoveInfo move;

public StunMonsterPower(AbstractMonster owner)
{
Expand All @@ -35,6 +39,13 @@ public StunMonsterPower(AbstractMonster owner, int amount)

moveByte = owner.nextMove;
moveIntent = owner.intent;
try {
Field f = AbstractMonster.class.getDeclaredField("move");
f.setAccessible(true);
move = (EnemyMoveInfo) f.get(owner);
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}

@Override
Expand All @@ -55,8 +66,13 @@ public void atEndOfRound()
if (amount <= 0) {
if (owner instanceof AbstractMonster) {
AbstractMonster m = (AbstractMonster)owner;
m.setMove(moveByte, moveIntent);
if (move != null) {
m.setMove(moveByte, moveIntent, move.baseDamage, move.multiplier, move.isMultiDamage);
} else {
m.setMove(moveByte, moveIntent);
}
m.createIntent();
m.applyPowers();
}
AbstractDungeon.actionManager.addToBottom(new RemoveSpecificPowerAction(owner, owner, ID));
}
Expand Down

0 comments on commit 70047a3

Please sign in to comment.