pokemon-io-core 0.0.86 → 0.0.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/engine/actions/forcedSwitch.d.ts +1 -1
  2. package/dist/engine/actions/forcedSwitch.js +1 -1
  3. package/dist/engine/actions/item.d.ts +2 -2
  4. package/dist/engine/actions/item.js +5 -5
  5. package/dist/engine/actions/move.d.ts +2 -2
  6. package/dist/engine/actions/move.js +8 -8
  7. package/dist/engine/actions/priority.d.ts +2 -2
  8. package/dist/engine/actions/priority.js +1 -1
  9. package/dist/engine/actions/switch.d.ts +2 -2
  10. package/dist/engine/actions/switch.js +1 -1
  11. package/dist/engine/combat/crit.d.ts +1 -1
  12. package/dist/engine/combat/damage.d.ts +2 -2
  13. package/dist/engine/combat/damage.js +4 -4
  14. package/dist/engine/combat/heal.d.ts +2 -2
  15. package/dist/engine/combat/heal.js +2 -2
  16. package/dist/engine/combat/typeEffectiveness.d.ts +2 -2
  17. package/dist/engine/combat/winner.d.ts +1 -1
  18. package/dist/engine/effects/applyEffects.d.ts +2 -2
  19. package/dist/engine/effects/applyEffects.js +6 -6
  20. package/dist/engine/effects/target.d.ts +1 -1
  21. package/dist/engine/events.d.ts +1 -1
  22. package/dist/engine/fighters/fighter.d.ts +2 -2
  23. package/dist/engine/fighters/fighter.js +1 -1
  24. package/dist/engine/fighters/selectors.d.ts +2 -2
  25. package/dist/engine/fighters/update.d.ts +2 -2
  26. package/dist/engine/rules.d.ts +1 -1
  27. package/dist/engine/runtime.d.ts +2 -2
  28. package/dist/engine/runtime.js +2 -2
  29. package/dist/engine/status/apply.d.ts +2 -2
  30. package/dist/engine/status/apply.js +3 -3
  31. package/dist/engine/status/clear.d.ts +2 -2
  32. package/dist/engine/status/clear.js +2 -2
  33. package/dist/engine/status/endOfTurn.d.ts +2 -2
  34. package/dist/engine/status/endOfTurn.js +4 -4
  35. package/dist/engine/status/hardCc.d.ts +2 -2
  36. package/dist/engine/turn/resolveTurn.d.ts +1 -1
  37. package/dist/engine/turn/resolveTurn.js +11 -11
  38. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { BattleEvent, BattleState } from "../../core";
1
+ import { BattleEvent, BattleState } from "../../core/index.js";
2
2
  export declare const applyForcedSwitchChoice: (state: BattleState, targetPlayer: "player1" | "player2", newIndex: number) => {
3
3
  state: BattleState;
4
4
  events: BattleEvent[];
@@ -1,4 +1,4 @@
1
- import { createBaseEvent } from "../events";
1
+ import { createBaseEvent } from "../events.js";
2
2
  export const applyForcedSwitchChoice = (state, targetPlayer, newIndex) => {
3
3
  const forced = state.forcedSwitch;
4
4
  if (!forced)
@@ -1,5 +1,5 @@
1
- import { BattleEvent, PlayerAction } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, PlayerAction } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const resolveItemUse: (state: RuntimeBattleState, playerKey: "player1" | "player2", action: PlayerAction) => {
4
4
  state: RuntimeBattleState;
5
5
  events: BattleEvent[];
@@ -1,8 +1,8 @@
1
- import { dbg } from "../debug";
2
- import { applyEffectsOnTarget } from "../effects/applyEffects";
3
- import { createBaseEvent } from "../events";
4
- import { getPlayersAndActives } from "../fighters/selectors";
5
- import { updateFightersInState } from "../fighters/update";
1
+ import { dbg } from "../debug.js";
2
+ import { applyEffectsOnTarget } from "../effects/applyEffects.js";
3
+ import { createBaseEvent } from "../events.js";
4
+ import { getPlayersAndActives } from "../fighters/selectors.js";
5
+ import { updateFightersInState } from "../fighters/update.js";
6
6
  export const resolveItemUse = (state, playerKey, action) => {
7
7
  if (action.kind !== "use_item") {
8
8
  return { state, events: [] };
@@ -1,5 +1,5 @@
1
- import { BattleEvent, PlayerAction } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, PlayerAction } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const resolveDamageMove: (state: RuntimeBattleState, playerKey: "player1" | "player2", action: PlayerAction) => {
4
4
  state: RuntimeBattleState;
5
5
  events: BattleEvent[];
@@ -1,11 +1,11 @@
1
- import { computeCritChance } from "../combat/crit";
2
- import { getTypeEffectiveness } from "../combat/typeEffectiveness";
3
- import { dbg } from "../debug";
4
- import { applyEffectsOnTarget } from "../effects/applyEffects";
5
- import { createBaseEvent } from "../events";
6
- import { getOpponentAndSelf } from "../fighters/selectors";
7
- import { updateFightersInState } from "../fighters/update";
8
- import { chance, randomInRange } from "../rng";
1
+ import { computeCritChance } from "../combat/crit.js";
2
+ import { getTypeEffectiveness } from "../combat/typeEffectiveness.js";
3
+ import { dbg } from "../debug.js";
4
+ import { applyEffectsOnTarget } from "../effects/applyEffects.js";
5
+ import { createBaseEvent } from "../events.js";
6
+ import { getOpponentAndSelf } from "../fighters/selectors.js";
7
+ import { updateFightersInState } from "../fighters/update.js";
8
+ import { chance, randomInRange } from "../rng.js";
9
9
  export const resolveDamageMove = (state, playerKey, action) => {
10
10
  if (action.kind !== "use_move") {
11
11
  return { state, events: [] };
@@ -1,5 +1,5 @@
1
- import { PlayerAction } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { PlayerAction } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const getMovePriorityAndSpeed: (state: RuntimeBattleState, playerKey: "player1" | "player2", action: PlayerAction) => {
4
4
  priority: number;
5
5
  speed: number;
@@ -1,4 +1,4 @@
1
- import { getOpponentAndSelf } from "../fighters/selectors";
1
+ import { getOpponentAndSelf } from "../fighters/selectors.js";
2
2
  export const getMovePriorityAndSpeed = (state, playerKey, action) => {
3
3
  const { self } = getOpponentAndSelf(state, playerKey);
4
4
  if (action.kind === "no_action") {
@@ -1,5 +1,5 @@
1
- import { BattleEvent, PlayerAction } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, PlayerAction } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const resolveSwitchFighter: (state: RuntimeBattleState, playerKey: "player1" | "player2", action: PlayerAction) => {
4
4
  state: RuntimeBattleState;
5
5
  events: BattleEvent[];
@@ -1,4 +1,4 @@
1
- import { createBaseEvent } from "../events";
1
+ import { createBaseEvent } from "../events.js";
2
2
  export const resolveSwitchFighter = (state, playerKey, action) => {
3
3
  if (action.kind !== "switch_fighter")
4
4
  return { state, events: [] };
@@ -1,2 +1,2 @@
1
- import { BattleRules } from "../rules";
1
+ import { BattleRules } from "../rules.js";
2
2
  export declare const computeCritChance: (rules: BattleRules, critStat: number) => number;
@@ -1,5 +1,5 @@
1
- import { BattleEvent, BattleFighter, FighterId, TypeId } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, BattleFighter, FighterId, TypeId } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  interface DamageComputationInput {
4
4
  state: RuntimeBattleState;
5
5
  attacker: BattleFighter;
@@ -1,7 +1,7 @@
1
- import { dbg } from "../debug";
2
- import { createBaseEvent } from "../events";
3
- import { randomInRange } from "../rng";
4
- import { getTypeEffectiveness } from "./typeEffectiveness";
1
+ import { dbg } from "../debug.js";
2
+ import { createBaseEvent } from "../events.js";
3
+ import { randomInRange } from "../rng.js";
4
+ import { getTypeEffectiveness } from "./typeEffectiveness.js";
5
5
  export const computeDamage = (input) => {
6
6
  dbg("🧨 computeDamage", { input });
7
7
  const { state, attacker, defender, moveTypeId, basePower, isCritical } = input;
@@ -1,5 +1,5 @@
1
- import { BattleEvent, BattleFighter, FighterId } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, BattleFighter, FighterId } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const applyHealToFighter: (state: RuntimeBattleState, target: BattleFighter, amount: number, sourceId: FighterId) => {
4
4
  updated: BattleFighter;
5
5
  events: BattleEvent[];
@@ -1,5 +1,5 @@
1
- import { dbg } from "../debug";
2
- import { createBaseEvent } from "../events";
1
+ import { dbg } from "../debug.js";
2
+ import { createBaseEvent } from "../events.js";
3
3
  export const applyHealToFighter = (state, target, amount, sourceId) => {
4
4
  const newHp = Math.min(target.maxHp, target.currentHp + amount);
5
5
  const healed = newHp - target.currentHp;
@@ -1,3 +1,3 @@
1
- import { TypeId } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { TypeId } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const getTypeEffectiveness: (state: RuntimeBattleState, attackerTypeId: TypeId, defenderTypeId: TypeId) => number;
@@ -1,2 +1,2 @@
1
- import { RuntimeBattleState } from "../rules";
1
+ import { RuntimeBattleState } from "../rules.js";
2
2
  export declare const checkWinner: (state: RuntimeBattleState) => "none" | "player1" | "player2" | "draw";
@@ -1,5 +1,5 @@
1
- import { BattleEvent, BattleFighter, EffectDefinition, TypeId } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, BattleFighter, EffectDefinition, TypeId } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const applyEffectsOnTarget: (state: RuntimeBattleState, actor: BattleFighter, target: BattleFighter, moveTypeId: TypeId | null, isCritical: boolean, effects: EffectDefinition[]) => {
4
4
  actor: BattleFighter;
5
5
  target: BattleFighter;
@@ -1,9 +1,9 @@
1
- import { applyDamageToFighter, computeDamage } from "../combat/damage";
2
- import { applyHealToFighter } from "../combat/heal";
3
- import { dbg } from "../debug";
4
- import { applyStatusToFighter } from "../status/apply";
5
- import { clearStatusFromFighter } from "../status/clear";
6
- import { resolveEffectTarget } from "./target";
1
+ import { applyDamageToFighter, computeDamage } from "../combat/damage.js";
2
+ import { applyHealToFighter } from "../combat/heal.js";
3
+ import { dbg } from "../debug.js";
4
+ import { applyStatusToFighter } from "../status/apply.js";
5
+ import { clearStatusFromFighter } from "../status/clear.js";
6
+ import { resolveEffectTarget } from "./target.js";
7
7
  export const applyEffectsOnTarget = (state, actor, target, moveTypeId, isCritical, effects) => {
8
8
  dbg("applyEffectsOnTarget", {
9
9
  actorId: actor.fighterId,
@@ -1,4 +1,4 @@
1
- import { BattleFighter, EffectDefinition, EffectKind, EffectTarget } from "../../core";
1
+ import { BattleFighter, EffectDefinition, EffectKind, EffectTarget } from "../../core/index.js";
2
2
  export declare const defaultTargetForKind: (kind: EffectKind) => EffectTarget;
3
3
  export declare const resolveEffectTarget: (eff: EffectDefinition, actor: BattleFighter, target: BattleFighter) => {
4
4
  primary: BattleFighter;
@@ -1,4 +1,4 @@
1
- import { BattleEvent } from "../core";
1
+ import { BattleEvent } from "../core/index.js";
2
2
  export declare const createBaseEvent: (turnNumber: number, kind: BattleEvent["kind"], message: string) => Omit<BattleEvent, "kind"> & {
3
3
  kind: typeof kind;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { BattleFighter } from "../../core";
2
- import { PlayerFighterBattleConfig, RuntimeBattleState } from "../rules";
1
+ import { BattleFighter } from "../../core/index.js";
2
+ import { PlayerFighterBattleConfig, RuntimeBattleState } from "../rules.js";
3
3
  export declare const createBattleFighter: (cfg: PlayerFighterBattleConfig) => BattleFighter;
4
4
  export declare const recomputeEffectiveStatsForFighter: (state: RuntimeBattleState, fighter: BattleFighter) => BattleFighter;
@@ -1,4 +1,4 @@
1
- import { cloneStats } from "../runtime";
1
+ import { cloneStats } from "../runtime.js";
2
2
  export const createBattleFighter = (cfg) => {
3
3
  if (cfg.moves.length !== 4) {
4
4
  throw new Error("Each fighter must have exactly 4 moves in MVP");
@@ -1,5 +1,5 @@
1
- import { BattleFighter, PlayerBattleState } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleFighter, PlayerBattleState } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const getActiveFighter: (player: PlayerBattleState) => BattleFighter;
4
4
  export declare const getOpponentAndSelf: (state: RuntimeBattleState, playerKey: "player1" | "player2") => {
5
5
  self: BattleFighter;
@@ -1,3 +1,3 @@
1
- import { BattleFighter } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleFighter } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const updateFightersInState: (state: RuntimeBattleState, actingPlayerKey: "player1" | "player2", updatedSelf: BattleFighter, updatedOpponent: BattleFighter) => RuntimeBattleState;
@@ -1,4 +1,4 @@
1
- import { AmuletDefinition, BattleState, FighterDefinition, ItemDefinition, ItemId, MoveDefinition, MoveId, StatusDefinition, StatusId, TypeDefinition, TypeEffectivenessMatrix, TypeId } from "../core";
1
+ import { AmuletDefinition, BattleState, FighterDefinition, ItemDefinition, ItemId, MoveDefinition, MoveId, StatusDefinition, StatusId, TypeDefinition, TypeEffectivenessMatrix, TypeId } from "../core/index.js";
2
2
  export interface BattleRules {
3
3
  baseCritChance: number;
4
4
  critPerStat: number;
@@ -1,5 +1,5 @@
1
- import { BattleState, FighterStats } from "../core";
2
- import { BattleConfig } from "./rules";
1
+ import { BattleState, FighterStats } from "../core/index.js";
2
+ import { BattleConfig } from "./rules.js";
3
3
  export declare const buildMap: <T extends {
4
4
  id: string;
5
5
  }>(list: T[]) => Record<string, T>;
@@ -1,5 +1,5 @@
1
- import { createBattleFighter } from "./fighters/fighter";
2
- import { DEFAULT_RULES, } from "./rules";
1
+ import { createBattleFighter } from "./fighters/fighter.js";
2
+ import { DEFAULT_RULES } from "./rules.js";
3
3
  export const buildMap = (list) => list.reduce((acc, item) => {
4
4
  acc[item.id] = item;
5
5
  return acc;
@@ -1,5 +1,5 @@
1
- import { BattleEvent, BattleFighter, StatusId } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, BattleFighter, StatusId } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const applyStatusToFighter: (state: RuntimeBattleState, target: BattleFighter, statusId: StatusId) => {
4
4
  updated: BattleFighter;
5
5
  events: BattleEvent[];
@@ -1,6 +1,6 @@
1
- import { dbg } from "../debug";
2
- import { createBaseEvent } from "../events";
3
- import { randomInRange } from "../rng";
1
+ import { dbg } from "../debug.js";
2
+ import { createBaseEvent } from "../events.js";
3
+ import { randomInRange } from "../rng.js";
4
4
  export const applyStatusToFighter = (state, target, statusId) => {
5
5
  const def = state.runtime.statusesById[statusId];
6
6
  dbg("APPLY_STATUS_FN", {
@@ -1,5 +1,5 @@
1
- import { BattleEvent, BattleFighter, ClearStatusEffect } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent, BattleFighter, ClearStatusEffect } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const clearStatusFromFighter: (state: RuntimeBattleState, target: BattleFighter, effect: ClearStatusEffect) => {
4
4
  updated: BattleFighter;
5
5
  events: BattleEvent[];
@@ -1,5 +1,5 @@
1
- import { dbg } from "../debug";
2
- import { createBaseEvent } from "../events";
1
+ import { dbg } from "../debug.js";
2
+ import { createBaseEvent } from "../events.js";
3
3
  export const clearStatusFromFighter = (state, target, effect) => {
4
4
  const { statusIds, kinds, clearAll } = effect;
5
5
  const events = [];
@@ -1,5 +1,5 @@
1
- import { BattleEvent } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleEvent } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const applyEndOfTurnStatuses: (state: RuntimeBattleState) => {
4
4
  state: RuntimeBattleState;
5
5
  events: BattleEvent[];
@@ -1,7 +1,7 @@
1
- import { applyDamageToFighter } from "../combat/damage";
2
- import { dbg } from "../debug";
3
- import { createBaseEvent } from "../events";
4
- import { getActiveFighter } from "../fighters/selectors";
1
+ import { applyDamageToFighter } from "../combat/damage.js";
2
+ import { dbg } from "../debug.js";
3
+ import { createBaseEvent } from "../events.js";
4
+ import { getActiveFighter } from "../fighters/selectors.js";
5
5
  export const applyEndOfTurnStatuses = (state) => {
6
6
  const events = [];
7
7
  const applyForPlayer = (player) => {
@@ -1,3 +1,3 @@
1
- import { BattleFighter } from "../../core";
2
- import { RuntimeBattleState } from "../rules";
1
+ import { BattleFighter } from "../../core/index.js";
2
+ import { RuntimeBattleState } from "../rules.js";
3
3
  export declare const hasHardCc: (state: RuntimeBattleState, fighter: BattleFighter) => boolean;
@@ -1,4 +1,4 @@
1
- import { BattleActions, BattleEvent, BattleState } from "../../core";
1
+ import { BattleActions, BattleEvent, BattleState } from "../../core/index.js";
2
2
  export declare const resolveTurn: (state: BattleState, actions: BattleActions) => {
3
3
  newState: BattleState;
4
4
  events: BattleEvent[];
@@ -1,16 +1,16 @@
1
1
  // ------------------------------------------------------
2
2
  // Bucle principal de turno
3
- import { resolveItemUse } from "../actions/item";
4
- import { resolveDamageMove } from "../actions/move";
5
- import { getMovePriorityAndSpeed } from "../actions/priority";
6
- import { resolveSwitchFighter } from "../actions/switch";
7
- import { checkWinner } from "../combat/winner";
8
- import { dbg } from "../debug";
9
- import { createBaseEvent } from "../events";
10
- import { recomputeEffectiveStatsForFighter } from "../fighters/fighter";
11
- import { getOpponentAndSelf } from "../fighters/selectors";
12
- import { applyEndOfTurnStatuses } from "../status/endOfTurn";
13
- import { hasHardCc } from "../status/hardCc";
3
+ import { resolveItemUse } from "../actions/item.js";
4
+ import { resolveDamageMove } from "../actions/move.js";
5
+ import { getMovePriorityAndSpeed } from "../actions/priority.js";
6
+ import { resolveSwitchFighter } from "../actions/switch.js";
7
+ import { checkWinner } from "../combat/winner.js";
8
+ import { dbg } from "../debug.js";
9
+ import { createBaseEvent } from "../events.js";
10
+ import { recomputeEffectiveStatsForFighter } from "../fighters/fighter.js";
11
+ import { getOpponentAndSelf } from "../fighters/selectors.js";
12
+ import { applyEndOfTurnStatuses } from "../status/endOfTurn.js";
13
+ import { hasHardCc } from "../status/hardCc.js";
14
14
  // ------------------------------------------------------
15
15
  export const resolveTurn = (state, actions) => {
16
16
  const runtimeState = state;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pokemon-io-core",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",