@pkmn/engine 0.1.0-dev.02b7f810

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.
Files changed (52) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +332 -0
  3. package/build/pkg/addon.d.ts +7 -0
  4. package/build/pkg/addon.js +111 -0
  5. package/build/pkg/addon.js.map +1 -0
  6. package/build/pkg/data/ids.json +240 -0
  7. package/build/pkg/data/layout.json +86 -0
  8. package/build/pkg/data/protocol.json +173 -0
  9. package/build/pkg/data.d.ts +91 -0
  10. package/build/pkg/data.js +150 -0
  11. package/build/pkg/data.js.map +1 -0
  12. package/build/pkg/gen1.d.ts +109 -0
  13. package/build/pkg/gen1.js +668 -0
  14. package/build/pkg/gen1.js.map +1 -0
  15. package/build/pkg/index.d.ts +383 -0
  16. package/build/pkg/index.js +122 -0
  17. package/build/pkg/index.js.map +1 -0
  18. package/build/pkg/protocol.d.ts +71 -0
  19. package/build/pkg/protocol.js +452 -0
  20. package/build/pkg/protocol.js.map +1 -0
  21. package/build/test/display.js +382 -0
  22. package/build/test/display.js.map +1 -0
  23. package/build/tools/debug.js +133 -0
  24. package/build/tools/debug.js.map +1 -0
  25. package/build.zig +346 -0
  26. package/package.json +202 -0
  27. package/src/bin/install-pkmn-engine +391 -0
  28. package/src/bin/pkmn-debug +62 -0
  29. package/src/lib/binding/node.zig +229 -0
  30. package/src/lib/binding/wasm.zig +10 -0
  31. package/src/lib/common/data.zig +129 -0
  32. package/src/lib/common/debug.zig +64 -0
  33. package/src/lib/common/options.zig +40 -0
  34. package/src/lib/common/protocol.zig +1297 -0
  35. package/src/lib/common/rng.zig +234 -0
  36. package/src/lib/gen1/README.md +791 -0
  37. package/src/lib/gen1/data/moves.zig +1854 -0
  38. package/src/lib/gen1/data/species.zig +1105 -0
  39. package/src/lib/gen1/data/types.zig +131 -0
  40. package/src/lib/gen1/data.zig +620 -0
  41. package/src/lib/gen1/helpers.zig +234 -0
  42. package/src/lib/gen1/mechanics.zig +2819 -0
  43. package/src/lib/gen2/README.md +309 -0
  44. package/src/lib/gen2/data/items.zig +236 -0
  45. package/src/lib/gen2/data/moves.zig +2784 -0
  46. package/src/lib/gen2/data/species.zig +1798 -0
  47. package/src/lib/gen2/data/types.zig +123 -0
  48. package/src/lib/gen2/data.zig +425 -0
  49. package/src/lib/gen2/helpers.zig +225 -0
  50. package/src/lib/gen2/mechanics.zig +53 -0
  51. package/src/lib/pkmn.zig +54 -0
  52. package/src/test/display/pkmn.html.tmpl +368 -0
@@ -0,0 +1,240 @@
1
+ [
2
+ {
3
+ "types": [
4
+ "Normal",
5
+ "Fighting",
6
+ "Flying",
7
+ "Poison",
8
+ "Ground",
9
+ "Rock",
10
+ "Bug",
11
+ "Ghost",
12
+ "Fire",
13
+ "Water",
14
+ "Grass",
15
+ "Electric",
16
+ "Psychic",
17
+ "Ice",
18
+ "Dragon"
19
+ ]
20
+ },
21
+ {
22
+ "types": [
23
+ "Normal",
24
+ "Fighting",
25
+ "Flying",
26
+ "Poison",
27
+ "Ground",
28
+ "Rock",
29
+ "Bug",
30
+ "Ghost",
31
+ "Steel",
32
+ "???",
33
+ "Fire",
34
+ "Water",
35
+ "Grass",
36
+ "Electric",
37
+ "Psychic",
38
+ "Ice",
39
+ "Dragon",
40
+ "Dark"
41
+ ],
42
+ "items": [
43
+ "pinkbow",
44
+ "blackbelt",
45
+ "sharpbeak",
46
+ "poisonbarb",
47
+ "softsand",
48
+ "hardstone",
49
+ "silverpowder",
50
+ "spelltag",
51
+ "metalcoat",
52
+ "polkadotbow",
53
+ "charcoal",
54
+ "mysticwater",
55
+ "miracleseed",
56
+ "magnet",
57
+ "twistedspoon",
58
+ "nevermeltice",
59
+ "dragonscale",
60
+ "blackglasses",
61
+ "brightpowder",
62
+ "metalpowder",
63
+ "quickclaw",
64
+ "kingsrock",
65
+ "stick",
66
+ "thickclub",
67
+ "focusband",
68
+ "berryjuice",
69
+ "scopelens",
70
+ "leftovers",
71
+ "berserkgene",
72
+ "lightball",
73
+ "psncureberry",
74
+ "przcureberry",
75
+ "burntberry",
76
+ "iceberry",
77
+ "bitterberry",
78
+ "mintberry",
79
+ "miracleberry",
80
+ "mysteryberry",
81
+ "berry",
82
+ "goldberry",
83
+ "masterball",
84
+ "ultraball",
85
+ "greatball",
86
+ "pokeball",
87
+ "moonstone",
88
+ "firestone",
89
+ "thunderstone",
90
+ "waterstone",
91
+ "luckypunch",
92
+ "leafstone",
93
+ "dragonfang",
94
+ "heavyball",
95
+ "levelball",
96
+ "lureball",
97
+ "fastball",
98
+ "friendball",
99
+ "moonball",
100
+ "loveball",
101
+ "sunstone",
102
+ "upgrade",
103
+ "flowermail",
104
+ "surfmail",
105
+ "lightbluemail",
106
+ "portrailmail",
107
+ "lovelymail",
108
+ "eonmail",
109
+ "morphmail",
110
+ "blueskymail",
111
+ "musicmail",
112
+ "miragemail",
113
+ "townmap",
114
+ "antidote",
115
+ "burnheal",
116
+ "iceheal",
117
+ "awakening",
118
+ "parylzeheal",
119
+ "fullrestore",
120
+ "maxpotion",
121
+ "hyperpotion",
122
+ "superpotion",
123
+ "potion",
124
+ "escaperope",
125
+ "repel",
126
+ "maxelixir",
127
+ "hpup",
128
+ "protein",
129
+ "iron",
130
+ "carbos",
131
+ "calcium",
132
+ "rarecandy",
133
+ "xaccuracy",
134
+ "nugget",
135
+ "pokedoll",
136
+ "fullheal",
137
+ "revive",
138
+ "maxrevive",
139
+ "guardspec",
140
+ "superrepel",
141
+ "maxrepel",
142
+ "direhit",
143
+ "freshwater",
144
+ "sodapop",
145
+ "lemonade",
146
+ "xattack",
147
+ "xdefend",
148
+ "xspeed",
149
+ "xspecial",
150
+ "pokeflute",
151
+ "expshare",
152
+ "silverleaf",
153
+ "ppup",
154
+ "ether",
155
+ "maxether",
156
+ "elixir",
157
+ "moomoomilk",
158
+ "goldleaf",
159
+ "redapricorn",
160
+ "tinymushroom",
161
+ "bigmushroom",
162
+ "blueapricorn",
163
+ "amuletcoin",
164
+ "yellowapricorn",
165
+ "greenapricorn",
166
+ "cleansetag",
167
+ "whiteapricorn",
168
+ "blackapricorn",
169
+ "pinkapricorn",
170
+ "slowpoketail",
171
+ "smokeball",
172
+ "pearl",
173
+ "bigpearl",
174
+ "everstone",
175
+ "ragecandybar",
176
+ "energypowder",
177
+ "energyroot",
178
+ "healpowder",
179
+ "revivalherb",
180
+ "luckyegg",
181
+ "stardust",
182
+ "starpiece",
183
+ "sacredash",
184
+ "normalbox",
185
+ "gorgeousbox",
186
+ "parkball",
187
+ "brickpiece",
188
+ "tm01",
189
+ "tm02",
190
+ "tm03",
191
+ "tm04",
192
+ "tm05",
193
+ "tm06",
194
+ "tm07",
195
+ "tm08",
196
+ "tm09",
197
+ "tm10",
198
+ "tm11",
199
+ "tm12",
200
+ "tm13",
201
+ "tm14",
202
+ "tm15",
203
+ "tm16",
204
+ "tm17",
205
+ "tm18",
206
+ "tm19",
207
+ "tm20",
208
+ "tm21",
209
+ "tm22",
210
+ "tm23",
211
+ "tm24",
212
+ "tm25",
213
+ "tm26",
214
+ "tm27",
215
+ "tm28",
216
+ "tm29",
217
+ "tm30",
218
+ "tm31",
219
+ "tm32",
220
+ "tm33",
221
+ "tm34",
222
+ "tm35",
223
+ "tm36",
224
+ "tm37",
225
+ "tm38",
226
+ "tm39",
227
+ "tm40",
228
+ "tm41",
229
+ "tm42",
230
+ "tm43",
231
+ "tm44",
232
+ "tm45",
233
+ "tm46",
234
+ "tm47",
235
+ "tm48",
236
+ "tm49",
237
+ "tm50"
238
+ ]
239
+ }
240
+ ]
@@ -0,0 +1,86 @@
1
+ [
2
+ {
3
+ "sizes": {
4
+ "Battle": 384,
5
+ "Side": 184,
6
+ "Pokemon": 24,
7
+ "ActivePokemon": 32
8
+ },
9
+ "offsets": {
10
+ "Battle": {
11
+ "sides": 0,
12
+ "turn": 368,
13
+ "last_damage": 370,
14
+ "last_selected_indexes": 372,
15
+ "rng": 373
16
+ },
17
+ "Side": {
18
+ "pokemon": 0,
19
+ "active": 144,
20
+ "order": 176,
21
+ "last_selected_move": 182,
22
+ "last_used_move": 183
23
+ },
24
+ "Pokemon": {
25
+ "stats": 0,
26
+ "moves": 10,
27
+ "hp": 18,
28
+ "status": 20,
29
+ "species": 21,
30
+ "types": 22,
31
+ "level": 23
32
+ },
33
+ "ActivePokemon": {
34
+ "stats": 0,
35
+ "species": 10,
36
+ "types": 11,
37
+ "boosts": 12,
38
+ "volatiles": 16,
39
+ "moves": 24
40
+ },
41
+ "Stats": {
42
+ "hp": 0,
43
+ "atk": 2,
44
+ "def": 4,
45
+ "spe": 6,
46
+ "spc": 8
47
+ },
48
+ "Boosts": {
49
+ "atk": 0,
50
+ "def": 4,
51
+ "spe": 8,
52
+ "spc": 12,
53
+ "accuracy": 16,
54
+ "evasion": 20
55
+ },
56
+ "Volatiles": {
57
+ "Bide": 0,
58
+ "Thrashing": 1,
59
+ "MultiHit": 2,
60
+ "Flinch": 3,
61
+ "Charging": 4,
62
+ "Binding": 5,
63
+ "Invulnerable": 6,
64
+ "Confusion": 7,
65
+ "Mist": 8,
66
+ "FocusEnergy": 9,
67
+ "Substitute": 10,
68
+ "Recharging": 11,
69
+ "Rage": 12,
70
+ "LeechSeed": 13,
71
+ "Toxic": 14,
72
+ "LightScreen": 15,
73
+ "Reflect": 16,
74
+ "Transform": 17,
75
+ "confusion": 18,
76
+ "attacks": 21,
77
+ "state": 24,
78
+ "substitute": 40,
79
+ "transform": 48,
80
+ "disabled_duration": 52,
81
+ "disabled_move": 56,
82
+ "toxic": 59
83
+ }
84
+ }
85
+ }
86
+ ]
@@ -0,0 +1,173 @@
1
+ {
2
+ "ArgType": [
3
+ "None",
4
+ "LastStill",
5
+ "LastMiss",
6
+ "Move",
7
+ "Switch",
8
+ "Cant",
9
+ "Faint",
10
+ "Turn",
11
+ "Win",
12
+ "Tie",
13
+ "Damage",
14
+ "Heal",
15
+ "Status",
16
+ "CureStatus",
17
+ "Boost",
18
+ "ClearAllBoost",
19
+ "Fail",
20
+ "Miss",
21
+ "HitCount",
22
+ "Prepare",
23
+ "MustRecharge",
24
+ "Activate",
25
+ "FieldActivate",
26
+ "Start",
27
+ "End",
28
+ "OHKO",
29
+ "Crit",
30
+ "SuperEffective",
31
+ "Resisted",
32
+ "Immune",
33
+ "Transform",
34
+ "Drag",
35
+ "Item",
36
+ "EndItem",
37
+ "CureTeam",
38
+ "SetHP",
39
+ "SetBoost",
40
+ "CopyBoost",
41
+ "SideStart",
42
+ "SideEnd",
43
+ "SingleMove",
44
+ "SingleTurn",
45
+ "Weather",
46
+ "Block",
47
+ "Ability",
48
+ "EndAbility",
49
+ "ClearNegativeBoost",
50
+ "FormeChange",
51
+ "NoTarget",
52
+ "SwapBoost",
53
+ "FieldStart",
54
+ "FieldEnd",
55
+ "DetailsChange",
56
+ "ClearPoke",
57
+ "Poke",
58
+ "TeamPreview",
59
+ "Center",
60
+ "Swap",
61
+ "Combine",
62
+ "Waiting",
63
+ "Replace",
64
+ "ClearBoost",
65
+ "Mega",
66
+ "Primal",
67
+ "InvertBoost",
68
+ "ZBroken",
69
+ "ZPower",
70
+ "Burst",
71
+ "ClearPositiveBoost",
72
+ "CanDynamax",
73
+ "SwapSideConditions"
74
+ ],
75
+ "Move": [
76
+ "None",
77
+ "From"
78
+ ],
79
+ "Cant": [
80
+ "Sleep",
81
+ "Freeze",
82
+ "Paralysis",
83
+ "Bound",
84
+ "Flinch",
85
+ "Disable",
86
+ "Recharge",
87
+ "PP"
88
+ ],
89
+ "Heal": [
90
+ "None",
91
+ "Silent",
92
+ "Drain"
93
+ ],
94
+ "Damage": [
95
+ "None",
96
+ "Poison",
97
+ "Burn",
98
+ "Confusion",
99
+ "LeechSeed",
100
+ "RecoilOf"
101
+ ],
102
+ "Status": [
103
+ "None",
104
+ "Silent",
105
+ "From"
106
+ ],
107
+ "CureStatus": [
108
+ "Message",
109
+ "Silent"
110
+ ],
111
+ "Boost": [
112
+ "Rage",
113
+ "Attack",
114
+ "Defense",
115
+ "Speed",
116
+ "SpecialAttack",
117
+ "SpecialDefense",
118
+ "Accuracy",
119
+ "Evasion"
120
+ ],
121
+ "Fail": [
122
+ "None",
123
+ "Sleep",
124
+ "Poison",
125
+ "Burn",
126
+ "Freeze",
127
+ "Paralysis",
128
+ "Toxic",
129
+ "Substitute",
130
+ "Weak"
131
+ ],
132
+ "Activate": [
133
+ "Bide",
134
+ "Confusion",
135
+ "Haze",
136
+ "Mist",
137
+ "Struggle",
138
+ "Substitute",
139
+ "Splash"
140
+ ],
141
+ "Start": [
142
+ "Bide",
143
+ "Confusion",
144
+ "ConfusionSilent",
145
+ "FocusEnergy",
146
+ "LeechSeed",
147
+ "LightScreen",
148
+ "Mist",
149
+ "Reflect",
150
+ "Substitute",
151
+ "TypeChange",
152
+ "Disable",
153
+ "Mimic"
154
+ ],
155
+ "End": [
156
+ "Disable",
157
+ "Confusion",
158
+ "Bide",
159
+ "Substitute",
160
+ "DisableSilent",
161
+ "ConfusionSilent",
162
+ "Mist",
163
+ "FocusEnergy",
164
+ "LeechSeed",
165
+ "Toxic",
166
+ "LightScreen",
167
+ "Reflect"
168
+ ],
169
+ "Immune": [
170
+ "None",
171
+ "OHKO"
172
+ ]
173
+ }
@@ -0,0 +1,91 @@
1
+ import { Generation, ID, TypeName } from '@pkmn/data';
2
+ export declare const LE: boolean;
3
+ export type IDs = [
4
+ {
5
+ types: TypeName[];
6
+ },
7
+ {
8
+ items: ID[];
9
+ types: TypeName[];
10
+ }
11
+ ];
12
+ export declare const IDS: IDs;
13
+ export declare const PROTOCOL: {
14
+ [decl: string]: {
15
+ [name: string]: number;
16
+ };
17
+ };
18
+ export declare const LAYOUT: {
19
+ sizes: {
20
+ [decl: string]: number;
21
+ };
22
+ offsets: {
23
+ [decl: string]: {
24
+ [field: string]: number;
25
+ };
26
+ };
27
+ }[];
28
+ export declare const Data: {
29
+ view(buf: number[] | Buffer): DataView;
30
+ };
31
+ /**
32
+ * Translation table for encoding/decoding Pokémon Showdown string identifiers
33
+ * to the identifiers used internally by the pkmn engine.
34
+ */
35
+ export declare class Lookup {
36
+ private readonly gen;
37
+ private readonly typesByNum;
38
+ private readonly typesByName;
39
+ private readonly species;
40
+ private readonly moves;
41
+ private readonly itemsByNum;
42
+ private readonly itemsByID;
43
+ /** Returns a `Lookup` table for a given generation. */
44
+ static get(gen: Generation): Lookup;
45
+ private constructor();
46
+ /**
47
+ * Returns the respective sizes of the various data types in the lookup table.
48
+ */
49
+ get sizes(): {
50
+ types: number;
51
+ species: number;
52
+ moves: number;
53
+ items: number;
54
+ };
55
+ /**
56
+ * Decodes the Pokémon Showdown `TypeName` for a type corresponding to the
57
+ * identifying `num` returned by the engine.
58
+ */
59
+ typeByNum(num: number): TypeName;
60
+ /**
61
+ * Encodes a `TypeName` to the number used as an identifier by the engine.
62
+ */
63
+ typeByName(name: TypeName): number;
64
+ /**
65
+ * Decodes the Pokémon Showdown `ID` for a species corresponding to the
66
+ * identifying `num` returned by the engine.
67
+ */
68
+ speciesByNum(num: number): ID;
69
+ /**
70
+ * Encodes a species `ID` to the number used as an identifier by the engine.
71
+ */
72
+ speciesByID(id: ID | undefined): number;
73
+ /**
74
+ * Decodes the Pokémon Showdown `ID` for a move corresponding to the
75
+ * identifying `num` returned by the engine.
76
+ */
77
+ moveByNum(num: number): ID;
78
+ /**
79
+ * Encodes a move `ID` to the number used as an identifier by the engine.
80
+ */
81
+ moveByID(id: ID | undefined): number;
82
+ /**
83
+ * Decodes the Pokémon Showdown `ID` for an item corresponding to the
84
+ * identifying `num` returned by the engine.
85
+ */
86
+ itemByNum(num: number): ID;
87
+ /**
88
+ * Encodes an item `ID` to the number used as an identifier by the engine.
89
+ */
90
+ itemByID(id: ID | undefined): number;
91
+ }