diff --git a/CHANGES.txt b/CHANGES.txt index bea846a6..b9d7e8de 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,8 @@ TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014 ============================================================================== [work in progress] +. (kfsone) Added a "--ls-max" option to "run" for filtering stations +. (kfsone) +140 Systems . (tKE) "buy" sub-command now supports ship names (find a ship vendor) . (kfsone) Partial code/documentation cleanup . (kfsone) Added a "getRoute" function to TradeDB() diff --git a/commands/run_cmd.py b/commands/run_cmd.py index a6f7b579..aa925955 100644 --- a/commands/run_cmd.py +++ b/commands/run_cmd.py @@ -91,7 +91,7 @@ metavar='N', type=int, ), - ParseArgument('--max-days-old', '-MD', + ParseArgument('--age', '--max-days-old', '-MD', help='Maximum age (in days) of trade data to use.', metavar='DAYS', type=float, @@ -113,6 +113,13 @@ type=float, dest='lsPenalty' ), + ParseArgument('--ls-max', + help='Only consider stations upto this many ls from their star.', + metavar='LS', + dest='maxLs', + type=int, + default=0, + ), ParseArgument('--unique', help='Only visit each station once.', action='store_true', @@ -372,12 +379,20 @@ def checkStationSuitability(cmdenv, station, src): "requirement.".format( src, station.name(), )) + mls = cmdenv.maxLs + if mls and station.lsFromStar > mls: + raise CommandLineError( + "{} station {} does not meet max-ls requirement " + "requirement.".format( + src, station.name(), + )) def filterStationSet(src, cmdenv, stnSet): if not stnSet: return stnSet bm, mps = cmdenv.blackMarket, cmdenv.maxPadSize + mls = cmdenv.maxLs for place in stnSet: if not isinstance(place, Station): continue @@ -390,6 +405,8 @@ def filterStationSet(src, cmdenv, stnSet): if bm and place.blackMarket != 'Y': stnSet.remove(place) continue + if mls and place.lsFromStar > mls: + stnSet.remove(place) if not stnSet: raise CommandLineError( "No {} station met your criteria.".format( diff --git a/tradecalc.py b/tradecalc.py index 85e1a2ca..b2454f7a 100644 --- a/tradecalc.py +++ b/tradecalc.py @@ -723,6 +723,7 @@ def considerStation(dstStation, dest): maxLyPer=maxLyPer, avoidPlaces=avoidPlaces, maxPadSize=tdenv.padSize, + maxLsFromStar=tdenv.maxLs, ): dstStation = dest.station if dstStation is srcStation: diff --git a/tradedb.py b/tradedb.py index 187bc5d5..a338d822 100644 --- a/tradedb.py +++ b/tradedb.py @@ -1321,7 +1321,9 @@ def getDestinations(self, maxLyPer=None, avoidPlaces=None, trading=False, - maxPadSize=None): + maxPadSize=None, + maxLsFromStar=0, + ): """ Gets a list of the Station destinations that can be reached from this Station within the specified constraints. @@ -1410,6 +1412,8 @@ def getDestinations(self, continue if (maxPadSize and not station.checkPadSize(maxPadSize)): continue + if (maxLsFromStar and station.lsFromStar > maxLsFromStar): + continue destStations.append( Destination(node.system, station,