Skip to content

Commit

Permalink
Merged kfsone/tradedangerous into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anothermindbomb committed Aug 18, 2014
2 parents beb41d6 + fad8efb commit ff32ef9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
# Multi-function display wrappers

class DummyMFD(object):
hopNo = None

def __init__(self):
pass

Expand All @@ -52,7 +54,7 @@ def update(self, *args, **kwargs):
def finish(self):
pass

class X52ProMFD(object):
class X52ProMFD(DummyMFD):
def __init__(self):
import saitek.X52Pro
self.doObj = saitek.X52Pro.SaitekX52Pro()
Expand Down Expand Up @@ -207,7 +209,7 @@ def parse_command_line():

def doStep(stepNo, action, detail=""):
stepNo += 1
mfd.update("Step # %d" % stepNo, action, detail)
mfd.update("Step %d. Hop %d" % (stepNo, mfd.hopNo), action, detail)
if detail:
input(" %3d: %s %s: " % (stepNo, action, detail))
else:
Expand Down Expand Up @@ -241,9 +243,13 @@ def doChecklist(route, credits):
print()

for idx in range(lastHopIdx):
mfd.hopNo = hopNo = idx + 1
cur, nxt, hop = stations[idx], stations[idx + 1], hops[idx]

# Tell them what they need to buy.
if args.detail:
note("HOP %d of %d" % (hopNo, lastHopIdx))

note("Buy [%s]" % cur)
for item in sorted(hop[0], key=lambda item: item[1] * item[0].gainCr, reverse=True):
stepNo = doStep(stepNo, 'Buy %d x' % item[1], str(item[0]))
Expand All @@ -269,11 +275,12 @@ def doChecklist(route, credits):
if args.detail and gainCr > 0:
note("GAINED: %scr, CREDITS: %scr" % (localedNo(gainCr), localedNo(credits + gainCr)))

if idx + 1 < lastHopIdx:
if hopNo < lastHopIdx:
print()
print("--------------------------------------")
print()

mfd.hopNo = None
mfd.update("FINISHED", "+%scr" % localedNo(gainCr), "=%scr" % localedNo(credits + gainCr), delay=3)

def main():
Expand Down Expand Up @@ -323,16 +330,15 @@ def main():

routes.sort()

for i in range(0, min(len(routes), args.routes)):
print(routes[i].detail(args.detail))

# User wants to be guided through the route.
if args.checklist:
assert args.routes == 1
doChecklist(routes[0], args.credits)
return

# Just print the routes.
for i in range(0, min(len(routes), args.routes)):
print(routes[i].detail(args.detail))

if __name__ == "__main__":
main()
if mfd:
Expand Down
1 change: 1 addition & 0 deletions tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def detail(self, verbose=False):
gainCr += hop[1]

str += " <-< %s gaining %dcr => %dcr total" % (route[-1], gainCr, credits + gainCr)
str += "\n"

return str

Expand Down

0 comments on commit ff32ef9

Please sign in to comment.