Skip to content

Commit e727a1b

Browse files
committed
Added a banner -w- closing Quips.
1 parent 8e6ee57 commit e727a1b

File tree

7 files changed

+98
-49
lines changed

7 files changed

+98
-49
lines changed

AbsDisplay.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
class abs_display(abc.ABC):
44
'''
55
The plan is to have several places to
6-
display information. The goal is to
7-
use only one display, to display a
8-
certain type of message. Networked
9-
screens would also be a great idea.
10-
Logging would be in there somewhere,
11-
as well.
6+
display information. The idea is to
7+
use only one display to show a certain
8+
type of message.
9+
10+
Networked screens would (let alone game
11+
play)would also be a great idea.
12+
13+
Event logging would be in there somewhere
14+
as well?
1215
'''
1316

1417
ST_DEFAULT = 'd'
@@ -26,9 +29,28 @@ def __init__(self, type_ = ST_DEFAULT, width = 80, height = 24):
2629
def display(self, message):
2730
pass
2831

29-
3032
def show_strings(self, string_list):
33+
'''
34+
Enumerate an array of strings into
35+
self.display.
36+
'''
3137
for string in string_list:
3238
self.display(string)
3339
self.display()
3440

41+
def show_banner(self, string_list, star = '*'):
42+
'''
43+
Enumerate an array of strings into a
44+
single-character self.display box.
45+
'''
46+
if not star:
47+
star = '*'
48+
star = star[0]
49+
sz = len(max(string_list, key=len))
50+
max_ = sz + 4
51+
self.display(star * max_)
52+
for str_ in string_list:
53+
self.display(star + ' ' + str_.center(sz) + ' ' + star)
54+
self.display(star * max_)
55+
return sz
56+

Console.py

+2
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ def read_xypos(self, prompt= "Helm: a-h, 1-8?"):
4747
if __name__ == '__main__':
4848
con = Con()
4949
con.display("Testing!")
50+
con.show_banner(["Testing, too!"])
51+
con.show_banner(["Testing", " .......... too!"])

MapGame.py

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def update_counts(self)->None:
180180
self.game_starbases += area.count_glyphs(Glyphs.STARBASE)
181181
self.game_stars += area.count_glyphs(Glyphs.STAR)
182182
area = self.get_pw_sector()
183+
area = self.get_pw_sector()
183184

184185

185186
def remove_area_items(self, piece_array)->None:

MapSparse.py

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def place_glyph(self, glyph, dest=None):
136136

137137
@staticmethod
138138
def clone(piece):
139-
''' Copy a piece. '''
140139
''' Copy a piece. '''
141140
return SparseMap.Area.Piece(piece.xpos, piece.ypos, piece.glyph)
142141

Quips.py

+31-16
Original file line numberDiff line numberDiff line change
@@ -42,49 +42,64 @@
4242
" crew is spaced.",
4343
" crew is recycled.",
4444
" crew is recovered.",
45-
" yells: 'Thy mother mates poorly!'",
46-
" snarls: 'Lucky shot.'",
47-
" laughs: 'You'll not do THAT again!'",
45+
" yells: 'thy mother mates poorly!'",
46+
" snarls: 'lucky shot.'",
47+
" laughs: 'you'll not do THAT again!'",
4848
" says nothing.",
49-
" screams: 'Thy father is a Targ!'",
50-
" yells: 'Your parents eat bats!'",
51-
" snarls: 'Thy people eat vermin!'",
52-
" yells: 'May you create social disease!'",
53-
" curses: 'Thy fathers spreadeth pox!'",
54-
" yells: 'Your mother is progressive!'",
49+
" screams: 'thy father is a Targ!'",
50+
" yells: 'thine family eats bats!'",
51+
" snarls: 'thine people eat vermin!'",
52+
" curses: 'thy fathers spreadeth pox!'",
53+
" yells: 'thy mother is progressive!'",
5554
]
5655
MISTAKES = [
5756
"... the crew was not impressed ...",
5857
"... that's going to leave a mark ...",
59-
"... next time, remember to 'carry the 1'? ...",
58+
"... next time carry the 1?",
6059
"... math lives matter ...",
61-
"... that's coming out of your paycheck ...",
60+
"... its coming out of your pay ...",
6261
"... this is not a bumper car ...",
63-
"... life can be tough, that way ...",
64-
"... who ordered THAT take-out ...",
62+
"... life can be tough that way ...",
63+
"... who ordered THAT take-out?",
6564
"... random is, what random does ...",
6665
"... you've got their attention ...",
67-
"... next time, just text them ...",
66+
"... next time, just text them?",
6867
"... how rude!",
6968
"... yes, karma CAN hurt ...",
7069
"... life is but a dream!",
7170
"... game over.",
72-
"... they will talk about this one for years.",
73-
"... who is going to pay for this?",
71+
"... starfleet will talk about this for years.",
72+
"... who is going to pay for that?",
7473
"... galactic insurance premiums skyrocket ...",
7574
"... captain goes down with the starship ...",
7675
"... we'll notify your next-of-kin.",
7776
"... that was not in the script ...",
7877
"... you never did THAT in the simulator ...",
7978
]
8079

80+
QUITS = [
81+
"-Let's call it a draw?",
82+
"-You call yourself a 'Trekkie?",
83+
"Kobayashi Maru. Python for you?",
84+
"(Spock shakes his head)",
85+
"(Duras, stop laughing!)",
86+
"(... and the Klingons rejoice)",
87+
"(... and our enemies, rejoice)",
88+
"Kobayashi Maru... Got Python?",
89+
"(Kirk shakes his head)",
90+
]
91+
8192
class Quips():
8293

8394
@staticmethod
8495
def jibe(noun, prefix, suffix):
8596
prand = random.randrange(0, len(prefix))
8697
srand = random.randrange(0, len(suffix))
8798
return prefix[prand] + noun + suffix[srand]
99+
100+
@staticmethod
101+
def jibe_quit():
102+
return QUITS[random.randrange(0, len(QUITS))]
88103

89104
@staticmethod
90105
def jibe_damage(noun):

Reports.py

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Glyphs
2+
from Quips import Quips
23

34
class Stats():
45
'''
@@ -33,23 +34,18 @@ def show_galactic_status(game):
3334
@staticmethod
3435
def show_exit_status(game):
3536
if game.destroyed:
36-
msg = "MISSION FAILED: ENTERPRISE DESTROYED!!!"
37-
game.display('!' * len(msg))
38-
game.display(msg)
39-
game.display('!' * len(msg))
37+
msg = "MISSION FAILED: SHIP DESTROYED"
38+
game.show_banner([msg], '!')
4039
elif game.enterprise.energy == 0:
41-
msg = "MISSION FAILED: ENTERPRISE RAN OUT OF ENERGY."
42-
game.display('!' * len(msg))
43-
game.display(msg)
44-
game.display('!' * len(msg))
40+
msg = "MISSION FAILED: OUT OF ENERGY."
41+
game.show_banner([msg], '!')
4542
elif game.game_map.game_klingons == 0:
46-
msg = "MISSION ACCOMPLISHED: ALL ENEMY SHIPS DESTROYED. WELL DONE!!!"
47-
game.display('!' * len(msg))
48-
game.display(msg)
49-
game.display('!' * len(msg))
43+
msg = "MISSION ACCOMPLISHED: ENEMIES DESTROYED. WELL DONE!"
44+
game.show_banner([msg])
5045
elif game.time_remaining == 0:
51-
msg = "MISSION FAILED: ENTERPRISE RAN OUT OF TIME."
52-
game.display('!' * len(msg))
53-
game.display(msg)
54-
game.display('!' * len(msg))
46+
msg = "MISSION FAILED: OUT OF TIME."
47+
game.show_banner([msg], '!')
48+
else:
49+
ary = ["::::::::: MISSION ABORTED :::::::::", Quips.jibe_quit()]
50+
game.show_banner(ary, ':')
5551

StarTrek2020.py

+23-9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ def __init__(self):
2424
self.destroyed = False
2525

2626
def move_to(self, dest):
27+
'''
28+
Move the player to a nav, or a sub,
29+
destination. Handles docking, random
30+
warp-in placement, as well as deliberate
31+
collisions / rammming.
32+
33+
Returns final resting coordinate on success.
34+
Raises ErrorEnterpriseCollision on yikes.
35+
'''
2736
pos = self.game_map._go_to(dest)
2837
area = self.game_map.pw_area()
2938
was_docked = self.enterprise.docked
@@ -38,16 +47,19 @@ def move_to(self, dest):
3847
ShipStarbase.launch_enterprise(self.enterprise)
3948
return pos
4049

41-
def game_over(self):
50+
def game_on(self):
4251
'''
43-
Check to see if the game is over.
52+
See if the game is still running.
4453
'''
4554
running = self.enterprise.energy > 0 and not \
4655
self.destroyed and self.game_map.game_klingons > 0 and \
4756
self.time_remaining > 0
4857
return running
4958

5059
def run(self):
60+
'''
61+
The game loop - runs until the game is over.
62+
'''
5163
self.show_strings(TrekStrings.LOGO_TREKER)
5264
game.star_date = random.randint(2250, 2300)
5365
game.time_remaining = random.randint(40, 45)
@@ -64,12 +76,10 @@ def run(self):
6476
self.show_strings(TrekStrings.HELM_CMDS)
6577
running = True
6678
try:
67-
while running:
68-
self.command_prompt()
69-
if not self.game_over():
70-
Stats.show_exit_status(game)
79+
while self.game_on():
80+
if not self.command_prompt():
81+
break
7182
except ErrorEnterpriseCollision as ex:
72-
Stats.show_exit_status(game)
7383
game.display()
7484
if ex.glyph == Glyphs.KLINGON:
7585
self.display("You flew into a KLINGON!")
@@ -79,7 +89,10 @@ def run(self):
7989
self.display("You flew into a STAR?")
8090
self.destroyed = True
8191
game.display()
82-
self.display(Quips.jibe_fatal_mistake())
92+
Stats.show_exit_status(game)
93+
game.display()
94+
if self.destroyed == True:
95+
self.display(Quips.jibe_fatal_mistake())
8396
game.display()
8497
game.display(';-)')
8598
return False
@@ -104,9 +117,10 @@ def command_prompt(self):
104117
elif command == "com":
105118
Control.computer(game)
106119
elif command.startswith('qui') or command.startswith('exi'):
107-
exit()
120+
return False
108121
else:
109122
self.show_strings(TrekStrings.HELM_CMDS)
123+
return True
110124

111125
def print_mission(self):
112126
self.display("Mission: Destroy {0} Klingon ships in {1} stardates with {2} starbases.".format(

0 commit comments

Comments
 (0)