|
@@ -1059,11 +1059,19 @@ class ScriptExplore(object):
|
|
|
self.nl + txt + self.r + self.nl
|
|
|
)
|
|
|
|
|
|
+ def resetStuff(self):
|
|
|
+ self.didScan = False
|
|
|
+ self.dense = []
|
|
|
+ self.clear = []
|
|
|
+ self.highwarp = 0
|
|
|
+ self.highsector = 0
|
|
|
+ log.msg("ScriptExplore.resetStuff()")
|
|
|
+
|
|
|
def game_prompt(self, prompt: str):
|
|
|
log.msg("{0} : {1}".format(self.state, prompt))
|
|
|
if self.state == 3:
|
|
|
log.msg("dense is {0} sectors big".format(len(self.dense)))
|
|
|
- self.state = 4
|
|
|
+ self.state += 1
|
|
|
self.send2game("SH")
|
|
|
|
|
|
def game_line(self, line: str):
|
|
@@ -1078,8 +1086,9 @@ class ScriptExplore(object):
|
|
|
self.didScan = True
|
|
|
|
|
|
if "Relative Density Scan" in line:
|
|
|
- self.state = 2
|
|
|
- elif self.state == 2:
|
|
|
+ self.state += 1
|
|
|
+
|
|
|
+ if self.state == 2:
|
|
|
if line.startswith("Sector"):
|
|
|
work = line.replace(':', '').replace(')', '').replace('%', '').replace('==>', '')
|
|
|
work = re.split(r"\s+", work)
|
|
@@ -1104,7 +1113,7 @@ class ScriptExplore(object):
|
|
|
# {'sector': 8192, 'density': 0, 'warps': 4, 'navhaz': 0, 'anom': False}
|
|
|
|
|
|
elif line == "":
|
|
|
- self.state = 3
|
|
|
+ self.state += 1
|
|
|
elif self.state == 4:
|
|
|
# Ok so we do our Holo-Scan now how can we parse this... hmm.
|
|
|
# Or do we just do that and then do a move? Hmmm... (I think we get enough info to make a choice)
|
|
@@ -1124,8 +1133,6 @@ class ScriptExplore(object):
|
|
|
# Attempt to resolve no new sectors!
|
|
|
if self.stacksector: # Do we have anything on the stack? (If so we set highsector with one of the randomly selected sectors)
|
|
|
self.highsector = self.stacksector.pop()
|
|
|
- # Ok so here is were we should jump into some other way to safely get to that said sector, and safely also meaning if we see and
|
|
|
- # new sectors along the way stop and grab them too... or just throw them onto the stack.
|
|
|
self.deactivate()
|
|
|
elif self.dense: # Dense does contain at least 1 new sector, continue on
|
|
|
t = [] # Pre-Test to check if there are just a bunch of 1 warp sectors
|
|
@@ -1137,9 +1144,7 @@ class ScriptExplore(object):
|
|
|
self.send2player("Find a new area for me to look at!")
|
|
|
# Attempt to resolve no new sectors with more than 1 warp!
|
|
|
if self.stacksector: # Do we have anything on the stack? (If so we set highsector with one of the randomly selected sectors)
|
|
|
- self.highsector = self.stacksector.pop()
|
|
|
- # Ok so here is were we should jump into some other way to safely get to that said sector, and safely also meaning if we see and
|
|
|
- # new sectors along the way stop and grab them too... or just throw them onto the stack.
|
|
|
+ self.highsector = self.stacksector.pop()
|
|
|
self.deactivate()
|
|
|
|
|
|
# Is the sector safe to go into?
|
|
@@ -1156,7 +1161,7 @@ class ScriptExplore(object):
|
|
|
|
|
|
if self.clear: # We have sector(s) we can move to!
|
|
|
log.msg("Clear Sectors: {0}".format(len(self.clear)))
|
|
|
- self.state = 5
|
|
|
+ self.state += 1
|
|
|
elif self.state == 5:
|
|
|
# Ok so we now have a idea of howmany and what sectors are clear and have greater than 1 warps
|
|
|
# Now to sort thru that to see which ones have the highest warps and if they have a port or not
|
|
@@ -1180,14 +1185,14 @@ class ScriptExplore(object):
|
|
|
# If we found the best sector to move to and with previous test of safety we will now move to that sector!
|
|
|
if self.highwarp != 0 or self.highsector != 0:
|
|
|
log.msg("Sector: {0:5d} Warps: {1}".format(self.highsector, self.highwarp))
|
|
|
- self.state = 6
|
|
|
+ self.state += 1
|
|
|
else:
|
|
|
log.msg("Oh Nose! We didn't find any Sector with higher Warps than any of the others!")
|
|
|
self.deactivate()
|
|
|
elif self.state == 6:
|
|
|
- # Add the dense scan of unknown sectors onto the stack of sectors
|
|
|
- for d in self.dense:
|
|
|
- self.stacksector.add(d['sector'])
|
|
|
+ # 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)
|
|
|
|
|
|
# Remove the sector we are just about to go to, we use discard so if the sector does not exist we don't throw a error!
|
|
|
self.stacksector.discard(self.highsector)
|
|
@@ -1196,11 +1201,7 @@ class ScriptExplore(object):
|
|
|
self.send2game("m{0}\n\r".format(self.highsector))
|
|
|
|
|
|
# Reset Variables for fresh data
|
|
|
- self.didScan = False
|
|
|
- self.dense = []
|
|
|
- self.clear = []
|
|
|
- self.highwarp = 0
|
|
|
- self.highsector = 0
|
|
|
+ self.resetStuff()
|
|
|
self.state = 1
|
|
|
|
|
|
# Warning! Yes we can and will eat all the turns! :P
|