-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathmodels.py
More file actions
1432 lines (1152 loc) · 38 KB
/
models.py
File metadata and controls
1432 lines (1152 loc) · 38 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
from __future__ import annotations
from datetime import datetime
import random
import re
import typing
import unicodedata
from abc import ABC, abstractmethod
from collections import defaultdict
from dataclasses import dataclass
from functools import cached_property
from typing import List, Literal, Optional, Set, Union
import copy
from data.utils import comma_formatted, unwind
from . import constants
# Month to season
SEASONS = unwind(
{
(6, 7, 8): "summer",
(9, 10, 11): "autumn",
(12, 1, 2): "winter",
(3, 4, 5): "spring",
}
)
def deaccent(text):
norm = unicodedata.normalize("NFD", text)
result = "".join(ch for ch in norm if unicodedata.category(ch) != "Mn")
return unicodedata.normalize("NFKC", result)
class UnregisteredError(Exception):
pass
class UnregisteredDataManager:
pass
# Moves
@dataclass
class MoveEffect:
id: int
description: str
instance: typing.Any = UnregisteredDataManager()
@dataclass
class StatChange:
stat_id: int
change: int
@cached_property
def stat(self):
return ("hp", "atk", "defn", "satk", "sdef", "spd", "evasion", "accuracy")[
self.stat_id - 1
]
@dataclass
class StatStages:
hp: int = 0
atk: int = 0
defn: int = 0
satk: int = 0
sdef: int = 0
spd: int = 0
evasion: int = 0
accuracy: int = 0
crit: int = 0
def update(self, stages):
self.hp += stages.hp
self.atk += stages.atk
self.defn += stages.defn
self.satk += stages.satk
self.sdef += stages.sdef
self.spd += stages.spd
self.evasion += stages.evasion
self.accuracy += stages.accuracy
self.crit += stages.crit
@dataclass
class MoveResult:
success: bool
damage: int
healing: int
ailment: str
messages: typing.List[str]
stat_changes: typing.List[StatChange]
@dataclass
class MoveMeta:
meta_category_id: int
meta_ailment_id: int
drain: int
healing: int
crit_rate: int
ailment_chance: int
flinch_chance: int
stat_chance: int
min_hits: typing.Optional[int] = None
max_hits: typing.Optional[int] = None
min_turns: typing.Optional[int] = None
max_turns: typing.Optional[int] = None
stat_changes: typing.List[StatChange] = None
def __post_init__(self):
if self.stat_changes is None:
self.stat_changes = []
@cached_property
def meta_category(self):
return constants.MOVE_META_CATEGORIES[self.meta_category_id]
@cached_property
def meta_ailment(self):
return constants.MOVE_AILMENTS[self.meta_ailment_id]
@dataclass
class Move:
id: int
slug: str
name: str
power: int
pp: int
accuracy: int
priority: int
target_id: int
type_id: int
damage_class_id: int
effect_id: int
effect_chance: int
meta: MoveMeta
instance: typing.Any = UnregisteredDataManager()
@property
def type(self):
return constants.TYPES[self.type_id]
@cached_property
def target_text(self):
return constants.MOVE_TARGETS[self.target_id]
@cached_property
def damage_class(self):
return constants.DAMAGE_CLASSES[self.damage_class_id]
@cached_property
def effect(self):
return self.instance.effects[self.effect_id]
@cached_property
def description(self):
return self.effect.description.format(effect_chance=self.effect_chance)
def __str__(self):
return self.name
def hook(self, pokemon):
"""
Pre-execution hook to apply move stuff that should happen before the move is executed.
This is called multiple times.
"""
# Arceus's Judgment type changing
if pokemon.species.dex_number == 493 and self.id == 449:
self.type_id = constants.TYPES.index(pokemon.species.types[0])
# Silvally's Multi-attack type changing
if pokemon.species.dex_number == 773 and self.id == 718:
self.type_id = constants.TYPES.index(pokemon.species.types[0])
def calculate_turn(self, pokemon, opponent):
self.hook(pokemon)
if self.damage_class_id == 1 or self.power is None:
success = True
damage = 0
hits = 0
else:
success = random.randrange(100) < (self.accuracy or 0) * (
constants.STAT_STAGE_MULTIPLIERS[pokemon.stages.accuracy] * 2 + 1
) / (constants.STAT_STAGE_MULTIPLIERS[opponent.stages.evasion] * 2 + 1)
hits = random.randint(self.meta.min_hits or 1, self.meta.max_hits or 1)
if self.damage_class_id == 2:
atk = pokemon.atk * constants.STAT_STAGE_MULTIPLIERS[pokemon.stages.atk]
defn = (
opponent.defn
* constants.STAT_STAGE_MULTIPLIERS[opponent.stages.defn]
)
else:
atk = (
pokemon.satk * constants.STAT_STAGE_MULTIPLIERS[pokemon.stages.satk]
)
defn = (
opponent.sdef
* constants.STAT_STAGE_MULTIPLIERS[opponent.stages.sdef]
)
damage = int((2 * pokemon.level / 5 + 2) * self.power * atk / defn / 50 + 2)
healing = damage * self.meta.drain / 100
healing += pokemon.max_hp * self.meta.healing / 100
for ailment in pokemon.ailments:
if ailment == "Paralysis":
if random.random() < 0.25:
success = False
elif ailment == "Sleep":
if self.id not in (173, 214):
success = False
elif ailment == "Freeze":
if self.id not in (588, 172, 221, 293, 503, 592):
success = False
elif ailment == "Burn":
if self.damage_class_id == 2:
damage /= 2
# elif ailment == "Confusion":
# pass
# elif ailment == "Infatuation":
# pass
# elif ailment == "Trap":
# pass
# elif ailment == "Nightmare":
# pass
# elif ailment == "Torment":
# pass
# elif ailment == "Disable":
# pass
# elif ailment == "Yawn":
# pass
# elif ailment == "Heal Block":
# pass
# elif ailment == "No type immunity":
# pass
# elif ailment == "Leech Seed":
# pass
# elif ailment == "Embargo":
# pass
# elif ailment == "Perish Song":
# pass
# elif ailment == "Ingrain":
# pass
# elif ailment == "Silence":
# pass
ailment = (
self.meta.meta_ailment
if random.randrange(100) < self.meta.ailment_chance
else None
)
typ_mult = 1
for typ in opponent.species.types:
try:
typ_mult *= constants.TYPE_EFFICACY[self.type_id][
constants.TYPES.index(typ)
]
except IndexError: # Type does not exist in the TYPE_EFFICACY list. Such as the Shadow type.
pass
damage *= typ_mult
messages = []
if typ_mult == 0:
messages.append("It's not effective...")
elif typ_mult > 1:
messages.append("It's super effective!")
elif typ_mult < 1:
messages.append("It's not very effective...")
if hits > 1:
messages.append(f"It hit {hits} times!")
changes = []
for change in self.meta.stat_changes:
if random.randrange(100) < self.meta.stat_chance:
changes.append(change)
if self.type in pokemon.species.types:
damage *= 1.5
return MoveResult(
success=success,
damage=damage,
healing=healing,
ailment=ailment,
messages=messages,
stat_changes=changes,
)
# Items
@dataclass
class Item:
id: int
name: str
description: str
cost: int
page: int
action: str
inline: bool
emote: str = None
shard: bool = False
instance: typing.Any = UnregisteredDataManager()
def __str__(self):
return self.name
class MoveMethod(ABC):
pass
@dataclass
class LevelMethod(MoveMethod):
level: int
instance: typing.Any = UnregisteredDataManager()
slug = "level-up"
name = "Level up"
aliases = ["level"]
@cached_property
def text(self):
return f"Level {self.level}"
@dataclass
class EggMethod(MoveMethod):
instance: typing.Any = UnregisteredDataManager()
slug = "egg"
name = "Egg"
aliases = ["eggs", "breeding"]
@cached_property
def text(self):
return f"Breeding"
@dataclass
class LightBallEggMethod(MoveMethod):
instance: typing.Any = UnregisteredDataManager()
slug = "light-ball-egg"
name = "Light Ball Egg"
aliases = ["light ball", "light-ball"]
@cached_property
def text(self):
return f"Breeding, while holding Light Ball"
MOVE_METHODS = {
1: LevelMethod,
2: EggMethod,
6: LightBallEggMethod,
}
@dataclass
class PokemonMove:
move_id: int
method: MoveMethod
instance: typing.Any = UnregisteredDataManager()
@cached_property
def move(self):
return self.instance.moves[self.move_id]
@cached_property
def text(self):
return self.method.text
# Evolution
@dataclass
class EvolutionTrigger(ABC):
pass
@dataclass
class LevelTrigger(EvolutionTrigger):
level: int
item_id: int
move_id: int
move_type_id: int
time: str
relative_stats: int
gender_id: str
natures: List[str]
instance: typing.Any = UnregisteredDataManager()
@cached_property
def item(self):
if self.item_id is None:
return None
return self.instance.items[self.item_id]
@cached_property
def move(self):
if self.move_id is None:
return None
return self.instance.moves[self.move_id]
@cached_property
def move_type(self):
if self.move_type_id is None:
return None
return constants.TYPES[self.move_type_id]
@cached_property
def gender(self):
if self.gender_id is None:
return None
return constants.GENDER_TYPES[self.gender_id]
@cached_property
def text(self):
if self.level is None:
text = f"when leveled up"
else:
text = f"starting from level {self.level}"
if self.gender:
text += f" as {self.gender}"
if self.item is not None:
text += f" while holding a {self.item}"
if self.move is not None:
text += f" while knowing {self.move}"
if self.move_type is not None:
text += f" while knowing a {self.move_type}-type move"
if self.relative_stats == 1:
text += f" when its Attack is higher than its Defense"
elif self.relative_stats == -1:
text += f" when its Defense is higher than its Attack"
elif self.relative_stats == 0:
text += f" when its Attack is equal to its Defense"
if self.time is not None:
text += " in the " + self.time + "time"
if self.natures:
text += (
f" with a Nature of {comma_formatted(self.natures, conjunction='or')}"
)
return text
@dataclass
class ItemTrigger(EvolutionTrigger):
item_id: int
instance: typing.Any = UnregisteredDataManager()
@cached_property
def item(self):
return self.instance.items[self.item_id]
@cached_property
def text(self):
return f"using a {self.item}"
@dataclass
class TradeTrigger(EvolutionTrigger):
item_id: int = None
instance: typing.Any = UnregisteredDataManager()
@cached_property
def item(self):
if self.item_id is None:
return None
return self.instance.items[self.item_id]
@cached_property
def text(self):
if self.item_id is None:
return "when traded"
return f"when traded while holding a {self.item}"
@dataclass
class OtherTrigger(EvolutionTrigger):
instance: typing.Any = UnregisteredDataManager()
@cached_property
def text(self):
return "somehow"
@dataclass
class Evolution:
target_id: int
trigger: EvolutionTrigger
type: bool
instance: typing.Any = UnregisteredDataManager()
@classmethod
def evolve_from(cls, target: int, trigger: EvolutionTrigger, instance=None):
if instance is None:
instance: typing.Any = UnregisteredDataManager()
return cls(target, trigger, False, instance=instance)
@classmethod
def evolve_to(cls, target: int, trigger: EvolutionTrigger, instance=None):
if instance is None:
instance: typing.Any = UnregisteredDataManager()
return cls(target, trigger, True, instance=instance)
@cached_property
def dir(self) -> str:
return "to" if self.type == True else "from" if self.type == False else "??"
@cached_property
def target(self):
return self.instance.pokemon[self.target_id]
@cached_property
def current(self):
for dir in ("to", "from"):
species = next(
(
s
for s in self.instance.all_pokemon()
if getattr(s, f"evolution_{dir}")
and self in getattr(s, f"evolution_{dir}").items
),
None,
)
if species:
return species
@cached_property
def text(self):
# At the moment this says 'transforms' only for Piroette Meloetta, Resolute Keldeo and School WIshiwashi since
# we're piggybacking off the evolution method. But in the future this could show the incorrect action, although unlikely.
action = "evolves"
if (
self.target.is_form
and self.target.dex_number
== self.current.dex_number # checks if target is a form of the same base pokemon, aka 'transforms to'
and self.dir != "from"
) or (
self.current.is_form
and self.target.id
== self.current.dex_number # checks if target is the base species, aka 'transforms from'
):
action = "transforms"
if getattr(self.target, f"evolution_{self.dir}") is not None:
pevo = getattr(self.target, f"evolution_{self.dir}")
return f"{action} {self.dir} **{self.target}** {self.trigger.text}, which {pevo.text}"
return f"{action} {self.dir} **{self.target}** {self.trigger.text}"
@dataclass
class EvolutionList:
items: list
def __init__(self, evolutions: Union[list, Evolution]):
if type(evolutions) == Evolution:
evolutions = [evolutions]
self.items = evolutions
@cached_property
def text(self):
txt = " and ".join(e.text for e in self.items)
txt = txt.replace(" and ", ", ", txt.count(" and ") - 1)
return txt
# Stats
@dataclass
class Stats:
hp: int
atk: int
defn: int
satk: int
sdef: int
spd: int
@property
def total(self) -> int:
return self.hp + self.atk + self.defn + self.satk + self.sdef + self.spd
@dataclass
class EggGroup:
id: int
slug: str
name: str
instance: typing.Any = UnregisteredDataManager()
def __eq__(self, value):
if isinstance(value, str):
value = value.casefold().strip()
return self.slug == value or self.name.casefold() == value
if isinstance(value, int):
return self.id == value
if not isinstance(value, EggGroup):
return self.id == value.id
return False
# Species
@dataclass
class Species:
id: int
names: typing.List[typing.Tuple[str, str]]
slug: str
base_stats: Stats
height: int
weight: int
dex_number: int
catchable: bool
spawn_time: str | None
spawn_season: str | None
types: typing.List[str]
abundance: int
gender_rate: int
has_gender_differences: int
_egg_groups: typing.List[EggGroup] | None
_hatch_counter: int | None
description: str = None
mega_id: int = None
mega_x_id: int = None
mega_y_id: int = None
evolution_from: EvolutionList = None
evolution_to: EvolutionList = None
mythical: bool = False
legendary: bool = False
ultra_beast: bool = False
event: bool = False
is_form: bool = False
form_item: int = None
_moves: typing.List[PokemonMove] = None
region: str = None
art_credit: str = None
instance: typing.Any = UnregisteredDataManager()
def __post_init__(self):
self.name = next(filter(lambda x: x[0] == "🇬🇧", self.names))[1]
if self._moves is None:
self._moves = []
def __str__(self):
return self.name
@cached_property
def moves(self) -> List[PokemonMove]:
if not self._moves:
if self.base_species:
self._moves.extend(self.base_species.moves)
return self._moves
@cached_property
def egg_groups(self) -> List[EggGroup]:
if self._egg_groups is None:
if self.base_species:
self._egg_groups = self.base_species.egg_groups
return self._egg_groups
@cached_property
def hatch_counter(self) -> List[EggGroup]:
if self._hatch_counter is None:
if self.base_species:
self._hatch_counter = self.base_species.hatch_counter
return self._hatch_counter
@cached_property
def moveset(self) -> List[Move]:
return [pmove.move for pmove in self.moves]
@cached_property
def gender_ratios(self):
return constants.GENDER_RATES[self.gender_rate]
@cached_property
def default_gender(self) -> Literal["Unknown", "Male", "Female"] | None:
if self.gender_rate == -1:
return "Unknown"
if 100 in self.gender_ratios: # If species is exclusively one gender
always_male = self.gender_ratios[0] == 100
if always_male:
return "Male"
else:
return "Female"
else: # If both male and female are possible
return None # There is no default
@cached_property
def mega(self):
if self.mega_id is None:
return None
return self.instance.pokemon[self.mega_id]
@cached_property
def mega_x(self):
if self.mega_x_id is None:
return None
return self.instance.pokemon[self.mega_x_id]
@cached_property
def mega_y(self):
if self.mega_y_id is None:
return None
return self.instance.pokemon[self.mega_y_id]
@cached_property
def is_mega(self):
return self.base_species and self in (
self.base_species.mega,
self.base_species.mega_x,
self.base_species.mega_y,
)
@cached_property
def is_rare(self):
return self.id in [
i
for rarity in ("mythical", "legendary", "ub")
for i in getattr(self.instance, f"list_{rarity}")
]
@cached_property
def is_regional(self):
return self.id in [
i
for regional in ("alolan", "galarian", "hisuian", "paldean")
for i in getattr(self.instance, f"list_{regional}")
]
@cached_property
def gmax(self) -> Species | None:
return self.instance.gmax_mapping.get(self.id)
@cached_property
def is_gmax(self) -> bool:
return self.id in self.instance.list_gmax
@cached_property
def variants(self) -> List[Species]:
return self.instance.all_species_by_number(self.dex_number)
@cached_property
def transformable_form(self) -> bool:
return (self.is_form and self.form_item is not None) or self.is_mega
def get_evoline(self, evos_done: Set[int]) -> Set[int]:
evoline = {self.id}
evos = (self.evolution_from.items if self.evolution_from else []) + (
self.evolution_to.items if self.evolution_to else []
)
for evo in evos:
evo_species = self.instance.species_by_number(evo.target_id)
if evo_species.id in evos_done:
continue
evoline.update(evo_species.get_evoline(evoline))
evos_done.add(evo_species.id)
return evoline
@cached_property
def evolution_line(self) -> List[Species]:
return [
self.instance.species_by_number(i)
for i in sorted(self.get_evoline({self.id}))
]
@cached_property
def first_evolution(self) -> Species:
first = self
while (e := first.evolution_from) is not None:
first = self.instance.species_by_number(e.items[0].target_id)
return first
@cached_property
def breedable(self) -> bool:
return "no-eggs" not in self.egg_groups
@cached_property
def hatchable(self) -> bool:
EXCEPTIONS = [490] # Manaphy
if self.id in EXCEPTIONS:
return False
if "ditto" in self.egg_groups:
return False
if self.transformable_form or (
self.base_species and not self.is_regional and not self.is_gmax
):
return False
first_evo = self == self.first_evolution
evo_line_not_undiscovered = any(
("no-eggs" not in evo.egg_groups for evo in self.evolution_line)
)
return first_evo and evo_line_not_undiscovered
@cached_property
def base_species(self) -> Species | None:
if self.id != self.dex_number:
return self.instance.species_by_number(self.dex_number)
else:
return None
@cached_property
def image_url(self):
return self.instance.asset(f"/images/{self.id}.png")
@cached_property
def shiny_image_url(self):
return self.instance.asset(f"/shiny/{self.id}.png")
@cached_property
def image_url_female(self):
if self.has_gender_differences == 1:
return self.instance.asset(f"/images/{self.id}F.png")
@cached_property
def shiny_image_url_female(self):
if self.has_gender_differences == 1:
return self.instance.asset(f"/shiny/{self.id}F.png")
@cached_property
def correct_guesses(self):
extra = []
if self.is_form or self.event:
extra.extend(self.instance.pokemon[self.dex_number].correct_guesses)
if "nidoran" in self.slug:
extra.append("nidoran")
# Event pokemon with extra names
# Elsa Galarian Ponyta
if self.id == 50053:
extra.extend(self.instance.pokemon[10159].correct_guesses)
# Halloween Alolan Ninetales
if self.id == 50076:
extra.extend(self.instance.pokemon[10104].correct_guesses)
# Pride Gardevoir & Delphox
if self.id == 50107:
# can't set two dex_numbers
extra.extend(self.instance.pokemon[655].correct_guesses)
extra.append("pride gardevoir")
extra.append("pride delphox")
# Pyjama Plusle & Minun
if self.id == 50149:
# can't set two dex_numbers
extra.extend(self.instance.pokemon[312].correct_guesses)
extra.append("christmas minun")
# Santa Hisuian Zorua
if self.id == 50145:
extra.extend(self.instance.pokemon[10230].correct_guesses)
extra.append("christmas zorua")
# Reindeer Deerling
if self.id == 50147:
extra.append("christmas deerling")
# Birthday Cake Alolan Vulpix
if self.id == 50168:
extra.extend(self.instance.pokemon[10103].correct_guesses)
extra.extend(["anniversary alolan vulpix", "anniversary vulpix"])
# Día de Muertos pokémon
if self.id in range(50192, 50199):
extra.append(f"day of the dead {self.base_species.name.lower()}")
# La Catrina Hisuian Lilligant
if self.id == 50198:
extra.extend(self.instance.pokemon[10229].correct_guesses)
extra.extend(
["dia de muertos lilligant", "day of the dead hisuian lilligant"]
)
# Grinch Grimmsnarl
if self.id == 50207:
extra.append("christmas grimmsnarl")
# Autumn Swoobat
if self.id == 50244:
extra.append("autumn swoobat")
# Autumn Foongus
if self.id == 50245:
extra.append("autumn foongus")
# Halloween Bewear
if self.id == 50254:
extra.append("halloween bewear")
# Halloween Solrock
if self.id == 50249:
extra.extend(self.instance.pokemon[337].correct_guesses)
names = extra + [deaccent(x.lower()) for _, x in self.names] + [self.slug]
punctuationless_names = [
re.sub(r"[^\w\s-]", "", name)
for name in names # Allow punctuationless guesses
]
return [k for k in dict.fromkeys(names + punctuationless_names) if k]
@cached_property
def trade_evolutions(self):
if self.evolution_to is None:
return []
evos = []
for e in self.evolution_to.items:
if isinstance(e.trigger, TradeTrigger):
evos.append(e)
return evos
@cached_property
def evolution_text(self):
text = ""
if self.transformable_form:
if self.is_mega:
match self:
case self.base_species.mega:
form_item = 12001
case self.base_species.mega_x:
form_item = 12002
case self.base_species.mega_y:
form_item = 12003
else:
form_item = self.form_item
species = self.instance.pokemon[self.dex_number]
item = self.instance.items[form_item]
text += f" transforms from **{species}** when given a {item.name}"
elif self.evolution_from is not None:
text += f" {self.evolution_from.text}"
if text and self.evolution_to is not None:
text += " and"