|
@@ -10,6 +10,7 @@ from itertools import cycle
|
|
|
import pendulum
|
|
|
from pprint import pformat
|
|
|
from galaxy import GameData, PORT_CLASSES, CLASSES_PORT
|
|
|
+from boxes import Boxes
|
|
|
|
|
|
class SpinningCursor(object):
|
|
|
""" Spinner class, that handles every so many clicks
|
|
@@ -1067,12 +1068,44 @@ 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 == 3:
|
|
|
log.msg("dense is {0} sectors big".format(len(self.dense)))
|
|
|
self.state += 1
|
|
|
self.send2game("SH")
|
|
|
+ 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))
|
|
@@ -1089,71 +1122,70 @@ class ScriptExplore(object):
|
|
|
self.state += 1
|
|
|
|
|
|
if self.state == 2:
|
|
|
+
|
|
|
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)
|
|
|
+ log.msg(work)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if work[1] == '(':
|
|
|
- temp1 = True
|
|
|
- else:
|
|
|
- temp1 = False
|
|
|
-
|
|
|
-
|
|
|
- if temp1:
|
|
|
+ if new_sector:
|
|
|
|
|
|
- if(work[9] == 'No'):
|
|
|
+ if(work[8] == 'No'):
|
|
|
temp = False
|
|
|
else:
|
|
|
temp = True
|
|
|
|
|
|
- self.dense.append( {'sector': int(work[2]), 'density': int(work[3]), 'warps': int(work[5]), 'navhaz': int(work[7]), 'anom': temp} )
|
|
|
+ self.dense.append( {'sector': int(work[1]), 'density': int(work[2]), 'warps': int(work[4]), 'navhaz': int(work[6]), 'anom': temp} )
|
|
|
+ log.msg(self.dense)
|
|
|
|
|
|
|
|
|
elif line == "":
|
|
|
self.state += 1
|
|
|
elif self.state == 4:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
if not self.dense:
|
|
|
log.msg("No New Sectors Found!")
|
|
|
- self.send2player("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("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:
|
|
|
if not d['anom']:
|
|
|
|
|
|
- if d['navhaz'] == 0:
|
|
|
+ if not d['navhaz']:
|
|
|
|
|
|
- if d['density'] == 0 or d['density'] == 1 or d['density'] == 100 or d['density'] == 101:
|
|
|
+ if d['density'] in (0, 1, 100, 101):
|
|
|
|
|
|
if d['warps'] > 1:
|
|
|
|
|
@@ -1161,35 +1193,22 @@ class ScriptExplore(object):
|
|
|
|
|
|
if self.clear:
|
|
|
log.msg("Clear Sectors: {0}".format(len(self.clear)))
|
|
|
- self.state += 1
|
|
|
+
|
|
|
+
|
|
|
+ for c in self.clear:
|
|
|
+ for d in self.dense:
|
|
|
+ if d['sector'] == c:
|
|
|
+ if d['warps'] > self.highwarp:
|
|
|
+ self.highwarp = d['warps']
|
|
|
+ self.highsector = d['sector']
|
|
|
+ elif d['warps'] == self.highwarp:
|
|
|
+ if d['sector'] > self.highsector:
|
|
|
+ self.highsector = d['sector']
|
|
|
+
|
|
|
+ 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:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for c in self.clear:
|
|
|
- for d in self.dense:
|
|
|
- if d['sector'] == c:
|
|
|
- if d['warps'] > self.highwarp:
|
|
|
- self.highwarp = d['warps']
|
|
|
- self.highsector = c
|
|
|
- elif d['warps'] == self.highwarp:
|
|
|
- if c > self.highsector:
|
|
|
- self.highsector = c
|
|
|
-
|
|
|
-
|
|
|
- if self.highwarp != 0 or self.highsector != 0:
|
|
|
- log.msg("Sector: {0:5d} Warps: {1}".format(self.highsector, self.highwarp))
|
|
|
- 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:
|
|
|
|
|
|
for c in self.clear:
|
|
|
self.stacksector.add(c)
|
|
@@ -1209,6 +1228,53 @@ class ScriptExplore(object):
|
|
|
if self.times <= 0:
|
|
|
self.send2player("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
|
|
|
+
|
|
|
|
|
|
|
|
|
|