From 9e148b88fe2070cb66f7389589b81cf44e3fb632 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 29 Apr 2019 14:51:01 +0300 Subject: [PATCH] implement the --deal command line param. It implements a starting deal seed/index/number. --- pysollib/app.py | 8 ++++++-- pysollib/main.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pysollib/app.py b/pysollib/app.py index f3b7513b..9a794c91 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -38,7 +38,7 @@ from pysollib.mfxutil import latin1_normalize, print_err from pysollib.mfxutil import pickle, unpickle from pysollib.mygettext import _ from pysollib.options import Options -from pysollib.pysolrandom import PysolRandom +from pysollib.pysolrandom import PysolRandom, constructRandom from pysollib.pysoltk import HTMLViewer from pysollib.pysoltk import HelpStatusbar, PysolStatusbar from pysollib.pysoltk import MfxDialog, MfxExceptionDialog, MfxMessageDialog @@ -419,6 +419,7 @@ class Application: loadgame=None, # load a game ? game=None, gameid=None, + deal=None, ) self.demo_counter = 0 @@ -490,7 +491,10 @@ class Application: print_err(_("can't find game: ") + self.commandline.game) sys.exit(-1) else: - self.nextgame.id, self.nextgame.random = gameid, None + self.nextgame.id = gameid + deal = self.commandline.deal + self.nextgame.random = \ + None if deal is None else constructRandom(deal) elif self.commandline.gameid is not None: self.nextgame.id, self.nextgame.random = \ self.commandline.gameid, None diff --git a/pysollib/main.py b/pysollib/main.py index 15b960a8..5a7561fc 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -86,7 +86,7 @@ def parse_option(argv): prog_name = argv[0] try: optlist, args = getopt.getopt(argv[1:], "g:i:hD:", - ["game=", "gameid=", + ["deal=", "game=", "gameid=", "french-only", "noplugins", "nosound", @@ -97,6 +97,7 @@ def parse_option(argv): (err, prog_name), 0) return None opts = {"help": False, + "deal": None, "game": None, "gameid": None, "french-only": False, @@ -107,6 +108,8 @@ def parse_option(argv): for i in optlist: if i[0] in ("-h", "--help"): opts["help"] = True + elif i[0] in ("--deal"): + opts["deal"] = i[1] elif i[0] in ("-g", "--game"): opts["game"] = i[1] elif i[0] in ("-i", "--gameid"): @@ -164,6 +167,7 @@ def pysol_init(app, args): opts, filename = opts if filename: app.commandline.loadgame = filename + app.commandline.deal = opts['deal'] app.commandline.game = opts['game'] if opts['gameid'] is not None: try: