pokemon-io-core 0.0.54 → 0.0.55
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.
- package/dist/api/battle.d.ts +26 -0
- package/dist/api/battle.js +2 -0
- package/dist/api/room.d.ts +21 -0
- package/dist/api/room.js +2 -0
- package/dist/api/socketTypes.d.ts +46 -0
- package/dist/api/socketTypes.js +1 -0
- package/dist/core/actions.d.ts +21 -0
- package/dist/core/actions.js +1 -0
- package/dist/core/amulets.d.ts +18 -0
- package/dist/core/amulets.js +1 -0
- package/dist/core/battleState.d.ts +39 -0
- package/dist/core/battleState.js +1 -0
- package/dist/core/engine.d.ts +45 -0
- package/dist/core/engine.js +869 -0
- package/dist/core/events.d.ts +67 -0
- package/dist/core/events.js +1 -0
- package/dist/core/fighters.d.ts +13 -0
- package/dist/core/fighters.js +1 -0
- package/dist/core/ids.d.ts +6 -0
- package/dist/core/ids.js +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.js +11 -0
- package/dist/core/items.d.ts +12 -0
- package/dist/core/items.js +1 -0
- package/dist/core/moves.d.ts +73 -0
- package/dist/core/moves.js +2 -0
- package/dist/core/status.d.ts +11 -0
- package/dist/core/status.js +1 -0
- package/dist/core/types.d.ts +14 -0
- package/dist/core/types.js +1 -0
- package/dist/engine/index.d.ts +1 -0
- package/dist/engine/index.js +1 -0
- package/dist/engine/pokemonBattleService.d.ts +6 -0
- package/dist/engine/pokemonBattleService.js +32 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/skins/CombatSkin.d.ts +18 -0
- package/dist/skins/CombatSkin.js +1 -0
- package/dist/skins/index.d.ts +2 -0
- package/dist/skins/index.js +2 -0
- package/dist/skins/pokemon/fighters.d.ts +2 -0
- package/dist/skins/pokemon/fighters.js +174 -0
- package/dist/skins/pokemon/index.d.ts +6 -0
- package/dist/skins/pokemon/index.js +6 -0
- package/dist/skins/pokemon/items.d.ts +2 -0
- package/dist/skins/pokemon/items.js +143 -0
- package/dist/skins/pokemon/moves.d.ts +2 -0
- package/dist/skins/pokemon/moves.js +459 -0
- package/dist/skins/pokemon/pokemonSkin.d.ts +13 -0
- package/dist/skins/pokemon/pokemonSkin.js +91 -0
- package/dist/skins/pokemon/statuses.d.ts +2 -0
- package/dist/skins/pokemon/statuses.js +85 -0
- package/dist/skins/pokemon/types.d.ts +13 -0
- package/dist/skins/pokemon/types.js +97 -0
- package/package.json +7 -7
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BattleEvent, StatusId } from "../core";
|
|
2
|
+
export interface BattlePlayerStatusView {
|
|
3
|
+
statusId: StatusId;
|
|
4
|
+
stacks: 1 | 2;
|
|
5
|
+
remainingTurns: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BattlePlayerView {
|
|
8
|
+
playerId: string;
|
|
9
|
+
nickname: string;
|
|
10
|
+
hp: number;
|
|
11
|
+
statuses: BattlePlayerStatusView[];
|
|
12
|
+
}
|
|
13
|
+
export type BattleStatus = "ongoing" | "finished";
|
|
14
|
+
export interface BattleView {
|
|
15
|
+
roomId: string;
|
|
16
|
+
status: BattleStatus;
|
|
17
|
+
winnerId: string | null;
|
|
18
|
+
currentTurnPlayerId: string | null;
|
|
19
|
+
startedAt: string;
|
|
20
|
+
players: BattlePlayerView[];
|
|
21
|
+
events: BattleEvent[];
|
|
22
|
+
turnStartHpByPlayerId: {
|
|
23
|
+
[playerId: string]: number;
|
|
24
|
+
};
|
|
25
|
+
turnNumber: number;
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PlayerLoadoutView {
|
|
2
|
+
fighterId: string | null;
|
|
3
|
+
moveIds: string[];
|
|
4
|
+
itemIds: string[];
|
|
5
|
+
amuletId: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface PlayerView {
|
|
8
|
+
id: string;
|
|
9
|
+
nickname: string;
|
|
10
|
+
isOwner: boolean;
|
|
11
|
+
isSelf: boolean;
|
|
12
|
+
isReady: boolean;
|
|
13
|
+
loadout: PlayerLoadoutView | null;
|
|
14
|
+
}
|
|
15
|
+
export type RoomStatusView = "waiting" | "in_battle" | "finished";
|
|
16
|
+
export interface RoomView {
|
|
17
|
+
id: string;
|
|
18
|
+
ownerId: string;
|
|
19
|
+
status: RoomStatusView;
|
|
20
|
+
players: PlayerView[];
|
|
21
|
+
}
|
package/dist/api/room.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BattleView } from "./battle";
|
|
2
|
+
import { RoomView } from "./room";
|
|
3
|
+
export interface ClientToServerEvents {
|
|
4
|
+
"room:create": (payload: {
|
|
5
|
+
nickname: string;
|
|
6
|
+
}) => void;
|
|
7
|
+
"room:join": (payload: {
|
|
8
|
+
roomId: string;
|
|
9
|
+
nickname: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
"room:leave": (payload: {
|
|
12
|
+
roomId: string;
|
|
13
|
+
}) => void;
|
|
14
|
+
"room:setLoadout": (payload: {
|
|
15
|
+
roomId: string;
|
|
16
|
+
fighterId: string;
|
|
17
|
+
moveIds: string[];
|
|
18
|
+
itemIds: string[];
|
|
19
|
+
amuletId?: string | null;
|
|
20
|
+
}) => void;
|
|
21
|
+
"room:startBattleRequest": (payload: {
|
|
22
|
+
roomId: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
"battle:useMove": (payload: {
|
|
25
|
+
roomId: string;
|
|
26
|
+
moveIndex: number;
|
|
27
|
+
}) => void;
|
|
28
|
+
"battle:useItem": (payload: {
|
|
29
|
+
roomId: string;
|
|
30
|
+
itemIndex: number;
|
|
31
|
+
}) => void;
|
|
32
|
+
"ping": () => void;
|
|
33
|
+
}
|
|
34
|
+
export interface ServerToClientEvents {
|
|
35
|
+
"connection:state": (payload: {
|
|
36
|
+
isConnected: boolean;
|
|
37
|
+
socketId: string | null;
|
|
38
|
+
}) => void;
|
|
39
|
+
"room:state": (payload: RoomView) => void;
|
|
40
|
+
"room:error": (payload: {
|
|
41
|
+
code: string;
|
|
42
|
+
message: string;
|
|
43
|
+
}) => void;
|
|
44
|
+
"battle:state": (payload: BattleView) => void;
|
|
45
|
+
"pong": (msg: string) => void;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ActionKind = "use_move" | "use_item" | "switch_fighter" | "no_action";
|
|
2
|
+
export interface UseMoveAction {
|
|
3
|
+
kind: "use_move";
|
|
4
|
+
moveIndex: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseItemAction {
|
|
7
|
+
kind: "use_item";
|
|
8
|
+
itemIndex: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SwitchFighterAction {
|
|
11
|
+
kind: "switch_fighter";
|
|
12
|
+
targetIndex: number;
|
|
13
|
+
}
|
|
14
|
+
export interface NoAction {
|
|
15
|
+
kind: "no_action";
|
|
16
|
+
}
|
|
17
|
+
export type PlayerAction = UseMoveAction | UseItemAction | SwitchFighterAction | NoAction;
|
|
18
|
+
export interface BattleActions {
|
|
19
|
+
player1: PlayerAction;
|
|
20
|
+
player2: PlayerAction;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AmuletId, TypeId, StatusId } from "./ids";
|
|
2
|
+
import type { EffectDefinition } from "./moves";
|
|
3
|
+
export type PassiveTriggerKind = "always" | "on_hit" | "on_damage_taken" | "on_below_hp_threshold";
|
|
4
|
+
export interface PassiveTriggerCondition {
|
|
5
|
+
kind: PassiveTriggerKind;
|
|
6
|
+
hpThresholdPercent?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PassiveEffectDefinition {
|
|
9
|
+
trigger: PassiveTriggerCondition;
|
|
10
|
+
effects: EffectDefinition[];
|
|
11
|
+
appliedStatusId?: StatusId;
|
|
12
|
+
}
|
|
13
|
+
export interface AmuletDefinition {
|
|
14
|
+
id: AmuletId;
|
|
15
|
+
name: string;
|
|
16
|
+
classId: TypeId | null;
|
|
17
|
+
passiveEffects: PassiveEffectDefinition[];
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BattleRuntime } from "../core/engine";
|
|
2
|
+
import type { FighterId, TypeId, MoveId, ItemId, AmuletId, StatusId } from "./ids";
|
|
3
|
+
import type { FighterStats } from "./types";
|
|
4
|
+
export interface EquippedMove {
|
|
5
|
+
moveId: MoveId;
|
|
6
|
+
currentPP: number;
|
|
7
|
+
}
|
|
8
|
+
export interface EquippedItem {
|
|
9
|
+
itemId: ItemId;
|
|
10
|
+
usesRemaining: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ActiveStatus {
|
|
13
|
+
statusId: StatusId;
|
|
14
|
+
stacks: 1 | 2;
|
|
15
|
+
remainingTurns: number;
|
|
16
|
+
}
|
|
17
|
+
export interface BattleFighter {
|
|
18
|
+
fighterId: FighterId;
|
|
19
|
+
classId: TypeId;
|
|
20
|
+
maxHp: number;
|
|
21
|
+
currentHp: number;
|
|
22
|
+
baseStats: FighterStats;
|
|
23
|
+
effectiveStats: FighterStats;
|
|
24
|
+
moves: EquippedMove[];
|
|
25
|
+
items: EquippedItem[];
|
|
26
|
+
amuletId: AmuletId | null;
|
|
27
|
+
statuses: ActiveStatus[];
|
|
28
|
+
isAlive: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface PlayerBattleState {
|
|
31
|
+
fighterTeam: BattleFighter[];
|
|
32
|
+
activeIndex: number;
|
|
33
|
+
}
|
|
34
|
+
export interface BattleState {
|
|
35
|
+
turnNumber: number;
|
|
36
|
+
player1: PlayerBattleState;
|
|
37
|
+
player2: PlayerBattleState;
|
|
38
|
+
runtime: BattleRuntime;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type BattleState, type FighterDefinition, type MoveDefinition, type ItemDefinition, type AmuletDefinition, type StatusDefinition, type TypeDefinition, type TypeEffectivenessMatrix, type BattleActions, type BattleEvent, type MoveId, type ItemId, type StatusId, type TypeId } from "../core";
|
|
2
|
+
interface BattleRules {
|
|
3
|
+
baseCritChance: number;
|
|
4
|
+
critPerStat: number;
|
|
5
|
+
critMultiplier: number;
|
|
6
|
+
stabMultiplier: number;
|
|
7
|
+
randomMinDamageFactor: number;
|
|
8
|
+
randomMaxDamageFactor: number;
|
|
9
|
+
}
|
|
10
|
+
export interface BattleRuntime {
|
|
11
|
+
rules: BattleRules;
|
|
12
|
+
typesById: Record<TypeId, TypeDefinition>;
|
|
13
|
+
movesById: Record<MoveId, MoveDefinition>;
|
|
14
|
+
itemsById: Record<ItemId, ItemDefinition>;
|
|
15
|
+
amuletsById: Record<string, AmuletDefinition>;
|
|
16
|
+
statusesById: Record<StatusId, StatusDefinition>;
|
|
17
|
+
typeEffectiveness: TypeEffectivenessMatrix;
|
|
18
|
+
}
|
|
19
|
+
export interface PlayerBattleConfig {
|
|
20
|
+
fighter: FighterDefinition;
|
|
21
|
+
maxHp: number;
|
|
22
|
+
moves: MoveDefinition[];
|
|
23
|
+
items: ItemDefinition[];
|
|
24
|
+
amulet: AmuletDefinition | null;
|
|
25
|
+
}
|
|
26
|
+
export interface BattleConfig {
|
|
27
|
+
types: TypeDefinition[];
|
|
28
|
+
typeEffectiveness: TypeEffectivenessMatrix;
|
|
29
|
+
moves: MoveDefinition[];
|
|
30
|
+
items: ItemDefinition[];
|
|
31
|
+
amulets: AmuletDefinition[];
|
|
32
|
+
statuses: StatusDefinition[];
|
|
33
|
+
player1: PlayerBattleConfig;
|
|
34
|
+
player2: PlayerBattleConfig;
|
|
35
|
+
rules?: Partial<BattleRules>;
|
|
36
|
+
}
|
|
37
|
+
export interface RuntimeBattleState extends BattleState {
|
|
38
|
+
runtime: BattleRuntime;
|
|
39
|
+
}
|
|
40
|
+
export declare const createInitialBattleState: (config: BattleConfig) => BattleState;
|
|
41
|
+
export declare const resolveTurn: (state: BattleState, actions: BattleActions) => {
|
|
42
|
+
newState: BattleState;
|
|
43
|
+
events: BattleEvent[];
|
|
44
|
+
};
|
|
45
|
+
export {};
|