pokemon-io-core 0.0.10 → 0.0.11
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.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Para MVP: 4 objetos simples
|
|
2
|
+
export const POKEMON_ITEMS = [
|
|
3
|
+
{
|
|
4
|
+
id: "potion",
|
|
5
|
+
name: "Poción",
|
|
6
|
+
category: "heal_shield",
|
|
7
|
+
maxUses: 2,
|
|
8
|
+
effects: [
|
|
9
|
+
{
|
|
10
|
+
kind: "heal", // tu EffectDefinition debe tener esto
|
|
11
|
+
amount: 30
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "super_potion",
|
|
17
|
+
name: "Super Poción",
|
|
18
|
+
category: "heal_shield",
|
|
19
|
+
maxUses: 1,
|
|
20
|
+
effects: [
|
|
21
|
+
{
|
|
22
|
+
kind: "heal",
|
|
23
|
+
amount: 60
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "bomb",
|
|
29
|
+
name: "Bomba",
|
|
30
|
+
category: "damage",
|
|
31
|
+
maxUses: 1,
|
|
32
|
+
effects: [
|
|
33
|
+
{
|
|
34
|
+
kind: "damage",
|
|
35
|
+
powerMultiplier: 1.5
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "guard_charm",
|
|
41
|
+
name: "Amuleto de Guardia",
|
|
42
|
+
category: "status_buff",
|
|
43
|
+
maxUses: 1,
|
|
44
|
+
effects: [
|
|
45
|
+
{
|
|
46
|
+
kind: "apply_status",
|
|
47
|
+
statusId: "guard"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
];
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import { ItemDefinition, MoveDefinition, PlayerBattleConfig } from "../../core";
|
|
1
2
|
import type { CombatSkin, FighterLoadout } from "../CombatSkin";
|
|
2
|
-
import type { MoveDefinition, ItemDefinition, AmuletDefinition, StatusDefinition } from "../../core";
|
|
3
|
-
import type { PlayerBattleConfig } from "../../core/engine";
|
|
4
3
|
export declare class PokemonSkin implements CombatSkin {
|
|
5
4
|
readonly id = "pokemon";
|
|
6
5
|
getTypes(): import("../..").TypeDefinition[];
|
|
7
6
|
getTypeEffectiveness(): import("../..").TypeEffectivenessMatrix;
|
|
8
7
|
getMoves(): MoveDefinition[];
|
|
9
8
|
getItems(): ItemDefinition[];
|
|
10
|
-
getAmulets():
|
|
11
|
-
getStatuses():
|
|
9
|
+
getAmulets(): never[];
|
|
10
|
+
getStatuses(): never[];
|
|
12
11
|
buildPlayerConfig(loadout: FighterLoadout): PlayerBattleConfig;
|
|
13
12
|
}
|
|
14
13
|
export declare const createPokemonSkin: () => CombatSkin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// src/skins/pokemon/pokemonSkin.ts
|
|
2
|
-
import { POKEMON_TYPES, POKEMON_TYPE_MATRIX, POKEMON_MOVES, POKEMON_FIGHTERS } from "./index";
|
|
1
|
+
// pokemon-io-core/src/skins/pokemon/pokemonSkin.ts
|
|
2
|
+
import { POKEMON_TYPES, POKEMON_TYPE_MATRIX, POKEMON_MOVES, POKEMON_FIGHTERS, POKEMON_ITEMS } from "./index";
|
|
3
3
|
const MAX_HP_DEFAULT = 100;
|
|
4
|
-
//
|
|
4
|
+
// --- helpers ---
|
|
5
5
|
const findPokemonById = (id) => {
|
|
6
6
|
const lower = id.toLowerCase();
|
|
7
7
|
return (POKEMON_FIGHTERS.find((f) => f.id.toLowerCase() === lower || f.name.toLowerCase() === lower) ?? null);
|
|
@@ -9,19 +9,19 @@ const findPokemonById = (id) => {
|
|
|
9
9
|
const findMoveById = (id) => {
|
|
10
10
|
return POKEMON_MOVES.find((m) => m.id === id) ?? null;
|
|
11
11
|
};
|
|
12
|
+
const findItemById = (id) => {
|
|
13
|
+
return POKEMON_ITEMS.find((i) => i.id === id) ?? null;
|
|
14
|
+
};
|
|
12
15
|
const FILLER_MOVE_ID = "tackle";
|
|
13
16
|
const buildMovesFromLoadout = (fighter, loadout) => {
|
|
14
|
-
// 1) si el jugador ha elegido moveIds, intentamos respetarlos
|
|
15
17
|
const selectedMoveIds = loadout.moveIds ?? [];
|
|
16
18
|
const selectedMoves = selectedMoveIds
|
|
17
19
|
.map((id) => findMoveById(id))
|
|
18
20
|
.filter((m) => m !== null);
|
|
19
|
-
// 2) si ya hay 4 válidos → nos quedamos con los primeros 4
|
|
20
21
|
if (selectedMoves.length >= 4) {
|
|
21
22
|
return selectedMoves.slice(0, 4);
|
|
22
23
|
}
|
|
23
24
|
const result = [...selectedMoves];
|
|
24
|
-
// 3) completamos con recommendedMoves del fighter
|
|
25
25
|
const recommendedIds = fighter.recommendedMoves ?? [];
|
|
26
26
|
for (const recId of recommendedIds) {
|
|
27
27
|
if (result.length >= 4)
|
|
@@ -31,22 +31,27 @@ const buildMovesFromLoadout = (fighter, loadout) => {
|
|
|
31
31
|
result.push(move);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
// 4) si sigue faltando, rellenamos con "tackle"
|
|
35
34
|
const filler = findMoveById(FILLER_MOVE_ID);
|
|
36
35
|
while (result.length < 4 && filler) {
|
|
37
36
|
result.push(filler);
|
|
38
37
|
}
|
|
39
|
-
// Garantizamos que haya al menos 1 movimiento
|
|
40
38
|
if (result.length === 0 && filler) {
|
|
41
39
|
result.push(filler);
|
|
42
40
|
}
|
|
43
|
-
// Cortamos por si acaso
|
|
44
41
|
return result.slice(0, 4);
|
|
45
42
|
};
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
43
|
+
const buildItemsFromLoadout = (loadout) => {
|
|
44
|
+
const selectedItemIds = loadout.itemIds ?? [];
|
|
45
|
+
const selectedItems = selectedItemIds
|
|
46
|
+
.map((id) => findItemById(id))
|
|
47
|
+
.filter((i) => i !== null);
|
|
48
|
+
// Si tu motor sigue exigiendo 4 items, puedes rellenar aquí:
|
|
49
|
+
// while (selectedItems.length < 4 && POKEMON_ITEMS[selectedItems.length]) {
|
|
50
|
+
// selectedItems.push(POKEMON_ITEMS[selectedItems.length]);
|
|
51
|
+
// }
|
|
52
|
+
return selectedItems;
|
|
53
|
+
};
|
|
54
|
+
// --- skin ---
|
|
50
55
|
export class PokemonSkin {
|
|
51
56
|
id = "pokemon";
|
|
52
57
|
getTypes() {
|
|
@@ -62,10 +67,10 @@ export class PokemonSkin {
|
|
|
62
67
|
return POKEMON_ITEMS;
|
|
63
68
|
}
|
|
64
69
|
getAmulets() {
|
|
65
|
-
return
|
|
70
|
+
return []; // más adelante
|
|
66
71
|
}
|
|
67
72
|
getStatuses() {
|
|
68
|
-
return
|
|
73
|
+
return []; // más adelante
|
|
69
74
|
}
|
|
70
75
|
buildPlayerConfig(loadout) {
|
|
71
76
|
if (!loadout.fighterId) {
|
|
@@ -76,17 +81,16 @@ export class PokemonSkin {
|
|
|
76
81
|
throw new Error(`Unknown fighterId for Pokemon skin: ${loadout.fighterId}`);
|
|
77
82
|
}
|
|
78
83
|
const moves = buildMovesFromLoadout(fighter, loadout);
|
|
79
|
-
|
|
84
|
+
const items = buildItemsFromLoadout(loadout);
|
|
80
85
|
return {
|
|
81
86
|
fighter,
|
|
82
87
|
maxHp: MAX_HP_DEFAULT,
|
|
83
88
|
moves,
|
|
84
|
-
items
|
|
85
|
-
amulet: null
|
|
89
|
+
items,
|
|
90
|
+
amulet: null
|
|
86
91
|
};
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
|
-
// Helper para crear la skin (así importas siempre una factoría)
|
|
90
94
|
export const createPokemonSkin = () => {
|
|
91
95
|
return new PokemonSkin();
|
|
92
96
|
};
|