1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

implement the --deal command line param.

It implements a starting deal seed/index/number.
This commit is contained in:
Shlomi Fish 2019-04-29 14:51:01 +03:00
parent da256a30b0
commit 9e148b88fe
2 changed files with 11 additions and 3 deletions

View file

@ -38,7 +38,7 @@ from pysollib.mfxutil import latin1_normalize, print_err
from pysollib.mfxutil import pickle, unpickle from pysollib.mfxutil import pickle, unpickle
from pysollib.mygettext import _ from pysollib.mygettext import _
from pysollib.options import Options 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 HTMLViewer
from pysollib.pysoltk import HelpStatusbar, PysolStatusbar from pysollib.pysoltk import HelpStatusbar, PysolStatusbar
from pysollib.pysoltk import MfxDialog, MfxExceptionDialog, MfxMessageDialog from pysollib.pysoltk import MfxDialog, MfxExceptionDialog, MfxMessageDialog
@ -419,6 +419,7 @@ class Application:
loadgame=None, # load a game ? loadgame=None, # load a game ?
game=None, game=None,
gameid=None, gameid=None,
deal=None,
) )
self.demo_counter = 0 self.demo_counter = 0
@ -490,7 +491,10 @@ class Application:
print_err(_("can't find game: ") + self.commandline.game) print_err(_("can't find game: ") + self.commandline.game)
sys.exit(-1) sys.exit(-1)
else: 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: elif self.commandline.gameid is not None:
self.nextgame.id, self.nextgame.random = \ self.nextgame.id, self.nextgame.random = \
self.commandline.gameid, None self.commandline.gameid, None

View file

@ -86,7 +86,7 @@ def parse_option(argv):
prog_name = argv[0] prog_name = argv[0]
try: try:
optlist, args = getopt.getopt(argv[1:], "g:i:hD:", optlist, args = getopt.getopt(argv[1:], "g:i:hD:",
["game=", "gameid=", ["deal=", "game=", "gameid=",
"french-only", "french-only",
"noplugins", "noplugins",
"nosound", "nosound",
@ -97,6 +97,7 @@ def parse_option(argv):
(err, prog_name), 0) (err, prog_name), 0)
return None return None
opts = {"help": False, opts = {"help": False,
"deal": None,
"game": None, "game": None,
"gameid": None, "gameid": None,
"french-only": False, "french-only": False,
@ -107,6 +108,8 @@ def parse_option(argv):
for i in optlist: for i in optlist:
if i[0] in ("-h", "--help"): if i[0] in ("-h", "--help"):
opts["help"] = True opts["help"] = True
elif i[0] in ("--deal"):
opts["deal"] = i[1]
elif i[0] in ("-g", "--game"): elif i[0] in ("-g", "--game"):
opts["game"] = i[1] opts["game"] = i[1]
elif i[0] in ("-i", "--gameid"): elif i[0] in ("-i", "--gameid"):
@ -164,6 +167,7 @@ def pysol_init(app, args):
opts, filename = opts opts, filename = opts
if filename: if filename:
app.commandline.loadgame = filename app.commandline.loadgame = filename
app.commandline.deal = opts['deal']
app.commandline.game = opts['game'] app.commandline.game = opts['game']
if opts['gameid'] is not None: if opts['gameid'] is not None:
try: try: