pokemon-io-core 0.0.108 → 0.0.109

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.
@@ -26,6 +26,14 @@ export interface StatsChangedEvent extends BaseBattleEvent {
26
26
  export interface ActionDeclaredEvent extends BaseBattleEvent {
27
27
  kind: "action_declared";
28
28
  actorId: FighterId;
29
+ /**
30
+ * Optional custom list of narration lines.
31
+ * If present, the frontend should play these lines instead of the default message.
32
+ */
33
+ narration?: string[];
34
+ moveId?: MoveId;
35
+ itemId?: ItemId;
36
+ targetId?: FighterId;
29
37
  }
30
38
  export interface ActionSkippedHardCcEvent extends BaseBattleEvent {
31
39
  kind: "action_skipped_hard_cc";
@@ -4,9 +4,9 @@ export type ItemCategory = "damage" | "heal_shield" | "status_buff";
4
4
  export interface ItemDefinition {
5
5
  id: ItemId;
6
6
  name: string;
7
- category: ItemCategory;
8
7
  target: TargetKind;
9
8
  maxUses: number;
10
9
  image: string;
11
10
  effects: EffectDefinition[];
11
+ narration?: string[];
12
12
  }
@@ -82,5 +82,6 @@ export interface MoveDefinition {
82
82
  };
83
83
  bypassInvulnerability?: string[];
84
84
  effects: EffectDefinition[];
85
+ narration?: string[];
85
86
  }
86
87
  export {};
@@ -3,6 +3,7 @@ import { applyEffectsOnTarget } from "../effects/applyEffects.js";
3
3
  import { createBaseEvent } from "../events.js";
4
4
  import { getPlayersAndActives } from "../fighters/selectors.js";
5
5
  import { updateFightersInState } from "../fighters/update.js";
6
+ import { processNarration } from "./move.js";
6
7
  export const resolveItemUse = (state, playerKey, action) => {
7
8
  if (action.kind !== "use_item") {
8
9
  return { state, events: [] };
@@ -30,10 +31,17 @@ export const resolveItemUse = (state, playerKey, action) => {
30
31
  : it);
31
32
  let updatedSelf = { ...self };
32
33
  let updatedOpponent = { ...opponent };
33
- events.push({
34
+ const actionDeclaredEv = {
34
35
  ...createBaseEvent(state.turnNumber, "action_declared", `${self.fighterId} usó ${itemDef.name}`),
35
36
  actorId: self.fighterId,
36
- });
37
+ itemId: itemDef.id,
38
+ targetId: opponent.fighterId, // Items typically target self or enemy, need to be careful with context
39
+ };
40
+ if (itemDef.narration && itemDef.narration.length > 0) {
41
+ actionDeclaredEv.narration = processNarration(itemDef.narration, self.fighterId, opponent.fighterId // or target? itemDef.target tells us who it targets.
42
+ );
43
+ }
44
+ events.push(actionDeclaredEv);
37
45
  const { actor: finalSelf, target: finalOpp, events: extraEvents, } = applyEffectsOnTarget(state, updatedSelf, updatedOpponent, null, // los items no usan fórmula de tipo por ahora
38
46
  false, itemDef.effects);
39
47
  events.push(...extraEvents);
@@ -1,5 +1,6 @@
1
1
  import { BattleEvent, PlayerAction } from "../../core/index.js";
2
2
  import { RuntimeBattleState } from "../rules.js";
3
+ export declare const processNarration: (lines: string[], actorId: string, targetId: string) => string[];
3
4
  export declare const resolveDamageMove: (state: RuntimeBattleState, playerKey: "player1" | "player2", action: PlayerAction) => {
4
5
  state: RuntimeBattleState;
5
6
  events: BattleEvent[];
@@ -7,6 +7,10 @@ import { createBaseEvent } from "../events.js";
7
7
  import { getOpponentAndSelf } from "../fighters/selectors.js";
8
8
  import { updateFightersInState } from "../fighters/update.js";
9
9
  import { chance, randomInRange } from "../rng.js";
10
+ // Helper for custom narration processing
11
+ export const processNarration = (lines, actorId, targetId) => {
12
+ return lines.map((line) => line.replace(/\{actor\}/g, actorId).replace(/\{victim\}/g, targetId));
13
+ };
10
14
  export const resolveDamageMove = (state, playerKey, action) => {
11
15
  if (action.kind !== "use_move") {
12
16
  return { state, events: [] };
@@ -35,10 +39,17 @@ export const resolveDamageMove = (state, playerKey, action) => {
35
39
  });
36
40
  return { state, events };
37
41
  }
38
- events.push({
42
+ const actionDeclaredEv = {
39
43
  ...createBaseEvent(state.turnNumber, "action_declared", `${self.fighterId} usó ${move.name}`),
40
44
  actorId: self.fighterId,
41
- });
45
+ moveId: move.id,
46
+ targetId: opponent.fighterId, // Default target
47
+ }; // Cast generic to allow optional fields safely if interface strictness varies
48
+ // Custom Narration Logic
49
+ if (move.narration && move.narration.length > 0) {
50
+ actionDeclaredEv.narration = processNarration(move.narration, self.fighterId, opponent.fighterId);
51
+ }
52
+ events.push(actionDeclaredEv);
42
53
  // Prepare mutable copies for updates through the function
43
54
  let updatedSelf = { ...self };
44
55
  let updatedOpponent = { ...opponent };
@@ -2,7 +2,6 @@ export const POKEMON_ITEMS = [
2
2
  {
3
3
  id: "super_potion",
4
4
  name: "Super Poción",
5
- category: "heal_shield",
6
5
  target: "self",
7
6
  maxUses: 1,
8
7
  effects: [{ kind: "heal", amount: 50 }],
@@ -11,7 +10,6 @@ export const POKEMON_ITEMS = [
11
10
  {
12
11
  id: "potion",
13
12
  name: "Poción",
14
- category: "heal_shield",
15
13
  target: "self",
16
14
  maxUses: 2,
17
15
  effects: [{ kind: "heal", amount: 25 }],
@@ -20,7 +18,6 @@ export const POKEMON_ITEMS = [
20
18
  {
21
19
  id: "apple",
22
20
  name: "Manzana",
23
- category: "heal_shield",
24
21
  target: "self",
25
22
  maxUses: 3,
26
23
  effects: [{ kind: "heal", amount: 17 }],
@@ -29,7 +26,6 @@ export const POKEMON_ITEMS = [
29
26
  {
30
27
  id: "mushroom",
31
28
  name: "Seta",
32
- category: "heal_shield",
33
29
  target: "self",
34
30
  maxUses: 4,
35
31
  effects: [{ kind: "heal", amount: 14 }],
@@ -39,7 +35,6 @@ export const POKEMON_ITEMS = [
39
35
  id: "shotgun",
40
36
  name: "Escopeta",
41
37
  target: "enemy",
42
- category: "damage",
43
38
  maxUses: 2,
44
39
  effects: [
45
40
  { kind: "damage", flatAmount: 15 },
@@ -50,7 +45,6 @@ export const POKEMON_ITEMS = [
50
45
  {
51
46
  id: "pistol",
52
47
  name: "Pistola",
53
- category: "damage",
54
48
  target: "enemy",
55
49
  maxUses: 4,
56
50
  effects: [
@@ -63,7 +57,6 @@ export const POKEMON_ITEMS = [
63
57
  id: "riffle",
64
58
  name: "Rifle",
65
59
  target: "enemy",
66
- category: "damage",
67
60
  maxUses: 3,
68
61
  effects: [
69
62
  { kind: "damage", flatAmount: 10 },
@@ -75,7 +68,6 @@ export const POKEMON_ITEMS = [
75
68
  id: "sniper",
76
69
  name: "Sniper",
77
70
  target: "enemy",
78
- category: "damage",
79
71
  maxUses: 1,
80
72
  effects: [
81
73
  { kind: "damage", flatAmount: 30 },
@@ -86,7 +78,6 @@ export const POKEMON_ITEMS = [
86
78
  {
87
79
  id: "blue-berry",
88
80
  name: "Baya azul",
89
- category: "status_buff",
90
81
  maxUses: 1,
91
82
  target: "self",
92
83
  effects: [
@@ -100,7 +91,6 @@ export const POKEMON_ITEMS = [
100
91
  {
101
92
  id: "pink-berry",
102
93
  name: "Baya rosa",
103
- category: "status_buff",
104
94
  maxUses: 1,
105
95
  target: "self",
106
96
  effects: [
@@ -114,7 +104,6 @@ export const POKEMON_ITEMS = [
114
104
  {
115
105
  id: "yellow-berry",
116
106
  name: "Baya amarilla",
117
- category: "status_buff",
118
107
  maxUses: 1,
119
108
  target: "self",
120
109
  effects: [
@@ -128,7 +117,6 @@ export const POKEMON_ITEMS = [
128
117
  {
129
118
  id: "green-berry",
130
119
  name: "Baya verde",
131
- category: "status_buff",
132
120
  maxUses: 1,
133
121
  target: "self",
134
122
  effects: [
@@ -2,7 +2,6 @@ export const POKEMON_ITEMS = [
2
2
  {
3
3
  id: "super_potion",
4
4
  name: "Super Poción",
5
- category: "heal_shield",
6
5
  target: "self",
7
6
  maxUses: 1,
8
7
  effects: [{ kind: "heal", amount: 50 }],
@@ -11,7 +10,6 @@ export const POKEMON_ITEMS = [
11
10
  {
12
11
  id: "potion",
13
12
  name: "Poción",
14
- category: "heal_shield",
15
13
  target: "self",
16
14
  maxUses: 2,
17
15
  effects: [{ kind: "heal", amount: 25 }],
@@ -20,7 +18,6 @@ export const POKEMON_ITEMS = [
20
18
  {
21
19
  id: "apple",
22
20
  name: "Manzana",
23
- category: "heal_shield",
24
21
  target: "self",
25
22
  maxUses: 3,
26
23
  effects: [{ kind: "heal", amount: 17 }],
@@ -29,7 +26,6 @@ export const POKEMON_ITEMS = [
29
26
  {
30
27
  id: "mushroom",
31
28
  name: "Seta",
32
- category: "heal_shield",
33
29
  target: "self",
34
30
  maxUses: 4,
35
31
  effects: [{ kind: "heal", amount: 14 }],
@@ -39,7 +35,6 @@ export const POKEMON_ITEMS = [
39
35
  id: "shotgun",
40
36
  name: "Escopeta",
41
37
  target: "enemy",
42
- category: "damage",
43
38
  maxUses: 2,
44
39
  effects: [
45
40
  { kind: "damage", flatAmount: 15 },
@@ -49,7 +44,6 @@ export const POKEMON_ITEMS = [
49
44
  {
50
45
  id: "pistol",
51
46
  name: "Pistola",
52
- category: "damage",
53
47
  target: "enemy",
54
48
  maxUses: 4,
55
49
  effects: [
@@ -61,7 +55,6 @@ export const POKEMON_ITEMS = [
61
55
  id: "riffle",
62
56
  name: "Rifle",
63
57
  target: "enemy",
64
- category: "damage",
65
58
  maxUses: 3,
66
59
  effects: [
67
60
  { kind: "damage", flatAmount: 10 },
@@ -72,7 +65,6 @@ export const POKEMON_ITEMS = [
72
65
  id: "sniper",
73
66
  name: "Sniper",
74
67
  target: "enemy",
75
- category: "damage",
76
68
  maxUses: 1,
77
69
  effects: [
78
70
  { kind: "damage", flatAmount: 30 },
@@ -82,7 +74,6 @@ export const POKEMON_ITEMS = [
82
74
  {
83
75
  id: "blue-berry",
84
76
  name: "Baya azul",
85
- category: "status_buff",
86
77
  maxUses: 1,
87
78
  target: "self",
88
79
  effects: [
@@ -96,7 +87,6 @@ export const POKEMON_ITEMS = [
96
87
  {
97
88
  id: "pink-berry",
98
89
  name: "Baya rosa",
99
- category: "status_buff",
100
90
  maxUses: 1,
101
91
  target: "self",
102
92
  effects: [
@@ -110,7 +100,6 @@ export const POKEMON_ITEMS = [
110
100
  {
111
101
  id: "yellow-berry",
112
102
  name: "Baya amarilla",
113
- category: "status_buff",
114
103
  maxUses: 1,
115
104
  target: "self",
116
105
  effects: [
@@ -124,7 +113,6 @@ export const POKEMON_ITEMS = [
124
113
  {
125
114
  id: "green-berry",
126
115
  name: "Baya verde",
127
- category: "status_buff",
128
116
  maxUses: 1,
129
117
  target: "self",
130
118
  effects: [
@@ -139,7 +127,6 @@ export const POKEMON_ITEMS = [
139
127
  {
140
128
  id: "attack_potion",
141
129
  name: "Poción Ofensiva",
142
- category: "status_buff",
143
130
  maxUses: 2,
144
131
  target: "self",
145
132
  effects: [
@@ -151,7 +138,6 @@ export const POKEMON_ITEMS = [
151
138
  {
152
139
  id: "defense_potion",
153
140
  name: "Poción Defensiva",
154
- category: "status_buff",
155
141
  maxUses: 2,
156
142
  target: "self",
157
143
  effects: [
@@ -163,7 +149,6 @@ export const POKEMON_ITEMS = [
163
149
  {
164
150
  id: "speed_elixir",
165
151
  name: "Elixir de Velocidad",
166
- category: "status_buff",
167
152
  maxUses: 2,
168
153
  target: "self",
169
154
  effects: [
@@ -175,7 +160,6 @@ export const POKEMON_ITEMS = [
175
160
  {
176
161
  id: "crit_injection",
177
162
  name: "Inyección Crítica",
178
- category: "status_buff",
179
163
  maxUses: 2,
180
164
  target: "self",
181
165
  effects: [
@@ -187,7 +171,6 @@ export const POKEMON_ITEMS = [
187
171
  {
188
172
  id: "chesto_berry",
189
173
  name: "Baya Atania",
190
- category: "status_buff",
191
174
  maxUses: 1,
192
175
  target: "self",
193
176
  effects: [
@@ -46,6 +46,12 @@ export const POKEMON_MOVES = [
46
46
  typeId: "fire",
47
47
  accuracy: 85,
48
48
  maxPP: 4,
49
+ narration: [
50
+ `{actor} se fué al infierno`,
51
+ `...`,
52
+ `...`,
53
+ `{actor} volvió del infierno para quemar a {victim}`
54
+ ],
49
55
  effects: [
50
56
  { kind: "damage", basePower: 45 },
51
57
  { kind: "modify_stats", target: "self", offenseDelta: -2 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pokemon-io-core",
3
- "version": "0.0.108",
3
+ "version": "0.0.109",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",