-
Notifications
You must be signed in to change notification settings - Fork 0
/
Attacks.py
87 lines (78 loc) · 2.78 KB
/
Attacks.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
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
#!/usr/bin/python
from Standards import AutoNumber, Effects, Types, Attributes
class Attacks(AutoNumber):
#normal
Struggle = ()
QuickAttack = ()
#fire
FireBreath = ()
Explosion = ()
#water
WaterBall = ()
#wind
Tornado = ()
#earth
Earthquake = ()
Mudball = ()
def getAttack(attackNum):
if attackNum == Attacks.QuickAttack:
return BasicAttack(1.5, Types.Normal, Attributes.STR, Attributes.DEF, 2, Effects.NoEffect, 0)
else: #Struggle
return BasicAttack(1.0, Types.Normal, Attributes.STR, Attributes.DEF, 1, Effects.Recoil, 20)
def CalculateDamage(attack, attacker, defender):
damage = 0
if attack.offAttr == Attributes.STR:
damage = attacker.attr.STR * attack.power
elif attack.offAttr == Attributes.MSTR:
damage = attacker.attr.MSTR * attack.power
elif attack.offAttr == Attributes.DEF:
damage = attacker.attr.DEF * attack.power
elif attack.offAttr == Attributes.MDEF:
damage = attacker.attr.MDEF * attack.power
elif attack.offAttr == Attributes.SPD:
damage = attacker.attr.SPD * attack.power
elif attack.offAttr == Attributes.ACC:
damage = attacker.ACC * attack.power
elif attack.offAttr == Attributes.EVA:
damage = attacker.EVA * attack.power
elif attack.offAttr == Attributes.HP:
damage = attacker.attr.HP * attack.power
else:
damage = attack.power
if attacker.montype == attack.attacktype:
damage = damage * 1.5
if attack.defAttr == Attributes.STR:
damage = damage / defender.attr.STR
elif attack.defAttr == Attributes.MSTR:
damage = damage / defender.attr.MSTR
elif attack.defAttr == Attributes.DEF:
damage = damage / defender.attr.DEF
elif attack.defAttr == Attributes.MDEF:
damage = damage / defender.attr.MDEF
elif attack.defAttr == Attributes.SPD:
damage = damage / defender.attr.SPD
elif attack.defAttr == Attributes.ACC:
damage = damage / defender.ACC
elif attack.defAttr == Attributes.EVA:
damage = damage / defender.EVA
elif attack.defAttr == Attributes.HP:
damage = damage / defender.attr.HP
return damage
# power (The attack power. This is a multiplier on most attacks. ex 1.5)
# attackType (The type of the attack. Used for weaknesses and resistances)
# offAttr (The attribute that is used for dealing damage. Usually STR or MSTR)
# defAttr (The attribute used by the defender for blocking damage. Usually DEF or MDEF)
# priority (The higher the priority, the faster the attack. Default is 1)
# effect (A standard effect that the attack can inflict)
# effpercent (The chance fo the effect to be inflicted.)
class BasicAttack():
def __init__(self, power, attackType, offAttr, defAttr, priority, effect, effpercent):
self.power = power
self.attackType = attackType
self.offAttr = offAttr
self.defAttr = defAttr
self.priority = priority
self.effect = effect
self.effpercent = effpercent
def extraEffect(self, attacker):
return 0