-
Notifications
You must be signed in to change notification settings - Fork 1
/
type_modifiers.py
58 lines (50 loc) · 1.84 KB
/
type_modifiers.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
from csv_loader import load_moves
all_types = ["Bug", "Dark", "Dragon", "Electric", "Fighting", "Fire",
"Flying", "Ghost", "Grass", "Ground", "Ice", "Normal",
"Poison", "Psychic", "Rock", "Steel", "Water", None]
supes = {
"Normal": [],
"Fire": ["Grass", "Ice", "Bug", "Steel"],
"Water": ["Fire", "Ground", "Rock"],
"Electric": ["Water", "Flying"],
"Grass": ["Water", "Ground", "Rock"],
"Ice": ["Grass", "Ground", "Flying", "Dragon"],
"Fighting": ["Normal", "Ice", "Rock", "Dark", "Steel"],
"Poison": ["Grass"],
"Ground": ["Fire", "Electric", "Poison", "Rock", "Steel"],
"Flying": ["Grass", "Fighting", "Bug"],
"Psychic": ["Fighting", "Poison"],
"Bug": ["Grass", "Psychic", "Dark"],
"Rock": ["Fire", "Ice", "Flying", "Bug"],
"Ghost": ["Psychic", "Ghost"],
"Dragon": ["Dragon"],
"Dark": ["Psychic", "Ghost"],
"Steel": ["Ice", "Rock"]
}
moves = load_moves()
def isSuperEffective(attacker_type, victim_type):
return True if victim_type in supes[attacker_type] else False
def getSECoverage(move_type):
return supes[move_type]
def getUsageDict():
types = {}
for type in all_types:
types[type] = 0
return types
def getTypeCoverage(moveset):
"""Returns a list of types the moveset is SE against. """
coverage = []
for move in moveset:
move_coverage = getSECoverage(moves[move].type)
for covered_type in move_coverage:
if covered_type not in coverage:
coverage.append(covered_type)
return coverage
def STAB(pokemon, move):
"""Returns True if the pokemon is the same type as the attack. """
if pokemon.type1 == move.type:
return True
elif pokemon.type2 == move.type:
return True
else:
return False