pokemon-io-core 0.0.55 → 0.0.57

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.
@@ -155,6 +155,7 @@ const computeCritChance = (rules, critStat) => {
155
155
  return Math.max(0, Math.min(1, raw));
156
156
  };
157
157
  const computeDamage = (input) => {
158
+ dbg("🧨 computeDamage", { input });
158
159
  const { state, attacker, defender, moveTypeId, basePower, isCritical } = input;
159
160
  const rules = state.runtime.rules;
160
161
  const attackerOff = attacker.effectiveStats.offense;
@@ -175,7 +176,18 @@ const computeDamage = (input) => {
175
176
  stabMultiplier *
176
177
  critMultiplier *
177
178
  randomFactor;
179
+ dbg("🧨 computeDamage", `
180
+ basePower(${basePower}) *
181
+ (attackerOff(${attackerOff}) / Math.max(1, defenderDef(${defenderDef}))) = ${attackerOff / Math.max(1, defenderDef)}*
182
+ typeEffectiveness(${typeEffectiveness}) *
183
+ stabMultiplier(${stabMultiplier}) *
184
+ critMultiplier(${critMultiplier}) *
185
+ randomFactor(${randomFactor}) = ${rawDamage}
186
+ `);
178
187
  const finalDamage = Math.max(1, Math.floor(rawDamage));
188
+ dbg("🧨 computeDamage", `
189
+ finalDamage(${finalDamage}) = Math.max(1, Math.floor(rawDamage))
190
+ `);
179
191
  return {
180
192
  damage: finalDamage,
181
193
  effectiveness: typeEffectiveness,
@@ -1,5 +1,5 @@
1
- import { POKEMON_FIGHTERS, POKEMON_MOVES, POKEMON_TYPE_MATRIX, POKEMON_TYPES } from "../skins/pokemon";
2
- import { createInitialBattleState, resolveTurn } from "../core/engine";
1
+ import { POKEMON_FIGHTERS, POKEMON_MOVES, POKEMON_TYPE_MATRIX, POKEMON_TYPES, } from "../skins/pokemon";
2
+ import { createInitialBattleState, resolveTurn, } from "../core/engine";
3
3
  const findPokemon = (id) => POKEMON_FIGHTERS.find((p) => p.id === id);
4
4
  const findMove = (id) => POKEMON_MOVES.find((m) => m.id === id);
5
5
  export const createPokemonBattle = (fighter1Id, fighter2Id) => {
@@ -14,18 +14,18 @@ export const createPokemonBattle = (fighter1Id, fighter2Id) => {
14
14
  statuses: [],
15
15
  player1: {
16
16
  fighter: f1,
17
- maxHp: 100,
17
+ maxHp: f1.baseStats.defense + f1.baseStats.offense,
18
18
  moves: POKEMON_MOVES.filter((m) => (f1.recommendedMoves ?? []).includes(m.id)),
19
19
  items: [],
20
- amulet: null
20
+ amulet: null,
21
21
  },
22
22
  player2: {
23
23
  fighter: f2,
24
- maxHp: 100,
24
+ maxHp: f2.baseStats.defense + f1.baseStats.offense,
25
25
  moves: POKEMON_MOVES.filter((m) => (f2.recommendedMoves ?? []).includes(m.id)),
26
26
  items: [],
27
- amulet: null
28
- }
27
+ amulet: null,
28
+ },
29
29
  };
30
30
  return createInitialBattleState(config);
31
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pokemon-io-core",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",