-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.py
More file actions
153 lines (109 loc) · 4.02 KB
/
class.py
File metadata and controls
153 lines (109 loc) · 4.02 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from random import *
class Unit:
def __init__(self, name, hp, speed):
self.name = name
self.hp = hp
self.speed = speed
print(f'{self.name}유닛이 생성되었습니다.')
def move(self, location):
print("[지상 유닛 이동]")
print(f'{self.name} : {location} 방향으로 이동합니다. [속도 {self.speed}]')
class Attackunit(Unit):
def __init__(self, name, hp, speed, damage):
Unit.__init__(self, name, hp, speed)
self.damage = damage
print(f'체력 {self.hp}, 공격력 {self.damage}')
def attack(self, location):
print(f'{self.name} : {location} 방향으로 적군을 공격합니다. [공격력 {self.damage}]')
def damaged(self, damage):
print(f'{self.name} : {damage}데미지를 입었습니다.')
self.hp -= damage
print(f'{self.name} : 현재 체력은 {self.hp} 입니다.')
if self.hp <= 0:
print(f'{self.name} : 파괴되었습니다.')
class Flyable:
def __init__(self, name, flyingspeed):
self.name = name
self.flyingspeed = flyingspeed
def fly(self, location):
print(f'{self.name} : {location} 방향으로 날아갑니다. 속도 : {self.flyingspeed}')
class flyableAttackUnit(Attackunit, Flyable):
def __init__(self, name, hp, damage, flyingspeed):
Attackunit.__init__(self, name, hp, 0, damage)
Flyable.__init__(self, name, flyingspeed)
def move(self, location):
print("[공중 유닛 이동]")
self.fly(location)
class Buildingunit(Unit):
def __init__(self, name, hp, location):
super().__init__(name, hp, 0)
self.location = location
class Marine(Attackunit):
def __init__(self):
Attackunit.__init__(self, "마린", 40, 1, 5)
def stimpack(self):
if self.hp > 10:
self.hp -= 10
print("{0} : 스팀팩을 사용합니다. (hp 10 감소)".format(self.name))
else:
print(f'{self.name} : 체력이 부족하여 스팀팩을 사용하지 않습니다.')
class Tank(Attackunit):
seize_developed = False
def __init__(self):
Attackunit.__init__(self, "탱크", 150, 1, 35)
self.seize_mode = False
def set_seize_mode(self):
if Tank.seize_developed == False:
return
if self.seize_mode == False:
print(f'{self.name} : 시즈모드로 전환합니다.')
self.damage *= 2
self.seize_mode = True
else:
print(f'{self.name} : 시즈모드를 해제합니다.')
self.damage /= 2
self.seize_mode = False
class Wraith(flyableAttackUnit):
def __init__(self):
flyableAttackUnit.__init__(self, "레이스", 80, 20, 5)
self.clocked = False
def clocking(self):
if self.clocked == True:
print(f'{self.name} : 클로킹 모드를 해제합니다..')
self.clocked = False
else:
print(f'{self.name} : 클로킹 모드를 설정합니다..')
self.clocked = True
def game_start():
print("[알림] 새로운 게임을 시작합니다.")
def game_over():
print("player : gg")
game_start()
m1 = Marine()
m2 = Marine()
m3 = Marine()
t1 = Tank()
t2 = Tank()
w1 = Wraith()
attack_units = []
attack_units.append(m1)
attack_units.append(m2)
attack_units.append(t1)
attack_units.append(t2)
attack_units.append(w1)
for Unit in attack_units:
Unit.move("1시")
Tank.seize_developed = True
print("[알림] 탱크 시즈 모드 개발이 완료되었습니다.")
for Unit in attack_units:
if isinstance(Unit,Marine):
Unit.stimpack()
elif isinstance(Unit, Tank):
Unit.set_seize_mode()
elif isinstance(Unit, Wraith):
Unit.clocking()
for Unit in attack_units:
Unit.attack("1시")
for Unit in attack_units:
Unit.damaged(randint(5,21))
game_over()