Skip to content

Commit dc4b847

Browse files
committed
Alpha testing underway ...
1 parent 9030ec1 commit dc4b847

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

Controls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,3 @@ def torpedos(game):
172172
game.display()
173173
game.enterprise.damage(game, Probabilities.PHOTON)
174174

175-
176-

MapGame.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
class GameMap(MapSparse.SparseMap):
1313

1414
def __init__(self):
15+
'''
16+
Prepare a 'Trekian GameMap for future
17+
initialization.
18+
'''
1519
super().__init__()
1620
self.sector = -1
1721
self.xpos = self.ypos = -1
@@ -179,9 +183,6 @@ def update_counts(self)->None:
179183
self.game_klingons += area.count_glyphs(Glyphs.KLINGON)
180184
self.game_starbases += area.count_glyphs(Glyphs.STARBASE)
181185
self.game_stars += area.count_glyphs(Glyphs.STAR)
182-
area = self.get_pw_sector()
183-
area = self.get_pw_sector()
184-
185186

186187
def remove_area_items(self, piece_array)->None:
187188
'''
@@ -199,16 +200,16 @@ def get_area_klingons(self)->list:
199200
'''
200201
results = []
201202
area = self.pw_area()
202-
for data in area.get_data(Glyphs.KLINGON):
203+
for data in area.query(Glyphs.KLINGON):
203204
ship = ShipKlingon()
204205
ship.from_map(data.xpos, data.ypos)
205206
results.append(ship)
206207
return results
207208

208209
def get_area_objects(self)->list:
209210
'''
210-
Return the actual objects, as located in the Area.
211-
NOTE: Changes to this collection will update Area
211+
Return the actual pieces, as maintained in the Area.
212+
WARNING: Changes to this collection WILL update Area
212213
content.
213214
'''
214215
area = self.pw_area()
@@ -228,7 +229,7 @@ def get_all(self, glyph)->list:
228229
'''
229230
results = []
230231
for area in self.areas():
231-
for piece in area.get_data(glyph):
232+
for piece in area.query(glyph):
232233
results.append([area, piece])
233234
return results
234235

@@ -247,7 +248,8 @@ def get_map(self)->list:
247248
return area.get_map()
248249

249250
def _go_to(self, dest):
250-
''' Either a WARP ~or~ a SUBSPACE destination is ok.
251+
'''
252+
Either a WARP ~or~ a SUBSPACE destination is ok.
251253
Place the main player (Enterprise, for now) into the Area.
252254
Returns the final, effective, player location.
253255
'''
@@ -274,6 +276,12 @@ def _go_to(self, dest):
274276
return dest
275277

276278
def randomize(self, bases=None, stars=None, aliens=None)->None:
279+
'''
280+
Randomly place the inventoried items into the map.
281+
If no bases ot aliens are specified, a random number
282+
will be selected. Stars are not required. Not having
283+
any stars is ok.
284+
'''
277285
if not aliens:
278286
aliens = random.randint(5, 10)
279287
if not bases:

MapSparse.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Area():
2020
A minimalist collection of Area-plotted Glyphs.
2121
Area numbers are 1's based.
2222
Area plotting is 0's based.
23-
Names are Trekian.
23+
Area names are Trekian.
2424
'''
2525
class Piece:
2626
'''
@@ -37,7 +37,6 @@ def __init__(self):
3737
'''
3838
self.name = ""
3939
self.number = -1
40-
self.scanned = False
4140
self._pieces = []
4241

4342
def is_null(self):
@@ -47,15 +46,14 @@ def is_null(self):
4746
dum = Area()
4847
return dum.name == self.name and \
4948
dum.number == self.number and \
50-
dum.scanned == self.scanned and \
5149
len(dum.objs) == len(self._pieces)
5250

5351
def is_empty(self):
5452
''' Checks to see if the Area has anything ...'''
5553
return len(self._pieces) == True
5654

57-
def items(self):
58-
''' Items in the Area ...'''
55+
def item_count(self)->int:
56+
''' The number of pieces / items in the randint ...'''
5957
return len(self._pieces)
6058

6159
def remove(self, xpos, ypos):
@@ -67,7 +65,7 @@ def remove(self, xpos, ypos):
6765

6866
def get_map(self)->list:
6967
'''
70-
Generate a map of this AREA. Map is full
68+
Generate a map of this randint. Map is full
7169
of Glyphs.SPACE on error.
7270
'''
7371
results = [[Glyphs.SPACE for _ in range(8)] for _ in range(8)]
@@ -89,7 +87,12 @@ def range_ok(self, xpos, ypos):
8987
return False
9088
return True
9189

92-
def get_data(self, glyph):
90+
def query(self, glyph):
91+
'''
92+
Clone each Piece for a glyph into a new
93+
collection. Changes to the results WILL NOT
94+
affect the glyph in the AREA.
95+
'''
9396
results = []
9497
for p in self._pieces:
9598
if p.glyph == glyph:
@@ -140,10 +143,17 @@ def clone(piece):
140143
return SparseMap.Area.Piece(piece.xpos, piece.ypos, piece.glyph)
141144

142145
def __init__(self):
146+
'''
147+
Create the uninitialized REGION. Use .init() to
148+
populate same with AREAs.
149+
'''
143150
self.initalized = False
144151
self._map = [[[y,x] for y in range(8)] for x in range(8)]
145152

146153
def init(self, reset=False):
154+
'''
155+
Fill a newly-created map with a set of randomly-named AREAs.
156+
'''
147157
if not reset and self.initalized:
148158
return
149159
for xx, row in enumerate(self._map):

Reports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def show_exit_status(game):
4040
msg = "MISSION FAILED: OUT OF ENERGY."
4141
game.show_banner([msg], '!')
4242
elif game.game_map.game_klingons == 0:
43-
msg = "MISSION ACCOMPLISHED: ENEMIES DESTROYED. WELL DONE!"
44-
game.show_banner([msg])
43+
msg = "MISSION ACCOMPLISHED","ENEMIES DESTROYED","WELL DONE!"
44+
game.show_banner(msg)
4545
elif game.time_remaining == 0:
4646
msg = "MISSION FAILED: OUT OF TIME."
4747
game.show_banner([msg], '!')

Sector.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def __init__(self, num=-1, name='',
1010
self.area_klingons = aliens
1111
self.area_stars = stars
1212
self.area_starbases = starbases
13-
self.scanned = True # meh
1413

1514
def is_null(self):
1615
return self.num == -1

ShipKlingon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def attack_if_you_can(game):
2222
'''
2323
IF you ever find yourself in the AREA, then have at USS?
2424
'''
25-
if game.is_testing:
25+
if game.is_cloked:
2626
return False
2727
from Calculators import Calc
2828
kships = game.game_map.get_area_klingons()

StarTrek2020.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import TrekStrings
44
from Console import Con
55
from ShipKlingon import ShipKlingon
6-
from ShipStarbase import ShipStarbase
76
from ShipEnterprise import ShipEnterprise
7+
from ShipStarbase import ShipStarbase
88
from Calculators import Calc
99
from Controls import Control
1010
from Reports import Stats
@@ -17,6 +17,7 @@ class Game(Con):
1717

1818
def __init__(self):
1919
self.is_testing = False
20+
self.is_cloked = False # unable to be fired-upon
2021
self.game_map = GameMap()
2122
self.enterprise = ShipEnterprise()
2223
self.star_date = 0
@@ -80,6 +81,12 @@ def run(self):
8081
while self.game_on():
8182
if not self.command_prompt():
8283
break
84+
if self.is_testing:
85+
self.destoryed = False
86+
ShipStarbase.dock_enterprise(self.enterprise)
87+
ShipStarbase.launch_enterprise(self.enterprise)
88+
self.enterprise.shield_level = 1000
89+
8390
except ErrorEnterpriseCollision as ex:
8491
if ex.glyph == Glyphs.KLINGON:
8592
self.display("You flew into a KLINGON!")
@@ -94,7 +101,6 @@ def run(self):
94101
if self.destroyed == True:
95102
self.display(Quips.jibe_fatal_mistake())
96103
game.display()
97-
game.display(';-)')
98104
return False
99105

100106
def command_prompt(self):

0 commit comments

Comments
 (0)