|
@@ -383,6 +383,7 @@ class CIMPortReport(object):
|
|
|
self.queue_player.put("^") # Activate CIM
|
|
|
self.state = 1
|
|
|
# self.portdata = {}
|
|
|
+ self.queue_game.put("Loading ...")
|
|
|
self.portcycle = SpinningCursor()
|
|
|
|
|
|
def game_prompt(self, prompt):
|
|
@@ -518,6 +519,17 @@ class ScriptPort(object):
|
|
|
self.sector1 = None # Current Sector
|
|
|
self.sector2 = None # Next Sector Stop
|
|
|
self.percent = self.game.gamedata.get_config('Trade_Percent', '5')
|
|
|
+ self.stop = self.game.gamedata.get_config('Trade_Stop', '10')
|
|
|
+
|
|
|
+ try:
|
|
|
+ self.stop = int(self.stop)
|
|
|
+ except ValueError:
|
|
|
+ self.stop = 10
|
|
|
+
|
|
|
+ # Validate what we got from the config.
|
|
|
+ # Not an int: make it 5, and update.
|
|
|
+ # > 50, make it 5 and update.
|
|
|
+ # < 0, make it 0 and update.
|
|
|
|
|
|
update_config = False
|
|
|
try:
|
|
@@ -686,6 +698,10 @@ class ScriptPort(object):
|
|
|
|
|
|
elif self.state == 6:
|
|
|
if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
+ if self.end_trans:
|
|
|
+ self.deactivate()
|
|
|
+ return
|
|
|
+
|
|
|
if self.fixable:
|
|
|
# self.queue_game.put("Ok! Let's fix this by going to the other sector..." + self.nl)
|
|
|
self.queue_game.put(self.nl + Boxes.alert("Ok, FINE. We'll trade with the other port.", base="green", style=0))
|
|
@@ -701,6 +717,9 @@ class ScriptPort(object):
|
|
|
elif self.state == 7:
|
|
|
if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
# Done
|
|
|
+ if self.end_trans:
|
|
|
+ self.deactivate()
|
|
|
+ return
|
|
|
|
|
|
# Swap this and other sector
|
|
|
self.this_sector, self.other_sector = (self.other_sector, self.this_sector)
|
|
@@ -785,6 +804,9 @@ class ScriptPort(object):
|
|
|
self.queue_player.put("\r")
|
|
|
elif re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
|
|
|
# Done
|
|
|
+ if self.end_trans:
|
|
|
+ self.deactivate()
|
|
|
+ return
|
|
|
|
|
|
# Swap this and other sector
|
|
|
self.this_sector, self.other_sector = (self.other_sector, self.this_sector)
|
|
@@ -822,6 +844,7 @@ class ScriptPort(object):
|
|
|
# state 5
|
|
|
log.debug("trade!")
|
|
|
self.queue_player.put("pt") # Port Trade
|
|
|
+ self.end_trans = False
|
|
|
self.fixable = False
|
|
|
self.this_port = self.game.gamedata.ports[self.this_sector]
|
|
|
# I think other_sector will alway be correct, but leaving this
|
|
@@ -978,7 +1001,7 @@ class ScriptPort(object):
|
|
|
self.state = 8
|
|
|
self.sell_percent = 100 - self.percent
|
|
|
if line.startswith('Fuel Ore') or line.startswith('Organics') or line.startswith('Equipment'):
|
|
|
- work = line.replace('Fuel Ore', 'Fuel')
|
|
|
+ work = line.replace('Fuel Ore', 'Fuel').replace('%', '')
|
|
|
parts = re.split(r"\s+", work)
|
|
|
# log.debug(parts)
|
|
|
# Equipment, Selling xxx x% xxx
|
|
@@ -988,6 +1011,9 @@ class ScriptPort(object):
|
|
|
if self.game.gamedata.port_buying(self.other_sector, stuff):
|
|
|
log.info("fixable")
|
|
|
self.fixable = True
|
|
|
+ if int(parts[3]) < self.stop:
|
|
|
+ log.warn("Port is burnt! % < {0}".format(self.stop))
|
|
|
+ self.end_trans = True
|
|
|
|
|
|
if "You don't have anything they want" in line:
|
|
|
log.warn("Don't have anything they want.")
|