|
@@ -1933,6 +1933,7 @@ class PlanetUpScript(object):
|
|
|
# Yes, at this point we would activate
|
|
|
self.prompt = game.buffer
|
|
|
self.save = self.observer.save()
|
|
|
+ self.nl = "\n\r"
|
|
|
|
|
|
# I actually don't want the player input, but I'll grab it anyway.
|
|
|
self.observer.connect("player", self.player)
|
|
@@ -1956,15 +1957,38 @@ class PlanetUpScript(object):
|
|
|
def game_prompt(self, prompt):
|
|
|
if self.state == 2 and re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
# For now we output the information, and exit
|
|
|
- self.queue_game.put("{0}\r\n".format(self.planets))
|
|
|
+ # self.queue_game.put("{0}\r\n".format(self.planets))
|
|
|
+ self.queue_game.put(pformat(self.planets).replace("\n", self.nl) + self.nl)
|
|
|
+
|
|
|
+ if len(self.planets) == 0:
|
|
|
+ # Ok, this is easy.
|
|
|
+ self.queue_game.put(Boxes.alert("You don't have any planets? You poor dear.", base="red"))
|
|
|
+ self.deactivate()
|
|
|
+ return
|
|
|
+
|
|
|
+ # Get current sector from the prompt
|
|
|
# Command [TL=00:00:00]:[10202] (?=Help)? :
|
|
|
_, _, part = prompt.partition(']:[')
|
|
|
sector, _, _ = part.partition(']')
|
|
|
self.current_sector = int(sector)
|
|
|
- self.queue_game.put("Current: {0}\r\n".format(sector))
|
|
|
+ # self.queue_game.put("Current: {0}\r\n".format(sector))
|
|
|
# Only ONE planet right in front of us? Default to upgrading it!
|
|
|
# Otherwise, we'll have to ask.
|
|
|
obvious = [ s for s in self.planets.keys() if self.planets[s]['sector'] == self.current_sector ]
|
|
|
+ if len(obvious) == 1:
|
|
|
+ # There is one.
|
|
|
+ self.planet_number = obvious[0]
|
|
|
+ self.planet_sector = self.planets[self.number]['sector']
|
|
|
+ self.planet_name = self.planets[self.number]['name']
|
|
|
+ self.state = 4
|
|
|
+ # begin landing procedure ...
|
|
|
+ self.queue_player.put("L")
|
|
|
+ else:
|
|
|
+ # There are either no obvious planets to upgrade,
|
|
|
+ # or there are multiple planet choices.
|
|
|
+
|
|
|
+ pass
|
|
|
+
|
|
|
self.queue_game.put(Boxes.alert("Choices: {0}".format(obvious)))
|
|
|
|
|
|
# Wooah Hoss! What if there's more then one planet in this sector?!
|
|
@@ -1985,8 +2009,24 @@ class PlanetUpScript(object):
|
|
|
sector, number, name = re.split(r'\s+', detail, 2)
|
|
|
sector = int(sector)
|
|
|
number = int(number[1:])
|
|
|
+ self.last_seen = number
|
|
|
self.planets[number] = {"sector": sector, "name": name}
|
|
|
log.info("Planet # {0} in {1} called {2}".format( number, sector, name))
|
|
|
+ if '---' in line:
|
|
|
+ number = self.last_seen
|
|
|
+ # Ok, take the last_seen number, and use it for this line
|
|
|
+ # [ Sector Planet Name Ore Org Equ Ore Org Equ Fighters Citadel]
|
|
|
+ # [ Shields Population -=Productions=- -=-=-=-=-On Hands-=-=-=-=- Credits]
|
|
|
+ # [ 10202 #3 Home of Bugz Class M, Earth Type No Citadel]
|
|
|
+ # [ --- (1M) 144 49 26 145 75 12 10 0]
|
|
|
+ details = re.split(r"\s+", line.strip())
|
|
|
+ self.planets[number]['population'] = details[1].replace('(', '').replace(')', '')
|
|
|
+ # Ok, there's going to have to be some sort of modifier (K, M, etc.)
|
|
|
+ # to these numbers. Beware!
|
|
|
+ self.planets[number]['ore'] = details[5]
|
|
|
+ self.planets[number]['org'] = details[6]
|
|
|
+ self.planets[number]['equ'] = details[7]
|
|
|
+
|
|
|
|
|
|
def __del__(self):
|
|
|
log.debug("PlanetUpScript {0} RIP".format(self))
|
|
@@ -2612,6 +2652,7 @@ class ProxyMenu(object):
|
|
|
ask.colorp(merge(Style.BRIGHT + Fore.YELLOW + Back.RED))
|
|
|
d = ask.prompt("How many loops of terror?", 4, name="loops", digits=True, abort_blank=True)
|
|
|
d.addCallback(self.terror, ask)
|
|
|
+ d.addErrback(self.deactivate_scripts_menu)
|
|
|
return
|
|
|
elif key == '2':
|
|
|
self.queue_game.put(self.c + key + self.r + self.nl)
|