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

Compare commits

...

4 commits

Author SHA1 Message Date
Shlomi Fish
fd5bf10ddd moved functionality to pysol-cards.py 2019-08-04 18:47:19 +03:00
Shlomi Fish
0082962a93 Extract a common class/struct.
This is Refactoring / code cleanup.

See:

* https://en.wikipedia.org/wiki/God_object

* https://en.wikipedia.org/wiki/Extract_class

* https://en.wikipedia.org/wiki/Code_refactoring

* https://www.refactoring.com/

* https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/

Some small optimisations may have slipped in as well.
2019-07-31 16:10:28 +03:00
Shlomi Fish
4d61d73f3a consolidate diffs 2019-07-30 12:37:22 +03:00
Shlomi Fish
6b228291cc update to latest pypi ver 2019-07-30 12:36:31 +03:00
4 changed files with 8 additions and 38 deletions

View file

@ -567,14 +567,7 @@ class Game(object):
# optional MfxCanvasText items
self.texts = GameTexts()
# initial position of the texts
self.init_texts = Struct(
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=[],
)
self.init_texts = GameTexts()
def createPreview(self, app):
old_busy = self.busy

View file

@ -37,7 +37,7 @@ except ImportError:
"https://pypi.python.org/pypi/random2 using pip or similar.")
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 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):
# 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):
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):
t = int(time.time() * 256.0)
t = (t ^ (t >> 24)) % (self.MAX_SEED + 1)
@ -217,7 +197,7 @@ class LCRandom31(MFXRandom):
return "ms" + str(self.initial_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 seed

View file

@ -230,8 +230,6 @@ class SelectGameData(SelectDialogTreeData):
lambda gi: gi.si.redeals == 3),
SelectGameNode(None, _("Unlimited redeals"),
lambda gi: gi.si.redeals == -1),
# SelectGameNode(None, "Variable redeals",
# lambda gi: gi.si.redeals == -2),
SelectGameNode(
None, _("Other number of redeals"),
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),

View file

@ -165,16 +165,16 @@ class SelectGameData(SelectDialogTreeData):
list(app.gdb.getGamesTuplesSortedByAlternateName()))
#
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, _("Popular Games"),
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
s_by_type,
s_mahjongg,
s_oriental,
s_special,
SelectGameNode(None, _("Custom Games"),
lambda gi: gi.si.game_type == GI.GT_CUSTOM),
s_by_type,
SelectGameNode(None, _('by Skill Level'), (
SelectGameNode(None, _('Luck only'),
lambda gi: gi.skill_level == GI.SL_LUCK),
@ -230,8 +230,6 @@ class SelectGameData(SelectDialogTreeData):
lambda gi: gi.si.redeals == 3),
SelectGameNode(None, _("Unlimited redeals"),
lambda gi: gi.si.redeals == -1),
SelectGameNode(None, "Variable redeals",
lambda gi: gi.si.redeals == -2),
SelectGameNode(
None, _("Other number of redeals"),
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
@ -435,7 +433,8 @@ class SelectGameDialogWithPreview(SelectGameDialog):
def initKw(self, kw):
kw = KwStruct(kw,
strings=(_("&Select"), _("&Rules"), _("&Cancel"),),
strings=((_("&Rules"), 10), 'sep',
_("&Select"), _("&Cancel"),),
default=0,
)
return SelectGameDialog.initKw(self, kw)
@ -544,7 +543,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
#
self.updateInfo(gameid)
#
rules_button = self.buttons[1]
rules_button = self.buttons[0]
if self.app.getGameRulesFilename(gameid):
rules_button.config(state="normal")
else: