def make_pysol_board__main(args): obj = SingleDealArgsParser(args) g = Game(obj.which_game, obj.game_num, obj.which_deals, obj.max_rank) g.deal() getattr(g, g.game_class)() renderer = JsonRenderer(obj.print_ts) je = json.JSONEncoder(sort_keys=True) json_obj = {} json_obj["tableau piles"] = [ renderer.render_l(x) for x in g.board.columns.cols] try: talon = renderer.render_l(g.board.talon) json_obj["stock"] = talon except AttributeError: pass print(je.encode(json_obj))
def make_pysol_board__main(args): print_ts = False which_deals = RandomBase.DEALS_PYSOL max_rank = 13 print_ts = False while args[1][0] == '-': a = args[1] if a == "-t": # print_ts = True args.pop(1) elif (a == "--max-rank"): args.pop(1) max_rank = int(args.pop(1)) elif (a == "--pysolfc") or (a == "-F"): which_deals = RandomBase.DEALS_PYSOLFC args.pop(1) elif (a == "--ms") or (a == "-M"): which_deals = RandomBase.DEALS_MS args.pop(1) else: raise ValueError("Unknown flag " + a + "!") game_num = int(args[1]) which_game = args[2] if len(args) >= 3 else "freecell" g = Game(which_game, game_num, which_deals, max_rank) g.deal() getattr(g, g.game_class)() renderer = JsonRenderer(print_ts) je = json.JSONEncoder(sort_keys=True) json_obj = {} json_obj["tableau piles"] = [ renderer.render_l(x) for x in g.board.columns.cols] try: talon = renderer.render_l(g.board.talon) json_obj["stock"] = talon except AttributeError: pass print(je.encode(json_obj))