|
@@ -1975,6 +1975,7 @@ class PlanetUpScript(object):
|
|
|
self.queue_game.put(Boxes.alert("Let me see what I can see here..."))
|
|
|
|
|
|
def game_prompt(self, prompt):
|
|
|
+ log.info("prompt {0} : {1}".format(self.state, prompt))
|
|
|
if self.state == 2 and re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
self.game.to_player = True
|
|
|
|
|
@@ -2080,16 +2081,52 @@ class PlanetUpScript(object):
|
|
|
self.fetch = 'C'
|
|
|
self.queue_player.put("NTE")
|
|
|
self.state = 7
|
|
|
-
|
|
|
else:
|
|
|
+ for i in ('F','O','E'):
|
|
|
+ if self.need[i] > self.cargo[i]:
|
|
|
+ self.fetch = i
|
|
|
+ place = self.game.gamedata.find_nearest_selling(self.planet_sector, i)
|
|
|
+ if place == 0:
|
|
|
+ self.queue_game.put(self.nl + Boxes.alert("Find Nearest Failed!"))
|
|
|
+ self.deactivate()
|
|
|
+ return
|
|
|
+ self.queue_player.put("{0}\rE".format(place))
|
|
|
+ self.state = 7
|
|
|
+ return
|
|
|
+
|
|
|
self.queue_game.put("No, not yet!" + self.nl)
|
|
|
self.deactivate()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
elif self.state == 7:
|
|
|
if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
if self.fetch == 'C':
|
|
|
|
|
|
|
|
|
self.queue_player.put("L")
|
|
|
+ elif self.fetch in ('F', 'O', 'E'):
|
|
|
+
|
|
|
+ self.queue_player.put("pt")
|
|
|
+ elif re.match(r"How many holds of .+ do you want to sell", prompt):
|
|
|
+
|
|
|
+ self.queue_game.put("OH NOSE!" + self.nl)
|
|
|
+ self.deactivate()
|
|
|
+ elif prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ?'):
|
|
|
+ self.queue_game.put("N")
|
|
|
+ elif re.match(r"How many holds of .+ do you want to buy \[\d+\]\? ", prompt):
|
|
|
+ if prompt.startswith('How many holds of ' + self.fetch):
|
|
|
+ _, _, holds = prompt.partition('[')
|
|
|
+ holds, _, _ = holds.partition(']')
|
|
|
+ self.fetch_amount = int(holds)
|
|
|
+ self.queue_player.put("\r\r")
|
|
|
+ self.state = 8
|
|
|
+ else:
|
|
|
+
|
|
|
+ self.queue_player.put("0\r")
|
|
|
elif prompt.startswith('Land on which planet <Q to abort> ?'):
|
|
|
if self.fetch == 'C':
|
|
|
self.queue_player.put("1\r")
|
|
@@ -2112,7 +2149,22 @@ class PlanetUpScript(object):
|
|
|
if self.fetch == 'C':
|
|
|
|
|
|
self.queue_player.put("SNL")
|
|
|
+ elif self.fetch in ('F', 'O', 'E'):
|
|
|
+
|
|
|
+ self.queue_player.put("TNL")
|
|
|
+ elif prompt.startswith('(1)Ore, (2)Org or (3)Equipment ?'):
|
|
|
+ if self.fetch == 'F':
|
|
|
+ idx = 1
|
|
|
+ elif self.fetch == 'O':
|
|
|
+ idx = 2
|
|
|
+ elif self.fetch == 'E':
|
|
|
+ idx = 3
|
|
|
+ self.queue_player.put("{0}\r\rQ".format(idx))
|
|
|
+ self.cargo[self.fetch] += self.fetch_amount
|
|
|
+ self.state = 6
|
|
|
+
|
|
|
elif prompt.startswith('(1)Ore, (2)Org or (3)Equipment Production?'):
|
|
|
+
|
|
|
|
|
|
self.queue_player.put("1\r\rQ")
|
|
|
self.colonists += self.fetch_amount
|
|
@@ -2139,6 +2191,7 @@ class PlanetUpScript(object):
|
|
|
self.deactivate()
|
|
|
|
|
|
def game_line(self, line):
|
|
|
+ log.info("line {0} : {1}".format(self.state, line))
|
|
|
if self.state == 1:
|
|
|
if 'Personal Planet Scan' in line:
|
|
|
self.state = 2
|