|
@@ -2932,6 +2932,7 @@ class ColoScript2(object):
|
|
|
self.loops = 0
|
|
|
self.maxloops = 0
|
|
|
self.last_seen = 0
|
|
|
+ self.valid2From = True
|
|
|
|
|
|
# Sector Numbers of Planets TO and FROM
|
|
|
self.TO = 0
|
|
@@ -2987,7 +2988,14 @@ class ColoScript2(object):
|
|
|
self.deactivate(True)
|
|
|
else:
|
|
|
self.to_number = int(choice)
|
|
|
- if self.to_number in self.planets:
|
|
|
+ if self.to_number == 1:
|
|
|
+ # Oooh Terra!
|
|
|
+ self.TO = 1
|
|
|
+ self.planet_name = "Terra"
|
|
|
+ ask1 = PlayerInput(self.game)
|
|
|
+ d1 = ask1.prompt("From: (1 = Terra) ", 3, name="from", digits=True)
|
|
|
+ d1.addCallback(self.from_chosen)
|
|
|
+ elif self.to_number in self.planets:
|
|
|
# Ok, this'll work
|
|
|
self.TO = self.planets[self.to_number]["sector"]
|
|
|
self.planet_name = self.planets[self.to_number]["name"]
|
|
@@ -3004,6 +3012,10 @@ class ColoScript2(object):
|
|
|
self.deactivate(True)
|
|
|
else:
|
|
|
self.from_number = int(choice)
|
|
|
+ if self.from_number == self.to_number:
|
|
|
+ # Prevent the user from asking to move folks to the same planet they would be getting
|
|
|
+ # them from. See Recursion!
|
|
|
+ self.valid2From = False
|
|
|
if self.from_number in self.planets:
|
|
|
# Ok, this'll work
|
|
|
self.FROM = self.planets[self.from_number]["sector"]
|
|
@@ -3033,9 +3045,14 @@ class ColoScript2(object):
|
|
|
# ask2 = PlayerInput(self.game)
|
|
|
# d2 = ask2.prompt("From? ", 5, name="from", digits=True)
|
|
|
# d2.addCallback(self.from_chosen)
|
|
|
- self.state = 3
|
|
|
- self.game.to_player = False
|
|
|
- self.send2game("I")
|
|
|
+ if self.valid2From:
|
|
|
+ self.state = 3
|
|
|
+ self.game.to_player = False
|
|
|
+ self.send2game("I")
|
|
|
+ else:
|
|
|
+ self.game.to_player = True
|
|
|
+ self.send2player(self.nl + Boxes.alert("Completed ({0})".format(self.maxloops)))
|
|
|
+ self.deactivate(True)
|
|
|
|
|
|
def game_prompt(self, prompt: str):
|
|
|
log.debug("P {0} | {1}".format(self.state, prompt))
|
|
@@ -3188,36 +3205,80 @@ class ColoScript2(object):
|
|
|
elif re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
self.state = 6
|
|
|
self.send2game("L")
|
|
|
- elif prompt.startswith("Land on which planet <Q to abort> ?"):
|
|
|
- self.state = 7
|
|
|
- self.send2game("{0}\r".format(self.to_number))
|
|
|
- # Planetary Scanner Detected selecting planet number
|
|
|
- elif prompt.startswith("Planet command (?=help) [D] "):
|
|
|
- self.state = 7
|
|
|
- self.send2game("D")
|
|
|
- # No Planetary Scaner skip on
|
|
|
+ if self.TO != 1:
|
|
|
+ if prompt.startswith("Land on which planet <Q to abort> ?"):
|
|
|
+ self.state = 7
|
|
|
+ self.send2game("{0}\r".format(self.to_number))
|
|
|
+ # Planetary Scanner Detected selecting planet number
|
|
|
+ elif prompt.startswith("Planet command (?=help) [D] "):
|
|
|
+ self.state = 7
|
|
|
+ self.send2game("D")
|
|
|
+ # No Planetary Scaner skip on
|
|
|
+ else:
|
|
|
+ if prompt.startswith("Land on which planet <Q to abort> ?"):
|
|
|
+ self.state = 7
|
|
|
+ self.send2game("1\r")
|
|
|
+ # Planetary Scanner Detected selecting planet number
|
|
|
+ elif prompt.startswith("Do you wish to (L)eave or (T)ake Colonists?"):
|
|
|
+ self.state = 7
|
|
|
+ self.send2game("L")
|
|
|
+ # No Planetary Scaner skip on
|
|
|
elif self.state == 7:
|
|
|
if prompt.startswith("Engage the Autopilot? (Y/N/Single step/Express) [Y]"):
|
|
|
self.state = 6
|
|
|
self.send2game("E")
|
|
|
# Missed moving jump back to state 6
|
|
|
- if prompt.startswith("Land on which planet <Q to abort> ?"):
|
|
|
- self.queue_player.put("{0}\r".format(self.to_number))
|
|
|
- # Planetary Scanner Detected selecting planet number
|
|
|
- if prompt.startswith("Planet command (?=help) [D] "):
|
|
|
- # Unload people and process the loop
|
|
|
- self.loops -= 1
|
|
|
- if self.loops:
|
|
|
- self.state = 3
|
|
|
- self.send2game("S\r\r1\rQ")
|
|
|
- # Jump to state 3 we are not done
|
|
|
- else:
|
|
|
- self.send2game("S\r\r1\rQ")
|
|
|
- self.send2player(
|
|
|
- "\r" + Boxes.alert("Completed ({0})".format(self.maxloops))
|
|
|
- )
|
|
|
- self.deactivate(True)
|
|
|
- # Ok we are done
|
|
|
+ if self.TO != 1:
|
|
|
+ if prompt.startswith("Land on which planet <Q to abort> ?"):
|
|
|
+ self.queue_player.put("{0}\r".format(self.to_number))
|
|
|
+ # Planetary Scanner Detected selecting planet number
|
|
|
+ if prompt.startswith("Planet command (?=help) [D] "):
|
|
|
+ # Unload people and process the loop
|
|
|
+ self.loops -= 1
|
|
|
+ if self.loops:
|
|
|
+ self.state = 3
|
|
|
+ self.send2game("S\r\r1\rQ")
|
|
|
+ # Jump to state 3 we are not done
|
|
|
+ else:
|
|
|
+ self.send2game("S\r\r1\rQ")
|
|
|
+ self.send2player(
|
|
|
+ "\r" + Boxes.alert("Completed ({0})".format(self.maxloops))
|
|
|
+ )
|
|
|
+ self.deactivate(True)
|
|
|
+ # Ok we are done
|
|
|
+ else:
|
|
|
+ if prompt.startswith("Land on which planet <Q to abort> ?"):
|
|
|
+ self.queue_player.put("1\r")
|
|
|
+ # Planetary Scanner Detected selecting planet number
|
|
|
+ if prompt.startswith("Do you wish to (L)eave or (T)ake Colonists?"):
|
|
|
+ # Unload people and process the loop
|
|
|
+ self.loops -= 1
|
|
|
+ if self.loops:
|
|
|
+ self.state = 3
|
|
|
+ self.send2game("L\r")
|
|
|
+ # Jump to state 3 we are not done
|
|
|
+ else:
|
|
|
+ self.send2game("L\r")
|
|
|
+ self.send2player(
|
|
|
+ "\r" + Boxes.alert("Completed ({0})".format(self.maxloops))
|
|
|
+ )
|
|
|
+ self.deactivate(True)
|
|
|
+ # Ok we are done
|
|
|
+ if prompt.startswith(
|
|
|
+ "How many groups of Colonists do you want to leave"
|
|
|
+ ):
|
|
|
+ self.loops -= 1
|
|
|
+ if self.loops:
|
|
|
+ self.state = 3
|
|
|
+ self.send2game("\r")
|
|
|
+ # Jump to state 3 we are not done
|
|
|
+ else:
|
|
|
+ self.send2game("\r")
|
|
|
+ self.send2player(
|
|
|
+ "\r" + Boxes.alert("Completed ({0})".format(self.maxloops))
|
|
|
+ )
|
|
|
+ self.deactivate(True)
|
|
|
+ # Ok we are done
|
|
|
|
|
|
def game_line(self, line: str):
|
|
|
log.debug("L {0} | {1}".format(self.state, line))
|
|
@@ -3388,7 +3449,7 @@ class MaxFighterMake(object):
|
|
|
|
|
|
def deactivate(self, andExit=False):
|
|
|
self.state = 0
|
|
|
- log.debug("ColoScript2.deactivate()")
|
|
|
+ log.debug("MaxFighterMake.deactivate()")
|
|
|
self.game.to_player = True
|
|
|
assert not self.save is None
|
|
|
self.observer.load(self.save)
|