@robsonbittencourt/calc 0.10.0
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/.eslintignore +2 -0
- package/.eslintrc +12 -0
- package/bundle +107 -0
- package/dist/adaptable.d.ts +6 -0
- package/dist/adaptable.js +28 -0
- package/dist/adaptable.js.map +1 -0
- package/dist/calc.d.ts +6 -0
- package/dist/calc.js +26 -0
- package/dist/calc.js.map +1 -0
- package/dist/data/abilities.d.ts +15 -0
- package/dist/data/abilities.js +448 -0
- package/dist/data/abilities.js.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.js +30 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/interface.d.ts +150 -0
- package/dist/data/interface.js +3 -0
- package/dist/data/interface.js.map +1 -0
- package/dist/data/items.d.ts +24 -0
- package/dist/data/items.js +708 -0
- package/dist/data/items.js.map +1 -0
- package/dist/data/moves.d.ts +86 -0
- package/dist/data/moves.js +5014 -0
- package/dist/data/moves.js.map +1 -0
- package/dist/data/natures.d.ts +17 -0
- package/dist/data/natures.js +127 -0
- package/dist/data/natures.js.map +1 -0
- package/dist/data/production.min.js +1 -0
- package/dist/data/species.d.ts +48 -0
- package/dist/data/species.js +10126 -0
- package/dist/data/species.js.map +1 -0
- package/dist/data/types.d.ts +23 -0
- package/dist/data/types.js +538 -0
- package/dist/data/types.js.map +1 -0
- package/dist/desc.d.ts +65 -0
- package/dist/desc.js +866 -0
- package/dist/desc.js.map +1 -0
- package/dist/field.d.ts +49 -0
- package/dist/field.js +111 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/dist/items.d.ts +13 -0
- package/dist/items.js +434 -0
- package/dist/items.js.map +1 -0
- package/dist/mechanics/gen12.d.ts +6 -0
- package/dist/mechanics/gen12.js +271 -0
- package/dist/mechanics/gen12.js.map +1 -0
- package/dist/mechanics/gen3.d.ts +11 -0
- package/dist/mechanics/gen3.js +371 -0
- package/dist/mechanics/gen3.js.map +1 -0
- package/dist/mechanics/gen4.d.ts +11 -0
- package/dist/mechanics/gen4.js +596 -0
- package/dist/mechanics/gen4.js.map +1 -0
- package/dist/mechanics/gen56.d.ts +13 -0
- package/dist/mechanics/gen56.js +836 -0
- package/dist/mechanics/gen56.js.map +1 -0
- package/dist/mechanics/gen789.d.ts +14 -0
- package/dist/mechanics/gen789.js +1325 -0
- package/dist/mechanics/gen789.js.map +1 -0
- package/dist/mechanics/util.d.ts +39 -0
- package/dist/mechanics/util.js +675 -0
- package/dist/mechanics/util.js.map +1 -0
- package/dist/move.d.ts +50 -0
- package/dist/move.js +324 -0
- package/dist/move.js.map +1 -0
- package/dist/pokemon.d.ts +55 -0
- package/dist/pokemon.js +240 -0
- package/dist/pokemon.js.map +1 -0
- package/dist/production.min.js +1 -0
- package/dist/result.d.ts +34 -0
- package/dist/result.js +94 -0
- package/dist/result.js.map +1 -0
- package/dist/state.d.ts +77 -0
- package/dist/state.js +3 -0
- package/dist/state.js.map +1 -0
- package/dist/stats.d.ts +26 -0
- package/dist/stats.js +183 -0
- package/dist/stats.js.map +1 -0
- package/dist/test/calc.test.d.ts +1 -0
- package/dist/test/calc.test.js +1297 -0
- package/dist/test/calc.test.js.map +1 -0
- package/dist/test/data.test.d.ts +1 -0
- package/dist/test/data.test.js +368 -0
- package/dist/test/data.test.js.map +1 -0
- package/dist/test/gen.d.ts +135 -0
- package/dist/test/gen.js +636 -0
- package/dist/test/gen.js.map +1 -0
- package/dist/test/helper.d.ts +55 -0
- package/dist/test/helper.js +174 -0
- package/dist/test/helper.js.map +1 -0
- package/dist/test/move.test.d.ts +1 -0
- package/dist/test/move.test.js +14 -0
- package/dist/test/move.test.js.map +1 -0
- package/dist/test/pokemon.test.d.ts +1 -0
- package/dist/test/pokemon.test.js +102 -0
- package/dist/test/pokemon.test.js.map +1 -0
- package/dist/test/stats.test.d.ts +1 -0
- package/dist/test/stats.test.js +64 -0
- package/dist/test/stats.test.js.map +1 -0
- package/dist/test/utils.test.d.ts +1 -0
- package/dist/test/utils.test.js +19 -0
- package/dist/test/utils.test.js.map +1 -0
- package/dist/util.d.ts +17 -0
- package/dist/util.js +115 -0
- package/dist/util.js.map +1 -0
- package/jest.config.js +11 -0
- package/package.json +40 -0
- package/src/adaptable.ts +12 -0
- package/src/calc.ts +40 -0
- package/src/data/abilities.ts +383 -0
- package/src/data/index.ts +36 -0
- package/src/data/interface.ts +176 -0
- package/src/data/items.ts +632 -0
- package/src/data/moves.ts +5028 -0
- package/src/data/natures.ts +65 -0
- package/src/data/species.ts +10098 -0
- package/src/data/types.ts +478 -0
- package/src/desc.ts +1063 -0
- package/src/field.ts +124 -0
- package/src/index.ts +156 -0
- package/src/items.ts +423 -0
- package/src/mechanics/gen12.ts +297 -0
- package/src/mechanics/gen3.ts +444 -0
- package/src/mechanics/gen4.ts +702 -0
- package/src/mechanics/gen56.ts +1134 -0
- package/src/mechanics/gen789.ts +1788 -0
- package/src/mechanics/util.ts +676 -0
- package/src/move.ts +337 -0
- package/src/pokemon.ts +244 -0
- package/src/result.ts +106 -0
- package/src/state.ts +81 -0
- package/src/stats.ts +213 -0
- package/src/test/calc.test.ts +1588 -0
- package/src/test/data.test.ts +129 -0
- package/src/test/gen.ts +514 -0
- package/src/test/helper.ts +185 -0
- package/src/test/move.test.ts +13 -0
- package/src/test/pokemon.test.ts +121 -0
- package/src/test/stats.test.ts +84 -0
- package/src/test/utils.test.ts +18 -0
- package/src/util.ts +153 -0
- package/tsconfig.json +10 -0
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@robsonbittencourt/calc",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"unpkg": "dist/production.min.js",
|
|
7
|
+
"description": "Fork from Smogon Damage Calc",
|
|
8
|
+
"repository": "github:robsonbittencourt/damage-calc",
|
|
9
|
+
"contributors": [
|
|
10
|
+
"Austin Couturier <austincouturier@icloud.com>"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@types/node": "^18.14.2"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@pkmn/dex": "^0.9.19",
|
|
18
|
+
"@pkmn/eslint-config": "^2.15.0",
|
|
19
|
+
"@types/jest": "^29.4.0",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
|
21
|
+
"@typescript-eslint/parser": "^5.54.0",
|
|
22
|
+
"eslint": "^8.35.0",
|
|
23
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
24
|
+
"jest": "^29.4.3",
|
|
25
|
+
"ts-jest": "^29.0.5",
|
|
26
|
+
"typescript": "^4.9.5"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"lint": "eslint --cache src --ext ts",
|
|
30
|
+
"fix": "eslint --fix src --ext ts",
|
|
31
|
+
"compile": "tsc -p .",
|
|
32
|
+
"bundle": "node bundle",
|
|
33
|
+
"build": "npm run compile && npm run bundle",
|
|
34
|
+
"test": "jest",
|
|
35
|
+
"coverage": "jest --coverage",
|
|
36
|
+
"prepare": "npm run build",
|
|
37
|
+
"pretest": "npm run build",
|
|
38
|
+
"posttest": "npm run lint"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/adaptable.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// By default, importing `@smogon/calc` provides a convenience wrapper that is roughly equivalent
|
|
2
|
+
// to importing `@smogon/calc/adaptable` and `import Generations from '@smogon/calc/data'` and
|
|
3
|
+
// using `Generations` to populate the `Generation` param to these exports. Alternatively, an
|
|
4
|
+
// application may implement a different `@smogon/calc/data/interface` and pass a `Generation` from
|
|
5
|
+
// that to these exports.
|
|
6
|
+
|
|
7
|
+
export {calculate} from './calc';
|
|
8
|
+
export {Pokemon} from './pokemon';
|
|
9
|
+
export {Move} from './move';
|
|
10
|
+
export {Field, Side} from './field';
|
|
11
|
+
export {Result} from './result';
|
|
12
|
+
export {Stats} from './stats';
|
package/src/calc.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {Field} from './field';
|
|
2
|
+
import type {Generation} from './data/interface';
|
|
3
|
+
import type {Move} from './move';
|
|
4
|
+
import type {Pokemon} from './pokemon';
|
|
5
|
+
import type {Result} from './result';
|
|
6
|
+
|
|
7
|
+
import {calculateRBYGSC} from './mechanics/gen12';
|
|
8
|
+
import {calculateADV} from './mechanics/gen3';
|
|
9
|
+
import {calculateDPP} from './mechanics/gen4';
|
|
10
|
+
import {calculateBWXY} from './mechanics/gen56';
|
|
11
|
+
import {calculateSMSSSV} from './mechanics/gen789';
|
|
12
|
+
|
|
13
|
+
const MECHANICS = [
|
|
14
|
+
() => {},
|
|
15
|
+
calculateRBYGSC,
|
|
16
|
+
calculateRBYGSC,
|
|
17
|
+
calculateADV,
|
|
18
|
+
calculateDPP,
|
|
19
|
+
calculateBWXY,
|
|
20
|
+
calculateBWXY,
|
|
21
|
+
calculateSMSSSV,
|
|
22
|
+
calculateSMSSSV,
|
|
23
|
+
calculateSMSSSV,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export function calculate(
|
|
27
|
+
gen: Generation,
|
|
28
|
+
attacker: Pokemon,
|
|
29
|
+
defender: Pokemon,
|
|
30
|
+
move: Move,
|
|
31
|
+
field?: Field,
|
|
32
|
+
) {
|
|
33
|
+
return MECHANICS[gen.num](
|
|
34
|
+
gen,
|
|
35
|
+
attacker.clone(),
|
|
36
|
+
defender.clone(),
|
|
37
|
+
move.clone(),
|
|
38
|
+
field ? field.clone() : new Field()
|
|
39
|
+
) as Result;
|
|
40
|
+
}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import type * as I from './interface';
|
|
2
|
+
import {toID} from '../util';
|
|
3
|
+
|
|
4
|
+
const RBY: string[] = [];
|
|
5
|
+
|
|
6
|
+
const GSC: string[] = [];
|
|
7
|
+
|
|
8
|
+
const ADV = [
|
|
9
|
+
'Air Lock',
|
|
10
|
+
'Arena Trap',
|
|
11
|
+
'Battle Armor',
|
|
12
|
+
'Blaze',
|
|
13
|
+
'Chlorophyll',
|
|
14
|
+
'Clear Body',
|
|
15
|
+
'Cloud Nine',
|
|
16
|
+
'Color Change',
|
|
17
|
+
'Compound Eyes',
|
|
18
|
+
'Cute Charm',
|
|
19
|
+
'Drizzle',
|
|
20
|
+
'Damp',
|
|
21
|
+
'Drought',
|
|
22
|
+
'Early Bird',
|
|
23
|
+
'Effect Spore',
|
|
24
|
+
'Flame Body',
|
|
25
|
+
'Flash Fire',
|
|
26
|
+
'Forecast',
|
|
27
|
+
'Guts',
|
|
28
|
+
'Huge Power',
|
|
29
|
+
'Hustle',
|
|
30
|
+
'Hyper Cutter',
|
|
31
|
+
'Illuminate',
|
|
32
|
+
'Immunity',
|
|
33
|
+
'Inner Focus',
|
|
34
|
+
'Insomnia',
|
|
35
|
+
'Intimidate',
|
|
36
|
+
'Keen Eye',
|
|
37
|
+
'Levitate',
|
|
38
|
+
'Lightning Rod',
|
|
39
|
+
'Limber',
|
|
40
|
+
'Liquid Ooze',
|
|
41
|
+
'Magma Armor',
|
|
42
|
+
'Magnet Pull',
|
|
43
|
+
'Marvel Scale',
|
|
44
|
+
'Minus',
|
|
45
|
+
'Natural Cure',
|
|
46
|
+
'Oblivious',
|
|
47
|
+
'Overgrow',
|
|
48
|
+
'Own Tempo',
|
|
49
|
+
'Pickup',
|
|
50
|
+
'Plus',
|
|
51
|
+
'Poison Point',
|
|
52
|
+
'Pressure',
|
|
53
|
+
'Pure Power',
|
|
54
|
+
'Rain Dish',
|
|
55
|
+
'Rock Head',
|
|
56
|
+
'Rough Skin',
|
|
57
|
+
'Run Away',
|
|
58
|
+
'Sand Stream',
|
|
59
|
+
'Sand Veil',
|
|
60
|
+
'Serene Grace',
|
|
61
|
+
'Shadow Tag',
|
|
62
|
+
'Shed Skin',
|
|
63
|
+
'Shell Armor',
|
|
64
|
+
'Shield Dust',
|
|
65
|
+
'Soundproof',
|
|
66
|
+
'Speed Boost',
|
|
67
|
+
'Static',
|
|
68
|
+
'Stench',
|
|
69
|
+
'Sticky Hold',
|
|
70
|
+
'Sturdy',
|
|
71
|
+
'Suction Cups',
|
|
72
|
+
'Swarm',
|
|
73
|
+
'Swift Swim',
|
|
74
|
+
'Synchronize',
|
|
75
|
+
'Thick Fat',
|
|
76
|
+
'Torrent',
|
|
77
|
+
'Trace',
|
|
78
|
+
'Truant',
|
|
79
|
+
'Vital Spirit',
|
|
80
|
+
'Volt Absorb',
|
|
81
|
+
'Water Absorb',
|
|
82
|
+
'Water Veil',
|
|
83
|
+
'White Smoke',
|
|
84
|
+
'Wonder Guard',
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
const DPP = ADV.concat([
|
|
88
|
+
'Adaptability',
|
|
89
|
+
'Aftermath',
|
|
90
|
+
'Anger Point',
|
|
91
|
+
'Anticipation',
|
|
92
|
+
'Bad Dreams',
|
|
93
|
+
'Download',
|
|
94
|
+
'Dry Skin',
|
|
95
|
+
'Filter',
|
|
96
|
+
'Flower Gift',
|
|
97
|
+
'Forewarn',
|
|
98
|
+
'Frisk',
|
|
99
|
+
'Gluttony',
|
|
100
|
+
'Heatproof',
|
|
101
|
+
'Honey Gather',
|
|
102
|
+
'Hydration',
|
|
103
|
+
'Ice Body',
|
|
104
|
+
'Iron Fist',
|
|
105
|
+
'Klutz',
|
|
106
|
+
'Leaf Guard',
|
|
107
|
+
'Magic Guard',
|
|
108
|
+
'Mold Breaker',
|
|
109
|
+
'Motor Drive',
|
|
110
|
+
'Mountaineer',
|
|
111
|
+
'Multitype',
|
|
112
|
+
'No Guard',
|
|
113
|
+
'Normalize',
|
|
114
|
+
'Persistent',
|
|
115
|
+
'Poison Heal',
|
|
116
|
+
'Quick Feet',
|
|
117
|
+
'Rebound',
|
|
118
|
+
'Reckless',
|
|
119
|
+
'Rivalry',
|
|
120
|
+
'Scrappy',
|
|
121
|
+
'Simple',
|
|
122
|
+
'Skill Link',
|
|
123
|
+
'Slow Start',
|
|
124
|
+
'Sniper',
|
|
125
|
+
'Snow Cloak',
|
|
126
|
+
'Snow Warning',
|
|
127
|
+
'Solar Power',
|
|
128
|
+
'Solid Rock',
|
|
129
|
+
'Stall',
|
|
130
|
+
'Steadfast',
|
|
131
|
+
'Storm Drain',
|
|
132
|
+
'Super Luck',
|
|
133
|
+
'Tangled Feet',
|
|
134
|
+
'Technician',
|
|
135
|
+
'Tinted Lens',
|
|
136
|
+
'Unaware',
|
|
137
|
+
'Unburden',
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
const BW = DPP.concat([
|
|
141
|
+
'Analytic',
|
|
142
|
+
'Big Pecks',
|
|
143
|
+
'Contrary',
|
|
144
|
+
'Cursed Body',
|
|
145
|
+
'Defeatist',
|
|
146
|
+
'Defiant',
|
|
147
|
+
'Flare Boost',
|
|
148
|
+
'Friend Guard',
|
|
149
|
+
'Harvest',
|
|
150
|
+
'Healer',
|
|
151
|
+
'Heavy Metal',
|
|
152
|
+
'Illusion',
|
|
153
|
+
'Imposter',
|
|
154
|
+
'Infiltrator',
|
|
155
|
+
'Iron Barbs',
|
|
156
|
+
'Light Metal',
|
|
157
|
+
'Justified',
|
|
158
|
+
'Magic Bounce',
|
|
159
|
+
'Moody',
|
|
160
|
+
'Moxie',
|
|
161
|
+
'Multiscale',
|
|
162
|
+
'Mummy',
|
|
163
|
+
'Overcoat',
|
|
164
|
+
'Pickpocket',
|
|
165
|
+
'Poison Touch',
|
|
166
|
+
'Prankster',
|
|
167
|
+
'Rattled',
|
|
168
|
+
'Regenerator',
|
|
169
|
+
'Sand Force',
|
|
170
|
+
'Sand Rush',
|
|
171
|
+
'Sap Sipper',
|
|
172
|
+
'Sheer Force',
|
|
173
|
+
'Telepathy',
|
|
174
|
+
'Teravolt',
|
|
175
|
+
'Toxic Boost',
|
|
176
|
+
'Turboblaze',
|
|
177
|
+
'Unnerve',
|
|
178
|
+
'Victory Star',
|
|
179
|
+
'Weak Armor',
|
|
180
|
+
'Wonder Skin',
|
|
181
|
+
'Zen Mode',
|
|
182
|
+
]);
|
|
183
|
+
|
|
184
|
+
const XY = BW.concat([
|
|
185
|
+
'Aerilate',
|
|
186
|
+
'Aura Break',
|
|
187
|
+
'Aroma Veil',
|
|
188
|
+
'Bulletproof',
|
|
189
|
+
'Cheek Pouch',
|
|
190
|
+
'Competitive',
|
|
191
|
+
'Dark Aura',
|
|
192
|
+
'Delta Stream',
|
|
193
|
+
'Desolate Land',
|
|
194
|
+
'Fairy Aura',
|
|
195
|
+
'Flower Veil',
|
|
196
|
+
'Fur Coat',
|
|
197
|
+
'Gale Wings',
|
|
198
|
+
'Gooey',
|
|
199
|
+
'Grass Pelt',
|
|
200
|
+
'Magician',
|
|
201
|
+
'Mega Launcher',
|
|
202
|
+
'Parental Bond',
|
|
203
|
+
'Pixilate',
|
|
204
|
+
'Primordial Sea',
|
|
205
|
+
'Protean',
|
|
206
|
+
'Refrigerate',
|
|
207
|
+
'Stance Change',
|
|
208
|
+
'Strong Jaw',
|
|
209
|
+
'Sweet Veil',
|
|
210
|
+
'Symbiosis',
|
|
211
|
+
'Tough Claws',
|
|
212
|
+
]);
|
|
213
|
+
|
|
214
|
+
const SM = XY.concat([
|
|
215
|
+
'Battery',
|
|
216
|
+
'Battle Bond',
|
|
217
|
+
'Beast Boost',
|
|
218
|
+
'Berserk',
|
|
219
|
+
'Comatose',
|
|
220
|
+
'Corrosion',
|
|
221
|
+
'Dancer',
|
|
222
|
+
'Dazzling',
|
|
223
|
+
'Disguise',
|
|
224
|
+
'Electric Surge',
|
|
225
|
+
'Emergency Exit',
|
|
226
|
+
'Fluffy',
|
|
227
|
+
'Full Metal Body',
|
|
228
|
+
'Galvanize',
|
|
229
|
+
'Grassy Surge',
|
|
230
|
+
'Innards Out',
|
|
231
|
+
'Liquid Voice',
|
|
232
|
+
'Long Reach',
|
|
233
|
+
'Merciless',
|
|
234
|
+
'Misty Surge',
|
|
235
|
+
'Neuroforce',
|
|
236
|
+
'Power Construct',
|
|
237
|
+
'Power of Alchemy',
|
|
238
|
+
'Prism Armor',
|
|
239
|
+
'Psychic Surge',
|
|
240
|
+
'Queenly Majesty',
|
|
241
|
+
'RKS System',
|
|
242
|
+
'Receiver',
|
|
243
|
+
'Schooling',
|
|
244
|
+
'Shadow Shield',
|
|
245
|
+
'Shields Down',
|
|
246
|
+
'Slush Rush',
|
|
247
|
+
'Stamina',
|
|
248
|
+
'Stakeout',
|
|
249
|
+
'Steelworker',
|
|
250
|
+
'Soul-Heart',
|
|
251
|
+
'Surge Surfer',
|
|
252
|
+
'Tangling Hair',
|
|
253
|
+
'Triage',
|
|
254
|
+
'Water Bubble',
|
|
255
|
+
'Water Compaction',
|
|
256
|
+
'Wimp Out',
|
|
257
|
+
]);
|
|
258
|
+
|
|
259
|
+
const SS = SM.concat([
|
|
260
|
+
'As One (Glastrier)',
|
|
261
|
+
'As One (Spectrier)',
|
|
262
|
+
'Ball Fetch',
|
|
263
|
+
'Chilling Neigh',
|
|
264
|
+
'Cotton Down',
|
|
265
|
+
'Curious Medicine',
|
|
266
|
+
'Dauntless Shield',
|
|
267
|
+
'Dragon\'s Maw',
|
|
268
|
+
'Gorilla Tactics',
|
|
269
|
+
'Grim Neigh',
|
|
270
|
+
'Gulp Missile',
|
|
271
|
+
'Hunger Switch',
|
|
272
|
+
'Ice Face',
|
|
273
|
+
'Ice Scales',
|
|
274
|
+
'Intrepid Sword',
|
|
275
|
+
'Libero',
|
|
276
|
+
'Mimicry',
|
|
277
|
+
'Mirror Armor',
|
|
278
|
+
'Neutralizing Gas',
|
|
279
|
+
'Pastel Veil',
|
|
280
|
+
'Perish Body',
|
|
281
|
+
'Power Spot',
|
|
282
|
+
'Propeller Tail',
|
|
283
|
+
'Punk Rock',
|
|
284
|
+
'Quick Draw',
|
|
285
|
+
'Ripen',
|
|
286
|
+
'Sand Spit',
|
|
287
|
+
'Screen Cleaner',
|
|
288
|
+
'Stalwart',
|
|
289
|
+
'Steam Engine',
|
|
290
|
+
'Steely Spirit',
|
|
291
|
+
'Transistor',
|
|
292
|
+
'Unseen Fist',
|
|
293
|
+
'Wandering Spirit',
|
|
294
|
+
]);
|
|
295
|
+
|
|
296
|
+
const SV = SS.concat([
|
|
297
|
+
'Anger Shell',
|
|
298
|
+
'Armor Tail',
|
|
299
|
+
'Beads of Ruin',
|
|
300
|
+
'Commander',
|
|
301
|
+
'Costar',
|
|
302
|
+
'Cud Chew',
|
|
303
|
+
'Earth Eater',
|
|
304
|
+
'Electromorphosis',
|
|
305
|
+
'Embody Aspect (Cornerstone)',
|
|
306
|
+
'Embody Aspect (Hearthflame)',
|
|
307
|
+
'Embody Aspect (Teal)',
|
|
308
|
+
'Embody Aspect (Wellspring)',
|
|
309
|
+
'Good as Gold',
|
|
310
|
+
'Guard Dog',
|
|
311
|
+
'Hadron Engine',
|
|
312
|
+
'Hospitality',
|
|
313
|
+
'Lingering Aroma',
|
|
314
|
+
'Mind\'s Eye',
|
|
315
|
+
'Mycelium Might',
|
|
316
|
+
'Opportunist',
|
|
317
|
+
'Orichalcum Pulse',
|
|
318
|
+
'Poison Puppeteer',
|
|
319
|
+
'Protosynthesis',
|
|
320
|
+
'Purifying Salt',
|
|
321
|
+
'Quark Drive',
|
|
322
|
+
'Rocky Payload',
|
|
323
|
+
'Seed Sower',
|
|
324
|
+
'Sharpness',
|
|
325
|
+
'Supersweet Syrup',
|
|
326
|
+
'Supreme Overlord',
|
|
327
|
+
'Sword of Ruin',
|
|
328
|
+
'Tablets of Ruin',
|
|
329
|
+
'Tera Shell',
|
|
330
|
+
'Tera Shift',
|
|
331
|
+
'Teraform Zero',
|
|
332
|
+
'Thermal Exchange',
|
|
333
|
+
'Toxic Chain',
|
|
334
|
+
'Toxic Debris',
|
|
335
|
+
'Vessel of Ruin',
|
|
336
|
+
'Well-Baked Body',
|
|
337
|
+
'Wind Power',
|
|
338
|
+
'Wind Rider',
|
|
339
|
+
'Zero to Hero',
|
|
340
|
+
]);
|
|
341
|
+
|
|
342
|
+
export const ABILITIES = [[], RBY, GSC, ADV, DPP, BW, XY, SM, SS, SV];
|
|
343
|
+
|
|
344
|
+
export class Abilities implements I.Abilities {
|
|
345
|
+
private readonly gen: I.GenerationNum;
|
|
346
|
+
|
|
347
|
+
constructor(gen: I.GenerationNum) {
|
|
348
|
+
this.gen = gen;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
get(id: I.ID) {
|
|
352
|
+
return ABILITIES_BY_ID[this.gen][id];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
*[Symbol.iterator]() {
|
|
356
|
+
for (const id in ABILITIES_BY_ID[this.gen]) {
|
|
357
|
+
yield this.get(id as I.ID)!;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
class Ability implements I.Ability {
|
|
363
|
+
readonly kind: 'Ability';
|
|
364
|
+
readonly id: I.ID;
|
|
365
|
+
readonly name: I.AbilityName;
|
|
366
|
+
|
|
367
|
+
constructor(name: string) {
|
|
368
|
+
this.kind = 'Ability';
|
|
369
|
+
this.id = toID(name);
|
|
370
|
+
this.name = name as I.AbilityName;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const ABILITIES_BY_ID: Array<{[id: string]: Ability}> = [];
|
|
375
|
+
|
|
376
|
+
for (const abilities of ABILITIES) {
|
|
377
|
+
const map: {[id: string]: Ability} = {};
|
|
378
|
+
for (const ability of abilities) {
|
|
379
|
+
const a = new Ability(ability);
|
|
380
|
+
map[a.id] = a;
|
|
381
|
+
}
|
|
382
|
+
ABILITIES_BY_ID.push(map);
|
|
383
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as I from './interface';
|
|
2
|
+
|
|
3
|
+
import {Abilities} from './abilities';
|
|
4
|
+
import {Items} from './items';
|
|
5
|
+
import {Moves} from './moves';
|
|
6
|
+
import {Species} from './species';
|
|
7
|
+
import {Types} from './types';
|
|
8
|
+
import {Natures} from './natures';
|
|
9
|
+
|
|
10
|
+
export const Generations: I.Generations = new (class {
|
|
11
|
+
get(gen: I.GenerationNum) {
|
|
12
|
+
return new Generation(gen);
|
|
13
|
+
}
|
|
14
|
+
})();
|
|
15
|
+
|
|
16
|
+
class Generation implements I.Generation {
|
|
17
|
+
num: I.GenerationNum;
|
|
18
|
+
|
|
19
|
+
abilities: Abilities;
|
|
20
|
+
items: Items;
|
|
21
|
+
moves: Moves;
|
|
22
|
+
species: Species;
|
|
23
|
+
types: Types;
|
|
24
|
+
natures: Natures;
|
|
25
|
+
|
|
26
|
+
constructor(num: I.GenerationNum) {
|
|
27
|
+
this.num = num;
|
|
28
|
+
|
|
29
|
+
this.abilities = new Abilities(num);
|
|
30
|
+
this.items = new Items(num);
|
|
31
|
+
this.moves = new Moves(num);
|
|
32
|
+
this.species = new Species(num);
|
|
33
|
+
this.types = new Types(num);
|
|
34
|
+
this.natures = new Natures();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
export interface As<T> {__brand: T}
|
|
2
|
+
export type ID = (string & As<'ID'>) | (string & { __isID: true }) | '';
|
|
3
|
+
export type GenerationNum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
4
|
+
export type GenderName = 'M' | 'F' | 'N';
|
|
5
|
+
export type StatID = 'hp' | StatIDExceptHP;
|
|
6
|
+
export type StatIDExceptHP = 'atk' | 'def' | 'spa' | 'spd' | 'spe';
|
|
7
|
+
export type StatsTable<T = number> = {[stat in StatID]: T};
|
|
8
|
+
|
|
9
|
+
export type AbilityName = string & As<'AbilityName'>;
|
|
10
|
+
export type ItemName = string & As<'ItemName'>;
|
|
11
|
+
export type MoveName = string & As<'MoveName'>;
|
|
12
|
+
export type SpeciesName = string & As<'SpeciesName'>;
|
|
13
|
+
|
|
14
|
+
export type StatusName = 'slp' | 'psn' | 'brn' | 'frz' | 'par' | 'tox';
|
|
15
|
+
|
|
16
|
+
export type GameType = 'Singles' | 'Doubles';
|
|
17
|
+
export type Terrain = 'Electric' | 'Grassy' | 'Psychic' | 'Misty';
|
|
18
|
+
export type Weather =
|
|
19
|
+
| 'Sand' | 'Sun' | 'Rain' | 'Hail' | 'Snow' | 'Harsh Sunshine' | 'Heavy Rain' | 'Strong Winds';
|
|
20
|
+
|
|
21
|
+
export type NatureName =
|
|
22
|
+
'Adamant' | 'Bashful' | 'Bold' | 'Brave' | 'Calm' |
|
|
23
|
+
'Careful' | 'Docile' | 'Gentle' | 'Hardy' | 'Hasty' |
|
|
24
|
+
'Impish' | 'Jolly' | 'Lax' | 'Lonely' | 'Mild' |
|
|
25
|
+
'Modest' | 'Naive' | 'Naughty' | 'Quiet' | 'Quirky' |
|
|
26
|
+
'Rash' | 'Relaxed' | 'Sassy' | 'Serious' | 'Timid';
|
|
27
|
+
|
|
28
|
+
export type TypeName =
|
|
29
|
+
'Normal' | 'Fighting' | 'Flying' | 'Poison' | 'Ground' | 'Rock' | 'Bug' | 'Ghost' | 'Steel' |
|
|
30
|
+
'Fire' | 'Water' | 'Grass' | 'Electric' | 'Psychic' | 'Ice' | 'Dragon' | 'Dark' | 'Fairy' |
|
|
31
|
+
'Stellar' | '???';
|
|
32
|
+
|
|
33
|
+
export type MoveCategory = 'Physical' | 'Special' | 'Status';
|
|
34
|
+
|
|
35
|
+
export type MoveTarget =
|
|
36
|
+
'adjacentAlly' | 'adjacentAllyOrSelf' | 'adjacentFoe' | 'all' |
|
|
37
|
+
'allAdjacent' | 'allAdjacentFoes' | 'allies' | 'allySide' | 'allyTeam' |
|
|
38
|
+
'any' | 'foeSide' | 'normal' | 'randomNormal' | 'scripted' | 'self';
|
|
39
|
+
|
|
40
|
+
export interface Generations {
|
|
41
|
+
get(gen: GenerationNum): Generation;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Generation {
|
|
45
|
+
readonly num: GenerationNum;
|
|
46
|
+
readonly abilities: Abilities;
|
|
47
|
+
readonly items: Items;
|
|
48
|
+
readonly moves: Moves;
|
|
49
|
+
readonly species: Species;
|
|
50
|
+
readonly types: Types;
|
|
51
|
+
readonly natures: Natures;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type DataKind = 'Ability' | 'Item' | 'Move' | 'Species' | 'Type' | 'Nature';
|
|
55
|
+
|
|
56
|
+
export interface Data<NameT> {
|
|
57
|
+
readonly id: ID;
|
|
58
|
+
readonly name: NameT;
|
|
59
|
+
readonly kind: DataKind;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface Abilities {
|
|
63
|
+
get(id: ID): Ability | undefined;
|
|
64
|
+
[Symbol.iterator](): IterableIterator<Ability>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface Ability extends Data<AbilityName> {
|
|
68
|
+
readonly kind: 'Ability';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface Items {
|
|
72
|
+
get(id: ID): Item | undefined;
|
|
73
|
+
[Symbol.iterator](): IterableIterator<Item>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface Item extends Data<ItemName> {
|
|
77
|
+
readonly kind: 'Item';
|
|
78
|
+
readonly megaEvolves?: SpeciesName;
|
|
79
|
+
readonly isBerry?: boolean;
|
|
80
|
+
readonly naturalGift?: Readonly<{basePower: number; type: TypeName}>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface Moves {
|
|
84
|
+
get(id: ID): Move | undefined;
|
|
85
|
+
[Symbol.iterator](): IterableIterator<Move>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface MoveFlags {
|
|
89
|
+
contact?: 1 | 0;
|
|
90
|
+
bite?: 1 | 0;
|
|
91
|
+
sound?: 1 | 0;
|
|
92
|
+
// TODO: heal?: 1 | 0;
|
|
93
|
+
punch?: 1 | 0;
|
|
94
|
+
bullet?: 1 | 0;
|
|
95
|
+
pulse?: 1 | 0;
|
|
96
|
+
slicing?: 1 | 0;
|
|
97
|
+
wind?: 1| 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SelfOrSecondaryEffect {
|
|
101
|
+
boosts?: Partial<StatsTable>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface Move extends Data<MoveName> {
|
|
105
|
+
readonly kind: 'Move';
|
|
106
|
+
readonly basePower: number;
|
|
107
|
+
readonly type: TypeName;
|
|
108
|
+
readonly category?: MoveCategory;
|
|
109
|
+
readonly flags: MoveFlags;
|
|
110
|
+
readonly secondaries?: any;
|
|
111
|
+
readonly target?: MoveTarget;
|
|
112
|
+
readonly recoil?: [number, number];
|
|
113
|
+
readonly hasCrashDamage?: boolean;
|
|
114
|
+
readonly mindBlownRecoil?: boolean;
|
|
115
|
+
readonly struggleRecoil?: boolean;
|
|
116
|
+
readonly willCrit?: boolean;
|
|
117
|
+
readonly drain?: [number, number];
|
|
118
|
+
readonly priority?: number;
|
|
119
|
+
readonly self?: SelfOrSecondaryEffect | null;
|
|
120
|
+
readonly ignoreDefensive?: boolean;
|
|
121
|
+
readonly overrideOffensiveStat?: StatIDExceptHP;
|
|
122
|
+
readonly overrideDefensiveStat?: StatIDExceptHP;
|
|
123
|
+
readonly overrideOffensivePokemon?: 'target' | 'source';
|
|
124
|
+
readonly overrideDefensivePokemon?: 'target' | 'source';
|
|
125
|
+
readonly breaksProtect?: boolean;
|
|
126
|
+
readonly isZ?: boolean | string;
|
|
127
|
+
readonly zMove?: {
|
|
128
|
+
basePower?: number;
|
|
129
|
+
};
|
|
130
|
+
readonly isMax?: boolean | string;
|
|
131
|
+
readonly maxMove?: {
|
|
132
|
+
basePower: number;
|
|
133
|
+
};
|
|
134
|
+
readonly multihit?: number | number[];
|
|
135
|
+
readonly multiaccuracy?: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface Species {
|
|
139
|
+
get(id: ID): Specie | undefined;
|
|
140
|
+
[Symbol.iterator](): IterableIterator<Specie>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface Specie extends Data<SpeciesName> {
|
|
144
|
+
readonly kind: 'Species';
|
|
145
|
+
readonly types: [TypeName] | [TypeName, TypeName];
|
|
146
|
+
readonly baseStats: Readonly<StatsTable>;
|
|
147
|
+
readonly weightkg: number;
|
|
148
|
+
readonly nfe?: boolean;
|
|
149
|
+
readonly gender?: GenderName;
|
|
150
|
+
readonly otherFormes?: SpeciesName[];
|
|
151
|
+
readonly baseSpecies?: SpeciesName;
|
|
152
|
+
readonly abilities?: {0: AbilityName | ''};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface Types {
|
|
156
|
+
get(id: ID): Type | undefined;
|
|
157
|
+
[Symbol.iterator](): IterableIterator<Type>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type TypeEffectiveness = 0 | 0.5 | 1 | 2;
|
|
161
|
+
|
|
162
|
+
export interface Type extends Data<TypeName> {
|
|
163
|
+
readonly kind: 'Type';
|
|
164
|
+
readonly effectiveness: Readonly<{[type in TypeName]?: TypeEffectiveness}>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface Natures {
|
|
168
|
+
get(id: ID): Nature | undefined;
|
|
169
|
+
[Symbol.iterator](): IterableIterator<Nature>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface Nature extends Data<NatureName> {
|
|
173
|
+
readonly kind: 'Nature';
|
|
174
|
+
readonly plus?: StatID;
|
|
175
|
+
readonly minus?: StatID;
|
|
176
|
+
}
|