-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathability.py
More file actions
106 lines (87 loc) · 2.77 KB
/
ability.py
File metadata and controls
106 lines (87 loc) · 2.77 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
from pygame.locals import *
from constants import *
ability_types = [
"torpedo",
"missile",
"radar",
"passive sonar",
"active sonar",
]
class Ability:
def __init__(self):
self.targets_other = False
self.targets_self = False
self.range = None
self.ammo = None
def change_ammo(self, amt):
self.ammo = self.ammo + amt
if self.ammo < 0:
self.ammo = 0
# NOTE: In the future, I may allow the player to control some surface vessels and use some of these
# AI-only abilities.
class DropSonobuoy(Ability):
def __init__(self, ammo=DEFAULT_SONOBUOY_AMMO):
self.type = "drop sonobuoy"
self.ammo = ammo
class LaunchHelicopter(Ability):
def __init__(self):
self.type = "launch helicopter"
self.ammo = 1
class ToggleSpeed(Ability):
def __init__(self):
self.targets_self = True
self.type = "toggle speed"
self.key_literal = "7"
self.key_constant = K_7
def draw_str(self):
return "{}: toggle speed".format(self.key_literal)
class ShortRangeTorpedo(Ability):
def __init__(self, ammo=DEFAULT_TORP_AMMO):
super().__init__()
self.type = "torpedo"
self.ammo = ammo
self.range = TORPEDO_RANGE
self.targets_other = True
self.key_literal = "1"
self.key_constant = K_1
def draw_str(self):
return "{}: torpedo (x{})".format(self.key_literal, self.ammo)
class ShortRangeMissile(Ability):
def __init__(self, ammo=DEFAULT_MISSILE_AMMO):
super().__init__()
self.type = "missile"
self.ammo = ammo
self.range = MISSILE_RANGE
self.targets_other = True
self.key_literal = "2"
self.key_constant = K_2
def draw_str(self):
return "{}: missile (x{})".format(self.key_literal, self.ammo)
class PassiveSonar(Ability):
def __init__(self):
super().__init__()
self.type = "passive sonar"
self.range = PASSIVE_SONAR_RANGE
self.key_literal = "0"
self.key_constant = K_0
def draw_str(self):
return "{}: passive sonar".format(self.key_literal)
class ActiveSonar(Ability):
def __init__(self):
super().__init__()
self.type = "active sonar"
self.range = ACTIVE_SONAR_RANGE
self.key_literal = "8"
self.key_constant = K_8
def draw_str(self):
return "{}: active sonar".format(self.key_literal)
class Radar(Ability):
def __init__(self):
super().__init__()
self.type = "radar"
self.range = RADAR_RANGE
self.key_literal = "9"
self.key_constant = K_9
self.emerged_to_transmit = False
def draw_str(self):
return "{}: radar".format(self.key_literal)