-
Notifications
You must be signed in to change notification settings - Fork 0
/
warrior.py
136 lines (98 loc) · 3 KB
/
warrior.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# -*- coding: utf-8 -*-
# 在这里定义的是游戏中角色的基本单位---Warrior的类
from config import *
# 父类型
class Warrior:
def __init__(self, wtype, wteam, wgrid, wpos):
self.wType = wtype
self.wTeam = wteam
self.wGrid = wgrid # 在三个格子中的哪个 1 2 3
self.pos = wpos
self.attacked = 0 # 本回合是否攻击
self.couldMove = 1
# type 0
# 主塔
class Base(Warrior):
def __init__(self, wteam, wgrid, wpos=BasePos):
super().__init__(0, wteam, wgrid, wpos)
self.wAttack = BaseAttack
self.wDefence = BaseDefence
self.wLife = BaseLife
self.wRange = BaseRange
self.mCD = BasemCD
self.aCD = BaseaCD
self.pos = wpos
def updatemCD(self, moved):
if self.mCD > 0:
self.mCD -= 1
if moved:
self.mCD = BasemCD
def updateaCD(self, attacked):
if self.aCD > 0:
self.aCD -= 1
if attacked:
self.aCD = BaseaCD
# type 1
# 防御塔
class Turret(Warrior):
def __init__(self, wteam, wgrid=2, wpos=TurretPos):
super().__init__(1, wteam, wgrid, wpos)
self.wAttack = TurretAttack
self.wDefence = TurretDefence
self.wLife = TurretLife
self.wRange = TurretRange
self.mCD = TurretmCD
self.aCD = TurretaCD
self.pos = wpos
def updatemCD(self, moved):
if self.mCD > 0:
self.mCD -= 1
if moved:
self.mCD = TurretmCD
def updateaCD(self, attacked):
if self.aCD > 0:
self.aCD -= 1
if attacked:
self.aCD = TurretaCD
# type 2
# 骑士
class Knight(Warrior):
def __init__(self, wteam, wgrid, wpos=0):
super().__init__(2, wteam, wgrid, wpos)
self.wAttack = KnightAttack
self.wDefence = KnightDefence
self.wLife = KnightLife
self.wRange = KnightRange
self.mCD = KnightmCD
self.aCD = KnightaCD
def updatemCD(self, moved):
if self.mCD > 0:
self.mCD -= 1
if moved:
self.mCD = KnightmCD
def updateaCD(self, attacked):
if self.aCD > 0:
self.aCD -= 1
if attacked:
self.aCD = KnightaCD
# type 3
# 弓箭手
class Archer(Warrior):
def __init__(self, wteam, wgrid, wpos=0):
super().__init__(3, wteam, wgrid, wpos)
self.wAttack = ArcherAttack
self.wDefence = ArcherDefence
self.wLife = ArcherLife
self.wRange = ArcherRange
self.mCD = ArchermCD
self.aCD = ArcheraCD
def updatemCD(self, moved):
if self.mCD > 0:
self.mCD -= 1
if moved:
self.mCD = ArchermCD
def updateaCD(self, attacked):
if self.aCD > 0:
self.aCD -= 1
if attacked:
self.aCD = ArcheraCD