Skip to content

Commit

Permalink
presentation of data age in run
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Dec 29, 2014
1 parent 90087f8 commit 10f3297
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def genSubValues(key):
text += self.summary() + "\n"
hopFmt = " Load from {station}:\n{purchases}"
hopStepFmt = (" {qty:>4} x {item:<{longestName}}"
" {eacost:>10n}cr each, {ttlcost:>10n}cr total {age}\n")
" {eacost:>10n}cr each, {ttlcost:>10n}cr total, data from {age}\n")
jumpsFmt = (" Jump {jumps}\n")
dockFmt = " Unload at {station} => Gain {gain:n}cr ({tongain:n}cr/ton) => {credits:n}cr\n"
footer = ' ' + '-' * 76 + "\n"
Expand Down Expand Up @@ -159,8 +159,14 @@ def makeAge(value):
key=lambda tradeOpt:
tradeOpt[1] * tradeOpt[0].gainCr,
reverse=True):
age = max(trade.srcAge, trade.dstAge)
age = "("+makeAge(max(trade.srcAge, trade.dstAge))+")"
# Are they within 30 minutes of each other?
if abs(trade.srcAge - trade.dstAge) <= (30*60):
age = max(trade.srcAge, trade.dstAge)
age = makeAge(age)
else:
srcAge = makeAge(trade.srcAge)
dstAge = makeAge(trade.dstAge)
age = "{} and {}".format(srcAge, dstAge)
purchases += hopStepFmt.format(
qty=qty, item=trade.name(),
eacost=trade.costCr,
Expand Down

0 comments on commit 10f3297

Please sign in to comment.