Repository navigation
Expand file tree
/
Copy pathcheatmenu.js
More file actions
1492 lines (1405 loc) · 94.7 KB
/
Copy pathcheatmenu.js
File metadata and controls
1492 lines (1405 loc) · 94.7 KB
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
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ============================================================
// POKÉLIKE CHEAT MENU — pokelike.xyz (v6)
//
// HOW TO USE:
// Option A — paste into browser DevTools console (F12)
// Option B — add <script src="cheat-menu.js"></script>
// at the END of the game's <body> tag
// Option C — paste in a userscript (Tampermonkey) with
// @match https://pokelike.xyz/* to auto-load
//
// Toggle: ` (backtick) | ⌨ button (bottom-right)
// Close: Esc | click backdrop
// ============================================================
(function () {
'use strict';
if (document.getElementById('cm-overlay')) return; // already loaded
const TOGGLE_KEY = '`';
const MENU_ID = 'cm-overlay';
const SP = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/';
const SPS = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/';
const IP = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/items/';
// ── CONFIRMED items from ITEM_POOL / USABLE_ITEM_POOL ─────
const HELD_ITEMS = [
{id:'lucky_egg', name:'Lucky Egg'}, {id:'life_orb', name:'Life Orb'},
{id:'choice_band', name:'Choice Band'}, {id:'choice_specs', name:'Choice Specs'},
{id:'choice_scarf', name:'Choice Scarf'}, {id:'muscle_band', name:'Muscle Band'},
{id:'wise_glasses', name:'Wise Glasses'}, {id:'metronome', name:'Metronome'},
{id:'scope_lens', name:'Scope Lens'}, {id:'rocky_helmet', name:'Rocky Helmet'},
{id:'shell_bell', name:'Shell Bell'}, {id:'eviolite', name:'Eviolite'},
{id:'sharp_beak', name:'Sharp Beak'}, {id:'charcoal', name:'Charcoal'},
{id:'mystic_water', name:'Mystic Water'}, {id:'magnet', name:'Magnet'},
{id:'miracle_seed', name:'Miracle Seed'}, {id:'twisted_spoon',name:'Twisted Spoon'},
{id:'black_belt', name:'Black Belt'}, {id:'soft_sand', name:'Soft Sand'},
{id:'silver_powder',name:'Silver Powder'},{id:'hard_stone', name:'Hard Stone'},
{id:'dragon_fang', name:'Dragon Fang'}, {id:'poison_barb', name:'Poison Barb'},
{id:'spell_tag', name:'Spell Tag'}, {id:'silk_scarf', name:'Silk Scarf'},
{id:'assault_vest', name:'Assault Vest'}, {id:'leftovers', name:'Leftovers'},
{id:'expert_belt', name:'Expert Belt'}, {id:'focus_band', name:'Focus Band'},
{id:'focus_sash', name:'Focus Sash'}, {id:'wide_lens', name:'Wide Lens'},
{id:'air_balloon', name:'Air Balloon'},
];
const USABLE_ITEMS = [
{id:'max_revive', name:'Max Revive', usable:true},
{id:'rare_candy', name:'Rare Candy', usable:true},
{id:'moon_stone', name:'Moon Stone', usable:true},
];
// 18 types confirmed from TYPE_CHART in game source
const GAME_TYPES = [
'Normal','Fire','Water','Electric','Grass','Ice','Fighting','Poison',
'Ground','Flying','Psychic','Bug','Rock','Ghost','Dragon','Dark','Steel','Fairy',
];
// Achievements — confirmed from ACHIEVEMENTS array in game source
const ALL_ACH_IDS = [
'gym_0','gym_1','gym_2','gym_3','gym_4','gym_5','gym_6','gym_7',
'elite_four','elite_10','elite_100',
'starter_1','starter_4','starter_7',
'solo_run','nuzlocke_win','three_birds','no_pokecenter','no_items',
'type_quartet','all_shiny_win','back_to_back','back_3_back',
'endless_stage_1','endless_stage_2','endless_stage_3','endless_stage_4','endless_stage_5',
'starters_stage_1','starters_stage_2','starters_stage_3','starters_stage_4','starters_stage_5',
'pokedex_complete','shinydex_complete','shinydex_all',
'pokedex_gen2','pokedex_gen3','pokedex_gen4','pokedex_gen5',
'max_stats_1','max_stats_2','max_stats_3','max_stats_4','max_stats_all',
'shinydex_100','shinydex_200','shinydex_300','shinydex_400','shinydex_500','shinydex_600',
];
// Stage names from STAGE_META in game source
const STAGE_NAMES = {1:'Kanto',2:'Johto',3:'Hoenn',4:'Sinnoh',5:'Unova'};
// Gen 1 names
const GEN1 = ['Bulbasaur','Ivysaur','Venusaur','Charmander','Charmeleon','Charizard','Squirtle','Wartortle','Blastoise','Caterpie','Metapod','Butterfree','Weedle','Kakuna','Beedrill','Pidgey','Pidgeotto','Pidgeot','Rattata','Raticate','Spearow','Fearow','Ekans','Arbok','Pikachu','Raichu','Sandshrew','Sandslash','Nidoran♀','Nidorina','Nidoqueen','Nidoran♂','Nidorino','Nidoking','Clefairy','Clefable','Vulpix','Ninetales','Jigglypuff','Wigglytuff','Zubat','Golbat','Oddish','Gloom','Vileplume','Paras','Parasect','Venonat','Venomoth','Diglett','Dugtrio','Meowth','Persian','Psyduck','Golduck','Mankey','Primeape','Growlithe','Arcanine','Poliwag','Poliwhirl','Poliwrath','Abra','Kadabra','Alakazam','Machop','Machoke','Machamp','Bellsprout','Weepinbell','Victreebel','Tentacool','Tentacruel','Geodude','Graveler','Golem','Ponyta','Rapidash','Slowpoke','Slowbro','Magnemite','Magneton',"Farfetch'd",'Doduo','Dodrio','Seel','Dewgong','Grimer','Muk','Shellder','Cloyster','Gastly','Haunter','Gengar','Onix','Drowzee','Hypno','Krabby','Kingler','Voltorb','Electrode','Exeggcute','Exeggutor','Cubone','Marowak','Hitmonlee','Hitmonchan','Lickitung','Koffing','Weezing','Rhyhorn','Rhydon','Chansey','Tangela','Kangaskhan','Horsea','Seadra','Goldeen','Seaking','Staryu','Starmie','Mr. Mime','Scyther','Jynx','Electabuzz','Magmar','Pinsir','Tauros','Magikarp','Gyarados','Lapras','Ditto','Eevee','Vaporeon','Jolteon','Flareon','Porygon','Omanyte','Omastar','Kabuto','Kabutops','Aerodactyl','Snorlax','Articuno','Zapdos','Moltres','Dratini','Dragonair','Dragonite','Mewtwo','Mew'];
// Gen 2–9 names
const EXTRA_NAMES = {152:'Chikorita',153:'Bayleef',154:'Meganium',155:'Cyndaquil',156:'Quilava',157:'Typhlosion',158:'Totodile',159:'Croconaw',160:'Feraligatr',161:'Sentret',162:'Furret',163:'Hoothoot',164:'Noctowl',165:'Ledyba',166:'Ledian',167:'Spinarak',168:'Ariados',169:'Crobat',170:'Chinchou',171:'Lanturn',172:'Pichu',173:'Cleffa',174:'Igglybuff',175:'Togepi',176:'Togetic',177:'Natu',178:'Xatu',179:'Mareep',180:'Flaaffy',181:'Ampharos',182:'Bellossom',183:'Marill',184:'Azumarill',185:'Sudowoodo',186:'Politoed',187:'Hoppip',188:'Skiploom',189:'Jumpluff',190:'Aipom',191:'Sunkern',192:'Sunflora',193:'Yanma',194:'Wooper',195:'Quagsire',196:'Espeon',197:'Umbreon',198:'Murkrow',199:'Slowking',200:'Misdreavus',201:'Unown',202:'Wobbuffet',203:'Girafarig',204:'Pineco',205:'Forretress',206:'Dunsparce',207:'Gligar',208:'Steelix',209:'Snubbull',210:'Granbull',211:'Qwilfish',212:'Scizor',213:'Shuckle',214:'Heracross',215:'Sneasel',216:'Teddiursa',217:'Ursaring',218:'Slugma',219:'Magcargo',220:'Swinub',221:'Piloswine',222:'Corsola',223:'Remoraid',224:'Octillery',225:'Delibird',226:'Mantine',227:'Skarmory',228:'Houndour',229:'Houndoom',230:'Kingdra',231:'Phanpy',232:'Donphan',233:'Porygon2',234:'Stantler',235:'Smeargle',236:'Tyrogue',237:'Hitmontop',238:'Smoochum',239:'Elekid',240:'Magby',241:'Miltank',242:'Blissey',243:'Raikou',244:'Entei',245:'Suicune',246:'Larvitar',247:'Pupitar',248:'Tyranitar',249:'Lugia',250:'Ho-oh',251:'Celebi',252:'Treecko',253:'Grovyle',254:'Sceptile',255:'Torchic',256:'Combusken',257:'Blaziken',258:'Mudkip',259:'Marshtomp',260:'Swampert',261:'Poochyena',262:'Mightyena',263:'Zigzagoon',264:'Linoone',265:'Wurmple',266:'Silcoon',267:'Beautifly',268:'Cascoon',269:'Dustox',270:'Lotad',271:'Lombre',272:'Ludicolo',273:'Seedot',274:'Nuzleaf',275:'Shiftry',276:'Taillow',277:'Swellow',278:'Wingull',279:'Pelipper',280:'Ralts',281:'Kirlia',282:'Gardevoir',283:'Surskit',284:'Masquerain',285:'Shroomish',286:'Breloom',287:'Slakoth',288:'Vigoroth',289:'Slaking',290:'Nincada',291:'Ninjask',292:'Shedinja',293:'Whismur',294:'Loudred',295:'Exploud',296:'Makuhita',297:'Hariyama',298:'Azurill',299:'Nosepass',300:'Skitty',301:'Delcatty',302:'Sableye',303:'Mawile',304:'Aron',305:'Lairon',306:'Aggron',307:'Meditite',308:'Medicham',309:'Electrike',310:'Manectric',311:'Plusle',312:'Minun',313:'Volbeat',314:'Illumise',315:'Roselia',316:'Gulpin',317:'Swalot',318:'Carvanha',319:'Sharpedo',320:'Wailmer',321:'Wailord',322:'Numel',323:'Camerupt',324:'Torkoal',325:'Spoink',326:'Grumpig',327:'Spinda',328:'Trapinch',329:'Vibrava',330:'Flygon',331:'Cacnea',332:'Cacturne',333:'Swablu',334:'Altaria',335:'Zangoose',336:'Seviper',337:'Lunatone',338:'Solrock',339:'Barboach',340:'Whiscash',341:'Corphish',342:'Crawdaunt',343:'Baltoy',344:'Claydol',345:'Lileep',346:'Cradily',347:'Anorith',348:'Armaldo',349:'Feebas',350:'Milotic',351:'Castform',352:'Kecleon',353:'Shuppet',354:'Banette',355:'Duskull',356:'Dusclops',357:'Tropius',358:'Chimecho',359:'Absol',360:'Wynaut',361:'Snorunt',362:'Glalie',363:'Spheal',364:'Sealeo',365:'Walrein',366:'Clamperl',367:'Huntail',368:'Gorebyss',369:'Relicanth',370:'Luvdisc',371:'Bagon',372:'Shelgon',373:'Salamence',374:'Beldum',375:'Metang',376:'Metagross',377:'Regirock',378:'Regice',379:'Registeel',380:'Latias',381:'Latios',382:'Kyogre',383:'Groudon',384:'Rayquaza',385:'Jirachi',386:'Deoxys',387:'Turtwig',388:'Grotle',389:'Torterra',390:'Chimchar',391:'Monferno',392:'Infernape',393:'Piplup',394:'Prinplup',395:'Empoleon',396:'Starly',397:'Staravia',398:'Staraptor',399:'Bidoof',400:'Bibarel',401:'Kricketot',402:'Kricketune',403:'Shinx',404:'Luxio',405:'Luxray',406:'Budew',407:'Roserade',408:'Cranidos',409:'Rampardos',410:'Shieldon',411:'Bastiodon',412:'Burmy',413:'Wormadam',414:'Mothim',415:'Combee',416:'Vespiquen',417:'Pachirisu',418:'Buizel',419:'Floatzel',420:'Cherubi',421:'Cherrim',422:'Shellos',423:'Gastrodon',424:'Ambipom',425:'Drifloon',426:'Drifblim',427:'Buneary',428:'Lopunny',429:'Mismagius',430:'Honchkrow',431:'Glameow',432:'Purugly',433:'Chingling',434:'Stunky',435:'Skuntank',436:'Bronzor',437:'Bronzong',438:'Bonsly',439:'Mime Jr.',440:'Happiny',441:'Chatot',442:'Spiritomb',443:'Gible',444:'Gabite',445:'Garchomp',446:'Munchlax',447:'Riolu',448:'Lucario',449:'Hippopotas',450:'Hippowdon',451:'Skorupi',452:'Drapion',453:'Croagunk',454:'Toxicroak',455:'Carnivine',456:'Finneon',457:'Lumineon',458:'Mantyke',459:'Snover',460:'Abomasnow',461:'Weavile',462:'Magnezone',463:'Lickilicky',464:'Rhyperior',465:'Tangrowth',466:'Electivire',467:'Magmortar',468:'Togekiss',469:'Yanmega',470:'Leafeon',471:'Glaceon',472:'Gliscor',473:'Mamoswine',474:'Porygon-Z',475:'Gallade',476:'Probopass',477:'Dusknoir',478:'Froslass',479:'Rotom',480:'Uxie',481:'Mesprit',482:'Azelf',483:'Dialga',484:'Palkia',485:'Heatran',486:'Regigigas',487:'Giratina',488:'Cresselia',489:'Phione',490:'Manaphy',491:'Darkrai',492:'Shaymin',493:'Arceus',494:'Victini',495:'Snivy',496:'Servine',497:'Serperior',498:'Tepig',499:'Pignite',500:'Emboar',501:'Oshawott',502:'Dewott',503:'Samurott',504:'Patrat',505:'Watchog',506:'Lillipup',507:'Herdier',508:'Stoutland',509:'Purrloin',510:'Liepard',511:'Pansage',512:'Simisage',513:'Pansear',514:'Simisear',515:'Panpour',516:'Simipour',517:'Munna',518:'Musharna',519:'Pidove',520:'Tranquill',521:'Unfezant',522:'Blitzle',523:'Zebstrika',524:'Roggenrola',525:'Boldore',526:'Gigalith',527:'Woobat',528:'Swoobat',529:'Drilbur',530:'Excadrill',531:'Audino',532:'Timburr',533:'Gurdurr',534:'Conkeldurr',535:'Tympole',536:'Palpitoad',537:'Seismitoad',538:'Throh',539:'Sawk',540:'Sewaddle',541:'Swadloon',542:'Leavanny',543:'Venipede',544:'Whirlipede',545:'Scolipede',546:'Cottonee',547:'Whimsicott',548:'Petilil',549:'Lilligant',550:'Basculin',551:'Sandile',552:'Krokorok',553:'Krookodile',554:'Darumaka',555:'Darmanitan',556:'Maractus',557:'Dwebble',558:'Crustle',559:'Scraggy',560:'Scrafty',561:'Sigilyph',562:'Yamask',563:'Cofagrigus',564:'Tirtouga',565:'Carracosta',566:'Archen',567:'Archeops',568:'Trubbish',569:'Garbodor',570:'Zorua',571:'Zoroark',572:'Minccino',573:'Cinccino',574:'Gothita',575:'Gothorita',576:'Gothitelle',577:'Solosis',578:'Duosion',579:'Reuniclus',580:'Ducklett',581:'Swanna',582:'Vanillite',583:'Vanillish',584:'Vanilluxe',585:'Deerling',586:'Sawsbuck',587:'Emolga',588:'Karrablast',589:'Escavalier',590:'Foongus',591:'Amoonguss',592:'Frillish',593:'Jellicent',594:'Alomomola',595:'Joltik',596:'Galvantula',597:'Ferroseed',598:'Ferrothorn',599:'Klink',600:'Klang',601:'Klinklang',602:'Tynamo',603:'Eelektrik',604:'Eelektross',605:'Elgyem',606:'Beheeyem',607:'Litwick',608:'Lampent',609:'Chandelure',610:'Axew',611:'Fraxure',612:'Haxorus',613:'Cubchoo',614:'Beartic',615:'Cryogonal',616:'Shelmet',617:'Accelgor',618:'Stunfisk',619:'Mienfoo',620:'Mienshao',621:'Druddigon',622:'Golett',623:'Golurk',624:'Pawniard',625:'Bisharp',626:'Bouffalant',627:'Rufflet',628:'Braviary',629:'Vullaby',630:'Mandibuzz',631:'Heatmor',632:'Durant',633:'Deino',634:'Zweilous',635:'Hydreigon',636:'Larvesta',637:'Volcarona',638:'Cobalion',639:'Terrakion',640:'Virizion',641:'Tornadus',642:'Thundurus',643:'Reshiram',644:'Zekrom',645:'Landorus',646:'Kyurem',647:'Keldeo',648:'Meloetta',649:'Genesect',650:'Chespin',651:'Quilladin',652:'Chesnaught',653:'Fennekin',654:'Braixen',655:'Delphox',656:'Froakie',657:'Frogadier',658:'Greninja',700:'Sylveon',701:'Hawlucha',716:'Xerneas',717:'Yveltal',718:'Zygarde',722:'Rowlet',723:'Dartrix',724:'Decidueye',725:'Litten',726:'Torracat',727:'Incineroar',728:'Popplio',729:'Brionne',730:'Primarina',745:'Lycanroc',772:'Type: Null',773:'Silvally',778:'Mimikyu',785:'Tapu Koko',791:'Solgaleo',792:'Lunala',800:'Necrozma',810:'Grookey',811:'Thwackey',812:'Rillaboom',813:'Scorbunny',814:'Raboot',815:'Cinderace',816:'Sobble',817:'Drizzile',818:'Inteleon',884:'Duraludon',885:'Dreepy',886:'Drakloak',887:'Dragapult',888:'Zacian',889:'Zamazenta',890:'Eternatus',906:'Sprigatito',907:'Floragato',908:'Meowscarada',909:'Fuecoco',910:'Crocalor',911:'Skeledirge',912:'Quaxly',913:'Quaxwell',914:'Quaquaval',980:'Clodsire',1007:'Koraidon',1008:'Miraidon'};
function pokeName(id) {
if (id >= 1 && id <= 151) return GEN1[id - 1] || `#${id}`;
return EXTRA_NAMES[id] || `#${id}`;
}
// ── CSS ────────────────────────────────────────────────────
const CSS = `
#cm-fab {
position:fixed; bottom:14px; right:14px; z-index:99998;
background:#0d0d1a; color:#ffe066; border:2px solid #ffe066;
border-radius:6px; padding:6px 11px; font-size:16px; cursor:pointer;
box-shadow:0 2px 12px #000a; font-family:'Press Start 2P',monospace;
transition:opacity .15s; line-height:1;
}
#cm-fab:hover { opacity:.8; }
#cm-backdrop { position:fixed; inset:0; background:#000b; z-index:99997; }
#${MENU_ID} {
position:fixed; top:50%; left:50%; transform:translate(-50%,-50%);
z-index:99999; width:min(96vw,620px); max-height:92vh; overflow-y:auto;
background:#0d0d1a; border:2px solid #ffe066; border-radius:10px;
padding:0 0 14px; box-shadow:0 8px 40px #000e;
font-family:'Press Start 2P',monospace; color:#e8e8e8;
scrollbar-width:thin; scrollbar-color:#ffe066 #1a1a2e;
}
#${MENU_ID}::-webkit-scrollbar { width:5px; }
#${MENU_ID}::-webkit-scrollbar-track { background:#1a1a2e; }
#${MENU_ID}::-webkit-scrollbar-thumb { background:#ffe066; border-radius:3px; }
.cm-hdr {
position:sticky; top:0; z-index:10; background:#0d0d1a;
border-bottom:2px solid #1e1e38; padding:10px 14px 8px;
display:flex; align-items:center; justify-content:space-between;
}
.cm-hdr-title { font-size:9px; color:#ffe066; letter-spacing:2px; }
.cm-x { background:none; border:none; color:#888; font-size:18px; cursor:pointer; font-family:monospace; padding:0; }
.cm-x:hover { color:#fff; }
.cm-tabs { display:flex; overflow-x:auto; background:#12122a; border-bottom:2px solid #1e1e38; scrollbar-width:none; }
.cm-tabs::-webkit-scrollbar { display:none; }
.cm-tab {
flex-shrink:0; padding:8px 12px; font-size:7px; color:#666; cursor:pointer;
border-bottom:2px solid transparent; white-space:nowrap;
background:none; border-top:none; border-left:none; border-right:none;
font-family:inherit; transition:color .12s, border-color .12s;
}
.cm-tab:hover { color:#aaa; }
.cm-tab.active { color:#ffe066; border-bottom-color:#ffe066; }
.cm-panel { display:none; padding:10px 12px; }
.cm-panel.active { display:block; }
.cm-sec { margin-bottom:10px; border:1px solid #1e1e38; border-radius:6px; overflow:hidden; }
.cm-sec-ttl { background:#12122a; color:#ffe066; font-size:7px; letter-spacing:1px; padding:5px 9px; border-bottom:1px solid #1e1e38; }
.cm-sec-note { font-size:6px; color:#888; padding:5px 9px 0; }
.cm-sec-body { padding:9px; display:flex; flex-wrap:wrap; gap:6px; }
.cm-sec-body.col { flex-direction:column; gap:7px; }
.cm-btn {
font-family:inherit; font-size:7px; padding:5px 9px; border-radius:4px;
border:1px solid #3a3a5a; background:#1a1a30; color:#ccc;
cursor:pointer; white-space:nowrap; line-height:1.5;
display:inline-flex; align-items:center; gap:5px;
transition:background .1s, border-color .1s, color .1s;
}
.cm-btn:hover { background:#252545; border-color:#ffe066; color:#ffe066; }
.cm-btn.ok { border-color:#2a5; color:#6f6; }
.cm-btn.ok:hover { background:#0a200a; border-color:#4f4; }
.cm-btn.bad { border-color:#622; color:#f66; }
.cm-btn.bad:hover { background:#200a0a; border-color:#f44; }
.cm-btn.blu { border-color:#247; color:#8af; }
.cm-btn.blu:hover { background:#080e20; border-color:#6af; }
.cm-btn.yel { border-color:#660; color:#fda; }
.cm-btn.yel:hover { background:#1a1000; border-color:#fc0; }
.cm-btn img { width:14px; height:14px; image-rendering:pixelated; vertical-align:middle; }
.cm-row { display:flex; align-items:center; gap:7px; width:100%; }
.cm-row label { font-size:7px; color:#888; white-space:nowrap; min-width:70px; }
.cm-row input[type=range] { flex:1; accent-color:#ffe066; height:3px; }
.cm-row input[type=number], .cm-row input[type=text], .cm-row select {
font-family:inherit; font-size:7px; background:#12122a;
border:1px solid #3a3a5a; border-radius:4px; color:#e8e8e8; padding:3px 6px;
}
.cm-row input[type=number] { width:62px; }
.cm-row input[type=text] { flex:1; }
.cm-row select { flex:1; }
.cm-val { font-size:8px; color:#ffe066; min-width:28px; text-align:right; }
input:focus, select:focus { outline:1px solid #ffe066; }
select option { background:#12122a; color:#e8e8e8; }
/* Team */
.cm-tlist { display:flex; flex-direction:column; gap:6px; width:100%; }
.cm-prow {
display:flex; align-items:center; gap:7px; background:#12122a;
border-radius:5px; padding:5px 7px; border:1px solid transparent;
flex-wrap:wrap; cursor:pointer; transition:border-color .1s;
}
.cm-prow:hover { border-color:#3a3a5a; }
.cm-prow.sel { border-color:#ffe066; }
.cm-psp { width:36px; height:36px; image-rendering:pixelated; flex-shrink:0; }
.cm-pnm { flex:1; font-size:7px; color:#ddd; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:80px; }
.cm-php-wrap { flex:1; min-width:50px; background:#333; border-radius:3px; height:5px; overflow:hidden; }
.cm-php-bar { height:100%; border-radius:3px; transition:width .2s; }
.cm-php-txt { font-size:7px; color:#888; min-width:52px; text-align:right; }
.cm-detail { width:100%; background:#0d0d1a; border-radius:5px; padding:8px; border:1px solid #1e1e38; margin-top:3px; }
.cm-detail-ttl { font-size:7px; color:#ffe066; margin-bottom:5px; letter-spacing:1px; }
.cm-stat-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:5px; margin-bottom:7px; }
.cm-stat-item { display:flex; flex-direction:column; gap:2px; }
.cm-stat-item label { font-size:6px; color:#888; }
.cm-stat-item input { font-family:inherit; font-size:7px; background:#12122a; border:1px solid #3a3a5a; border-radius:3px; color:#e8e8e8; padding:2px 5px; width:100%; }
/* Search */
.cm-results { max-height:160px; overflow-y:auto; background:#12122a; border-radius:5px; border:1px solid #1e1e38; display:flex; flex-direction:column; }
.cm-result { display:flex; align-items:center; gap:7px; padding:4px 7px; cursor:pointer; font-size:7px; transition:background .1s; }
.cm-result:hover { background:#1a1a30; }
.cm-result img { width:28px; height:28px; image-rendering:pixelated; }
/* Bag */
#cm-bag-list { max-height:180px; overflow-y:auto; display:flex; flex-direction:column; gap:3px; width:100%; }
.cm-bag-row { display:flex; align-items:center; justify-content:space-between; padding:3px 6px; font-size:7px; color:#bbb; background:#12122a; border-radius:3px; }
.cm-bag-row img { width:14px; height:14px; image-rendering:pixelated; margin-right:3px; vertical-align:middle; }
/* Node picker */
.cm-node-grid { display:flex; flex-direction:column; gap:4px; width:100%; max-height:200px; overflow-y:auto; }
.cm-node-row { display:flex; align-items:center; gap:6px; padding:4px 6px; background:#12122a; border-radius:4px; font-size:7px; cursor:pointer; border:1px solid transparent; }
.cm-node-row:hover { border-color:#ffe066; color:#ffe066; }
.cm-node-badge { font-size:6px; padding:1px 4px; border-radius:3px; background:#1e1e38; color:#aaa; }
/* HoF editor */
.cm-hof-entry { background:#12122a; border-radius:5px; padding:7px 9px; border:1px solid #1e1e38; font-size:7px; display:flex; align-items:flex-start; gap:8px; flex-wrap:wrap; }
.cm-hof-sprites { display:flex; gap:3px; flex-shrink:0; }
.cm-hof-sprites img { width:26px; height:26px; image-rendering:pixelated; }
.cm-hof-meta { flex:1; color:#aaa; font-size:6px; line-height:1.8; }
.cm-hof-meta b { color:#ffe066; }
/* Freeze */
#cm-freeze-banner { display:none; position:fixed; top:0; left:0; right:0; z-index:89999; background:#ffe066; color:#0d0d1a; font-family:'Press Start 2P',monospace; font-size:7px; text-align:center; padding:5px; pointer-events:none; }
#cm-freeze-ov { display:none; position:fixed; inset:0; z-index:89998; pointer-events:all; cursor:not-allowed; }
/* Feedback */
#cm-feedback { font-size:7px; min-height:14px; text-align:center; padding:4px 12px 0; color:#4f4; }
#cm-feedback.err { color:#f66; }
#cm-feedback.warn { color:#fda; }
`;
// ── STATE ──────────────────────────────────────────────────
let _selIdx = null;
let _snapshot = null;
// ── HELPERS ────────────────────────────────────────────────
const S = () => (typeof state !== 'undefined' ? state : null);
function fb(msg, cls = '') {
const el = document.getElementById('cm-feedback');
if (!el) return;
el.textContent = msg; el.className = cls;
clearTimeout(el._t);
el._t = setTimeout(() => { el.textContent = ''; el.className = ''; }, 3500);
}
function need(fn) {
const s = S();
if (!s || !s.team?.length) { fb('No active run — start a game first!', 'err'); return; }
fn(s);
}
function persist(s) {
try { if (typeof saveRun === 'function') saveRun(); } catch (_) {}
try { if (typeof renderTeamBar === 'function') renderTeamBar(s.team); } catch (_) {}
try { if (typeof renderItemBadges === 'function') renderItemBadges(s.items); } catch (_) {}
}
// calcHp confirmed formula: Math.floor(baseHp * level / 50) + level + 10
function setLvl(p, lvl) {
lvl = Math.max(1, Math.floor(+lvl));
p.level = lvl;
try {
const raw = typeof calcHp === 'function'
? calcHp(p.baseStats.hp, lvl)
: (Math.floor((p.baseStats?.hp || 50) * lvl / 50) + lvl + 10);
const buff = p.statBuffs?.hp ?? 0;
const newMax = Math.floor(raw * (1 + 0.1 * buff));
if (p.currentHp > 0) p.currentHp = Math.min(p.currentHp, newMax);
p.maxHp = newMax;
} catch (_) {}
}
function iSpr(id, size = 14) {
const slug = id.replace(/_/g, '-');
return `<img src="${IP}${slug}.png" style="width:${size}px;height:${size}px;image-rendering:pixelated;vertical-align:middle;" onerror="this.style.display='none'">`;
}
function realItem(id) {
try {
return [...(typeof ITEM_POOL !== 'undefined' ? ITEM_POOL : []),
...(typeof USABLE_ITEM_POOL !== 'undefined' ? USABLE_ITEM_POOL : [])]
.find(it => it.id === id) || null;
} catch (_) { return null; }
}
// Get the evo-line root (game stores stat buffs by this key)
function evoRoot(speciesId) {
try {
if (typeof getEvoLineRoot === 'function') return getEvoLineRoot(speciesId);
// Fallback: walk EVOLUTIONS backwards
if (typeof EVOLUTIONS === 'undefined') return speciesId;
let id = speciesId, changed = true;
while (changed) {
changed = false;
for (const [from, evo] of Object.entries(EVOLUTIONS)) {
if (evo.into === id) { id = +from; changed = true; break; }
}
}
return id;
} catch (_) { return speciesId; }
}
// ── SNAPSHOT ───────────────────────────────────────────────
function takeSnapshot() {
try { _snapshot = JSON.stringify(S()); fb('Snapshot saved — click Restore to rewind here.'); }
catch (e) { fb('Snapshot failed: ' + e.message, 'err'); }
}
function restoreSnapshot() {
if (!_snapshot) { fb('No snapshot taken yet.', 'err'); return; }
if (!confirm('Restore snapshot? Current state will be overwritten.')) return;
try {
const s = S(); if (!s) { fb('No live state.', 'err'); return; }
Object.assign(s, JSON.parse(_snapshot));
persist(s); _selIdx = null; renderTeam('cm-teamlist'); fb('Snapshot restored!');
} catch (e) { fb('Restore failed: ' + e.message, 'err'); }
}
// ── FREEZE ─────────────────────────────────────────────────
function freezeGame() {
try { window._nodeClickBusy = true; } catch (_) {}
let ov = document.getElementById('cm-freeze-ov');
let bn = document.getElementById('cm-freeze-banner');
if (!ov) { ov = document.createElement('div'); ov.id = 'cm-freeze-ov'; document.body.appendChild(ov); }
if (!bn) { bn = document.createElement('div'); bn.id = 'cm-freeze-banner'; bn.textContent = '⏸ GAME PAUSED — press ` and click Unfreeze to resume'; document.body.appendChild(bn); }
ov.style.display = 'block'; bn.style.display = 'block';
fb('Game frozen — map clicks are blocked.');
}
function unfreezeGame() {
try { window._nodeClickBusy = false; } catch (_) {}
document.getElementById('cm-freeze-ov' )?.remove();
document.getElementById('cm-freeze-banner')?.remove();
fb('Game unpaused.');
}
// ── MOVE POWER PATCH ───────────────────────────────────────
function ensureMovePowerPatch() {
if (window.__cmMovePatch) return;
window.__cmMovePatch = true;
try {
const orig = getBestMove;
getBestMove = function(types, baseStats, speciesId, moveTier) {
const move = orig.call(this, types, baseStats, speciesId, moveTier);
const p = S()?.team?.find(pk => pk.speciesId === speciesId && pk._customMovePower);
return (p && move) ? { ...move, power: p._customMovePower } : move;
};
} catch (_) {}
}
// ── EVO CHAIN ──────────────────────────────────────────────
function getEvoChain(speciesId) {
try {
if (typeof buildEvoChain === 'function') {
const { chain } = buildEvoChain(speciesId);
const ids = []; function walk(n) { if (!ids.includes(n.id)) ids.push(n.id); (n.evolvesInto||[]).forEach(walk); } walk(chain);
return ids.sort((a, b) => a - b);
}
if (typeof EVOLUTIONS === 'undefined') return [];
let root = speciesId, changed = true;
while (changed) { changed = false; for (const [f, e] of Object.entries(EVOLUTIONS)) { if (e.into === root) { root = +f; changed = true; break; } } }
const ch = [root]; let cur = root;
while (EVOLUTIONS[cur]) { cur = EVOLUTIONS[cur].into; ch.push(cur); }
return ch;
} catch (_) { return []; }
}
// ── TEAM RENDER ────────────────────────────────────────────
function renderTeam(cid, detail = true) {
const el = document.getElementById(cid);
if (!el) return;
const s = S();
const bc = document.getElementById('cm-badge-val');
if (bc && s) bc.textContent = s.badges ?? 0;
if (!s?.team?.length) { el.innerHTML = '<span style="font-size:7px;color:#555;padding:4px;">No team yet — start a run first.</span>'; return; }
el.innerHTML = '';
s.team.forEach((p, i) => {
const pct = Math.max(0, Math.min(100, Math.round((p.currentHp / p.maxHp) * 100)));
const col = pct > 50 ? '#4f4' : pct > 20 ? '#ff0' : '#f44';
const sprite = p.spriteUrl || (p.isShiny ? `${SPS}${p.speciesId}.png` : `${SP}${p.speciesId}.png`);
const tags = [p.isShiny ? '✨' : '', p._customMovePower ? `⚡${p._customMovePower}` : '', p.heldItem ? '🎒' : ''].filter(Boolean).join(' ');
const row = document.createElement('div');
row.className = 'cm-prow' + (detail && _selIdx === i ? ' sel' : '');
row.dataset.idx = i;
row.innerHTML = `
<img class="cm-psp" src="${sprite}" alt="${p.name}" onerror="this.src='${SP}${p.speciesId}.png'">
<span class="cm-pnm">[${i}] ${p.nickname || p.name} Lv${p.level}${tags ? ' ' + tags : ''}</span>
<div class="cm-php-wrap" title="${p.currentHp}/${p.maxHp} HP">
<div class="cm-php-bar" style="width:${pct}%;background:${col};"></div>
</div>
<span class="cm-php-txt">${p.currentHp}/${p.maxHp}</span>`;
el.appendChild(row);
if (detail && _selIdx === i) {
const d = document.createElement('div'); d.className = 'cm-detail'; d.innerHTML = buildDetail(p, i); el.appendChild(d);
}
});
}
function buildDetail(p, idx) {
const bs = p.baseStats || {};
const statRows = ['hp','atk','def','speed','special','spdef'].map(k => `
<div class="cm-stat-item">
<label>${k.toUpperCase()}</label>
<input type="number" class="cm-si" data-pi="${idx}" data-st="${k}" min="1" max="9999" value="${bs[k] ?? 50}">
</div>`).join('');
const chain = getEvoChain(p.speciesId);
const evoHtml = chain.length > 1 ? `
<div class="cm-detail-ttl">EVO CHAIN</div>
<div style="display:flex;gap:5px;flex-wrap:wrap;margin-bottom:8px;">
${chain.map(id => `
<button class="cm-btn ${id===p.speciesId?'yel':id<p.speciesId?'bad':'ok'}"
style="padding:3px 7px;gap:3px;font-size:6px;" data-a="evo" data-pi="${idx}" data-eid="${id}">
<img src="${SP}${id}.png" style="width:20px;height:20px;image-rendering:pixelated;border-radius:2px;">
${pokeName(id)}
</button>`).join('')}
</div>` : '';
const typeOpts = GAME_TYPES.map(t => `<option value="${t}"${(p.types||[])[0]===t?' selected':''}>${t}</option>`).join('');
const type2Opts = '<option value="">— none —</option>' + GAME_TYPES.map(t => `<option value="${t}"${(p.types||[])[1]===t?' selected':''}>${t}</option>`).join('');
const curMode = (bs.special||0) >= (bs.atk||0) ? 'SPECIAL attacker' : 'PHYSICAL attacker';
return `
${evoHtml}
<div class="cm-detail-ttl">NICKNAME</div>
<div class="cm-row" style="margin-bottom:8px;">
<input type="text" class="cm-nick" data-pi="${idx}" placeholder="${p.name}" value="${p.nickname||''}" maxlength="20">
<button class="cm-btn ok" data-a="nick" data-pi="${idx}" style="font-size:6px;">Set</button>
<button class="cm-btn" data-a="nick-clear" data-pi="${idx}" style="font-size:6px;">Clear</button>
</div>
<div class="cm-detail-ttl">BASE STATS — ${curMode}</div>
<div class="cm-stat-grid">${statRows}</div>
<div style="display:flex;gap:5px;flex-wrap:wrap;margin-bottom:8px;">
<button class="cm-btn ok" data-a="applystats" data-pi="${idx}" style="font-size:6px;">✓ Apply Stats</button>
<button class="cm-btn yel" data-a="godmode" data-pi="${idx}" style="font-size:6px;">💥 God Mode (999 all)</button>
<button class="cm-btn blu" data-a="make-special" data-pi="${idx}" style="font-size:6px;">→ Force Special Attacker</button>
<button class="cm-btn blu" data-a="make-physical" data-pi="${idx}" style="font-size:6px;">→ Force Physical Attacker</button>
</div>
<div class="cm-detail-ttl">MOVE POWER — per-Pokémon damage override</div>
<div class="cm-row" style="margin-bottom:8px;">
<input type="number" class="cm-movepwr" data-pi="${idx}" min="1" max="9999" value="${p._customMovePower||''}" placeholder="e.g. 500">
<button class="cm-btn ok" data-a="setmovepwr" data-pi="${idx}" style="font-size:6px;">Set</button>
<button class="cm-btn" data-a="clearmovepwr" data-pi="${idx}" style="font-size:6px;">Reset</button>
<span style="font-size:6px;color:${p._customMovePower?'#ffe066':'#555'};">${p._customMovePower ? 'Active: ' + p._customMovePower : 'Default'}</span>
</div>
<div class="cm-detail-ttl">CUSTOM TYPE — all 18 game types affect damage and STAB</div>
<div class="cm-row" style="margin-bottom:8px;">
<label>Type 1</label><select class="cm-type1" data-pi="${idx}">${typeOpts}</select>
<label>Type 2</label><select class="cm-type2" data-pi="${idx}">${type2Opts}</select>
<button class="cm-btn ok" data-a="settype" data-pi="${idx}" style="font-size:6px;">Set</button>
</div>
<div style="font-size:6px;color:#888;margin-bottom:8px;">Current: ${(p.types||[]).join(' / ')}</div>
<div class="cm-detail-ttl">HELD ITEM</div>
<div style="display:flex;gap:4px;flex-wrap:wrap;margin-bottom:8px;">
${HELD_ITEMS.map(it => `<button class="cm-btn" style="font-size:5.5px;padding:2px 4px;" data-a="equip" data-pi="${idx}" data-iid="${it.id}" title="${it.name}">${iSpr(it.id)} ${it.name}</button>`).join('')}
<button class="cm-btn bad" data-a="unequip" data-pi="${idx}" style="font-size:6px;">✕ Remove</button>
</div>
<div class="cm-detail-ttl">MOVE TIER (0=weak 1=normal 2=strongest)</div>
<div style="display:flex;gap:5px;margin-bottom:8px;align-items:center;">
<button class="cm-btn" data-a="tier0" data-pi="${idx}" style="font-size:6px;">Tier 0</button>
<button class="cm-btn ok" data-a="tier1" data-pi="${idx}" style="font-size:6px;">Tier 1</button>
<button class="cm-btn yel" data-a="tier2" data-pi="${idx}" style="font-size:6px;">Tier 2</button>
<span style="font-size:6px;color:#ffe066;">Now: ${p.moveTier ?? 1}</span>
</div>
<div style="display:flex;gap:5px;flex-wrap:wrap;">
<button class="cm-btn yel" data-a="shiny1" data-pi="${idx}" style="font-size:6px;">✨ Shiny ON</button>
<button class="cm-btn" data-a="shiny0" data-pi="${idx}" style="font-size:6px;">Remove Shiny</button>
<button class="cm-btn ok" data-a="heal" data-pi="${idx}" style="font-size:6px;">❤ Heal</button>
<button class="cm-btn bad" data-a="ko" data-pi="${idx}" style="font-size:6px;">☠ KO</button>
</div>`;
}
// ── BAG RENDER ─────────────────────────────────────────────
function renderBag() {
const el = document.getElementById('cm-bag-list');
if (!el) return;
const s = S();
if (!s?.items?.length) { el.innerHTML = '<span style="font-size:7px;color:#555;padding:4px;">Bag is empty.</span>'; return; }
const g = {};
s.items.forEach(it => { if (!g[it.id]) g[it.id] = { ...it, count:0 }; g[it.id].count++; });
el.innerHTML = Object.values(g).map(it =>
`<div class="cm-bag-row"><span>${iSpr(it.id)} ${it.name||it.id}</span><span style="color:#ffe066;">×${it.count}</span></div>`
).join('');
}
// ── HoF RENDER ─────────────────────────────────────────────
function renderHoF() {
const el = document.getElementById('cm-hof-list');
if (!el) return;
let hof = [];
try { hof = JSON.parse(localStorage.getItem('poke_hall_of_fame') || '[]'); } catch (_) {}
if (!hof.length) { el.innerHTML = '<span style="font-size:7px;color:#555;">Hall of Fame is empty.</span>'; return; }
el.innerHTML = '';
hof.forEach((entry, i) => {
const div = document.createElement('div');
div.className = 'cm-hof-entry';
const sprites = (entry.team||[]).map(p =>
`<img src="${p.spriteUrl||`${SP}${p.speciesId}.png`}" onerror="this.style.display='none'">`).join('');
const label = entry.endless
? `${STAGE_NAMES[entry.stageNumber] || 'Endless'} Stage ${entry.stageNumber}`
: `Classic Run #${entry.runNumber}`;
div.innerHTML = `
<div class="cm-hof-sprites">${sprites}</div>
<div class="cm-hof-meta" style="flex:1;">
<b>${label}</b> ${entry.date || ''}<br>
${(entry.team||[]).map(p => `${p.nickname||p.name} Lv${p.level}`).join(', ')}
</div>
<button class="cm-btn bad" data-hof-del="${i}" style="font-size:6px;padding:2px 6px;">✕</button>`;
el.appendChild(div);
});
el.querySelectorAll('[data-hof-del]').forEach(btn => {
btn.addEventListener('click', () => {
try {
const idx = +btn.dataset.hofDel;
const hof2 = JSON.parse(localStorage.getItem('poke_hall_of_fame') || '[]');
hof2.splice(idx, 1);
localStorage.setItem('poke_hall_of_fame', JSON.stringify(hof2));
fb('Entry removed.'); renderHoF();
} catch (e) { fb(e.message, 'err'); }
});
});
}
// ── NODE PICKER ─────────────────────────────────────────────
function renderNodePicker() {
const el = document.getElementById('cm-node-grid');
if (!el) return;
const s = S();
if (!s?.map?.nodes) { el.innerHTML = '<span style="font-size:7px;color:#555;">No map loaded yet.</span>'; return; }
const nodes = Object.values(s.map.nodes).sort((a,b) => a.layer!==b.layer ? a.layer-b.layer : (a.col??0)-(b.col??0));
el.innerHTML = '';
nodes.forEach(node => {
const mark = node.visited ? '✓' : node.accessible ? '→' : '·';
const row = document.createElement('div'); row.className = 'cm-node-row';
row.innerHTML = `<span class="cm-node-badge">L${node.layer}</span><span style="flex:1;">${node.type||'battle'} ${node.id}</span><span style="color:${node.visited?'#888':node.accessible?'#ffe066':'#444'}">${mark}</span>`;
row.addEventListener('click', () => need(s => {
for (const n of Object.values(s.map.nodes)) {
if (n.layer < node.layer) { n.visited = true; n.accessible = false; }
if (n.layer === node.layer) { n.accessible = (n.id === node.id); n.visited = false; }
if (n.layer > node.layer) { n.visited = false; n.accessible = false; }
}
node.accessible = true; node.visited = false; s.currentNode = node;
persist(s); closeMenu();
try { if (typeof showMapScreen === 'function') showMapScreen(); } catch (_) {}
fb(`Teleported to node ${node.id} (L${node.layer})`);
}));
el.appendChild(row);
});
}
// ── BUILD MENU HTML ─────────────────────────────────────────
function buildMenuHTML() {
const heldOpts = HELD_ITEMS.map(it => `<option value="${it.id}">${it.name}</option>`).join('');
const usableOpts = USABLE_ITEMS.map(it => `<option value="${it.id}">${it.name}</option>`).join('');
const allOpts = `<optgroup label="Held Items">${heldOpts}</optgroup><optgroup label="Usable Items">${usableOpts}</optgroup>`;
return `
<div class="cm-hdr">
<span class="cm-hdr-title">⌨ POKELIKE CHEATS</span>
<button class="cm-x" id="cm-close">✕</button>
</div>
<div class="cm-tabs">
<button class="cm-tab active" data-tab="team">🐾 Team</button>
<button class="cm-tab" data-tab="items">🎒 Items</button>
<button class="cm-tab" data-tab="progress">🗺 Progress</button>
<button class="cm-tab" data-tab="unlock">🔓 Unlock</button>
<button class="cm-tab" data-tab="account">👤 Account</button>
<button class="cm-tab" data-tab="screens">📺 Screens</button>
</div>
<!-- ═══ TEAM ═══ -->
<div class="cm-panel active" id="cm-t-team">
<div class="cm-sec">
<div class="cm-sec-ttl">🔎 ADD POKÉMON — Gen 1–9 by name or Pokédex #</div>
<div class="cm-sec-body col">
<div class="cm-row">
<input type="text" id="cm-psearch" placeholder="e.g. Garchomp, 445, pikachu…" autocomplete="off">
<label>Lv</label>
<input type="number" id="cm-padd-lv" value="5" min="1" style="width:46px;">
</div>
<div id="cm-presults" class="cm-results" style="display:none;"></div>
<div id="cm-psel-label" style="font-size:7px;color:#ffe066;min-height:12px;"></div>
<div style="display:flex;gap:6px;">
<button class="cm-btn ok" id="cm-padd-btn">+ Add to Team</button>
<button class="cm-btn" id="cm-padd-clear">Clear</button>
</div>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🐾 TEAM — click a row to expand options</div>
<div class="cm-sec-body col">
<div class="cm-tlist" id="cm-teamlist"></div>
</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-heal-all">❤ Full Heal All</button>
<button class="cm-btn ok" id="cm-revive-all">↑ Revive Fainted</button>
<button class="cm-btn" id="cm-cure-status">✦ Cure Status</button>
<button class="cm-btn bad" id="cm-ko-all">☠ KO Own Team</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">⬆ BULK LEVELS — slider goes to 9999, no level cap enforced</div>
<div class="cm-sec-body">
<div class="cm-row" style="width:100%;">
<label>Set all Lv</label>
<input type="range" id="cm-lv-slider" min="1" max="9999" value="50">
<span class="cm-val" id="cm-lv-val">50</span>
<button class="cm-btn ok" id="cm-lv-apply">Apply</button>
</div>
<button class="cm-btn" id="cm-lv-p1">+1</button>
<button class="cm-btn" id="cm-lv-p5">+5</button>
<button class="cm-btn" id="cm-lv-p100">+100</button>
<button class="cm-btn" id="cm-lv-1">→ Lv 1</button>
<button class="cm-btn" id="cm-lv-100">→ Lv 100</button>
<button class="cm-btn yel" id="cm-lv-9999">→ Lv 9999 💥</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">✨ SHINY — whole team</div>
<div class="cm-sec-body">
<button class="cm-btn yel" id="cm-shiny-on">✨ Make All Shiny</button>
<button class="cm-btn" id="cm-shiny-off">Remove Shiny</button>
</div>
</div>
</div>
<!-- ═══ ITEMS ═══ -->
<div class="cm-panel" id="cm-t-items">
<div class="cm-sec">
<div class="cm-sec-ttl">➕ ADD ITEMS TO BAG</div>
<div class="cm-sec-body col">
<div class="cm-row"><label>Item</label><select id="cm-item-sel">${allOpts}</select></div>
<div class="cm-row">
<label>Quantity</label>
<input type="number" id="cm-item-qty" value="1" min="1" max="99">
<button class="cm-btn ok" id="cm-item-add">+ Add</button>
</div>
<div class="cm-row">
<button class="cm-btn ok" id="cm-candy-10">🍬 +10 Rare Candies</button>
<button class="cm-btn ok" id="cm-candy-99">🍬 +99 Rare Candies</button>
</div>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🎯 EQUIP HELD ITEM TO TEAM SLOT</div>
<div class="cm-sec-body col">
<div class="cm-row"><label>Item</label><select id="cm-equip-sel">${heldOpts}</select></div>
<div class="cm-row">
<label>→ Slot #</label>
<input type="number" id="cm-equip-slot" min="0" max="5" value="0" style="width:46px;">
<button class="cm-btn ok" id="cm-equip-btn">Equip</button>
<button class="cm-btn bad" id="cm-strip-all">Strip All</button>
</div>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🎒 CURRENT BAG</div>
<div class="cm-sec-body col">
<div id="cm-bag-list"></div>
<button class="cm-btn bad" id="cm-bag-clear" style="align-self:flex-start;margin-top:4px;">✕ Clear Bag</button>
</div>
</div>
</div>
<!-- ═══ PROGRESS ═══ -->
<div class="cm-panel" id="cm-t-progress">
<div class="cm-sec">
<div class="cm-sec-ttl">💾 SNAPSHOT — save a checkpoint to rewind to</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-snap-save">📸 Take Snapshot</button>
<button class="cm-btn yel" id="cm-snap-restore">↩ Restore Snapshot</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">⏸ FREEZE — blocks all map node clicks</div>
<div class="cm-sec-note">Sets the game's internal _nodeClickBusy flag. No map interactions until Unfreeze.</div>
<div class="cm-sec-body">
<button class="cm-btn bad" id="cm-freeze">⏸ Freeze Game</button>
<button class="cm-btn ok" id="cm-unfreeze">▶ Unfreeze</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🏅 BADGES — Current: <span id="cm-badge-val">?</span> / 8</div>
<div class="cm-sec-body">
<button class="cm-btn" id="cm-b-p1">+1</button>
<button class="cm-btn" id="cm-b-m1">-1</button>
<button class="cm-btn ok" id="cm-b-all">All 8</button>
<button class="cm-btn bad" id="cm-b-zero">Reset to 0</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🗺 MAP JUMP — regenerates the map via startMap()</div>
<div class="cm-sec-body">
<div class="cm-row" style="width:100%;">
<select id="cm-map-sel">
<option value="0">Route 1 — Brock (Rock)</option>
<option value="1">Mt Moon — Misty (Water)</option>
<option value="2">Nugget Bridge — Lt. Surge (Electric)</option>
<option value="3">Rock Tunnel — Erika (Grass)</option>
<option value="4">Silph Co — Koga (Poison)</option>
<option value="5">Safari Zone — Sabrina (Psychic)</option>
<option value="6">Seafoam Island — Blaine (Fire)</option>
<option value="7">Viridian City — Giovanni (Ground)</option>
<option value="8">Victory Road — Elite Four</option>
</select>
<button class="cm-btn ok" id="cm-map-go">Go</button>
</div>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">↩ UNDO LAST NODE — rewind the most recent map event</div>
<div class="cm-sec-note">Marks the highest visited layer as unvisited and accessible again. All nodes beyond it are locked. Useful for undoing a bad catch, trade, or battle result.</div>
<div class="cm-sec-body">
<button class="cm-btn yel" id="cm-go-back">↩ Undo Last Node</button>
<button class="cm-btn" id="cm-show-map">🗺 Show Map Screen</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">📍 NODE TELEPORT — jump to any specific map node</div>
<div class="cm-sec-body col">
<button class="cm-btn" id="cm-node-refresh">🔄 Load Node List</button>
<div class="cm-node-grid" id="cm-node-grid"></div>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">⚙ RUN OPTIONS</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-team-6">Team Limit → 6</button>
<button class="cm-btn" id="cm-toggle-nuzlocke">Toggle Nuzlocke</button>
<button class="cm-btn ok" id="cm-force-save">💾 Save Run</button>
<button class="cm-btn bad" id="cm-clear-run">⚠ Clear Run</button>
</div>
</div>
</div>
<!-- ═══ UNLOCK ═══ -->
<div class="cm-panel" id="cm-t-unlock">
<div class="cm-sec">
<div class="cm-sec-ttl">🗺 ENDLESS BATTLE TOWER — unlock all 5 regions</div>
<div class="cm-sec-note">
The game unlocks stages by reading your Hall of Fame. Each HoF entry with endless=true and a stageNumber unlocks the next stage.
This injects one completed entry per stage (Kanto→Johto→Hoenn→Sinnoh→Unova). Refresh to see them in the stage select.
</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-unlock-all-stages">Unlock All 5 Regions (Kanto→Unova)</button>
<button class="cm-btn blu" id="cm-unlock-johto">Unlock Johto only</button>
<button class="cm-btn blu" id="cm-unlock-hoenn">Unlock up to Hoenn</button>
<button class="cm-btn blu" id="cm-unlock-sinnoh">Unlock up to Sinnoh</button>
<button class="cm-btn bad" id="cm-reset-stages">Reset stage unlocks</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🏛 HALL OF FAME — view, edit, inject entries</div>
<div class="cm-sec-note">
Inject uses your current team if you're in a run. The injected entry appears in the HoF viewer and unlocks the Battle Tower. To use a specific team in Battle Tower, inject an entry with that team here, then start an Endless run — the game picks your last HoF team as a starting suggestion.
</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-hof-inject">Inject Entry (uses current team)</button>
<button class="cm-btn yel" id="cm-hof-refresh">🔄 View / Edit HoF</button>
<button class="cm-btn bad" id="cm-hof-reset">Reset HoF</button>
</div>
<div id="cm-hof-list" style="padding:6px 9px;display:flex;flex-direction:column;gap:5px;"></div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🏆 ACHIEVEMENTS — ${ALL_ACH_IDS.length} total</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-ach-all">Unlock ALL (${ALL_ACH_IDS.length})</button>
<button class="cm-btn blu" id="cm-ach-gyms">Gym badges only + set 8 badges</button>
<button class="cm-btn bad" id="cm-ach-reset">Reset All</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">📖 POKÉDEX — confirmed pool is Gen 1–5 (IDs 1–649)</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-dex-gen1">Catch Gen 1 (1–151)</button>
<button class="cm-btn ok" id="cm-dex-all">Catch All (1–649)</button>
<button class="cm-btn yel" id="cm-shiny-gen1">✨ Shiny Gen 1</button>
<button class="cm-btn yel" id="cm-shiny-all">✨ Shiny All (1–649)</button>
<button class="cm-btn bad" id="cm-dex-reset">Reset Pokédex</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">📈 PERSISTENT STAT BUFFS — keyed by evo-line root ID</div>
<div class="cm-sec-note">
The game stores buffs under the base-form species ID (evo-line root), not the current Pokémon's ID. E.g. Charizard (6) is stored under Charmander (4). "Max All" fills every root ID correctly. "Max Team" only buffs your current team's roots. Each stat can go up to 10/10, giving +100% to that stat.
</div>
<div class="cm-sec-body">
<button class="cm-btn ok" id="cm-buffs-max">Max All (every evo line)</button>
<button class="cm-btn blu" id="cm-buffs-team">Max Current Team Only</button>
<button class="cm-btn bad" id="cm-buffs-clear">Clear All Buffs</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🎮 WIN COUNTER (poke_elite_wins)</div>
<div class="cm-sec-body">
<div class="cm-row">
<label>Set count</label>
<input type="number" id="cm-wins-val" value="10" min="0">
<button class="cm-btn ok" id="cm-wins-set">Set</button>
</div>
</div>
</div>
</div>
<!-- ═══ ACCOUNT ═══ -->
<div class="cm-panel" id="cm-t-account">
<div class="cm-sec">
<div class="cm-sec-ttl">👤 TRAINER GENDER — changes in-battle sprite</div>
<div class="cm-sec-note">Sets poke_trainer and state.trainer. Takes effect immediately in any new battle.</div>
<div class="cm-sec-body">
<button class="cm-btn blu" id="cm-gender-boy">Set to Boy (Red)</button>
<button class="cm-btn blu" id="cm-gender-girl">Set to Girl (Dawn)</button>
<span id="cm-gender-cur" style="font-size:7px;color:#ffe066;margin-left:6px;"></span>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">📖 TUTORIAL — show or hide</div>
<div class="cm-sec-note">Removes poke_tutorial_seen and calls showTutorialOverlay() so the tutorial appears again on the next map visit.</div>
<div class="cm-sec-body">
<button class="cm-btn blu" id="cm-show-tutorial">Show Tutorial Again</button>
<button class="cm-btn" id="cm-hide-tutorial">Mark Tutorial Seen</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🏠 NAVIGATION</div>
<div class="cm-sec-body">
<button class="cm-btn blu" id="cm-go-main-menu">Go to Main Menu</button>
<button class="cm-btn blu" id="cm-go-title">Go to Title Screen</button>
<button class="cm-btn yel" id="cm-go-stage-select">Open Stage Select (Endless)</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">⚙ GAME SETTINGS (poke_settings)</div>
<div class="cm-sec-note">These match the in-game settings toggles.</div>
<div class="cm-sec-body">
<button class="cm-btn blu" id="cm-set-autoskip">Toggle Auto-Skip Battles</button>
<button class="cm-btn blu" id="cm-set-autoskipall">Toggle Auto-Skip All Battles</button>
<button class="cm-btn blu" id="cm-set-autoskipevolve">Toggle Auto-Skip Evolve</button>
<span id="cm-settings-cur" style="font-size:6px;color:#888;width:100%;margin-top:3px;"></span>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🐛 DEBUG</div>
<div class="cm-sec-body">
<button class="cm-btn" id="cm-log-state">Log state{}</button>
<button class="cm-btn" id="cm-log-team">Log team[]</button>
<button class="cm-btn" id="cm-log-items">Log items[]</button>
<button class="cm-btn" id="cm-log-dex">Log Pokédex</button>
<button class="cm-btn" id="cm-log-hof">Log HoF</button>
</div>
</div>
</div>
<!-- ═══ SCREENS ═══ -->
<div class="cm-panel" id="cm-t-screens">
<div class="cm-sec">
<div class="cm-sec-ttl">📺 NAVIGATE TO SCREEN — uses showScreen(id)</div>
<div class="cm-sec-body">
<button class="cm-btn blu" data-screen="map-screen">🗺 Map</button>
<button class="cm-btn blu" data-screen="catch-screen">🎣 Catch</button>
<button class="cm-btn blu" data-screen="item-screen">✦ Item</button>
<button class="cm-btn blu" data-screen="battle-screen">⚔ Battle</button>
<button class="cm-btn blu" data-screen="swap-screen">🔄 Swap</button>
<button class="cm-btn blu" data-screen="trade-screen">🤝 Trade</button>
<button class="cm-btn blu" data-screen="stat-buff-screen">📈 Stat Buff</button>
<button class="cm-btn blu" data-screen="endless-stage-select">🗺 Stage Select</button>
<button class="cm-btn blu" data-screen="title-screen">🏠 Title</button>
<button class="cm-btn blu" data-screen="starter-screen">🌟 Starter</button>
<button class="cm-btn blu" data-screen="trainer-screen">🧢 Trainer</button>
<button class="cm-btn yel" data-screen="win-screen">🏆 Win Screen</button>
<button class="cm-btn bad" data-screen="gameover-screen">💀 Game Over</button>
</div>
</div>
<div class="cm-sec">
<div class="cm-sec-ttl">🔁 CALL GAME FUNCTIONS</div>
<div class="cm-sec-body">
<button class="cm-btn" id="cm-fn-mapscreen">showMapScreen()</button>
<button class="cm-btn" id="cm-fn-gameover">showGameOver()</button>
<button class="cm-btn yel" id="cm-fn-winscreen">showWinScreen()</button>
<button class="cm-btn" id="cm-fn-skip">Click Skip Button</button>
<button class="cm-btn" id="cm-fn-dex">openPokedexModal()</button>
<button class="cm-btn" id="cm-fn-ach">openAchievementsModal()</button>
<button class="cm-btn" id="cm-fn-hof">openHallOfFameModal()</button>
</div>
</div>
</div>
<div id="cm-feedback"></div>
`;
}
// ── STAGE UNLOCK HELPERS ───────────────────────────────────
// Stage unlock is derived entirely from HoF entries:
// unlocked count = max stageNumber from entries with endless=true, then +1
// So to unlock stage N, inject an endless HoF entry with stageNumber = N-1
function injectStageEntry(stageNum, starterSpeciesId) {
// Minimal valid team entry that satisfies getHallOfFame() checks
const hof = JSON.parse(localStorage.getItem('poke_hall_of_fame') || '[]');
// Don't duplicate — only inject if no entry exists for this stage
if (hof.some(e => e.endless && e.stageNumber === stageNum)) return;
hof.push({
savedAt: Date.now() - (5-stageNum)*1000, // slightly in the past to keep order
runNumber: hof.length + 1,
hardMode: false,
endless: true,
stageNumber: stageNum,
starterSpeciesId: starterSpeciesId || 4,
date: new Date().toLocaleDateString(),
team: [{
speciesId: 6, name: 'Charizard', nickname: null, level: 60,
types: ['Fire','Flying'], spriteUrl: `${SP}6.png`, isShiny: false, heldItem: null,
}],
});
localStorage.setItem('poke_hall_of_fame', JSON.stringify(hof));
}
// ── WIRE EVENTS ────────────────────────────────────────────
function wire(ov) {
// Tabs
ov.querySelectorAll('.cm-tab').forEach(tab => {
tab.addEventListener('click', () => {
ov.querySelectorAll('.cm-tab').forEach(t => t.classList.remove('active'));
ov.querySelectorAll('.cm-panel').forEach(p => p.classList.remove('active'));
tab.classList.add('active');
ov.querySelector(`#cm-t-${tab.dataset.tab}`).classList.add('active');
if (tab.dataset.tab === 'team') { _selIdx = null; renderTeam('cm-teamlist'); }
if (tab.dataset.tab === 'items') renderBag();
if (tab.dataset.tab === 'progress') { const bc=document.getElementById('cm-badge-val'); const s=S(); if(bc&&s) bc.textContent=s.badges??0; }
if (tab.dataset.tab === 'account') updateGenderDisplay();
});
});
ov.querySelector('#cm-close').addEventListener('click', closeMenu);
// ── TEAM DELEGATION ──
const teamEl = document.getElementById('cm-teamlist');
teamEl.addEventListener('click', e => {
const btn = e.target.closest('[data-a]');
if (btn) {
e.stopPropagation();
const a = btn.dataset.a, pi = +btn.dataset.pi;
need(s => {
const p = s.team[pi]; if (!p) return;
if (a === 'heal') { p.currentHp = p.maxHp; persist(s); renderTeam('cm-teamlist'); fb(`${p.name} healed!`); }
else if (a === 'ko') { p.currentHp = 0; persist(s); renderTeam('cm-teamlist'); fb(`${p.name} KO'd.`, 'warn'); }
else if (a === 'nick') {
const inp = ov.querySelector(`.cm-nick[data-pi="${pi}"]`);
p.nickname = inp?.value.trim() || undefined;
persist(s); renderTeam('cm-teamlist'); fb(p.nickname ? `Nickname → "${p.nickname}"` : 'Nickname cleared.');
}
else if (a === 'nick-clear') {
p.nickname = undefined;
const inp = ov.querySelector(`.cm-nick[data-pi="${pi}"]`); if (inp) inp.value = '';
persist(s); renderTeam('cm-teamlist'); fb('Nickname cleared.');
}
else if (a === 'applystats') {
ov.querySelectorAll(`.cm-si[data-pi="${pi}"]`).forEach(inp => {
if (!p.baseStats) p.baseStats = {};
const v = +inp.value; if (v > 0) p.baseStats[inp.dataset.st] = v;
});
setLvl(p, p.level); persist(s); renderTeam('cm-teamlist'); fb(`Stats applied to ${p.name}!`);
}
else if (a === 'godmode') {
if (!p.baseStats) p.baseStats = {};
Object.assign(p.baseStats, {hp:255, atk:999, special:999, speed:999, def:999, spdef:999});
setLvl(p, p.level); persist(s); renderTeam('cm-teamlist'); fb(`${p.name} — God Mode!`);
}
else if (a === 'make-special') {
if (!p.baseStats) p.baseStats = {};
if ((p.baseStats.special||0) < (p.baseStats.atk||0)) {
[p.baseStats.atk, p.baseStats.special] = [p.baseStats.special, p.baseStats.atk];
[p.baseStats.def, p.baseStats.spdef] = [p.baseStats.spdef, p.baseStats.def];
}
setLvl(p, p.level); persist(s); renderTeam('cm-teamlist'); fb(`${p.name} → Special attacker`);
}
else if (a === 'make-physical') {
if (!p.baseStats) p.baseStats = {};
if ((p.baseStats.special||0) >= (p.baseStats.atk||0)) {
[p.baseStats.atk, p.baseStats.special] = [p.baseStats.special, p.baseStats.atk];
[p.baseStats.def, p.baseStats.spdef] = [p.baseStats.spdef, p.baseStats.def];
}
setLvl(p, p.level); persist(s); renderTeam('cm-teamlist'); fb(`${p.name} → Physical attacker`);
}
else if (a === 'setmovepwr') {
const inp = ov.querySelector(`.cm-movepwr[data-pi="${pi}"]`);
const val = parseInt(inp?.value, 10);
if (!val || val < 1) { fb('Enter a valid power value.', 'err'); return; }
p._customMovePower = val; ensureMovePowerPatch();
persist(s); renderTeam('cm-teamlist'); fb(`${p.name} move power → ${val}`);
}
else if (a === 'clearmovepwr') {
delete p._customMovePower; persist(s); renderTeam('cm-teamlist'); fb('Move power reset.');
}
else if (a === 'settype') {
const t1 = ov.querySelector(`.cm-type1[data-pi="${pi}"]`)?.value;
const t2 = ov.querySelector(`.cm-type2[data-pi="${pi}"]`)?.value;
p.types = t2 ? [t1, t2] : [t1];
persist(s); renderTeam('cm-teamlist'); fb(`${p.name} → ${p.types.join(' / ')}`);
}
else if (a === 'evo') {
const tid = +btn.dataset.eid;
(async () => {
try {
const sp = await fetchPokemonById(tid);
if (!sp) { fb(`Could not load #${tid}`, 'err'); return; }
const lvl = p.level, shiny = p.isShiny;
Object.assign(p, sp); p.speciesId = tid; p.level = lvl; p.isShiny = shiny;
p.spriteUrl = shiny ? `${SPS}${tid}.png` : `${SP}${tid}.png`;
setLvl(p, lvl); p.currentHp = Math.min(p.currentHp, p.maxHp);
persist(s); renderTeam('cm-teamlist'); fb(`Evolved to ${sp.name}!`);
} catch (err) { fb(err.message, 'err'); }
})();
}
else if (a === 'equip') {
const iid = btn.dataset.iid, def = HELD_ITEMS.find(it => it.id === iid);