Skip to content

Commit 2b36d43

Browse files
committed
Better in-play inventory.
1 parent dbc059f commit 2b36d43

8 files changed

+23
-28
lines changed

Calculators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def navigation(game):
3232
dist = dest_sys.warp * 8
3333
energy_required = int(dist)
3434
if energy_required >= game.enterprise.energy:
35-
game.display("Unable to comply. Insufficient energy to travel that speed.")
35+
game.display("Insufficient energy to travel at that speed.")
3636
game.display()
3737
return
3838
else:
@@ -79,7 +79,7 @@ def show_torp_targets(game):
7979
game.display()
8080
kships = game.game_map.get_area_klingons()
8181
if len(kships) == 0:
82-
game.display("There are no enemy ships in this quadrant.")
82+
game.display("There are no enemies in this quadrant.")
8383
return
8484

8585
game.display("Enemies:")

Controls.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def phasers(game):
6969
else:
7070
game.display(f"Hit ship at [{ship.xpos + 1},{ship.ypos + 1}].")
7171
game.display(f"Enemy shield down to {ship.shield_level}.")
72-
game.game_map.klingons -= len(destroyed_ships)
7372
game.game_map.remove_items(destroyed_ships)
7473
if game.game_map.klingons > 0:
7574
game.display()
@@ -141,7 +140,6 @@ def torpedos(game):
141140
num = game.game_map.game_id(ship)
142141
game.display(f"Klingon ship #{num} destroyed.")
143142
game.display(Quips.jibe_defeat('enemy'))
144-
game.game_map.klingons -= 1
145143
game.game_map.remove_items([ship])
146144
hit = True
147145
break
@@ -156,7 +154,7 @@ def torpedos(game):
156154
elif ship.glyph == Glyphs.STAR:
157155
num = game.game_map.game_id(ship)
158156
game.display(f"Torpedo vaporizes star #{num}!")
159-
game.display(Quips.jibe_defeat('scientist'))
157+
game.display(Quips.jibe_defeat('academic'))
160158
game.game_map.remove_items([ship])
161159
hit = True
162160
break

MapGame.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class GameMap(MapSparse.SparseMap):
1313
def __init__(self):
1414
super().__init__()
1515
self.sector = -1
16-
self.major_x = self.major_y = -1
17-
self.xpos = self.ypos = -1
16+
self.xpos = self.ypos = -1
1817
self.stars = -1
1918
self.klingons = -1
2019
self.starbases = -1
@@ -124,10 +123,16 @@ def _count(self, glyph):
124123
count += 1
125124
return count
126125

127-
def remove_items(self, destroyed_ships):
126+
def update_counts(self):
127+
self.klingons = self._count(Glyphs.KLINGON)
128+
self.starbases = self._count(Glyphs.STARBASE)
129+
self.stars = self._count(Glyphs.STAR)
130+
131+
def remove_items(self, removed):
128132
area = self.area()
129-
for obj in destroyed_ships:
133+
for obj in removed:
130134
area.remove(obj.xpos, obj.ypos)
135+
self.update_counts()
131136

132137
def get_area_klingons(self):
133138
'''
@@ -201,16 +206,6 @@ def go_to(self, dest):
201206
self.enterprise_out()
202207
assert(isinstance(self.sector, int))
203208
self.sector = dest.sector
204-
if self.sector > 0:
205-
fop = (self.sector + 8) / 8
206-
self.major_x = int(fop) - 1 # ZERO BASED REGIONS
207-
if not fop.is_integer():
208-
self.major_y = \
209-
((fop - float(self.major_x)) * 10) - 1 # ZBR
210-
else:
211-
self.major_x = -1
212-
self.major_y = -1
213-
214209
self.xpos = dest.xpos
215210
self.ypos = dest.ypos
216211
self.enterprise_in(dest)

MapSparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
class SparseMap:
66
'''
7-
Minimalist mapping. On-demand Area epansion to full-Area views.
7+
Minimalist mapping.
8+
On-demand 'sparse-array' expansion to full-Area views.
89
'''
910

1011
class Region():

Quips.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44
"The main ",
55
"That @#$#@& ",
66
"Our cheap ",
7-
"Darnit captian, that ",
7+
"Darn-it captain, that ",
88
"Yikes, the ",
99
]
1010
DAMAGE_SUFFIX = [
1111
" has died. We're on it!",
1212
" is out. We're working on it!",
1313
" is almost repaired!",
1414
" is dead.",
15-
" is fried. I'm working as fast as I can!",
15+
" is fried. Working as fast as we can!",
16+
" is toast. Working as fast as I can!",
1617
" is being replaced.",
1718
" is dead. Please leave a message.",
1819
]
1920
DEFEAT_PREFIX = [
2021
"A defeated ",
21-
"The vengefull ",
22+
"The vengeful ",
2223
"An angry ",
2324
"The ejecting ",
2425
"A confused ",
@@ -35,6 +36,7 @@
3536
" is no more.",
3637
" is recycled.",
3738
" is eliminated.",
39+
" was aborted. Few lives, matter?",
3840
" ejects.",
3941
" crew is rescued.",
4042
" crew is spaced.",
@@ -47,8 +49,8 @@
4749
" screams: 'Thy father is a Targ!'",
4850
" yells: 'Your parents eat bats!'",
4951
" snarls: 'Thy people eat vermin!'",
50-
" yells: 'May you create social diseases!'",
51-
" curses: 'Thy fathers spread pox!'",
52+
" yells: 'May you create social disease!'",
53+
" curses: 'Thy fathers spreadeth pox!'",
5254
" yells: 'Your mother is progressive!'",
5355
]
5456

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ So far:
1111

1212
Original authors did an excellent job here - made the modernization a WHOLE LOT easier!
1313

14-
:monocle_face:
1514

1615
-- Nagy
1716

Reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def show_galactic_status(game):
3131

3232

3333
@staticmethod
34-
def show_game_status(game):
34+
def show_exit_status(game):
3535
if game.destroyed:
3636
msg = "MISSION FAILED: ENTERPRISE DESTROYED!!!"
3737
game.display('!' * len(msg))

StarTrek2020.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def run(self):
3838
self.destroyed and self.game_map.klingons > 0 and \
3939
self.time_remaining > 0:
4040
self.command_prompt()
41-
Stats.show_game_status(game)
41+
Stats.show_exit_status(game)
4242

4343
def command_prompt(self):
4444
command = self.read("Enter command: ").strip().lower()

0 commit comments

Comments
 (0)