mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
moved functionality to pysol-cards.py
This commit is contained in:
parent
52eeb40942
commit
198038b1c9
1 changed files with 10 additions and 11 deletions
|
@ -35,6 +35,7 @@ except ImportError:
|
||||||
"https://pypi.python.org/pypi/random2 using pip or similar.")
|
"https://pypi.python.org/pypi/random2 using pip or similar.")
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -221,7 +222,9 @@ class LCRandom31(MFXRandom):
|
||||||
return "ms" + str(self.initial_seed)
|
return "ms" + str(self.initial_seed)
|
||||||
|
|
||||||
def str(self, seed):
|
def str(self, seed):
|
||||||
return "%05d" % int(seed) if not _match_ms(seed) else seed
|
if match_ms_deal_prefix(seed) is None:
|
||||||
|
return "%05d" % int(seed)
|
||||||
|
return seed
|
||||||
|
|
||||||
def setSeed(self, seed):
|
def setSeed(self, seed):
|
||||||
seed = int(seed)
|
seed = int(seed)
|
||||||
|
@ -263,18 +266,14 @@ PysolRandom = MTRandom
|
||||||
# * PySol support code
|
# * PySol support code
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
def _match_ms(s):
|
|
||||||
"""match an ms based seed string."""
|
|
||||||
return re.match(r"ms([0-9]+)\n?\Z", str(s))
|
|
||||||
|
|
||||||
|
|
||||||
# construct Random from seed string
|
# construct Random from seed string
|
||||||
def constructRandom(s):
|
def constructRandom(s):
|
||||||
if s == 'Custom':
|
if s == 'Custom':
|
||||||
return CustomRandom()
|
return CustomRandom()
|
||||||
m = _match_ms(s)
|
m = match_ms_deal_prefix(s)
|
||||||
if m:
|
if m is not None:
|
||||||
seed = int(m.group(1))
|
seed = m
|
||||||
if 0 <= seed <= LCRandom31.MAX_SEED:
|
if 0 <= seed <= LCRandom31.MAX_SEED:
|
||||||
ret = LCRandom31(seed)
|
ret = LCRandom31(seed)
|
||||||
ret.setSeedAsStr(s)
|
ret.setSeedAsStr(s)
|
||||||
|
@ -295,9 +294,9 @@ def constructRandom(s):
|
||||||
def random__str2long(s):
|
def random__str2long(s):
|
||||||
if s == 'Custom':
|
if s == 'Custom':
|
||||||
return CUSTOM_BIT | MS_LONG_BIT
|
return CUSTOM_BIT | MS_LONG_BIT
|
||||||
m = _match_ms(s)
|
m = match_ms_deal_prefix(s)
|
||||||
if m:
|
if m is not None:
|
||||||
return (int(m.group(1)) | MS_LONG_BIT)
|
return (m | MS_LONG_BIT)
|
||||||
else:
|
else:
|
||||||
return int(s)
|
return int(s)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue