-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathglobals.ts
963 lines (904 loc) · 35.8 KB
/
globals.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
type Battle = import('./../sim/battle')
type ModdedDex = typeof import('./../sim/dex')
type Pokemon = import('./../sim/pokemon')
type Side = import('./../sim/side')
type Validator = ReturnType<typeof import('./../sim/team-validator')>
type PageTable = import('./../chat').PageTable
type ChatCommands = import('./../chat').ChatCommands
type ChatFilter = import('./../chat').ChatFilter
type NameFilter = import('./../chat').NameFilter
interface AnyObject {[k: string]: any}
type DexTable<T> = {[key: string]: T}
let Config = require('../config/config');
let Monitor = require('../monitor');
let LoginServer = require('../loginserver');
// type RoomBattle = AnyObject;
let Verifier = require('../verifier');
let Dnsbl = require('../dnsbl');
let Sockets = require('../sockets');
// let TeamValidator = require('../sim/team-validator');
let TeamValidatorAsync = require('../team-validator-async');
type GenderName = 'M' | 'F' | 'N' | '';
type StatName = 'hp' | 'atk' | 'def' | 'spa' | 'spd' | 'spe';
type StatsTable = {hp: number, atk: number, def: number, spa: number, spd: number, spe: number};
type SparseStatsTable = Partial<StatsTable>;
type BoostsTable = {atk: number, def: number, spa: number, spd: number, spe: number, accuracy: number, evasion: number};
type SparseBoostsTable = Partial<BoostsTable>;
type PokemonSet = {
name: string,
species: string,
item: string,
ability: string,
moves: string[],
nature: string,
gender: string,
evs: StatsTable,
ivs: StatsTable,
level: number,
shiny?: boolean,
happiness?: number,
pokeball?: string,
hpType?: string,
};
/**
* Describes a possible way to get a move onto a pokemon.
*
* First character is a generation number, 1-7.
* Second character is a source ID, one of:
*
* - L = start or level-up, 3rd char+ is the level
* - M = TM/HM
* - T = tutor
* - E = egg
* - S = event, 3rd char+ is the index in .eventPokemon
* - D = Dream World, only 5D is valid
* - V = Virtual Console transfer, only 7V is valid
* - C = NOT A REAL SOURCE, see note, only 3C/4C is valid
*
* C marks certain moves learned by a pokemon's prevo. It's used to
* work around the chainbreeding checker's shortcuts for performance;
* it lets the pokemon be a valid father for teaching the move, but
* is otherwise ignored by the learnset checker (which will actually
* check prevos for compatibility).
*/
type MoveSource = string;
/**
* Describes a possible way to get a pokemon. Is not exhaustive!
* sourcesBefore covers all sources that do not have exclusive
* moves (like catching wild pokemon).
*
* First character is a generation number, 1-7.
* Second character is a source ID, one of:
*
* - E = egg, 3rd char+ is the father in gen 2-5, empty in gen 6-7
* because egg moves aren't restricted to fathers anymore
* - S = event, 3rd char+ is the index in .eventPokemon
* - D = Dream World, only 5D is valid
* - V = Virtual Console transfer, only 7V is valid
*
* Designed to match MoveSource where possible.
*/
type PokemonSource = string;
/**
* Keeps track of how a pokemon with a given set might be obtained.
*
* `sources` is a list of possible PokemonSources, and a nonzero
* sourcesBefore means the Pokemon is compatible with all possible
* PokemonSources from that gen or earlier.
*
* `limitedEgg` tracks moves that can only be obtained from an egg with
* another father in gen 2-5. If there are multiple such moves,
* potential fathers need to be checked to see if they can actually
* learn the move combination in question.
*/
type PokemonSources = {
sources: PokemonSource[]
sourcesBefore: number
babyOnly?: string
sketchMove?: string
hm?: string
restrictiveMoves?: string[]
limitedEgg?: (string | 'self')[]
isHidden?: boolean
fastCheck?: true
}
type EventInfo = {
generation: number,
level?: number,
shiny?: true | 1,
gender?: GenderName,
nature?: string,
ivs?: SparseStatsTable,
perfectIVs?: number,
isHidden?: boolean,
abilities?: string[],
moves?: string[],
pokeball?: string,
from?: string,
};
type UnknownEffect = Ability | Item | ActiveMove | Template | Status | Weather
interface SelfEffect {
boosts?: SparseBoostsTable
chance?: number
sideCondition?: string
volatileStatus?: string
onHit?: EffectData["onHit"]
}
interface SecondaryEffect {
chance?: number
ability?: Ability
boosts?: SparseBoostsTable
dustproof?: boolean
kingsrock?: boolean
self?: SelfEffect
status?: string
volatileStatus?: string
onAfterHit?: EffectData["onAfterHit"]
onHit?: EffectData["onHit"]
}
interface EventMethods {
beforeMoveCallback?: (this: Battle, pokemon: Pokemon) => void
beforeTurnCallback?: (this: Battle, pokemon: Pokemon, target: Pokemon) => void
damageCallback?: (this: Battle, pokemon: Pokemon, target: Pokemon) => number | false
durationCallback?: (this: Battle, target: Pokemon, source: Pokemon, effect: UnknownEffect) => number
onAfterDamage?: (this: Battle, damage: number, target: Pokemon, soruce: Pokemon, move: ActiveMove) => void
onAfterEachBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon) => void
onAfterHit?: (this: Battle, source: Pokemon, target: Pokemon, move: ActiveMove) => void
onAfterSetStatus?: (this: Battle, status: Status, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAfterSwitchInSelf?: (this: Battle, pokemon: Pokemon) => void
onAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void
onAfterBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAfterMoveSecondarySelf?: (this: Battle, source: Pokemon, target: Pokemon, move: ActiveMove) => void
onAfterMoveSecondary?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onAfterMove?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onAfterMoveSelf?: (this: Battle, pokemon: Pokemon) => void
onAllyTryAddVolatile?: (this: Battle, status: Status, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAllyBasePower?: (this: Battle, basePower: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => void
onAllyModifyAtk?: (this: Battle, atk: number) => void
onAllyModifySpD?: (this: Battle, spd: number) => void
onAllyBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAllySetStatus?: (this: Battle, status: Status, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAllyTryHitSide?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onAllyFaint?: (this: Battle, target: Pokemon) => void
onAllyAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void
onAllyModifyMove?: (this: Battle, move: ActiveMove) => void
onAnyTryPrimaryHit?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onAnyTryMove?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onAnyDamage?: (this: Battle, damage: number, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAnyBasePower?: (this: Battle, basePower: number, source: Pokemon, target: Pokemon, move: ActiveMove) => void
onAnySetWeather?: (this: Battle, target: Pokemon, source: Pokemon, weather: Weather) => void
onAnyModifyDamage?: (this: Battle, damage: number, source: Pokemon, target: Pokemon, move: ActiveMove) => void
onAnyRedirectTarget?: (this: Battle, target: Pokemon, source: Pokemon, source2: Pokemon, move: ActiveMove) => void
onAnyAccuracy?: (this: Battle, accuracy: number, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onAnyTryImmunity?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onAnyFaint?: (this: Battle) => void
onAnyModifyBoost?: (this: Battle, boosts: SparseBoostsTable, target: Pokemon) => void
onAnyDragOut?: (this: Battle, pokemon: Pokemon) => void
onAnySetStatus?: (this: Battle, status: Status, pokemon: Pokemon) => void
onAttract?: (this: Battle, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onAccuracy?: (this: Battle, accuracy: number, target: Pokemon, source: Pokemon, move: ActiveMove) => number | boolean | null | void
onBasePower?: (this: Battle, basePower: number, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onTryImmunity?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onBeforeFaint?: (this: Battle, pokemon: Pokemon) => void
onBeforeMove?: (this: Battle, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => void
onBeforeSwitchIn?: (this: Battle, pokemon: Pokemon) => void
onBeforeSwitchOut?: (this: Battle, pokemon: Pokemon) => void
onBeforeTurn?: (this: Battle, pokemon: Pokemon) => void
onBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onChargeMove?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onCheckShow?: (this: Battle, pokemon: Pokemon) => void
onCopy?: (this: Battle, pokemon: Pokemon) => void
onDamage?: (this: Battle, damage: number, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onDeductPP?: (this: Battle, target: Pokemon, source: Pokemon) => number | void
onDisableMove?: (this: Battle, pokemon: Pokemon) => void
onDragOut?: (this: Battle, pokemon: Pokemon) => void
onEat?: ((this: Battle, pokemon: Pokemon) => void) | false
onEatItem?: (this: Battle, item: Item, pokemon: Pokemon) => void
onEnd?: (this: Battle, pokemon: Pokemon & Side) => void
onFaint?: (this: Battle, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onFlinch?: ((this: Battle, pokemon: Pokemon) => void) | boolean
onFoeAfterDamage?: (this: Battle, damage: number, target: Pokemon) => void
onFoeBasePower?: (this: Battle, basePower: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => void
onFoeBeforeMove?: (this: Battle, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => void
onFoeDisableMove?: (this: Battle, pokemon: Pokemon) => void
onFoeMaybeTrapPokemon?: (this: Battle, pokemon: Pokemon, source: Pokemon) => void
onFoeModifyDef?: (this: Battle, def: number, pokemon: Pokemon) => number
onFoeRedirectTarget?: (this: Battle, target: Pokemon, source: Pokemon, source2: UnknownEffect, move: ActiveMove) => void
onFoeSwitchOut?: (this: Battle, pokemon: Pokemon) => void
onFoeTrapPokemon?: (this: Battle, pokemon: Pokemon) => void
onFoeTryMove?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onHit?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onHitField?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => boolean | void
onHitSide?: (this: Battle, side: Side, source: Pokemon) => void
onImmunity?: (this: Battle, type: string, pokemon: Pokemon) => void
onLockMove?: string | ((this: Battle, pokemon: Pokemon) => void)
onLockMoveTarget?: (this: Battle) => number
onModifyAccuracy?: (this: Battle, accuracy: number, target: Pokemon, source: Pokemon, move: ActiveMove) => number | void
onModifyAtk?: (this: Battle, atk: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => number | void
onModifyBoost?: (this: Battle, boosts: SparseBoostsTable) => void
onModifyCritRatio?: (this: Battle, critRatio: number, source: Pokemon, target: Pokemon) => number | void
onModifyDamage?: (this: Battle, damage: number, source: Pokemon, target: Pokemon, move: ActiveMove) => number | void
onModifyDef?: (this: Battle, def: number, pokemon: Pokemon) => number | void
onModifyMove?: (this: Battle, move: ActiveMove, pokemon: Pokemon, target: Pokemon) => void
onModifyPriority?: (this: Battle, priority: number, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => number | void
onModifySecondaries?: (this: Battle, secondaries: SecondaryEffect[], target: Pokemon, source: Pokemon, move: ActiveMove) => void
onModifySpA?: (this: Battle, atk: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => number | void
onModifySpD?: (this: Battle, spd: number, pokemon: Pokemon) => number | void
onModifySpe?: (this: Battle, spe: number, pokemon: Pokemon) => number | void
onModifyWeight?: (this: Battle, weight: number, pokemon: Pokemon) => number | void
onMoveAborted?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onMoveFail?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onNegateImmunity?: ((this: Battle, pokemon: Pokemon, type: string) => void) | boolean
onOverrideAction?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onPrepareHit?: (this: Battle, source: Pokemon, target: Pokemon, move: ActiveMove) => void
onPreStart?: (this: Battle, pokemon: Pokemon) => void
onPrimal?: (this: Battle, pokemon: Pokemon) => void
onRedirectTarget?: (this: Battle, target: Pokemon, source: Pokemon, source2: UnknownEffect) => void
onResidual?: (this: Battle, target: Pokemon & Side, source: Pokemon, effect: UnknownEffect) => void
onRestart?: (this: Battle, pokemon: Pokemon, source: Pokemon) => void
onSetAbility?: (this: Battle, ability: string, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onSetStatus?: (this: Battle, status: Status, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onSourceAccuracy?: (this: Battle, accuracy: number, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onSourceBasePower?: (this: Battle, basePower: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => void
onSourceFaint?: (this: Battle, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onSourceHit?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onSourceModifyAccuracy?: (this: Battle, accuracy: number, target: Pokemon, source: Pokemon) => number | void
onSourceModifyAtk?: (this: Battle, atk: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => number | void
onSourceModifyDamage?: (this: Battle, damage: number, source: Pokemon, target: Pokemon, move: ActiveMove) => number | void
onSourceModifySecondaries?: (this: Battle, secondaries: SecondaryEffect[], target: Pokemon, source: Pokemon, move: ActiveMove) => void
onSourceModifySpA?: (this: Battle, atk: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => number | void
onSourceTryHeal?: (this: Battle, damage: number, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onSourceTryPrimaryHit?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onStallMove?: (this: Battle, pokemon: Pokemon) => void
onStart?: (this: Battle, target: Pokemon & Side, source: Pokemon, effect: UnknownEffect, move: ActiveMove) => void
onSwitchIn?: (this: Battle, pokemon: Pokemon) => void
onSwitchOut?: (this: Battle, pokemon: Pokemon) => void
onTakeItem?: ((this: Battle, item: Item, pokemon: Pokemon, source: Pokemon) => void) | false
onTerrain?: (this: Battle, pokemon: Pokemon) => void
onTrapPokemon?: (this: Battle, pokemon: Pokemon) => void
onTry?: (this: Battle, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => void
onTryAddVolatile?: (this: Battle, status: Status, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onTryEatItem?: (this: Battle, item: Item, pokemon: Pokemon) => void
onTryHeal?: ((this: Battle, damage: number, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void) | boolean
onTryHit?: ((this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void) | boolean
onTryHitField?: (this: Battle, target: Pokemon, source: Pokemon) => boolean | void
onTryHitSide?: (this: Battle, side: Side, source: Pokemon) => void
onTryMove?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onTryPrimaryHit?: (this: Battle, target: Pokemon, source: Pokemon, move: ActiveMove) => void
onType?: (this: Battle, types: string[], pokemon: Pokemon) => void
onUpdate?: (this: Battle, pokemon: Pokemon) => void
onUseMoveMessage?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => void
onWeather?: (this: Battle, target: Pokemon, source: Pokemon, effect: UnknownEffect) => void
onWeatherModifyDamage?: (this: Battle, damage: number, attacker: Pokemon, defender: Pokemon, move: ActiveMove) => number | void
// multiple definitions due to relayVar (currently not supported)
onAfterSubDamage?: (this: Battle, damage: any, target: any, source: any, effect: any) => void
onEffectiveness?: (this: Battle, typeMod: any, target: any, type: any, move: any) => void
}
interface EffectData extends EventMethods {
id: string
name: string
num: number
affectsFainted?: boolean
counterMax?: number
desc?: string
drain?: number[]
duration?: number
effect?: Partial<EffectData>
effectType?: string
infiltrates?: boolean
isNonstandard?: boolean | string
isUnreleased?: boolean
/**
* `true` for generic Z-moves like Gigavolt Havoc.
* Also `true` for Z-powered status moves like Z-Encore.
* Move ID of the base move, for specific Z-moves like Stoked
* Sparksurfer.
*/
isZ?: boolean | string
noCopy?: boolean
onAccuracyPriority?: number
onAfterDamageOrder?: number
onAfterMoveSecondaryPriority?: number
onAfterMoveSecondarySelfPriority?: number
onAfterMoveSelfPriority?: number
onAnyFaintPriority?: number
onAttractPriority?: number
onBasePowerPriority?: number
onBeforeMovePriority?: number
onBeforeSwitchOutPriority?: number
onBoostPriority?: number
onCriticalHit?: boolean
onDamagePriority?: number
onDragOutPriority?: number
onFoeBeforeMovePriority?: number
onFoeModifyDefPriority?: number
onFoeRedirectTargetPriority?: number
onFoeTrapPokemonPriority?: number
onFoeTryEatItem?: boolean
onHitPriority?: number
onModifyAccuracyPriority?: number
onModifyAtkPriority?: number
onModifyCritRatioPriority?: number
onModifyDefPriority?: number
onModifyMovePriority?: number
onModifyPriorityPriority?: number
onModifySpAPriority?: number
onModifySpDPriority?: number
onModifyWeightPriority?: number
onRedirectTargetPriority?: number
onResidualOrder?: number
onResidualPriority?: number
onResidualSubOrder?: number
onSwitchInPriority?: number
onTrapPokemonPriority?: number
onTryHealPriority?: number
onTryHitPriority?: number
onTryMovePriority?: number
onTryPrimaryHitPriority?: number
onTypePriority?: number
recoil?: [number, number]
secondary?: SecondaryEffect | null
secondaries?: SecondaryEffect[] | null
self?: SelfEffect | null
shortDesc?: string
status?: string
weather?: string
}
interface ModdedEffectData extends Partial<EffectData> {
effect?: Partial<ModdedEffectData>
inherit?: string | boolean
onAnyModifyDamagePhase1?: (this: Battle, damage: number, source: Pokemon, target: Pokemon, move: ActiveMove) => number | void
onAnyModifyDamagePhase2?: ModdedEffectData["onAnyModifyDamagePhase1"]
onModifyDamagePhase1?: ModdedEffectData["onAnyModifyDamagePhase1"]
onModifyDamagePhase2?: ModdedEffectData["onAnyModifyDamagePhase1"]
}
type EffectTypes = 'Effect' | 'Pokemon' | 'Move' | 'Item' | 'Ability' | 'Format' | 'Ruleset' | 'Weather' | 'Status' | 'Rule' | 'ValidatorRule'
interface Effect extends EffectData {
effectType: EffectTypes
exists: boolean
flags: AnyObject
fullname: string
gen: number
sourceEffect: string
toString: () => string
}
interface Status extends Effect {
effectType: 'Status'
}
interface Weather extends Effect {
effectType: 'Weather'
}
interface AbilityData extends EffectData {
rating: number
isUnbreakable?: boolean
suppressWeather?: boolean
}
interface ModdedAbilityData extends Partial<AbilityData>, ModdedEffectData {
effect?: Partial<ModdedEffectData>
inherit?: boolean
}
interface Ability extends Readonly<Effect & AbilityData> {
readonly effectType: 'Ability'
}
interface FlingData {
basePower: number
status?: string
volatileStatus?: string
effect?: EventMethods["onHit"]
}
interface ItemData extends EffectData {
gen: number
fling?: FlingData
forcedForme?: string
ignoreKlutz?: boolean
isBerry?: boolean
isChoice?: boolean
isGem?: boolean
megaStone?: string
megaEvolves?: string
naturalGift?: {basePower: number, type: string}
onDrive?: string
onMemory?: string
onPlate?: string
spritenum?: number
zMove?: string | true
zMoveFrom?: string
zMoveType?: string
zMoveUser?: string[]
}
interface ModdedItemData extends Partial<ItemData>, ModdedEffectData {
effect?: Partial<ModdedEffectData>
inherit?: boolean
onCustap?: (this: Battle, pokemon: Pokemon) => void
}
interface Item extends Readonly<Effect & ItemData> {
readonly effectType: 'Item'
}
interface MoveData extends EffectData {
accuracy: true | number
basePower: number
category: 'Physical' | 'Special' | 'Status'
flags: AnyObject
pp: number
priority: number
target: string
type: string
alwaysHit?: boolean
baseMoveType?: string
basePowerModifier?: number
boosts?: SparseBoostsTable | false
breaksProtect?: boolean
contestType?: string
critModifier?: number
critRatio?: number
damage?: number | string | boolean | null
defensiveCategory?: 'Physical' | 'Special' | 'Status'
forceSwitch?: boolean
hasCustomRecoil?: boolean
heal?: number[] | null
ignoreAbility?: boolean
ignoreAccuracy?: boolean
ignoreDefensive?: boolean
ignoreEvasion?: boolean
ignoreImmunity?: boolean | {[k: string]: boolean}
ignoreNegativeOffensive?: boolean
ignoreOffensive?: boolean
ignorePositiveDefensive?: boolean
ignorePositiveEvasion?: boolean
isSelfHit?: boolean
isFutureMove?: boolean
isViable?: boolean
mindBlownRecoil?: boolean
multiaccuracy?: boolean
multihit?: number | number[]
multihitType?: string
noDamageVariance?: boolean
noFaint?: boolean
noMetronome?: string[]
nonGhostTarget?: string
noPPBoosts?: boolean
noSketch?: boolean
ohko?: boolean | string
pressureTarget?: string
pseudoWeather?: string
selfBoost?: {boosts?: SparseBoostsTable}
selfdestruct?: string | boolean
selfSwitch?: string | boolean
sideCondition?: string
sleepUsable?: boolean
spreadModifier?: number
stallingMove?: boolean
stealsBoosts?: boolean
struggleRecoil?: boolean
terrain?: string
thawsTarget?: boolean
useTargetOffensive?: boolean
useSourceDefensive?: boolean
volatileStatus?: string
weather?: string
willCrit?: boolean
forceSTAB?: boolean
zMovePower?: number
zMoveEffect?: string
zMoveBoost?: SparseBoostsTable
basePowerCallback?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => number | boolean | null
}
interface ModdedMoveData extends Partial<MoveData>, ModdedEffectData {
effect?: Partial<ModdedEffectData>
inherit?: boolean
}
interface Move extends Readonly<Effect & MoveData> {
readonly effectType: 'Move'
}
interface ActiveMove extends Effect, MoveData {
readonly effectType: 'Move'
typeMod: number
hit: number
ability?: Ability
aerilateBoosted?: boolean
allies?: Pokemon[]
auraBooster?: Pokemon
causedCrashDamage?: boolean
crit?: boolean
forceStatus?: string
galvanizeBoosted?: boolean
hasAuraBreak?: boolean
hasBounced?: boolean
hasSheerForce?: boolean
isExternal?: boolean
lastHit?: boolean
magnitude?: number
negateSecondary?: boolean
normalizeBoosted?: boolean
pixilateBoosted?: boolean
pranksterBoosted?: boolean
refrigerateBoosted?: boolean
selfDropped?: boolean
spreadHit?: boolean
stab?: number
statusRoll?: string
totalDamage?: number | false
willChangeForme?: boolean
/**
* Whether or not this move is a Z-Move that broke protect
* (affects damage calculation).
* @type {boolean}
*/
zBrokeProtect?: boolean
/**
* Has this move been boosted by a Z-crystal? Usually the same as
* `isZ`, but hacked moves will have this be `false` and `isZ` be
* truthy.
*/
isZPowered?: boolean
}
type TemplateAbility = {0: string, 1?: string, H?: string, S?: string}
interface TemplateData {
abilities: TemplateAbility
baseStats: StatsTable
color: string
eggGroups: string[]
heightm: number
num: number
species: string
types: string[]
weightkg: number
baseForme?: string
baseSpecies?: string
evoLevel?: number
evoMove?: string
evos?: string[]
forme?: string
formeLetter?: string
gender?: GenderName
genderRatio?: {[k: string]: number}
maxHP?: number
otherForms?: string[]
otherFormes?: string[]
prevo?: string
stage?: string
}
interface ModdedTemplateData extends Partial<TemplateData> {
inherit?: boolean
}
interface TemplateFormatsData {
battleOnly?: boolean
comboMoves?: string[]
doublesTier?: string
essentialMove?: string
eventOnly?: boolean
eventPokemon?: EventInfo[]
exclusiveMoves?: string[]
gen?: number
isNonstandard?: boolean | string
isUnreleased?: boolean
maleOnlyHidden?: boolean
randomBattleMoves?: string[]
randomDoubleBattleMoves?: string[]
requiredAbility?: string
requiredItem?: string
requiredItems?: string[]
requiredMove?: string
tier?: string
unreleasedHidden?: boolean
}
interface ModdedTemplateFormatsData extends Partial<TemplateFormatsData> {
inherit?: boolean
randomSet1?: RandomTeamsTypes["TemplateRandomSet"]
randomSet2?: RandomTeamsTypes["TemplateRandomSet"]
randomSet3?: RandomTeamsTypes["TemplateRandomSet"]
randomSet4?: RandomTeamsTypes["TemplateRandomSet"]
randomSet5?: RandomTeamsTypes["TemplateRandomSet"]
}
interface Template extends Readonly<Effect & TemplateData & TemplateFormatsData> {
readonly effectType: 'Pokemon'
readonly baseSpecies: string
readonly doublesTier: string
readonly eventOnly: boolean
readonly evos: string[]
readonly forme: string
readonly formeLetter: string
readonly gender: GenderName
readonly genderRatio: {M: number, F: number}
readonly maleOnlyHidden: boolean
readonly nfe: boolean
readonly prevo: string
readonly speciesid: string
readonly spriteid: string
readonly tier: string
readonly addedType?: string
readonly isMega?: boolean
readonly isPrimal?: boolean
readonly learnset?: {[k: string]: MoveSource[]}
readonly originalMega?: string
}
type GameType = 'singles' | 'doubles' | 'triples' | 'rotation'
interface FormatsData extends EventMethods {
name: string
banlist?: string[]
cannotMega?: string[]
canUseRandomTeam?: boolean
challengeShow?: boolean
debug?: boolean
defaultLevel?: number
desc?: string
effectType?: string
forcedLevel?: number
gameType?: GameType
maxForcedLevel?: number
maxLevel?: number
mod?: string
noChangeAbility?: boolean
noChangeForme?: boolean
onBasePowerPriority?: number
onModifyMovePriority?: number
onStartPriority?: number
onSwitchInPriority?: number
rated?: boolean
requirePentagon?: boolean
requirePlus?: boolean
restrictedAbilities?: string[]
restrictedMoves?: string[]
restrictedStones?: string[]
ruleset?: string[]
searchShow?: boolean
team?: string
teamLength?: {validate?: [number, number], battle?: number}
threads?: string[]
timer?: {starting?: number, perTurn?: number, maxPerTurn?: number, maxFirstTurn?: number, timeoutAutoChoose?: boolean, accelerate?: boolean}
tournamentShow?: boolean
unbanlist?: string[]
checkLearnset?: (this: Validator, move: Move, template: Template, lsetData: PokemonSources, set: PokemonSet) => {type: string, [any: string]: any} | null
onAfterMega?: (this: Battle, pokemon: Pokemon) => void
onBegin?: (this: Battle) => void
onChangeSet?: (this: ModdedDex, set: PokemonSet, format: Format, setHas: AnyObject, teamHas: AnyObject) => string[] | false | void
onModifyTemplate?: (this: Battle, template: Template, target: Pokemon, source: Pokemon) => Template | void
onTeamPreview?: (this: Battle) => void
onValidateSet?: (this: ModdedDex, set: PokemonSet, format: Format, setHas: AnyObject, teamHas: AnyObject) => string[] | false | void
onValidateTeam?: (this: ModdedDex, team: PokemonSet[], format: Format, teamHas: AnyObject) => string[] | false | void
validateSet?: (this: Validator, set: PokemonSet, teamHas: AnyObject) => string[] | false | void
validateTeam?: (this: Validator, team: PokemonSet[], removeNicknames: boolean) => string[] | false | void,
section?: string,
column?: number
}
interface ModdedFormatsData extends Partial<FormatsData> {
inherit?: boolean
}
interface RuleTable extends Map<string, string> {
checkLearnset: [Function, string] | null
complexBans: [string, string, number, string[]][]
complexTeamBans: [string, string, number, string[]][]
check: (thing: string, setHas: {[k: string]: true}) => string
getReason: (key: string) => string
}
interface Format extends Effect, FormatsData {
effectType: 'Format' | 'Ruleset' | 'Rule' | 'ValidatorRule'
baseRuleset: string[]
banlist: string[]
customRules: string[] | null
defaultLevel: number
maxLevel: number
noLog: boolean
ruleset: string[]
ruleTable: RuleTable | null
unbanlist: string[]
}
interface BattleScriptsData {
gen: number
zMoveTable?: {[k: string]: string}
calcRecoilDamage?: (this: Battle, damageDealt: number, move: Move) => number
canMegaEvo?: (this: Battle, pokemon: Pokemon) => string | undefined | null
canUltraBurst?: (this: Battle, pokemon: Pokemon) => string | null
canZMove?: (this: Battle, pokemon: Pokemon) => (AnyObject | null)[] | void
getZMove?: (this: Battle, move: Move, pokemon: Pokemon, skipChecks?: boolean) => string | undefined
getActiveZMove?: (this: Battle, move: Move, pokemon: Pokemon) => ActiveMove
isAdjacent?: (this: Battle, pokemon1: Pokemon, pokemon2: Pokemon) => boolean
moveHit?: (this: Battle, target: Pokemon | null, pokemon: Pokemon, move: ActiveMove, moveData?: ActiveMove, isSecondary?: boolean, isSelf?: boolean) => number | false
resolveAction?: (this: Battle, action: AnyObject, midTurn?: boolean) => Actions["Action"]
runAction?: (this: Battle, action: Actions["Action"]) => void
runMegaEvo?: (this: Battle, pokemon: Pokemon) => boolean
runMove?: (this: Battle, move: Move, pokemon: Pokemon, targetLoc: number, sourceEffect?: Effect | null, zMove?: string, externalMove?: boolean) => void
runZPower?: (this: Battle, move: ActiveMove, pokemon: Pokemon) => void
targetTypeChoices?: (this: Battle, targetType: string) => boolean
tryMoveHit?: (this: Battle, target: Pokemon, pokemon: Pokemon, move: ActiveMove) => number | false
useMove?: (this: Battle, move: Move, pokemon: Pokemon, target: Pokemon | false, sourceEffect?: Effect | null, zMove?: string) => boolean
useMoveInner?: (this: Battle, move: Move, pokemon: Pokemon, target: Pokemon | false, sourceEffect?: Effect | null, zMove?: string) => boolean
}
interface ModdedBattleSide {
lastMove?: Move | null
}
interface ModdedBattlePokemon {
boostBy?: (this: Pokemon, boost: SparseBoostsTable) => boolean
calculateStat?: (this: Pokemon, statName: string, boost: number, modifier?: number) => number
getActionSpeed?: (this: Pokemon) => number
getStat?: (this: Pokemon, statName: string, unboosted?: boolean, unmodified?: boolean) => number
getWeight?: (this: Pokemon) => number
isGrounded?: (this: Pokemon, negateImmunity: boolean | undefined) => boolean | null
modifyStat?: (this: Pokemon, statName: string, modifier: number) => void
moveUsed?: (this: Pokemon, move: Move, targetLoc?: number) => void
recalculateStats?: (this: Pokemon) => void
}
interface ModdedBattleScriptsData extends Partial<BattleScriptsData> {
inherit?: string
lastDamage?: number
pokemon?: ModdedBattlePokemon
side?: ModdedBattleSide
boost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source?: Pokemon | null, effect?: Effect | string | null, isSecondary?: boolean, isSelf?: boolean) => void
damage?: (this: Battle, damage: number, target: Pokemon, source: Pokemon, effect: Effect) => number
debug?: (this: Battle, activity: string) => void
directDamage?: (this: Battle, damage: number, target: Pokemon, source: Pokemon, effect: Effect) => number
getDamage?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: string | number | ActiveMove, suppressMessages: boolean) => number
init?: (this: Battle) => void
modifyDamage?: (this: Battle, baseDamage: number, pokemon: Pokemon, target: Pokemon, move: ActiveMove, suppressMessages?: boolean) => void
natureModify?: (this: Battle, stats: StatsTable, set: PokemonSet) => StatsTable
setTerrain?: (this: Battle, status: string | Effect, source: Pokemon | null | undefined, sourceEffect: Effect | null | undefined) => boolean
spreadModify?: (this: Battle, baseStats: StatsTable, set: PokemonSet) => StatsTable
// oms
doGetMixedTemplate?: (this: Battle, template: Template, deltas: AnyObject) => Template
getMegaDeltas?: (this: Battle, megaSpecies: Template) => AnyObject
getMixedTemplate?: (this: Battle, originalSpecies: string, megaSpecies: string) => Template
}
interface TypeData {
damageTaken: {[attackingTypeNameOrEffectid: string]: number}
HPdvs?: SparseStatsTable
HPivs?: SparseStatsTable
}
interface ModdedTypeData extends Partial<TypeData> {
inherit?: boolean
}
interface TypeInfo extends TypeData {
effectType: 'Type' | 'EffectType'
exists: boolean
gen: number
HPdvs: SparseStatsTable
HPivs: SparseStatsTable
id: string
name: string
toString: () => string
}
interface Actions {
/** A move action */
MoveAction: {
/** action type */
choice: 'move' | 'beforeTurnMove'
/** priority of the action (lower first) */
priority: number
/** speed of pokemon using move (higher first if priority tie) */
speed: number
/** the pokemon doing the move */
pokemon: Pokemon
/** location of the target, relative to pokemon's side */
targetLoc: number
/** a move to use (move action only) */
moveid: string
/** a move to use (move action only) */
move: Move
/** true if megaing or ultra bursting */
mega: boolean | 'done'
/** if zmoving, the name of the zmove */
zmove?: string
/** effect that called the move (eg Instruct) if any */
sourceEffect?: Effect | null
}
/** A switch action */
SwitchAction: {
/** action type */
choice: 'switch' | 'instaswitch'
/** priority of the action (lower first) */
priority: number
/** speed of pokemon switching (higher first if priority tie) */
speed: number
/** the pokemon doing the switch */
pokemon: Pokemon
/** pokemon to switch to */
target: Pokemon
/** effect that called the switch (eg U */
sourceEffect: Effect | null
}
/** A Team Preview choice action */
TeamAction: {
/** action type */
choice: 'team'
/** priority of the action (lower first) */
priority: number
/** unused for this action type */
speed: 1
/** the pokemon switching */
pokemon: Pokemon
/** new index */
index: number
}
/** A generic action not done by a pokemon */
FieldAction: {
/** action type */
choice: 'start' | 'residual' | 'pass' | 'beforeTurn'
/** priority of the action (lower first) */
priority: number
/** unused for this action type */
speed: 1
/** unused for this action type */
pokemon: null
}
/** A generic action done by a single pokemon */
PokemonAction: {
/** action type */
choice: 'megaEvo' | 'shift' | 'runPrimal' | 'runSwitch' | 'event' | 'runUnnerve'
/** priority of the action (lower first) */
priority: number
/** speed of pokemon doing action (higher first if priority tie) */
speed: number
/** the pokemon doing action */
pokemon: Pokemon
}
Action: Actions["MoveAction"] | Actions["SwitchAction"] | Actions["TeamAction"] | Actions["FieldAction"] | Actions["PokemonAction"]
}
interface RandomTeamsTypes {
TeamDetails: {
megaStone?: number
zMove?: number
hail?: number
rain?: number
sand?: number
sun?: number
stealthRock?: number
spikes?: number
toxicSpikes?: number
hazardClear?: number
rapidSpin?: number
illusion?: number
}
FactoryTeamDetails: {
megaCount: number
zCount?: number
forceResult: boolean
weather?: string
typeCount: {[k: string]: number}
typeComboCount: {[k: string]: number}
baseFormes: {[k: string]: number}
has: {[k: string]: number}
weaknesses: {[k: string]: number}
resistances: {[k: string]: number}
}
RandomSet: {
name: string
species: string
gender: string | boolean
moves: string[]
ability: string
evs: SparseStatsTable
ivs: SparseStatsTable
item: string
level: number
shiny: boolean
nature?: string
happiness?: number
moveset?: RandomTeamsTypes["RandomSet"]
other?: {discard: boolean, restrictMoves: {[k: string]: number}}
}
RandomFactorySet: {
name: string
species: string
gender: string
item: string
ability: string
shiny: boolean
level: number
happiness: number
evs: SparseStatsTable
ivs: SparseStatsTable
nature: string
moves: string[]
}
TemplateRandomSet: {
chance: number
item: string[]
baseMove1?: string
baseMove2?: string
baseMove3?: string
baseMove4?: string
fillerMoves1?: string[]
fillerMoves2?: string[]
fillerMoves3?: string[]
fillerMoves4?: string[]
}
}