|
@@ -1071,8 +1071,26 @@ class ScriptExplore(object):
|
|
|
self.highsector = 0
|
|
|
log.msg("ScriptExplore.resetStuff()")
|
|
|
|
|
|
+ def dead_end(self):
|
|
|
+ """ We've reached a dead end.
|
|
|
+
|
|
|
+ Either pop a new location to travel to, or give it up.
|
|
|
+ """
|
|
|
+ self.send2player(Boxes.alert("** DEAD END **", base="blue"))
|
|
|
+
|
|
|
+ if self.stacksector:
|
|
|
+
|
|
|
+ self.highsector = self.stacksector.pop()
|
|
|
+
|
|
|
+ self.state = 10
|
|
|
+ self.send2game("{0}\r".format(self.highsector))
|
|
|
+
|
|
|
+ else:
|
|
|
+ self.send2player(Boxes.alert("I've run out of places to look here."))
|
|
|
+ self.deactivate()
|
|
|
+
|
|
|
def game_prompt(self, prompt: str):
|
|
|
- log.msg("{0} : {1}".format(self.state, prompt))
|
|
|
+
|
|
|
if self.state == 2:
|
|
|
if "Select (H)olo Scan or (D)ensity Scan or (Q)uit" in prompt:
|
|
|
self.send2game("D")
|
|
@@ -1086,7 +1104,21 @@ class ScriptExplore(object):
|
|
|
log.msg("FATAL: No Holo Scanner Installed!")
|
|
|
self.send2player(Boxes.alert("You need a Holo Scanner!"))
|
|
|
self.deactivate()
|
|
|
-
|
|
|
+ if self.state == 12:
|
|
|
+
|
|
|
+ if prompt.startswith('Engage the Autopilot? (Y/N/Single step/Express) [Y]'):
|
|
|
+ self.send2game("S")
|
|
|
+ self.travel_path.pop(0)
|
|
|
+ if prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N]'):
|
|
|
+ self.send2game("SD")
|
|
|
+ self.state += 1
|
|
|
+ if self.state == 20:
|
|
|
+ if prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N]'):
|
|
|
+
|
|
|
+ self.send2game("Y")
|
|
|
+ self.state = 1
|
|
|
+
|
|
|
+
|
|
|
def game_line(self, line: str):
|
|
|
log.msg("{0} | {1}".format(self.state, line))
|
|
|
|
|
@@ -1122,19 +1154,14 @@ class ScriptExplore(object):
|
|
|
elif self.state == 3:
|
|
|
|
|
|
if line.startswith("Sector"):
|
|
|
- work = line.replace(':', '').replace(')', '').replace('%', '').replace('==>', '')
|
|
|
+ new_sector = '(' in line
|
|
|
+ work = line.replace(':', '').replace(')', '').replace('(', '').replace('%', '').replace('==>', '')
|
|
|
work = re.split(r"\s+", work)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if work[1] == '(':
|
|
|
- temp1 = True
|
|
|
- else:
|
|
|
- temp1 = False
|
|
|
-
|
|
|
-
|
|
|
- if temp1:
|
|
|
+ if new_sector:
|
|
|
|
|
|
if(work[9] == 'No'):
|
|
|
temp = False
|
|
@@ -1142,6 +1169,7 @@ class ScriptExplore(object):
|
|
|
temp = True
|
|
|
|
|
|
self.dense.append( {'sector': int(work[2]), 'density': int(work[3]), 'warps': int(work[5]), 'navhaz': int(work[7]), 'anom': temp} )
|
|
|
+ log.msg(self.dense)
|
|
|
|
|
|
|
|
|
elif line == "":
|
|
@@ -1153,23 +1181,32 @@ class ScriptExplore(object):
|
|
|
|
|
|
if not self.dense:
|
|
|
log.msg("No New Sectors Found!")
|
|
|
- self.send2player(Boxes.alert("Find a new area for me to search in!"))
|
|
|
+ self.dead_end()
|
|
|
+ return
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- if self.stacksector:
|
|
|
- self.highsector = self.stacksector.pop()
|
|
|
- self.deactivate()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
elif self.dense:
|
|
|
- t = []
|
|
|
- for d in self.dense:
|
|
|
- if d['warps'] > 1:
|
|
|
- t.append(d['sector'])
|
|
|
+
|
|
|
+ t = [d for d in self.dense if d['warps'] > 1]
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if not t:
|
|
|
log.msg("No Sectors Found except one move sector!")
|
|
|
- self.send2player(Boxes.alert("Find a new area for me to look at!"))
|
|
|
+ self.dead_end()
|
|
|
+ return
|
|
|
+
|
|
|
|
|
|
- if self.stacksector:
|
|
|
- self.highsector = self.stacksector.pop()
|
|
|
- self.deactivate()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
for d in self.dense:
|
|
@@ -1221,6 +1258,53 @@ class ScriptExplore(object):
|
|
|
self.send2player(Boxes.alert("Completed {0}".format(self.maxtimes), base="green"))
|
|
|
log.msg("Completed {0}".format(self.maxtimes))
|
|
|
self.deactivate()
|
|
|
+ elif self.state == 10:
|
|
|
+
|
|
|
+ self.go_on = True
|
|
|
+ if line.startswith('The shortest path ('):
|
|
|
+
|
|
|
+ self.state += 1
|
|
|
+ elif self.state == 11:
|
|
|
+ self.travel_path = line.split(' > ')
|
|
|
+ self.state += 1
|
|
|
+ elif self.state == 13:
|
|
|
+ if 'Relative Density Scan' in line:
|
|
|
+ self.state += 1
|
|
|
+ elif self.state == 14:
|
|
|
+ if line == "":
|
|
|
+
|
|
|
+ if self.stophere:
|
|
|
+
|
|
|
+
|
|
|
+ self.stacksector.add(self.highsector)
|
|
|
+ self.state = 20
|
|
|
+ else:
|
|
|
+ if self.go_on:
|
|
|
+
|
|
|
+ self.state = 12
|
|
|
+ self.travel_path.pop(0)
|
|
|
+ else:
|
|
|
+ work = line.replace(' :', '').replace('%', '').replace(')', '').replace('==>', '')
|
|
|
+
|
|
|
+ stophere = '(' in work
|
|
|
+ work = work.replace('(','')
|
|
|
+
|
|
|
+ parts = re.split(r'\s+', work)
|
|
|
+
|
|
|
+ if stophere and parts[4] == '1':
|
|
|
+ stophere = False
|
|
|
+
|
|
|
+ if stophere:
|
|
|
+ self.stophere = True
|
|
|
+
|
|
|
+ next_stop = travel_path[0]
|
|
|
+
|
|
|
+ if parts[1] == next_stop:
|
|
|
+
|
|
|
+ if parts[2] not in ('100', '0'):
|
|
|
+
|
|
|
+ self.go_on = False
|
|
|
+
|
|
|
|
|
|
|
|
|
|