| 
					
				 | 
			
			
				@@ -1756,6 +1756,10 @@ class ScriptTerror(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Move to it, fire off the Port Trading script. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Repeat until our loop is done, or there's no more 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     pairs. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    state=1 entered sector number to move to. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    state=2 (route "The shortest path") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Fire ScriptPort.  Callback journey_on. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def __init__(self, game, proxy, count): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.game = game 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1816,7 +1820,10 @@ class ScriptTerror(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             self.queue_player.put("{0}\r".format(self.target_sector)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def find_next_good_trade_pair(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        """ Find the next GOOD trade pair sector. """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ Find the next GOOD trade pair sector.  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Should this be the next NEAREST? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         show_limit = 90 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # Look for "GOOD" trades 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1947,6 +1954,8 @@ class ScriptTerror(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if self.state == 1: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if line.startswith('The shortest path ('): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.state = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            elif line.startswith('Warping to Sector '): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.state = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif line.startswith("You are already in that sector!"): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # Whoops. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ports = ScriptPort(self.game) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1955,6 +1964,29 @@ class ScriptTerror(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 d.addErrback(self.journey_on) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Planet Upgrade Script 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=1  Pulling TLQ (Team/Corp List Planets) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Pulling CYQ (Computer, Your planets) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=2  'Personal Planet Scan' or 'Corporate Planet Scan' parse. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Display  list of planets, and prompt user for planet number to upgrade. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=3  Moving to planet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=4  Landing on planet, parse planet contents.  select 'C' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=5  Parse requirements for next upgrade 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=6  move to next needed item. (Colonists, F, O, E) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                 If completed, 'L' and state=4 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                 Otherwise move, fetch=ITEM, and state=7 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=7  travel to where we need something. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                 Once there, L (land) for Colonist, otherwise PT (Port trade) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=8  Return to planet. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state=9  At planet, or in route.   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                 Land.  Transfer Colonists/Cargo.  state=6               
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def __init__(self, game): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.game = game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.queue_game = game.queue_game 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1977,6 +2009,7 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.defer = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.to_player = self.game.to_player 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.planets = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        self.citadel = False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # Hide what's happening from the player 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.game.to_player = False 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2077,6 +2110,9 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if ready: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     self.queue_game.put(self.nl + Boxes.alert("Party Planet Pants On!")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     self.queue_player.put('YQ') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if self.citadel: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        # Need extra Quit to get out of citadel, then out of planet. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        self.queue_player.put('Q') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if 'construct one' in prompt: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2088,6 +2124,7 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # Xfer cargo, and get ready to travel... 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif prompt.startswith('Citadel command (?=help)'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_player.put('U') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.citadel = True 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if prompt.startswith('Planet command (?=help) [D] '): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # self.queue_game.put(pformat(self.ship_cargo).replace("\n", self.nl) + self.nl) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # self.queue_game.put(pformat(self.cargo).replace("\n", self.nl) + self.nl)                 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2150,6 +2187,10 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_game.put("OH NOSE!" + self.nl) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            elif prompt.startswith('Do you want to engage the TransWarp drive? '): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.queue_player.put("N") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            elif prompt.startswith('Engage the Autopilot? (Y/N/Single step/Express) [Y]'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.queue_player.put("E") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ?'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_player.put("N") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif re.match(r"How many holds of .+ do you want to buy \[\d+\]\? ", prompt): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2179,12 +2220,14 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 # land 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_player.put('L') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            elif prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ? '): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            elif prompt.startswith('Do you want to engage the TransWarp drive? '): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_player.put("N") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            elif prompt.startswith('Land on which planet <Q to abort> ?'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.queue_player.put("{0}\r".format(self.planet_number)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            elif prompt.startswith('Engage the Autopilot? (Y/N/Single step/Express) [Y]'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.queue_player.put("E") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif prompt.startswith('Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ?'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_player.put("N") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            elif prompt.startswith('Land on which planet <Q to abort> ?'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.queue_player.put("{0}\r".format(self.planet_number)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif prompt.startswith("Planet command (?=help) [D]"): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if self.fetch == 'C': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     # Colonist / No display Planet / Leave 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2196,7 +2239,6 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_player.put("{0}\r\rQ".format(self.cargo_index[self.fetch] + 1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.cargo[self.fetch] += self.fetch_amount 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.state = 6 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif prompt.startswith('(1)Ore, (2)Org or (3)Equipment Production?'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.info("place_people: {0}".format(self.place_people)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 safe_places = [ k for k in self.place_people.keys() if self.place_people[k] ] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2322,7 +2364,7 @@ class PlanetUpScript(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             elif line.startswith('This Citadel cannot be upgraded further'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.queue_game.put(self.nl + Boxes.alert("NO MORE!") + self.nl) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.queue_player.put("QQ")  # quit Citidel, quit Planet menu. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.queue_player.put("QQ")  # quit Citadel, quit Planet menu. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.deactivate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 items = ['Colonists', 'Fuel Ore', 'Organics', 'Equipment']                 
			 |