Skip to content

Commit

Permalink
First pass at showing age (-vv) on run command
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Dec 14, 2014
1 parent cc306dc commit 9e8d7b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.2.1 [wip]
. (kfsone) "run" (with -vv) will now show data age
. (kfsone) Gamma 2.0.5 renamed "Slaves" category to "Slavery"
. (gazelle) Stations, distances, ship data
. (gulasch) Stations and distances
Expand Down
23 changes: 21 additions & 2 deletions tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,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\n")
" {eacost:>10n}cr each, {ttlcost:>10n}cr total {age}\n")
jumpsFmt = (" Jump {jumps} => "
"Gain {gain:n}cr "
"({tongain:n}cr/ton) "
Expand All @@ -126,18 +126,37 @@ def genSubValues(key):
footer = None
endFmt = " {station} +{gain:n}cr"

def makeAge(value):
value = int(value / 3600)
if value < 1:
return "<1hr"
if value == 1:
return "1hr"
if value < 48:
return str(value) + "hrs"
value = int(value / 24)
if value < 90:
return str(value) + "days"
value = int(value / 31)
return str(value) + "mths"


for i, hop in enumerate(hops):
hopGainCr, hopTonnes = hop[1], 0
purchases = ""
for (trade, qty) in sorted(hop[0],
key=lambda tradeOpt:
tradeOpt[1] * tradeOpt[0].gainCr,
reverse=True):
age = max(trade.srcAge, trade.dstAge)
age = "("+makeAge(max(trade.srcAge, trade.dstAge))+")"
purchases += hopStepFmt.format(
qty=qty, item=trade.name(),
eacost=trade.costCr,
ttlcost=trade.costCr*qty,
longestName=longestNameLen)
longestName=longestNameLen,
age=age,
)
hopTonnes += qty
text += hopFmt.format(station=route[i].name(), purchases=purchases)
if jumpsFmt and self.jumps[i]:
Expand Down

0 comments on commit 9e8d7b1

Please sign in to comment.