1 # Display card output and retreive input
7 def disp_bar(stdscr, stack, headers, obj):
8 (mlines, mcols) = stdscr.getmaxyx()
12 percent = str(round(obj.getIdx() / (len(stack)) * 100)).zfill(3)
14 stdscr.insstr(mlines - 1, 0,
16 stack[obj.getIdx()].printStar() +
20 str(obj.getIdx() + 1) +
25 headers[obj.getSide()] +
29 def disp_menu(stdscr, stack, headers, idx):
30 stdscr.addstr("Good job, you've completed a round!\n\n" +
31 "Choose one of the following options:\n" +
32 "[r]estart, [s]tarred only, [u]nstar all and restart, [q]uit")
39 get_key(stdscr, stack, headers, idx)
44 get_key(stdscr, stack, headers, idx)
53 stack = [x for x in stack if x.getStar()]
54 get_key(stdscr, stack, headers, idx)
57 stdscr.addstr("ERR: Stack empty. Choose another option\n\n")
58 disp_menu(stdscr, stack, headers, idx)
61 def disp_card(stdscr, stack, headers, obj):
63 if obj.getIdx() == len(stack):
64 disp_menu(stdscr, stack, headers, obj)
66 side_title = headers[obj.getSide()]
67 stdscr.addstr(side_title + "\n")
68 for i in range(len(side_title)):
70 stdscr.addstr("\n" + str(stack[obj.getIdx()][obj.getSide()]))
71 disp_bar(stdscr, stack, headers, obj)
74 def get_key(stdscr, stack, headers, idx):
76 disp_card(stdscr, stack, headers, idx)
82 elif key in ["l", "KEY_LEFT"]:
85 disp_card(stdscr, stack, headers, idx)
86 elif key in ["h", "KEY_RIGHT"]:
89 disp_card(stdscr, stack, headers, idx)
90 elif key in ["j", "k", "KEY_UP", "KEY_DOWN"]:
92 disp_card(stdscr, stack, headers, idx)
93 elif key in ["i", "/"]:
94 stack[idx.getIdx()].toggleStar()
95 disp_card(stdscr, stack, headers, idx)