pokemon-io-core 0.0.46 → 0.0.48
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,6 @@
|
|
|
1
|
+
import { BattleActions, BattleState } from "../core";
|
|
2
|
+
export declare const createPokemonBattle: (fighter1Id: string, fighter2Id: string) => BattleState;
|
|
3
|
+
export declare const runPokemonTurn: (state: BattleState, actions: BattleActions) => {
|
|
4
|
+
newState: BattleState;
|
|
5
|
+
events: import("..").BattleEvent[];
|
|
6
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { POKEMON_FIGHTERS, POKEMON_MOVES, POKEMON_TYPE_MATRIX, POKEMON_TYPES } from "../skins/pokemon";
|
|
2
|
+
import { createInitialBattleState, resolveTurn } from "./engine";
|
|
3
|
+
const findPokemon = (id) => POKEMON_FIGHTERS.find((p) => p.id === id);
|
|
4
|
+
const findMove = (id) => POKEMON_MOVES.find((m) => m.id === id);
|
|
5
|
+
export const createPokemonBattle = (fighter1Id, fighter2Id) => {
|
|
6
|
+
const f1 = findPokemon(fighter1Id);
|
|
7
|
+
const f2 = findPokemon(fighter2Id);
|
|
8
|
+
const config = {
|
|
9
|
+
types: POKEMON_TYPES,
|
|
10
|
+
typeEffectiveness: POKEMON_TYPE_MATRIX,
|
|
11
|
+
moves: POKEMON_MOVES,
|
|
12
|
+
items: [], // MVP: sin items
|
|
13
|
+
amulets: [],
|
|
14
|
+
statuses: [],
|
|
15
|
+
player1: {
|
|
16
|
+
fighter: f1,
|
|
17
|
+
maxHp: 100,
|
|
18
|
+
moves: POKEMON_MOVES.filter((m) => (f1.recommendedMoves ?? []).includes(m.id)),
|
|
19
|
+
items: [],
|
|
20
|
+
amulet: null
|
|
21
|
+
},
|
|
22
|
+
player2: {
|
|
23
|
+
fighter: f2,
|
|
24
|
+
maxHp: 100,
|
|
25
|
+
moves: POKEMON_MOVES.filter((m) => (f2.recommendedMoves ?? []).includes(m.id)),
|
|
26
|
+
items: [],
|
|
27
|
+
amulet: null
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return createInitialBattleState(config);
|
|
31
|
+
};
|
|
32
|
+
export const runPokemonTurn = (state, actions) => resolveTurn(state, actions);
|
|
@@ -44,13 +44,8 @@ const buildItemsFromLoadout = (loadout) => {
|
|
|
44
44
|
const selectedItems = selectedItemIds
|
|
45
45
|
.map((id) => findItemById(id))
|
|
46
46
|
.filter((i) => i !== null);
|
|
47
|
-
// Si tu motor sigue exigiendo 4 items, puedes rellenar aquí:
|
|
48
|
-
// while (selectedItems.length < 4 && POKEMON_ITEMS[selectedItems.length]) {
|
|
49
|
-
// selectedItems.push(POKEMON_ITEMS[selectedItems.length]);
|
|
50
|
-
// }
|
|
51
47
|
return selectedItems;
|
|
52
48
|
};
|
|
53
|
-
// --- skin ---
|
|
54
49
|
export class PokemonSkin {
|
|
55
50
|
id = "pokemon";
|
|
56
51
|
getTypes() {
|