فهرست منبع

Config edit by number. Terror checks trade configured.

Terror needs the port trade to be configured.  If it is not,
it will display alert boxes showing the problem.
Steve Thielemann 5 سال پیش
والد
کامیت
eed88ad835
2فایلهای تغییر یافته به همراه41 افزوده شده و 1 حذف شده
  1. 39 0
      flexible.py
  2. 2 1
      galaxy.py

+ 39 - 0
flexible.py

@@ -1797,6 +1797,32 @@ class ScriptTerror(object):
 
         self.state = 0
         self.defer = None
+
+        # Verify that they have configured auto-port trading.  
+        # Otherwise, this doesn't work!
+        usefirst = self.game.gamedata.get_config('Trade_UserFirst')
+        if usefirst is None:
+            usefirst = '?'
+        if userfirst.upper()[0] != 'Y':
+            self.queue_game.put(Boxes.alert("Sorry! You need to config Trade_UseFirst=Y", base="red"))
+            self.deactivate()
+            return
+
+        turns = self.game.gamedata.get_config('Trade_Turns')
+        if turns is None:
+            turns = '0'
+        try:
+            t = int(turns)
+        except ValueError:
+            self.queue_game.put(Boxes.alert("Sorry! You need to config Trade_Turns", base="red"))
+            self.deactivate()
+            return
+
+        if t < 5:
+            self.queue_game.put(Boxes.alert("Sorry! You need to config Trade_Turns >", base="red"))
+            self.deactivate()
+            return
+
         c = coiterate(self.find_next_good_trade_pair())
         c.addCallback(lambda unknown: self.scary())
 
@@ -2351,6 +2377,19 @@ class ProxyMenu(object):
             d.addCallback(self.option_input)
             d.addErrback(self.config_menu)
             return
+        elif key in ('1','2','3','4','5','6','7','8','9'):
+            self.queue_game.put(self.c + key + self.r + self.nl)
+            option = int(key)
+            if option in self.config_opt:
+                # Ok, it's a valid option!
+                self.option_select = self.config_opt[option]
+                ask = PlayerInput(self.game)
+                d = ask.prompt("Change {0} to?".format(self.option_select), 18)
+                d.addCallback(self.option_entry)
+                # d.addErrback(self.config_menu)
+                return
+            else:
+                self.queue_game.put("Unknown option, sorry." + self.nl)
 
         elif key == 'X':
             self.queue_game.put(self.c + key + self.r + self.nl)            

+ 2 - 1
galaxy.py

@@ -189,7 +189,8 @@ class GameData(object):
         if key in self.config:
             return self.config[key]
         else:
-            self.config[key] = default
+            if default is not None:
+                self.config[key] = default
         return default
 
     def set_config(self, key, value):