@pkmn/sim 0.8.3 → 0.8.5

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 (286) hide show
  1. package/build/cjs/config/formats.js +163 -212
  2. package/build/cjs/config/formats.js.map +1 -1
  3. package/build/cjs/data/abilities.js +370 -165
  4. package/build/cjs/data/abilities.js.map +1 -1
  5. package/build/cjs/data/conditions.js +0 -3
  6. package/build/cjs/data/conditions.js.map +1 -1
  7. package/build/cjs/data/formats-data.js +330 -312
  8. package/build/cjs/data/formats-data.js.map +1 -1
  9. package/build/cjs/data/items.js +2 -2
  10. package/build/cjs/data/items.js.map +1 -1
  11. package/build/cjs/data/legality.js +424 -104
  12. package/build/cjs/data/legality.js.map +1 -1
  13. package/build/cjs/data/mods/gen1/formats-data.js +22 -22
  14. package/build/cjs/data/mods/gen1/moves.js +6 -8
  15. package/build/cjs/data/mods/gen1/moves.js.map +1 -1
  16. package/build/cjs/data/mods/gen2/formats-data.js +43 -43
  17. package/build/cjs/data/mods/gen2/formats-data.js.map +1 -1
  18. package/build/cjs/data/mods/gen2/moves.js +4 -7
  19. package/build/cjs/data/mods/gen2/moves.js.map +1 -1
  20. package/build/cjs/data/mods/gen3/abilities.js +6 -5
  21. package/build/cjs/data/mods/gen3/abilities.js.map +1 -1
  22. package/build/cjs/data/mods/gen3/formats-data.js +32 -32
  23. package/build/cjs/data/mods/gen3/formats-data.js.map +1 -1
  24. package/build/cjs/data/mods/gen3/moves.js +15 -10
  25. package/build/cjs/data/mods/gen3/moves.js.map +1 -1
  26. package/build/cjs/data/mods/gen3/scripts.js +11 -6
  27. package/build/cjs/data/mods/gen3/scripts.js.map +1 -1
  28. package/build/cjs/data/mods/gen4/abilities.js +8 -2
  29. package/build/cjs/data/mods/gen4/abilities.js.map +1 -1
  30. package/build/cjs/data/mods/gen4/moves.js +49 -45
  31. package/build/cjs/data/mods/gen4/moves.js.map +1 -1
  32. package/build/cjs/data/mods/gen4/scripts.js +11 -6
  33. package/build/cjs/data/mods/gen4/scripts.js.map +1 -1
  34. package/build/cjs/data/mods/gen5/abilities.js +1 -0
  35. package/build/cjs/data/mods/gen5/abilities.js.map +1 -1
  36. package/build/cjs/data/mods/gen5/moves.js +44 -66
  37. package/build/cjs/data/mods/gen5/moves.js.map +1 -1
  38. package/build/cjs/data/mods/gen6/abilities.js +1 -1
  39. package/build/cjs/data/mods/gen6/abilities.js.map +1 -1
  40. package/build/cjs/data/mods/gen6/moves.js +1 -1
  41. package/build/cjs/data/mods/gen6/moves.js.map +1 -1
  42. package/build/cjs/data/mods/gen7/abilities.js +2 -2
  43. package/build/cjs/data/mods/gen7/abilities.js.map +1 -1
  44. package/build/cjs/data/mods/gen7/moves.js +21 -9
  45. package/build/cjs/data/mods/gen7/moves.js.map +1 -1
  46. package/build/cjs/data/mods/gen8/abilities.js +3 -1
  47. package/build/cjs/data/mods/gen8/abilities.js.map +1 -1
  48. package/build/cjs/data/mods/gen8/moves.js +6 -2
  49. package/build/cjs/data/mods/gen8/moves.js.map +1 -1
  50. package/build/cjs/data/moves.js +760 -770
  51. package/build/cjs/data/moves.js.map +1 -1
  52. package/build/cjs/data/rulesets.js +33 -56
  53. package/build/cjs/data/rulesets.js.map +1 -1
  54. package/build/cjs/data/text/abilities.js +34 -12
  55. package/build/cjs/data/text/abilities.js.map +1 -1
  56. package/build/cjs/data/text/moves.js +9 -9
  57. package/build/cjs/data/text/moves.js.map +1 -1
  58. package/build/cjs/sim/battle-actions.js +21 -21
  59. package/build/cjs/sim/battle-actions.js.map +1 -1
  60. package/build/cjs/sim/battle.js +4 -5
  61. package/build/cjs/sim/battle.js.map +1 -1
  62. package/build/cjs/sim/dex-abilities.d.ts +11 -2
  63. package/build/cjs/sim/dex-abilities.js +1 -0
  64. package/build/cjs/sim/dex-abilities.js.map +1 -1
  65. package/build/cjs/sim/dex-conditions.d.ts +6 -0
  66. package/build/cjs/sim/dex-conditions.js.map +1 -1
  67. package/build/cjs/sim/dex-formats.d.ts +2 -0
  68. package/build/cjs/sim/dex-formats.js +1 -0
  69. package/build/cjs/sim/dex-formats.js.map +1 -1
  70. package/build/cjs/sim/dex-moves.d.ts +1 -4
  71. package/build/cjs/sim/dex-moves.js +0 -1
  72. package/build/cjs/sim/dex-moves.js.map +1 -1
  73. package/build/cjs/sim/exported-global-types.d.ts +2 -2
  74. package/build/cjs/sim/global-types.d.ts +2 -2
  75. package/build/cjs/sim/pokemon.js +7 -4
  76. package/build/cjs/sim/pokemon.js.map +1 -1
  77. package/build/cjs/sim/team-validator.js +1 -1
  78. package/build/cjs/sim/team-validator.js.map +1 -1
  79. package/build/cjs/sim/tools/runner.js +1 -1
  80. package/build/cjs/sim/tools/runner.js.map +1 -1
  81. package/build/esm/config/formats.mjs +163 -212
  82. package/build/esm/config/formats.mjs.map +1 -1
  83. package/build/esm/data/abilities.mjs +370 -165
  84. package/build/esm/data/abilities.mjs.map +1 -1
  85. package/build/esm/data/conditions.mjs +0 -3
  86. package/build/esm/data/conditions.mjs.map +1 -1
  87. package/build/esm/data/formats-data.mjs +330 -312
  88. package/build/esm/data/formats-data.mjs.map +1 -1
  89. package/build/esm/data/items.mjs +2 -2
  90. package/build/esm/data/items.mjs.map +1 -1
  91. package/build/esm/data/legality.mjs +424 -104
  92. package/build/esm/data/legality.mjs.map +1 -1
  93. package/build/esm/data/mods/gen1/formats-data.mjs +22 -22
  94. package/build/esm/data/mods/gen1/moves.mjs +6 -8
  95. package/build/esm/data/mods/gen1/moves.mjs.map +1 -1
  96. package/build/esm/data/mods/gen2/formats-data.mjs +43 -43
  97. package/build/esm/data/mods/gen2/formats-data.mjs.map +1 -1
  98. package/build/esm/data/mods/gen2/moves.mjs +4 -7
  99. package/build/esm/data/mods/gen2/moves.mjs.map +1 -1
  100. package/build/esm/data/mods/gen3/abilities.mjs +6 -5
  101. package/build/esm/data/mods/gen3/abilities.mjs.map +1 -1
  102. package/build/esm/data/mods/gen3/formats-data.mjs +32 -32
  103. package/build/esm/data/mods/gen3/formats-data.mjs.map +1 -1
  104. package/build/esm/data/mods/gen3/moves.mjs +15 -10
  105. package/build/esm/data/mods/gen3/moves.mjs.map +1 -1
  106. package/build/esm/data/mods/gen3/scripts.mjs +11 -6
  107. package/build/esm/data/mods/gen3/scripts.mjs.map +1 -1
  108. package/build/esm/data/mods/gen4/abilities.mjs +8 -2
  109. package/build/esm/data/mods/gen4/abilities.mjs.map +1 -1
  110. package/build/esm/data/mods/gen4/moves.mjs +49 -45
  111. package/build/esm/data/mods/gen4/moves.mjs.map +1 -1
  112. package/build/esm/data/mods/gen4/scripts.mjs +11 -6
  113. package/build/esm/data/mods/gen4/scripts.mjs.map +1 -1
  114. package/build/esm/data/mods/gen5/abilities.mjs +1 -0
  115. package/build/esm/data/mods/gen5/abilities.mjs.map +1 -1
  116. package/build/esm/data/mods/gen5/moves.mjs +44 -66
  117. package/build/esm/data/mods/gen5/moves.mjs.map +1 -1
  118. package/build/esm/data/mods/gen6/abilities.mjs +1 -1
  119. package/build/esm/data/mods/gen6/abilities.mjs.map +1 -1
  120. package/build/esm/data/mods/gen6/moves.mjs +1 -1
  121. package/build/esm/data/mods/gen6/moves.mjs.map +1 -1
  122. package/build/esm/data/mods/gen7/abilities.mjs +2 -2
  123. package/build/esm/data/mods/gen7/abilities.mjs.map +1 -1
  124. package/build/esm/data/mods/gen7/moves.mjs +21 -9
  125. package/build/esm/data/mods/gen7/moves.mjs.map +1 -1
  126. package/build/esm/data/mods/gen8/abilities.mjs +3 -1
  127. package/build/esm/data/mods/gen8/abilities.mjs.map +1 -1
  128. package/build/esm/data/mods/gen8/moves.mjs +6 -2
  129. package/build/esm/data/mods/gen8/moves.mjs.map +1 -1
  130. package/build/esm/data/moves.mjs +760 -770
  131. package/build/esm/data/moves.mjs.map +1 -1
  132. package/build/esm/data/rulesets.mjs +33 -56
  133. package/build/esm/data/rulesets.mjs.map +1 -1
  134. package/build/esm/data/text/abilities.mjs +34 -12
  135. package/build/esm/data/text/abilities.mjs.map +1 -1
  136. package/build/esm/data/text/moves.mjs +9 -9
  137. package/build/esm/data/text/moves.mjs.map +1 -1
  138. package/build/esm/sim/battle-actions.mjs +21 -21
  139. package/build/esm/sim/battle-actions.mjs.map +1 -1
  140. package/build/esm/sim/battle.mjs +4 -5
  141. package/build/esm/sim/battle.mjs.map +1 -1
  142. package/build/esm/sim/dex-abilities.d.mts +11 -2
  143. package/build/esm/sim/dex-abilities.mjs +1 -0
  144. package/build/esm/sim/dex-abilities.mjs.map +1 -1
  145. package/build/esm/sim/dex-conditions.d.mts +6 -0
  146. package/build/esm/sim/dex-conditions.mjs.map +1 -1
  147. package/build/esm/sim/dex-formats.d.mts +2 -0
  148. package/build/esm/sim/dex-formats.mjs +1 -0
  149. package/build/esm/sim/dex-formats.mjs.map +1 -1
  150. package/build/esm/sim/dex-moves.d.mts +1 -4
  151. package/build/esm/sim/dex-moves.mjs +0 -1
  152. package/build/esm/sim/dex-moves.mjs.map +1 -1
  153. package/build/esm/sim/exported-global-types.d.mts +2 -2
  154. package/build/esm/sim/global-types.d.mts +2 -2
  155. package/build/esm/sim/pokemon.mjs +7 -4
  156. package/build/esm/sim/pokemon.mjs.map +1 -1
  157. package/build/esm/sim/team-validator.mjs +1 -1
  158. package/build/esm/sim/team-validator.mjs.map +1 -1
  159. package/build/esm/sim/tools/runner.mjs +1 -1
  160. package/build/esm/sim/tools/runner.mjs.map +1 -1
  161. package/package.json +1 -1
  162. package/build/types/config/formats.d.ts +0 -1
  163. package/build/types/data/abilities.d.ts +0 -3
  164. package/build/types/data/aliases.d.ts +0 -3
  165. package/build/types/data/conditions.d.ts +0 -3
  166. package/build/types/data/formats-data.d.ts +0 -3
  167. package/build/types/data/index.d.ts +0 -11
  168. package/build/types/data/items.d.ts +0 -3
  169. package/build/types/data/learnsets.d.ts +0 -3
  170. package/build/types/data/legality.d.ts +0 -3
  171. package/build/types/data/mods/gen1/conditions.d.ts +0 -12
  172. package/build/types/data/mods/gen1/formats-data.d.ts +0 -3
  173. package/build/types/data/mods/gen1/index.d.ts +0 -7
  174. package/build/types/data/mods/gen1/moves.d.ts +0 -7
  175. package/build/types/data/mods/gen1/pokedex.d.ts +0 -3
  176. package/build/types/data/mods/gen1/rulesets.d.ts +0 -3
  177. package/build/types/data/mods/gen1/scripts.d.ts +0 -6
  178. package/build/types/data/mods/gen1/typechart.d.ts +0 -10
  179. package/build/types/data/mods/gen2/conditions.d.ts +0 -3
  180. package/build/types/data/mods/gen2/formats-data.d.ts +0 -3
  181. package/build/types/data/mods/gen2/index.d.ts +0 -8
  182. package/build/types/data/mods/gen2/items.d.ts +0 -3
  183. package/build/types/data/mods/gen2/learnsets.d.ts +0 -3
  184. package/build/types/data/mods/gen2/legality.d.ts +0 -3
  185. package/build/types/data/mods/gen2/moves.d.ts +0 -6
  186. package/build/types/data/mods/gen2/pokedex.d.ts +0 -3
  187. package/build/types/data/mods/gen2/rulesets.d.ts +0 -3
  188. package/build/types/data/mods/gen2/scripts.d.ts +0 -4
  189. package/build/types/data/mods/gen2/typechart.d.ts +0 -3
  190. package/build/types/data/mods/gen3/abilities.d.ts +0 -3
  191. package/build/types/data/mods/gen3/conditions.d.ts +0 -3
  192. package/build/types/data/mods/gen3/formats-data.d.ts +0 -3
  193. package/build/types/data/mods/gen3/index.d.ts +0 -7
  194. package/build/types/data/mods/gen3/items.d.ts +0 -3
  195. package/build/types/data/mods/gen3/moves.d.ts +0 -6
  196. package/build/types/data/mods/gen3/rulesets.d.ts +0 -3
  197. package/build/types/data/mods/gen3/scripts.d.ts +0 -1
  198. package/build/types/data/mods/gen4/abilities.d.ts +0 -3
  199. package/build/types/data/mods/gen4/conditions.d.ts +0 -3
  200. package/build/types/data/mods/gen4/formats-data.d.ts +0 -3
  201. package/build/types/data/mods/gen4/index.d.ts +0 -8
  202. package/build/types/data/mods/gen4/items.d.ts +0 -3
  203. package/build/types/data/mods/gen4/moves.d.ts +0 -3
  204. package/build/types/data/mods/gen4/pokedex.d.ts +0 -3
  205. package/build/types/data/mods/gen4/rulesets.d.ts +0 -3
  206. package/build/types/data/mods/gen4/scripts.d.ts +0 -1
  207. package/build/types/data/mods/gen5/abilities.d.ts +0 -3
  208. package/build/types/data/mods/gen5/conditions.d.ts +0 -3
  209. package/build/types/data/mods/gen5/formats-data.d.ts +0 -3
  210. package/build/types/data/mods/gen5/index.d.ts +0 -9
  211. package/build/types/data/mods/gen5/items.d.ts +0 -3
  212. package/build/types/data/mods/gen5/moves.d.ts +0 -3
  213. package/build/types/data/mods/gen5/pokedex.d.ts +0 -3
  214. package/build/types/data/mods/gen5/rulesets.d.ts +0 -3
  215. package/build/types/data/mods/gen5/scripts.d.ts +0 -1
  216. package/build/types/data/mods/gen5/typechart.d.ts +0 -3
  217. package/build/types/data/mods/gen6/abilities.d.ts +0 -3
  218. package/build/types/data/mods/gen6/conditions.d.ts +0 -3
  219. package/build/types/data/mods/gen6/formats-data.d.ts +0 -3
  220. package/build/types/data/mods/gen6/index.d.ts +0 -8
  221. package/build/types/data/mods/gen6/items.d.ts +0 -3
  222. package/build/types/data/mods/gen6/learnsets.d.ts +0 -3
  223. package/build/types/data/mods/gen6/legality.d.ts +0 -3
  224. package/build/types/data/mods/gen6/moves.d.ts +0 -3
  225. package/build/types/data/mods/gen6/pokedex.d.ts +0 -3
  226. package/build/types/data/mods/gen6/scripts.d.ts +0 -1
  227. package/build/types/data/mods/gen6/typechart.d.ts +0 -3
  228. package/build/types/data/mods/gen7/abilities.d.ts +0 -3
  229. package/build/types/data/mods/gen7/formats-data.d.ts +0 -3
  230. package/build/types/data/mods/gen7/index.d.ts +0 -7
  231. package/build/types/data/mods/gen7/items.d.ts +0 -3
  232. package/build/types/data/mods/gen7/moves.d.ts +0 -3
  233. package/build/types/data/mods/gen7/pokedex.d.ts +0 -3
  234. package/build/types/data/mods/gen7/rulesets.d.ts +0 -3
  235. package/build/types/data/mods/gen7/scripts.d.ts +0 -1
  236. package/build/types/data/mods/gen8/abilities.d.ts +0 -3
  237. package/build/types/data/mods/gen8/formats-data.d.ts +0 -3
  238. package/build/types/data/mods/gen8/index.d.ts +0 -7
  239. package/build/types/data/mods/gen8/items.d.ts +0 -3
  240. package/build/types/data/mods/gen8/learnsets.d.ts +0 -3
  241. package/build/types/data/mods/gen8/legality.d.ts +0 -3
  242. package/build/types/data/mods/gen8/moves.d.ts +0 -3
  243. package/build/types/data/mods/gen8/pokedex.d.ts +0 -3
  244. package/build/types/data/mods/gen8/rulesets.d.ts +0 -3
  245. package/build/types/data/mods/gen8/scripts.d.ts +0 -1
  246. package/build/types/data/moves.d.ts +0 -3
  247. package/build/types/data/natures.d.ts +0 -3
  248. package/build/types/data/pokedex.d.ts +0 -3
  249. package/build/types/data/pokemongo.d.ts +0 -31
  250. package/build/types/data/rulesets.d.ts +0 -3
  251. package/build/types/data/scripts.d.ts +0 -1
  252. package/build/types/data/tags.d.ts +0 -15
  253. package/build/types/data/text/abilities.d.ts +0 -3
  254. package/build/types/data/text/default.d.ts +0 -3
  255. package/build/types/data/text/items.d.ts +0 -3
  256. package/build/types/data/text/moves.d.ts +0 -3
  257. package/build/types/data/typechart.d.ts +0 -3
  258. package/build/types/lib/index.d.ts +0 -2
  259. package/build/types/lib/streams.d.ts +0 -1
  260. package/build/types/lib/utils.d.ts +0 -139
  261. package/build/types/sim/battle-actions.d.ts +0 -90
  262. package/build/types/sim/battle-queue.d.ts +0 -164
  263. package/build/types/sim/battle-stream.d.ts +0 -67
  264. package/build/types/sim/battle.d.ts +0 -396
  265. package/build/types/sim/dex-abilities.d.ts +0 -35
  266. package/build/types/sim/dex-conditions.d.ts +0 -518
  267. package/build/types/sim/dex-data.d.ts +0 -169
  268. package/build/types/sim/dex-formats.d.ts +0 -170
  269. package/build/types/sim/dex-items.d.ts +0 -110
  270. package/build/types/sim/dex-moves.d.ts +0 -441
  271. package/build/types/sim/dex-species.d.ts +0 -289
  272. package/build/types/sim/dex.d.ts +0 -162
  273. package/build/types/sim/exported-global-types.d.ts +0 -510
  274. package/build/types/sim/field.d.ts +0 -30
  275. package/build/types/sim/global-types.d.ts +0 -510
  276. package/build/types/sim/index.d.ts +0 -13
  277. package/build/types/sim/pokemon.d.ts +0 -427
  278. package/build/types/sim/prng.d.ts +0 -97
  279. package/build/types/sim/side.d.ts +0 -127
  280. package/build/types/sim/state.d.ts +0 -42
  281. package/build/types/sim/team-validator.d.ts +0 -198
  282. package/build/types/sim/teams.d.ts +0 -26
  283. package/build/types/sim/tools/exhaustive-runner.d.ts +0 -52
  284. package/build/types/sim/tools/index.d.ts +0 -2
  285. package/build/types/sim/tools/random-player-ai.d.ts +0 -32
  286. package/build/types/sim/tools/runner.d.ts +0 -41
@@ -1,139 +0,0 @@
1
- /**
2
- * Utils library
3
- *
4
- * Miscellaneous utility functions that don't really have a better place.
5
- *
6
- * It'll always be a judgment call whether or not a function goes into a
7
- * "catch-all" library like this, so here are some guidelines:
8
- *
9
- * - It must not have any dependencies
10
- *
11
- * - It must conceivably have a use in a wide variety of projects, not just
12
- * Pokémon (if it's Pokémon-specific, Dex is probably a good place for it)
13
- *
14
- * - A lot of Chat functions are kind of iffy, but I'm going to say for now
15
- * that if it's English-specific, it should be left out of here.
16
- */
17
- /// <reference types="node" />
18
- export type Comparable = number | string | boolean | Comparable[] | {
19
- reverse: Comparable;
20
- };
21
- /**
22
- * Safely converts the passed variable into a string. Unlike '' + str,
23
- * String(str), or str.toString(), Utils.getString is guaranteed not to
24
- * crash.
25
- *
26
- * Specifically, the fear with untrusted JSON is an object like:
27
- *
28
- * let a = {"toString": "this is not a function"};
29
- * console.log(`a is ${a}`);
30
- *
31
- * This will crash (because a.toString() is not a function). Instead,
32
- * getString simply returns '' if the passed variable isn't a
33
- * string or a number.
34
- */
35
- export declare function getString(str: any): string;
36
- export declare function escapeRegex(str: string): string;
37
- /**
38
- * Escapes HTML in a string.
39
- */
40
- export declare function escapeHTML(str: string | number): string;
41
- /**
42
- * Strips HTML from a string.
43
- */
44
- export declare function stripHTML(htmlContent: string): string;
45
- /**
46
- * Maps numbers to their ordinal string.
47
- */
48
- export declare function formatOrder(place: number): string;
49
- /**
50
- * Visualizes eval output in a slightly more readable form
51
- */
52
- export declare function visualize(value: any, depth?: number): string;
53
- /**
54
- * Compares two variables; intended to be used as a smarter comparator.
55
- * The two variables must be the same type (TypeScript will not check this).
56
- *
57
- * - Numbers are sorted low-to-high, use `-val` to reverse
58
- * - Strings are sorted A to Z case-semi-insensitively, use `{reverse: val}` to reverse
59
- * - Booleans are sorted true-first (REVERSE of casting to numbers), use `!val` to reverse
60
- * - Arrays are sorted lexically in the order of their elements
61
- *
62
- * In other words: `[num, str]` will be sorted A to Z, `[num, {reverse: str}]` will be sorted Z to A.
63
- */
64
- export declare function compare(a: Comparable, b: Comparable): number;
65
- /**
66
- * Sorts an array according to the callback's output on its elements.
67
- *
68
- * The callback's output is compared according to `PSUtils.compare`
69
- * (numbers low to high, strings A-Z, booleans true-first, arrays in order).
70
- */
71
- export declare function sortBy<T>(array: T[], callback: (a: T) => Comparable): T[];
72
- /**
73
- * Sorts an array according to `PSUtils.compare`
74
- * (numbers low to high, strings A-Z, booleans true-first, arrays in order).
75
- *
76
- * Note that array.sort() only works on strings, not numbers, so you'll need
77
- * this to sort numbers.
78
- */
79
- export declare function sortBy<T extends Comparable>(array: T[]): T[];
80
- export declare function splitFirst(str: string, delimiter: string): [string, string];
81
- export declare function splitFirst(str: string, delimiter: string, limit: 2): [string, string, string];
82
- export declare function splitFirst(str: string, delimiter: string, limit: 3): [string, string, string, string];
83
- export declare function splitFirst(str: string, delimiter: string, limit: number): string[];
84
- /**
85
- * Template string tag function for escaping HTML
86
- */
87
- export declare function html(strings: TemplateStringsArray, ...args: any): string;
88
- /**
89
- * This combines escapeHTML and forceWrap. The combination allows us to use
90
- * <wbr /> instead of U+200B, which will make sure the word-wrapping hints
91
- * can't be copy/pasted (which would mess up code).
92
- */
93
- export declare function escapeHTMLForceWrap(text: string): string;
94
- /**
95
- * HTML doesn't support `word-wrap: break-word` in tables, but sometimes it
96
- * would be really nice if it did. This emulates `word-wrap: break-word` by
97
- * manually inserting U+200B to tell long words to wrap.
98
- */
99
- export declare function forceWrap(text: string): string;
100
- export declare function shuffle<T>(arr: T[]): T[];
101
- export declare function randomElement<T>(arr: T[]): T;
102
- /** Forces num to be an integer (between min and max). */
103
- export declare function clampIntRange(num: any, min?: number, max?: number): number;
104
- export declare function clearRequireCache(options?: {
105
- exclude?: string[];
106
- }): void;
107
- export declare function uncacheModuleTree(mod: NodeJS.Module, excludes: string[], depth?: number): void;
108
- export declare function deepClone(obj: any): any;
109
- export declare function levenshtein(s: string, t: string, l: number): number;
110
- export declare function waitUntil(time: number): Promise<void>;
111
- /** Like parseInt, but returns NaN if the int isn't already in normalized form */
112
- export declare function parseExactInt(str: string): number;
113
- /** formats an array into a series of question marks and adds the elements to an arguments array */
114
- export declare function formatSQLArray(arr: unknown[], args?: unknown[]): string;
115
- export declare class Multiset<T> extends Map<T, number> {
116
- add(key: T): this;
117
- remove(key: T): boolean;
118
- }
119
- export declare const Utils: {
120
- parseExactInt: typeof parseExactInt;
121
- waitUntil: typeof waitUntil;
122
- html: typeof html;
123
- escapeHTML: typeof escapeHTML;
124
- compare: typeof compare;
125
- sortBy: typeof sortBy;
126
- levenshtein: typeof levenshtein;
127
- shuffle: typeof shuffle;
128
- deepClone: typeof deepClone;
129
- clearRequireCache: typeof clearRequireCache;
130
- randomElement: typeof randomElement;
131
- forceWrap: typeof forceWrap;
132
- splitFirst: typeof splitFirst;
133
- stripHTML: typeof stripHTML;
134
- visualize: typeof visualize;
135
- getString: typeof getString;
136
- escapeRegex: typeof escapeRegex;
137
- formatSQLArray: typeof formatSQLArray;
138
- Multiset: typeof Multiset;
139
- };
@@ -1,90 +0,0 @@
1
- import { ActiveMove, Battle, Effect, ModdedDex, Move, Pokemon, Side, SpreadMoveDamage, SpreadMoveTargets, ZMoveOptions } from './exported-global-types';
2
- import { Dex } from './dex';
3
- export declare class BattleActions {
4
- battle: Battle;
5
- dex: ModdedDex;
6
- readonly MAX_MOVES: {
7
- readonly [k: string]: string;
8
- };
9
- readonly Z_MOVES: {
10
- readonly [k: string]: string;
11
- };
12
- constructor(battle: Battle);
13
- switchIn(pokemon: Pokemon, pos: number, sourceEffect?: Effect | null, isDrag?: boolean): boolean | "pursuitfaint";
14
- dragIn(side: Side, pos: number): boolean;
15
- runSwitch(pokemon: Pokemon): boolean;
16
- /**
17
- * runMove is the "outside" move caller. It handles deducting PP,
18
- * flinching, full paralysis, etc. All the stuff up to and including
19
- * the "POKEMON used MOVE" message.
20
- *
21
- * For details of the difference between runMove and useMove, see
22
- * useMove's info.
23
- *
24
- * externalMove skips LockMove and PP deduction, mostly for use by
25
- * Dancer.
26
- */
27
- runMove(moveOrMoveName: Move | string, pokemon: Pokemon, targetLoc: number, sourceEffect?: Effect | null, zMove?: string, externalMove?: boolean, maxMove?: string, originalTarget?: Pokemon): void;
28
- /**
29
- * useMove is the "inside" move caller. It handles effects of the
30
- * move itself, but not the idea of using the move.
31
- *
32
- * Most caller effects, like Sleep Talk, Nature Power, Magic Bounce,
33
- * etc use useMove.
34
- *
35
- * The only ones that use runMove are Instruct, Pursuit, and
36
- * Dancer.
37
- */
38
- useMove(move: Move | string, pokemon: Pokemon, target?: Pokemon | null, sourceEffect?: Effect | null, zMove?: string, maxMove?: string): boolean;
39
- useMoveInner(moveOrMoveName: Move | string, pokemon: Pokemon, target?: Pokemon | null, sourceEffect?: Effect | null, zMove?: string, maxMove?: string): boolean;
40
- /** NOTE: includes single-target moves */
41
- trySpreadMoveHit(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove, notActive?: boolean): boolean;
42
- hitStepInvulnerabilityEvent(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): any;
43
- hitStepTryHitEvent(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): any;
44
- hitStepTypeImmunity(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): boolean[];
45
- hitStepTryImmunity(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): boolean[];
46
- hitStepAccuracy(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): boolean[];
47
- hitStepBreakProtect(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): undefined;
48
- hitStepStealBoosts(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): undefined;
49
- afterMoveSecondaryEvent(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): undefined;
50
- /** NOTE: used only for moves that target sides/fields rather than pokemon */
51
- tryMoveHit(targetOrTargets: Pokemon | Pokemon[], pokemon: Pokemon, move: ActiveMove): number | undefined | false | '';
52
- hitStepMoveHitLoop(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): (number | boolean | undefined)[];
53
- spreadMoveHit(targets: SpreadMoveTargets, pokemon: Pokemon, moveOrMoveName: ActiveMove, hitEffect?: Dex.HitEffect, isSecondary?: boolean, isSelf?: boolean): [SpreadMoveDamage, SpreadMoveTargets];
54
- tryPrimaryHitEvent(damage: SpreadMoveDamage, targets: SpreadMoveTargets, pokemon: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean): SpreadMoveDamage;
55
- getSpreadDamage(damage: SpreadMoveDamage, targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean, isSelf?: boolean): SpreadMoveDamage;
56
- runMoveEffects(damage: SpreadMoveDamage, targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean, isSelf?: boolean): SpreadMoveDamage;
57
- selfDrops(targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean): void;
58
- secondaries(targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSelf?: boolean): void;
59
- forceSwitch(damage: SpreadMoveDamage, targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove): SpreadMoveDamage;
60
- moveHit(targets: Pokemon | null | (Pokemon | null)[], pokemon: Pokemon, moveOrMoveName: ActiveMove, moveData?: Dex.HitEffect, isSecondary?: boolean, isSelf?: boolean): number | undefined | false;
61
- calcRecoilDamage(damageDealt: number, move: Move, pokemon: Pokemon): number;
62
- getZMove(move: Move, pokemon: Pokemon, skipChecks?: boolean): string | undefined;
63
- getActiveZMove(move: Move, pokemon: Pokemon): ActiveMove;
64
- canZMove(pokemon: Pokemon): ZMoveOptions | undefined;
65
- getMaxMove(move: Move, pokemon: Pokemon): import("./dex-moves").Move | undefined;
66
- getActiveMaxMove(move: Move, pokemon: Pokemon): import("./dex-moves").ActiveMove;
67
- runZPower(move: ActiveMove, pokemon: Pokemon): void;
68
- targetTypeChoices(targetType: string): boolean;
69
- combineResults<T extends number | boolean | null | '' | undefined, U extends number | boolean | null | '' | undefined>(left: T, right: U): T | U;
70
- /**
71
- * 0 is a success dealing 0 damage, such as from False Swipe at 1 HP.
72
- *
73
- * Normal PS return value rules apply:
74
- * undefined = success, null = silent failure, false = loud failure
75
- */
76
- getDamage(source: Pokemon, target: Pokemon, move: string | number | ActiveMove, suppressMessages?: boolean): number | undefined | null | false;
77
- modifyDamage(baseDamage: number, pokemon: Pokemon, target: Pokemon, move: ActiveMove, suppressMessages?: boolean): number;
78
- /**
79
- * Confusion damage is unique - most typical modifiers that get run when calculating
80
- * damage (e.g. Huge Power, Life Orb, critical hits) don't apply. It also uses a 16-bit
81
- * context for its damage, unlike the regular damage formula (though this only comes up
82
- * for base damage).
83
- */
84
- getConfusionDamage(pokemon: Pokemon, basePower: number): number;
85
- canMegaEvo(pokemon: Pokemon): string | null | undefined;
86
- canUltraBurst(pokemon: Pokemon): "Necrozma-Ultra" | null;
87
- runMegaEvo(pokemon: Pokemon): boolean;
88
- canTerastallize(pokemon: Pokemon): string | null;
89
- terastallize(pokemon: Pokemon): void;
90
- }
@@ -1,164 +0,0 @@
1
- import { Effect, ID, Move, Pokemon } from './exported-global-types';
2
- /**
3
- * Simulator Battle Action Queue
4
- * Pokemon Showdown - http://pokemonshowdown.com/
5
- *
6
- * The action queue is the core of the battle simulation. A rough overview of
7
- * the core battle loop:
8
- *
9
- * - chosen moves/switches are added to the action queue
10
- * - the action queue is sorted in speed/priority order
11
- * - we go through the action queue
12
- * - repeat
13
- *
14
- * @license MIT
15
- */
16
- import type { Battle } from './battle';
17
- /** A move action */
18
- export interface MoveAction {
19
- /** action type */
20
- choice: 'move' | 'beforeTurnMove' | 'priorityChargeMove';
21
- order: 3 | 5 | 200 | 201 | 199 | 106;
22
- /** priority of the action (lower first) */
23
- priority: number;
24
- /** fractional priority of the action (lower first) */
25
- fractionalPriority: number;
26
- /** speed of pokemon using move (higher first if priority tie) */
27
- speed: number;
28
- /** the pokemon doing the move */
29
- pokemon: Pokemon;
30
- /** location of the target, relative to pokemon's side */
31
- targetLoc: number;
32
- /** original target pokemon, for target-tracking moves */
33
- originalTarget: Pokemon;
34
- /** a move to use (move action only) */
35
- moveid: ID;
36
- /** a move to use (move action only) */
37
- move: Move;
38
- /** true if megaing or ultra bursting */
39
- mega: boolean | 'done';
40
- /** if zmoving, the name of the zmove */
41
- zmove?: string;
42
- /** if dynamaxed, the name of the max move */
43
- maxMove?: string;
44
- /** effect that called the move (eg Instruct) if any */
45
- sourceEffect?: Effect | null;
46
- }
47
- /** A switch action */
48
- export interface SwitchAction {
49
- /** action type */
50
- choice: 'switch' | 'instaswitch' | 'revivalblessing';
51
- order: 3 | 6 | 103;
52
- /** priority of the action (lower first) */
53
- priority: number;
54
- /** speed of pokemon switching (higher first if priority tie) */
55
- speed: number;
56
- /** the pokemon doing the switch */
57
- pokemon: Pokemon;
58
- /** pokemon to switch to */
59
- target: Pokemon;
60
- /** effect that called the switch (eg U */
61
- sourceEffect: Effect | null;
62
- }
63
- /** A Team Preview choice action */
64
- export interface TeamAction {
65
- /** action type */
66
- choice: 'team';
67
- /** priority of the action (lower first) */
68
- priority: number;
69
- /** unused for this action type */
70
- speed: 1;
71
- /** the pokemon switching */
72
- pokemon: Pokemon;
73
- /** new index */
74
- index: number;
75
- }
76
- /** A generic action not done by a pokemon */
77
- export interface FieldAction {
78
- /** action type */
79
- choice: 'start' | 'residual' | 'pass' | 'beforeTurn';
80
- /** priority of the action (lower first) */
81
- priority: number;
82
- /** unused for this action type */
83
- speed: 1;
84
- /** unused for this action type */
85
- pokemon: null;
86
- }
87
- /** A generic action done by a single pokemon */
88
- export interface PokemonAction {
89
- /** action type */
90
- choice: 'megaEvo' | 'shift' | 'runPrimal' | 'runSwitch' | 'event' | 'runUnnerve' | 'runDynamax' | 'terastallize';
91
- /** priority of the action (lower first) */
92
- priority: number;
93
- /** speed of pokemon doing action (higher first if priority tie) */
94
- speed: number;
95
- /** the pokemon doing action */
96
- pokemon: Pokemon;
97
- /** `runSwitch` only: the pokemon forcing this pokemon to switch in */
98
- dragger?: Pokemon;
99
- /** `event` only: the event to run */
100
- event?: string;
101
- }
102
- export type Action = MoveAction | SwitchAction | TeamAction | FieldAction | PokemonAction;
103
- /**
104
- * An ActionChoice is like an Action and has the same structure, but it doesn't need to be fully filled out.
105
- *
106
- * Any Action or ChosenAction qualifies as an ActionChoice.
107
- *
108
- * The `[k: string]: any` part is required so TypeScript won't warn about unnecessary properties.
109
- */
110
- export interface ActionChoice {
111
- choice: string;
112
- [k: string]: any;
113
- }
114
- /**
115
- * Kind of like a priority queue, although not sorted mid-turn in Gen 1-7.
116
- *
117
- * Sort order is documented in `BattleQueue.comparePriority`.
118
- */
119
- export declare class BattleQueue {
120
- battle: Battle;
121
- list: Action[];
122
- constructor(battle: Battle);
123
- shift(): Action | undefined;
124
- peek(end?: boolean): Action | undefined;
125
- push(action: Action): number;
126
- unshift(action: Action): number;
127
- [Symbol.iterator](): IterableIterator<Action>;
128
- entries(): IterableIterator<[number, Action]>;
129
- /**
130
- * Takes an ActionChoice, and fills it out into a full Action object.
131
- *
132
- * Returns an array of Actions because some ActionChoices (like mega moves)
133
- * resolve to two Actions (mega evolution + use move)
134
- */
135
- resolveAction(action: ActionChoice, midTurn?: boolean): Action[];
136
- /**
137
- * Makes the passed action happen next (skipping speed order).
138
- */
139
- prioritizeAction(action: MoveAction | SwitchAction, sourceEffect?: Effect): void;
140
- /**
141
- * Changes a pokemon's action, and inserts its new action
142
- * in priority order.
143
- *
144
- * You'd normally want the OverrideAction event (which doesn't
145
- * change priority order).
146
- */
147
- changeAction(pokemon: Pokemon, action: ActionChoice): void;
148
- addChoice(choices: ActionChoice | ActionChoice[]): void;
149
- willAct(): Action | null;
150
- willMove(pokemon: Pokemon): MoveAction | null;
151
- cancelAction(pokemon: Pokemon): boolean;
152
- cancelMove(pokemon: Pokemon): boolean;
153
- willSwitch(pokemon: Pokemon): MoveAction | SwitchAction | TeamAction | PokemonAction | null;
154
- /**
155
- * Inserts the passed action into the action queue when it normally
156
- * would have happened (sorting by priority/speed), without
157
- * re-sorting the existing actions.
158
- */
159
- insertChoice(choices: ActionChoice | ActionChoice[], midTurn?: boolean): void;
160
- clear(): void;
161
- debug(action?: any): string;
162
- sort(): this;
163
- }
164
- export default BattleQueue;
@@ -1,67 +0,0 @@
1
- /// <reference types="node" />
2
- import { AnyObject } from './exported-global-types';
3
- /**
4
- * Battle Stream
5
- * Pokemon Showdown - http://pokemonshowdown.com/
6
- *
7
- * Supports interacting with a PS battle in Stream format.
8
- *
9
- * This format is VERY NOT FINALIZED, please do not use it directly yet.
10
- *
11
- * @license MIT
12
- */
13
- import { Streams } from '../lib';
14
- import { Battle } from './battle';
15
- export declare class BattleStream extends Streams.ObjectReadWriteStream<string> {
16
- debug: boolean;
17
- noCatch: boolean;
18
- replay: boolean | 'spectator';
19
- keepAlive: boolean;
20
- battle: Battle | null;
21
- constructor(options?: {
22
- debug?: boolean;
23
- noCatch?: boolean;
24
- keepAlive?: boolean;
25
- replay?: boolean | 'spectator';
26
- });
27
- _write(chunk: string): void;
28
- _writeLines(chunk: string): void;
29
- pushMessage(type: string, data: string): void;
30
- _writeLine(type: string, message: string): void;
31
- _writeEnd(): void;
32
- _destroy(): void;
33
- }
34
- /**
35
- * Splits a BattleStream into omniscient, spectator, p1, p2, p3 and p4
36
- * streams, for ease of consumption.
37
- */
38
- export declare function getPlayerStreams(stream: BattleStream): {
39
- omniscient: Streams.ObjectReadWriteStream<string>;
40
- spectator: Streams.ObjectReadStream<string>;
41
- p1: Streams.ObjectReadWriteStream<string>;
42
- p2: Streams.ObjectReadWriteStream<string>;
43
- p3: Streams.ObjectReadWriteStream<string>;
44
- p4: Streams.ObjectReadWriteStream<string>;
45
- };
46
- export declare abstract class BattlePlayer {
47
- readonly stream: Streams.ObjectReadWriteStream<string>;
48
- readonly log: string[];
49
- readonly debug: boolean;
50
- constructor(playerStream: Streams.ObjectReadWriteStream<string>, debug?: boolean);
51
- start(): Promise<void>;
52
- receive(chunk: string): void;
53
- receiveLine(line: string): void;
54
- abstract receiveRequest(request: AnyObject): void;
55
- receiveError(error: Error): void;
56
- choose(choice: string): void;
57
- }
58
- export declare class BattleTextStream extends Streams.ReadWriteStream {
59
- readonly battleStream: BattleStream;
60
- currentMessage: string;
61
- constructor(options: {
62
- debug?: boolean;
63
- });
64
- start(): Promise<void>;
65
- _write(message: string | Buffer): void;
66
- _writeEnd(): Promise<void>;
67
- }