-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcg_moves.py
More file actions
78 lines (59 loc) · 2.34 KB
/
cg_moves.py
File metadata and controls
78 lines (59 loc) · 2.34 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
from cg_types import *
from random import random as r, randint
class CGMove:
def __init__(self, name, priority=0):
self.name = name
self.priority = priority
self.__str__ = self.__repr__
def __repr__(self):
return self.name
def use(self, user, opponent) -> float:
pass
class CGStatusMove(CGMove):
typed = False
def __init__(self, stat, increment_stage: int, name, affect_self=False, priority=0):
super().__init__(name, priority)
self.type = status
self.stat = stat
self.increment_stage = increment_stage
self.affect_self = affect_self
def use(self, user, opponent):
affected = user if self.affect_self else opponent
if abs(affected.stat_stages[self.stat] + self.increment_stage) > 6:
return -3 if self.increment_stage > 0 else -4
exec("%s.stat_stages[%d] += %d" %
('user' if self.affect_self else 'opponent', self.stat, self.increment_stage))
return -2
class CGDmgMove(CGMove):
typed = True
def __init__(self, power, accuracy, move_type, name, priority=0):
super().__init__(name, priority)
self.power = power
self.accuracy = accuracy
self.type = move_type
def use(self, user, opponent):
if r() <= self.accuracy:
eff = opponent.calc_effectiveness(self.type)
opponent.current_hp -= int((self.power * user.current_stats[0] /
opponent.current_stats[1] *
(2 / 5 * user.level + 2) + 2) / 50 * eff *
(1.5 if self.type in user.types else 1) *
randint(85, 100) / 100)
if opponent.current_hp < 0:
opponent.current_hp = 0
return eff
else:
return -1
hazard = CGDmgMove(40, 1, env, "HAZARD")
skill_attack = CGDmgMove(40, 1, skill, "SKILL ATTACK")
viral_wave = CGDmgMove(40, 1, virus, "VIRAL WAVE")
lock_throw = CGDmgMove(40, 1, secure, "LOCK THROW")
glitch = CGDmgMove(40, 1, bug, "GLITCH")
weakest = CGDmgMove(0, 0, env, '')
defense_break = CGStatusMove(1, -1, "DEFENSE BREAK")
display_code = CGStatusMove(0, -2, "DISPLAY CODE")
class NoMove:
def __repr__(self):
return "CANCEL"
def __bool__(self):
return False