-
Notifications
You must be signed in to change notification settings - Fork 1
/
type.py
49 lines (43 loc) · 2.12 KB
/
type.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
from enum import Enum
class Type(Enum):
normal = 0
fighting = 1
flying = 2
poison = 3
ground = 4
rock = 5
bird = 6
bug = 7
ghost = 8
fire = 9
water = 10
grass = 11
electric = 12
psychic = 13
ice = 14
dragon = 15
blank = 16
type_matrix =[[1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[2.0, 1.0, 0.5, 0.5, 1.0, 2.0, 0.0, 0.5, 0.0, 1.0, 1.0, 1.0, 1.0, 0.5, 2.0, 1.0, 1.0],
[1.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.0, 2.0, 1.0, 1.0, 1.0, 2.0, 0.5, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.5, 1.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 0.0, 2.0, 1.0, 2.0, 0.0, 0.5, 1.0, 2.0, 1.0, 0.5, 2.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 0.5, 2.0, 1.0, 0.5, 1.0, 0.0, 2.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 2.0, 1.0, 1.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[1.0, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 1.0, 0.5, 0.5, 1.0, 2.0, 1.0, 2.0, 1.0, 1.0, 1.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 2.0, 1.0, 0.5, 0.5, 2.0, 1.0, 1.0, 2.0, 0.5, 1.0],
[1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 0.0, 1.0, 1.0, 2.0, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5, 1.0],
[1.0, 1.0, 0.5, 0.5, 2.0, 2.0, 0.0, 0.5, 1.0, 0.5, 2.0, 0.5, 1.0, 1.0, 1.0, 0.5, 1.0],
[1.0, 1.0, 2.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 2.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0],
[1.0, 2.0, 1.0, 2.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0],
[1.0, 1.0, 2.0, 1.0, 2.0, 1.0, 0.0, 1.0, 1.0, 0.5, 0.5, 2.0, 1.0, 1.0, 0.5, 2.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 1.0]]
def get_multiplier(atker, atk_type, defender):
"""Calcula o multiplicador de efetividade de um ataque em um Pokémon"""
ans = 1.0
if (atk_type is atker.typ1) or (atk_type is atker.typ2):
ans = ans * 1.5 # aplicando STAB (Same Type Attack Bonus)
ans = ans * Type.type_matrix.value[atk_type.value][defender.typ1.value]
ans = ans * Type.type_matrix.value[atk_type.value][defender.typ2.value]
return ans