Skip to content

Commit

Permalink
Fix for attribute error when something was out of price range
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Mar 23, 2015
1 parent 8f4a65a commit 5c043f4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,19 @@ def station_iterator(srcStation):
if not srcSelling:
tdenv.DEBUG1("Nothing sold - next.")
continue
affordable = True
for values in srcSelling:
if values[1] > startCr:
affordable = False
break
if not affordable:
srcSelling = [
values for values in srcSelling
if values[1] <= startCr
]
if not srcSelling:
tdenv.DEBUG1("Nothing affordable - next.")
continue

if goalSystem:
origSystem = route.firstSystem
Expand Down Expand Up @@ -835,10 +848,6 @@ def station_iterator(srcStation):
items = self.getTrades(srcStation, dstStation, srcSelling)
if not items:
continue
if max(items, key=lambda i: i.costCr).costCr > credits:
items = [i for i in items if i.costCr <= credits]
if not items:
continue
trade = fitFunction(items, startCr, capacity, maxUnits)

# Calculate total K-lightseconds supercruise time.
Expand Down

0 comments on commit 5c043f4

Please sign in to comment.