Skip to content

Commit

Permalink
Made --via accept routes with the via station as the first hop if the…
Browse files Browse the repository at this point in the history
… user doesn't specify a --from

Updated readme, added change log
  • Loading branch information
kfsone committed Aug 15, 2014
1 parent f7e2bb1 commit b1fb681
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==============================================================================
TradeDangerous v2.01
TradeDangerous v2.02
Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

Expand Down Expand Up @@ -361,3 +361,16 @@ Yeah, let me stop you there.
Whatever it is you want to do, you can do from there.

See "cli.py" for examples.


==============================================================================
== Change Log
==============================================================================

v2.02
"--via" will now accept the via station as the first station on
routes when the user doesn't specify a "--from".
Also made name matching far more flexible.

v2.01
"--avoid" now handles stations and system names
9 changes: 7 additions & 2 deletions trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def main():
routes = [ Route(stations=[src], hops=[], jumps=[], startCr=startCr, gainCr=0) for src in origins ]
numHops = args.hops
lastHop = numHops - 1
viaStartPos = 1 if originStation else 0
viaEndPos = -1 if finalStation else -1

if args.debug:
print("From %s via %s to %s with %d credits for %d hops" % (originName, viaName, destName, startCr, numHops))
Expand All @@ -182,11 +184,14 @@ def main():
restrictTo = finalStation
if viaStation and finalStation:
# Cull to routes that include the viaStation
routes = [ route for route in routes if viaStation in route.route[1:] ]
routes = [ route for route in routes if viaStation in route.route[viaStartPos:] ]
routes = calc.getBestHops(routes, startCr, restrictTo=restrictTo, maxJumps=args.maxJumps, maxJumpsPer=args.maxJumpsPer, maxLyPer=args.maxLyPer)

if viaStation:
routes = [ route for route in routes if viaStation in route.route[1:] ]
# If the user doesn't specify start or end stations, expand the
# search for "via" stations to encompass the first/last station
# as well as the hops in-between
routes = [ route for route in routes if viaStation in route.route[viaStartPos:viaEndPos] ]

if not routes:
print("No routes match your selected criteria.")
Expand Down

0 comments on commit b1fb681

Please sign in to comment.