Ver código fonte

ColoScript Now has 3 config settings!

 Colo_MaxHolds (Use all the holds or the setting Colo_PercentHolds)
 Colo_PercentHolds (Minimum Holds in percentage that must be empty)
 Colo_MinTurns (Minimum turns to keep going)
david 5 anos atrás
pai
commit
33cd745064
1 arquivos alterados com 45 adições e 8 exclusões
  1. 45 8
      flexible.py

+ 45 - 8
flexible.py

@@ -2520,6 +2520,36 @@ class ColoScript(object):
         self.loops = 0
         self.maxloops = 0
         
+        # Minimum Turns
+        mT = self.game.gamedata.get_config('Colo_minTurns', '200')
+        uMH = self.game.gamedata.get_config('Colo_MaxHolds', 'Y')
+        uHP = self.game.gamedata.get_config('Colo_PercentHolds', '100')
+        try:
+            self.minTurns = int(mT)
+        except ValueError:
+            self.minTurns = 200
+            log.debug("self.minTurns = {0}".format(mT))
+        
+        # Do we just use max Holds or do we check the percent of holds?
+        if uMH is None:
+            self.useMaxHolds = True
+        else:
+            if uMH.upper()[0] == 'Y':
+                self.useMaxHolds = True
+            else:
+                self.useMaxHolds = False
+
+        if not self.useMaxHolds:
+            # Require this percent of holds empty
+            try:
+                self.useHoldsPercent = int(uHP)
+            except ValueError:
+                self.useHoldsPercent = 100
+                log.debug("self.useMaxHolds = False")
+                log.debug("self.useHoldsPercent = {0}".format(uHP))
+        else:
+            log.debug("self.useMaxHolds = True")
+        
         # Activate
         self.prompt = game.buffer
         self.save = self.observer.save()
@@ -2565,7 +2595,7 @@ class ColoScript(object):
 
     def planet_chosen(self, choice: str):
         if choice.strip() == '':
-            self.deactivate()
+            self.deactivate(True)
         else:
             self.planet_number = int(choice)
             if self.planet_number in self.planets:
@@ -2578,11 +2608,11 @@ class ColoScript(object):
                 d1 = ask1.prompt("How many times ", 3, name="rolls", digits=True)
                 d1.addCallback(self.loop_chosen)
             else:
-                self.deactivate()
+                self.deactivate(True)
 
     def loop_chosen(self, choice: str):
         if choice.strip() == '':
-            self.deactivate()
+            self.deactivate(True)
         else:
             self.loops = abs(int(choice))
             if self.loops == 0:
@@ -2733,7 +2763,7 @@ class ColoScript(object):
                 work = line[19:].replace(' turns left.', '').strip()
                 self.turns = work
                 log.debug("TURNS LEFT: {0}".format(self.turns))
-                if int(self.turns) < 200:
+                if int(self.turns) < self.minTurns:
                     self.send2player("\r" + Boxes.alert("Low Turns! ({0})".format(self.turns)))
                     self.deactivate(True)
         # IF at any state we see how many holds avalible let's get that
@@ -2748,9 +2778,16 @@ class ColoScript(object):
                     count += 1
                     self.holds = int(work[count])
                     log.debug("EMPTY HOLDS = {0}".format(self.holds))
-                    if(self.holds < self.total_holds):
-                        self.send2player("\r" + Boxes.alert("You need {1} holds empty! ({0} Empty)".format(self.holds, self.total_holds)))
-                        self.deactivate(True)
+                    self.holds_percent = int((self.holds / self.total_holds) * 100.0)
+                    log.debug("HOLDS PERCENT = {0}%".format(self.holds_percent))
+                    if self.useMaxHolds:
+                        if(self.holds < self.total_holds):
+                            self.send2player("\r" + Boxes.alert("You need {0} holds empty! ({1} Empty)".format(self.total_holds, self.holds)))
+                            self.deactivate(True)
+                    else:
+                        if(self.holds_percent < self.useHoldsPercent):
+                            self.send2player("\r" + Boxes.alert("You need {0}% holds empty! ({1}% Empty)".format(self.useHoldsPercent, self.holds_percent)))
+                            self.deactivate(True)
         # Now back to our scheduled program
         if self.state == 1:
             if 'Personal Planet Scan' in line or 'Corporate Planet Scan' in line:
@@ -2795,7 +2832,7 @@ class ProxyMenu(object):
 
     from flexible import ProxyMenu
 
-    if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
+    if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt): 
         menu = ProxyMenu(self.game)
     """
     def __init__(self, game):