ソースを参照

Sort possible ports by "best" first.

Steve Thielemann 5 年 前
コミット
18e8106166
1 ファイル変更17 行追加1 行削除
  1. 17 1
      flexible.py

+ 17 - 1
flexible.py

@@ -643,7 +643,7 @@ class ScriptPort(object):
 
                     self.queue_game.put(self.r + self.nl + "Trading {0}".format(
                         self.game.gamedata.port_trade_show(self.this_sector,
-                        self.sector2)
+                        self.sector2, 0)
                     ))
 
                     pi = PlayerInput(self.game)
@@ -900,6 +900,22 @@ class ScriptPort(object):
                         return
 
                     possible = [ x for x in possible if GameData.port_trading(self.game.gamedata.ports[self.this_sector]['port'], self.game.gamedata.ports[x]['port'])]
+                    # sort by best, then by %
+                    start_port = self.game.gamedata.ports[self.this_sector]
+                    if 'port' in start_port:
+                        start_port_port = start_port['port']
+                        start_with = start_port_port[1:]
+
+                        if start_with in ('BS', 'SB'):
+                            # Ok, good trades may be possible
+                            best = GameData.flip(start_with)
+                            log.info("Sorting the best ({0}) to the top.".format(best))    
+                            log.info("{0}".format(possible))                        
+                            dec = [ [self.game.gamedata.ports[p].get('port', '---')[1:] == best, p] for p in possible]
+                            dec = sorted(dec, reverse=True)
+                            possible = [x[1] for x in dec]
+                            log.info("{0}".format(possible))                                                    
+
                     self.possible = possible
 
                     if len(possible) == 0: