Browse Source

Fixed out of money/PlanetUp and others.

Fixed sloppy mode, where the prompt is displayed
because we don't trigger on the full prompt.
(Use the regex!)
Steve Thielemann 5 years ago
parent
commit
54d20b0ef9
2 changed files with 35 additions and 10 deletions
  1. 34 9
      flexible.py
  2. 1 1
      proxy.py

+ 34 - 9
flexible.py

@@ -2408,11 +2408,17 @@ class PlanetUpScript(object):
 
         box = Boxes(44, color=tc)
         self.queue_game.put(box.top())
+        # Are we just displaying local only?  Then say so.
+        if justLocal:
+            planet_label = "LOCAL Planet Name"
+        else:
+            planet_label = "Planet Name"
+
         self.queue_game.put(
             box.row(
                 tc
                 + "{0:3} {1:6} {2:20} {3} ".format(
-                    " # ", "Sector", "Planet Name", "Citadel LVL"
+                    " # ", "Sector", planet_label, "Citadel LVL"
                 )
             )
         )
@@ -2621,6 +2627,19 @@ class PlanetUpScript(object):
                     holds, _, _ = holds.partition("]")
                     self.fetch_amount = int(holds)
                     log.info("Buying {0} of {1}".format(holds, self.fetch))
+                    # BTTZ.
+                    if int(holds) == 0:
+                        # FAIL-WHALE
+                        self.queue_player.put("\r")
+                        self.queue_game.put(
+                            self.nl
+                            + Boxes.alert(
+                                "FAILURE:  Just bought 0 holds!  Out of money!?!",
+                                base="red",
+                            )
+                        )
+                        self.deactivate(True)
+                        return
                     self.queue_player.put("\r\r")
                     self.state = 8
                 else:
@@ -2703,7 +2722,7 @@ class PlanetUpScript(object):
     def planet_chosen(self, choice: str):
         if choice.strip() == "":
             self.deactivate()
-        elif choice.strip()[0] == "L":
+        elif choice.strip().upper()[0] == "L":
             self.display_planets(False)
 
             ask = PlayerInput(self.game)
@@ -2794,7 +2813,7 @@ class PlanetUpScript(object):
                 # Ok, already building.
                 self.queue_game.put(self.nl + Boxes.alert("NO, NOT YET!") + self.nl)
                 self.queue_player.put("Q")  # quit Planet menu.
-                self.deactivate()
+                self.deactivate(True)
                 return
 
             # [  Item    Colonists  Colonists    Daily     Planet      Ship      Planet  ]
@@ -2832,11 +2851,11 @@ class PlanetUpScript(object):
                 # Ah HA!
                 self.queue_game.put(self.nl + Boxes.alert("NO, NOT YET!") + self.nl)
                 self.queue_player.put("Q")  # quit Planet menu.
-                self.deactivate()
+                self.deactivate(True)
             elif line.startswith("This Citadel cannot be upgraded further"):
                 self.queue_game.put(self.nl + Boxes.alert("NO MORE!") + self.nl)
                 self.queue_player.put("QQ")  # quit Citadel, quit Planet menu.
-                self.deactivate()
+                self.deactivate(True)
             else:
                 items = ["Colonists", "Fuel Ore", "Organics", "Equipment"]
                 work = line.replace(",", "").replace(" units of", "").strip()
@@ -4496,11 +4515,11 @@ class bustViewer(object):
 
 
 class firstActivate(object):
-    """ Uppon first time activation of the proxy what happens
+    """ Upon first time activation of the proxy what happens
 
         States:
         0 = Send V and gather information on when busts were cleared
-        1 = Calcualte date from pendulum.now().subtract(days=#)
+        1 = Calculate date from pendulum.now().subtract(days=#)
         2 = If pendulum.now() is greater than our date to clear then self.game.gamedata.reset_busts()
 
         Well drat... while in a game you can't access when busts were cleared. :(
@@ -4559,7 +4578,13 @@ class firstActivate(object):
     def game_prompt(self, prompt: str):
         log.debug("P {0} | {1}".format(self.state, prompt))
         if self.state == 0:
-            if prompt.startswith("Command"):
+            # Enable sloppy-shit mode.  This shows random parts
+            # of the command line because you don't wait for
+            # the entire commandline to be displayed.
+            # There's a darn good reason I worked on the regex to
+            # match the prompt...
+            if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
+                # if prompt.startswith("Command"):
                 self.deactivate()
 
     def game_line(self, line: str):
@@ -4627,7 +4652,7 @@ class ProxyMenu(object):
             d.addCallback(self.pre_back)
             d.addErrback(self.pre_back)
         else:
-            # welp that was all skipped because we already did that.
+            # well that was all skipped because we already did that.
             self.pre_back()
 
     def __del__(self):

+ 1 - 1
proxy.py

@@ -542,7 +542,7 @@ class Player(protocol.Protocol):
             # Computer command [TL=00:00:00]:[613] (?=Help)?
             # (and others I've yet to see...)
 
-            if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
+            if re.match(r"Command \[TL=.* \(\?=Help\)\? : ", prompt):
                 menu = ProxyMenu(self.game)
             else:
                 nl = "\n\r"