Explorar o código

ScriptExplore Update

We now will make sure we have a scanner installed if not we output FATAL
message to logs.
david %!s(int64=5) %!d(string=hai) anos
pai
achega
46764390a7
Modificáronse 1 ficheiros con 41 adicións e 12 borrados
  1. 41 12
      flexible.py

+ 41 - 12
flexible.py

@@ -994,8 +994,9 @@ class ScriptExplore(object):
         
         # Our Stuff, Not our pants!
         self.dense = []         # We did a density, store that info.
-        self.didScan = False    # Track if we did a scan already... prevents us calling a scan multiple times.
         self.clear = []         # Warps that we know are clear.
+        self.didDense = False
+        self.didHolo = False
         self.highsector = 0     # Selected Sector to move to next!
         self.highwarp = 0       # Selected Sector's Warp Count!
         self.stacksector = set()   # Set of sectors that we have not picked but are unexplored... even though we did a holo!
@@ -1061,7 +1062,8 @@ class ScriptExplore(object):
         )
 
     def resetStuff(self):
-        self.didScan = False
+        self.didDense = False
+        self.didHolo = False
         self.dense = []
         self.clear = []
         self.highwarp = 0
@@ -1070,10 +1072,25 @@ class ScriptExplore(object):
 
     def game_prompt(self, prompt: str):
         log.msg("{0} : {1}".format(self.state, prompt))
-        if self.state == 3:
+        if self.state == 2:
+            if "Select (H)olo Scan or (D)ensity Scan or (Q)uit" in prompt:
+                if not self.didDense:
+                    self.send2game("D")
+                    self.didDense = True
+                    self.state += 1
+            else:
+                log.msg("Possibly no Holo Scanner Installed.")
+                self.deactivate()
+        if self.state == 5:
             log.msg("dense is {0} sectors big".format(len(self.dense)))
-            self.state += 1
-            self.send2game("SH")
+            if "Select (H)olo Scan or (D)ensity Scan or (Q)uit" in prompt:
+                if not self.didHolo:
+                    self.send2game("H")
+                    self.didHolo = True
+                    self.state += 1
+            else:
+                log.msg("FATAL: No Holo Scanner Installed!")
+                self.deactivate()
     
     def game_line(self, line: str):
         log.msg("{0} | {1}".format(self.state, line))
@@ -1082,14 +1099,26 @@ class ScriptExplore(object):
 
         if self.state == 1:
             # Density Scan, (Assume we have the Holo-Scanner)
-            if not self.didScan:
-                self.send2game("SD")
-                self.didScan = True
+            self.send2game("S")
             
             if "Relative Density Scan" in line:
+                self.state = 3
+            elif "You don't have a long range scanner." in line:
+                log.msg("FATAL: No Long Range Scanner Installed!")
+                self.deactivate()
+            elif "Long Range Scan" in line:
                 self.state += 1
-        
-        if self.state == 2:
+        elif self.state == 4:
+            # Holo Scan, (Assume we have the Holo-Scanner)
+            self.send2game("S")
+            
+            if "You don't have a long range scanner." in line:
+                log.msg("FATAL: No Long Range Scanner Installed!")
+                self.deactivate()
+            elif "Long Range Scan" in line:
+                self.state += 1
+
+        elif self.state == 3:
             if line.startswith("Sector"):
                 work = line.replace(':', '').replace(')', '').replace('%', '').replace('==>', '')
                 work = re.split(r"\s+", work)
@@ -1115,7 +1144,7 @@ class ScriptExplore(object):
                 
             elif line == "":
                 self.state += 1
-        elif self.state == 4:
+        elif self.state == 6:
             # Begin Processing our data we got from density scan and find highest warp count in what sectors
             # Remove sectors with one warp
 
@@ -1169,7 +1198,7 @@ class ScriptExplore(object):
                 if self.highwarp and self.highsector:
                     log.msg("Sector: {0:5d} Warps: {1}".format(self.highsector, self.highwarp))
                     self.state += 1
-        elif self.state == 5:
+        elif self.state == 7:
             # Add the dense scan of unknown sectors onto the stack of sectors, only save the ones we think are clear... for now.
             for c in self.clear:
                 self.stacksector.add(c)