-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkm.py
60 lines (47 loc) · 1.38 KB
/
pkm.py
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
#!/usr/bin/env python
from __future__ import annotations
import json
DEX: dict = json.load(open("data/dex.json"))
class Pokemon:
def __init__(self) -> None:
self.name: str
self.gender = "male"
self.urlMessage: str
self.size = ""
self.ivs: str
self.iv: int
self.lvl: int
self.cp: int
self.despawn: int
self.thumbnail: str
self.country: str
self.quickmove = ""
self.chargedmove = ""
self.snowflake = None
self.sendDate: int
def __str__(self) -> str:
string = ""
for attr in vars(self):
string += f"{attr} = {getattr(self, attr)}\n"
return string
def __repr__(self) -> str:
return str(self)
def __eq__(self, other) -> bool:
if isinstance(other, Pokemon):
for attr in vars(self):
if attr in ["urlMessage", "snowflake", "sendDate"]:
continue
if getattr(self, attr) != getattr(other, attr):
return False
return True
return False
def isFullyEvolved(pkm: Pokemon) -> bool:
return "evos" not in DEX[pkm.name]
def formatName(name: str) -> str:
i = 0
while i < len(name):
if not name[i].isalnum():
name = name[:i] + name[i + 1 :]
else:
i += 1
return name.lower()