From 787f2b4db7ad191f4dedb031f1e867ed31f99860 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 18 Aug 2014 11:06:27 -0700 Subject: [PATCH 1/2] Presentation cleanup: - blank line after routes, - show routes before checklist so you know what you're checklisting. --- trade.py | 7 +++---- tradecalc.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/trade.py b/trade.py index 4e033d2b..70fe78e2 100644 --- a/trade.py +++ b/trade.py @@ -324,16 +324,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: diff --git a/tradecalc.py b/tradecalc.py index 8d72f789..da587ae9 100644 --- a/tradecalc.py +++ b/tradecalc.py @@ -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 From e1ed24c55857ad08b3fdaf181f09b16e3fb46cd3 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 18 Aug 2014 11:06:51 -0700 Subject: [PATCH 2/2] Show hop number on the MFD --- trade.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/trade.py b/trade.py index 70fe78e2..b0637d02 100644 --- a/trade.py +++ b/trade.py @@ -43,6 +43,8 @@ # Multi-function display wrappers class DummyMFD(object): + hopNo = None + def __init__(self): pass @@ -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() @@ -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: @@ -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])) @@ -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():