X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomrogue-server.py;h=a1717a71bdd5dcf0871938600b046b785c342678;hb=e767af39c79bc4904d8bed963faf357d0d8a8b6c;hp=9bb1559ab0c4462f3125e557691f8153a6f91299;hpb=f248dd2ed7841f9db076b5ab170b2892c9b317e0;p=plomrogue diff --git a/plomrogue-server.py b/plomrogue-server.py index 9bb1559..a1717a7 100755 --- a/plomrogue-server.py +++ b/plomrogue-server.py @@ -65,17 +65,20 @@ try: parser = argparse.ArgumentParser() parser.add_argument('-s', nargs='?', type=int, dest='replay', const=1, action='store') - args, unknown = parser.parse_known_args() - replay = args.replay - # print("DUMMY: Obey command-line arguments.") + opts, unknown = parser.parse_known_args() setup_server_io(io_db) # print("DUMMY: Run game.") path_recordfile = "recordfile" path_savefile = "savefile" detect_atomic_leftover(path_savefile) detect_atomic_leftover(path_recordfile) - if replay: - print("Replaying") + if None != opts.replay: + if opts.replay < 1: + opts.replay = 1 + print("Replay mode. Auto-replaying up to turn " + str(opts.replay) + + " (if so late a turn is to be found).") + if not os.access(path_savefile, os.F_OK): + raise HandledException("No record file found to replay.") elif os.access(path_savefile, os.F_OK): print(open(path_savefile, "r").read()) else: @@ -84,8 +87,7 @@ try: except SystemExit: pass except HandledException as exception: - print("Error:") - print(exception.args[0]) + print("ABORTING: " + exception.args[0]) except: print("SOMETHING WENT WRONG IN UNEXPECTED WAYS") raise