Parcourir la source

Added log.debug message to send2game & send2player

Also added those functions on ScriptPort.
david il y a 5 ans
Parent
commit
92f304057a
1 fichiers modifiés avec 16 ajouts et 6 suppressions
  1. 16 6
      flexible.py

+ 16 - 6
flexible.py

@@ -543,9 +543,7 @@ class ScriptPort(object):
         self.observer.connect("game-line", self.game_line)
 
         self.defer = None
-        self.queue_game.put(
-            self.nl + "Script based on: Port Pair Trading v2.00" + self.r + self.nl
-        )
+        self.send2player("Script based on: Port Pair Trading v2.00")
 
         self.possible_sectors = None
 
@@ -585,6 +583,16 @@ class ScriptPort(object):
     def player(self, chunk: bytes):
         # If we receive anything -- ABORT!
         self.deactivate()
+    
+    def send2game(self, txt):
+        log.debug("ScriptPort.send2game({0})".format(txt))
+        self.queue_player.put(txt)
+
+    def send2player(self, txt):
+        log.debug("ScriptPort.send2player({0})".format(txt))
+        self.queue_game.put(
+            self.nl + txt + self.r + self.nl
+        )
 
     def game_prompt(self, prompt: str):
         log.debug("{0} : {1}".format(self.state, prompt))
@@ -711,9 +719,9 @@ class ScriptPort(object):
                         self.sell_percent += 1
                     self.queue_player.put("{0}\r".format(price))                    
             # elif re.match(r"How many holds of .+ do you want to sell \[\d+\]\?", prompt):
-            #     log.info("Sell everything we can...")
-            #     # this seems to screw up the sync of everything.
-            #     self.queue_player.put("\r")
+            #    log.info("Sell everything we can...")
+            #    this seems to screw up the sync of everything.
+            #    self.queue_player.put("\r"))
 
         elif self.state == 8:
             # What are we trading
@@ -1088,9 +1096,11 @@ class ScriptExplore(object):
         self.deactivate(True)
     
     def send2game(self, txt):
+        log.debug("ScriptExplore.send2game({0})".format(txt))
         self.queue_player.put(txt)
 
     def send2player(self, txt):
+        log.debug("ScriptExplore.send2player({0})".format(txt))
         self.queue_game.put(
             self.nl + txt + self.r + self.nl
         )