Spot the bug - #164: Turn Combat Engine

This dungeon turn processor is skipping the wrong monster state.

function resolveTurn(entity, action, environment) {
  let actionLog = [];
  let statusEffect = entity.status ?? "normal";

  try {
    if (environment.hazard === "miasma" && !entity.immune) {
      throw new Error("suffocating");
    }

    switch (action.type) {
      case "attack":
        actionLog.push(`${entity.name} attacks for ${action.power} dmg`);
        break;
      case "cast":
        if (entity.mana < action.cost) {
          throw new Error("out of mana");
        }
        entity.mana -= action.cost;
        actionLog.push(`${entity.name} casts ${action.spell}`);
        break;
      case "defend":
        entity.guard = true;
        actionLog.push(`${entity.name} braces for impact`);
        break;
      default:
        throw new Error("invalid action");
    }
  } catch (err) {
    actionLog.push(`${entity.name} stumbled: ${err.message}`);
    return { success: false, log: actionLog, finalStatus: statusEffect };
  } finally {
    if (statusEffect === "poisoned") {
      entity.hp = Math.max(0, entity.hp - 5);
      actionLog.push(`${entity.name} takes poison damage`);
    }
    return { success: true, log: actionLog, finalStatus: statusEffect };
  }
}

Reply with what is broken and how you would fix it.