Skip to content

Commit

Permalink
fix(dungeon): can no longer heal by entering a dungeon
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Mar 30, 2023
1 parent 02feb89 commit 6ad963b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/stores/combat/combat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,22 @@ export class CombatState {
@Action(EnterDungeon)
enterDungeon(ctx: StateContext<IGameCombat>, { dungeon }: EnterDungeon) {
const store = this.store.snapshot();
const state = ctx.getState();

// we need the active player to exist. it always will. probably?
const activePlayer = store.charselect.characters[store.charselect.currentCharacter];
if(!activePlayer) {
return;
}

const currentCharacter = state.currentPlayer;
const dungeonCharacter = getPlayerCharacterReadyForCombat(store, ctx, activePlayer);

if(currentCharacter) {
dungeonCharacter.currentHealth = Math.min(currentCharacter.currentHealth, dungeonCharacter.maxHealth);
dungeonCharacter.currentEnergy = Math.min(currentCharacter.currentEnergy, dungeonCharacter.maxEnergy);
}

const startPos = findUniqueTileInDungeonFloor(dungeon, 0, DungeonTile.Entrance);
if(!startPos) {
return;
Expand All @@ -599,6 +606,8 @@ export class CombatState {

ctx.setState(patch<IGameCombat>({
currentPlayer: dungeonCharacter,
oocEnergyTicks: 0,
oocHealTicks: 0,
currentDungeon: {
currentLoot: {
items: [],
Expand Down

0 comments on commit 6ad963b

Please sign in to comment.