Skip to content

Commit

Permalink
Merged in WombatFromHell/tradedangerous (pull request #107)
Browse files Browse the repository at this point in the history
Added max-gain-per-ton to the Run command
  • Loading branch information
kfsone committed Mar 13, 2015
2 parents 087d6a8 + 3db5988 commit b7b372e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions commands/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
type=int,
default=1
),
ParseArgument('--max-gain-per-ton', '--mgpt',
help='Specify the maximum gain per ton of cargo',
dest='maxGainPerTon',
type=int,
default=10000
),
ParseArgument('--unique',
help='Only visit each station once.',
action='store_true',
Expand Down
3 changes: 2 additions & 1 deletion tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,14 @@ def getProfitables(self, srcSelling, dstBuying):
itemIdx = self.tdb.itemByID
trading = []
minGainCr = max(1, self.tdenv.minGainPerTon or 1)
maxGainCr = max(minGainCr, self.tdenv.maxGainPerTon or sys.maxsize)
for buy in dstBuying:
buyItemID = buy[0]
for sell in srcSelling:
sellItemID = sell[0]
if sellItemID == buyItemID:
buyCr, sellCr = buy[1], sell[1]
if sellCr + minGainCr <= buyCr:
if sellCr + minGainCr <= buyCr and sellCr + maxGainCr >= buyCr:
trading.append(Trade(
itemIdx[buyItemID],
buyItemID,
Expand Down

0 comments on commit b7b372e

Please sign in to comment.