mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Compare commits
4 commits
52348a4daa
...
fd5bf10ddd
Author | SHA1 | Date | |
---|---|---|---|
|
fd5bf10ddd | ||
|
0082962a93 | ||
|
4d61d73f3a | ||
|
6b228291cc |
4 changed files with 8 additions and 38 deletions
|
@ -567,14 +567,7 @@ class Game(object):
|
||||||
# optional MfxCanvasText items
|
# optional MfxCanvasText items
|
||||||
self.texts = GameTexts()
|
self.texts = GameTexts()
|
||||||
# initial position of the texts
|
# initial position of the texts
|
||||||
self.init_texts = Struct(
|
self.init_texts = GameTexts()
|
||||||
info=None, # misc info text
|
|
||||||
help=None, # a static help text
|
|
||||||
misc=None, #
|
|
||||||
score=None, # for displaying the score
|
|
||||||
base_rank=None, # for displaying the base_rank
|
|
||||||
list=[],
|
|
||||||
)
|
|
||||||
|
|
||||||
def createPreview(self, app):
|
def createPreview(self, app):
|
||||||
old_busy = self.busy
|
old_busy = self.busy
|
||||||
|
|
|
@ -37,7 +37,7 @@ except ImportError:
|
||||||
"https://pypi.python.org/pypi/random2 using pip or similar.")
|
"https://pypi.python.org/pypi/random2 using pip or similar.")
|
||||||
|
|
||||||
assert ((pysol_cards.VERSION if 'VERSION' in pysol_cards.__dict__
|
assert ((pysol_cards.VERSION if 'VERSION' in pysol_cards.__dict__
|
||||||
else (0, 0, 0)) >= (0, 8, 2))
|
else (0, 0, 0)) >= (0, 8, 5))
|
||||||
from pysol_cards.random_base import RandomBase # noqa: I100
|
from pysol_cards.random_base import RandomBase # noqa: I100
|
||||||
from pysol_cards.random import match_ms_deal_prefix # noqa: I100
|
from pysol_cards.random import match_ms_deal_prefix # noqa: I100
|
||||||
|
|
||||||
|
@ -50,29 +50,9 @@ from pysol_cards.random import match_ms_deal_prefix # noqa: I100
|
||||||
|
|
||||||
|
|
||||||
class BasicRandom(RandomBase):
|
class BasicRandom(RandomBase):
|
||||||
# MAX_SEED = 0L
|
|
||||||
# MAX_SEED = 0xffffffffffffffffL # 64 bits
|
|
||||||
MAX_SEED = int('100000000000000000000') # 20 digits
|
|
||||||
|
|
||||||
ORIGIN_UNKNOWN = 0
|
|
||||||
ORIGIN_RANDOM = 1
|
|
||||||
ORIGIN_PREVIEW = 2 # random from preview
|
|
||||||
ORIGIN_SELECTED = 3 # manually entered
|
|
||||||
ORIGIN_NEXT_GAME = 4 # "Next game number"
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
raise SubclassResponsibility
|
raise SubclassResponsibility
|
||||||
|
|
||||||
def copy(self):
|
|
||||||
random = self.__class__(0)
|
|
||||||
random.__dict__.update(self.__dict__)
|
|
||||||
return random
|
|
||||||
|
|
||||||
def increaseSeed(self, seed):
|
|
||||||
if seed < self.MAX_SEED:
|
|
||||||
return seed + 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def _getRandomSeed(self):
|
def _getRandomSeed(self):
|
||||||
t = int(time.time() * 256.0)
|
t = int(time.time() * 256.0)
|
||||||
t = (t ^ (t >> 24)) % (self.MAX_SEED + 1)
|
t = (t ^ (t >> 24)) % (self.MAX_SEED + 1)
|
||||||
|
@ -217,7 +197,7 @@ class LCRandom31(MFXRandom):
|
||||||
return "ms" + str(self.initial_seed)
|
return "ms" + str(self.initial_seed)
|
||||||
|
|
||||||
def str(self, seed):
|
def str(self, seed):
|
||||||
if match_ms_deal_prefix(seed) is None:
|
if match_ms_deal_prefix("{}".format(seed)) is None:
|
||||||
return "%05d" % int(seed)
|
return "%05d" % int(seed)
|
||||||
return seed
|
return seed
|
||||||
|
|
||||||
|
|
|
@ -230,8 +230,6 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
lambda gi: gi.si.redeals == 3),
|
lambda gi: gi.si.redeals == 3),
|
||||||
SelectGameNode(None, _("Unlimited redeals"),
|
SelectGameNode(None, _("Unlimited redeals"),
|
||||||
lambda gi: gi.si.redeals == -1),
|
lambda gi: gi.si.redeals == -1),
|
||||||
# SelectGameNode(None, "Variable redeals",
|
|
||||||
# lambda gi: gi.si.redeals == -2),
|
|
||||||
SelectGameNode(
|
SelectGameNode(
|
||||||
None, _("Other number of redeals"),
|
None, _("Other number of redeals"),
|
||||||
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
||||||
|
|
|
@ -165,16 +165,16 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
||||||
#
|
#
|
||||||
self.rootnodes = [_f for _f in (
|
self.rootnodes = [_f for _f in (
|
||||||
SelectGameNode(None, _("All Games"), None),
|
SelectGameNode(None, _("All Games"), None, expanded=0),
|
||||||
SelectGameNode(None, _("Alternate Names"), ul_alternate_names),
|
SelectGameNode(None, _("Alternate Names"), ul_alternate_names),
|
||||||
SelectGameNode(None, _("Popular Games"),
|
SelectGameNode(None, _("Popular Games"),
|
||||||
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
|
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
|
||||||
|
s_by_type,
|
||||||
s_mahjongg,
|
s_mahjongg,
|
||||||
s_oriental,
|
s_oriental,
|
||||||
s_special,
|
s_special,
|
||||||
SelectGameNode(None, _("Custom Games"),
|
SelectGameNode(None, _("Custom Games"),
|
||||||
lambda gi: gi.si.game_type == GI.GT_CUSTOM),
|
lambda gi: gi.si.game_type == GI.GT_CUSTOM),
|
||||||
s_by_type,
|
|
||||||
SelectGameNode(None, _('by Skill Level'), (
|
SelectGameNode(None, _('by Skill Level'), (
|
||||||
SelectGameNode(None, _('Luck only'),
|
SelectGameNode(None, _('Luck only'),
|
||||||
lambda gi: gi.skill_level == GI.SL_LUCK),
|
lambda gi: gi.skill_level == GI.SL_LUCK),
|
||||||
|
@ -230,8 +230,6 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
lambda gi: gi.si.redeals == 3),
|
lambda gi: gi.si.redeals == 3),
|
||||||
SelectGameNode(None, _("Unlimited redeals"),
|
SelectGameNode(None, _("Unlimited redeals"),
|
||||||
lambda gi: gi.si.redeals == -1),
|
lambda gi: gi.si.redeals == -1),
|
||||||
SelectGameNode(None, "Variable redeals",
|
|
||||||
lambda gi: gi.si.redeals == -2),
|
|
||||||
SelectGameNode(
|
SelectGameNode(
|
||||||
None, _("Other number of redeals"),
|
None, _("Other number of redeals"),
|
||||||
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
||||||
|
@ -435,7 +433,8 @@ class SelectGameDialogWithPreview(SelectGameDialog):
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
strings=(_("&Select"), _("&Rules"), _("&Cancel"),),
|
strings=((_("&Rules"), 10), 'sep',
|
||||||
|
_("&Select"), _("&Cancel"),),
|
||||||
default=0,
|
default=0,
|
||||||
)
|
)
|
||||||
return SelectGameDialog.initKw(self, kw)
|
return SelectGameDialog.initKw(self, kw)
|
||||||
|
@ -544,7 +543,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
|
||||||
#
|
#
|
||||||
self.updateInfo(gameid)
|
self.updateInfo(gameid)
|
||||||
#
|
#
|
||||||
rules_button = self.buttons[1]
|
rules_button = self.buttons[0]
|
||||||
if self.app.getGameRulesFilename(gameid):
|
if self.app.getGameRulesFilename(gameid):
|
||||||
rules_button.config(state="normal")
|
rules_button.config(state="normal")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue