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

extract more code to pysol_cards

This commit is contained in:
Shlomi Fish 2020-05-26 18:56:14 +03:00
parent 467a0f14e0
commit 2437c702fd
4 changed files with 7 additions and 29 deletions

View file

@ -30,6 +30,7 @@ from pickle import Pickler, Unpickler, UnpicklingError
import attr
from pysol_cards.cards import ms_rearrange
from pysol_cards.random import random__int2str
from pysollib.game.dump import pysolDumpGame
from pysollib.gamedb import GI
@ -53,8 +54,7 @@ from pysollib.move import ATurnStackMove
from pysollib.move import AUpdateStackMove
from pysollib.mygettext import _
from pysollib.mygettext import ungettext
from pysollib.pysolrandom import LCRandom31, PysolRandom, constructRandom, \
random__int2str
from pysollib.pysolrandom import LCRandom31, PysolRandom, constructRandom
from pysollib.pysoltk import CURSOR_WATCH
from pysollib.pysoltk import Card
from pysollib.pysoltk import EVENT_HANDLED, EVENT_PROPAGATE

View file

@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from pysollib.pysolrandom import random__str2int
from pysol_cards.random import random__str2int
from pysollib.settings import PACKAGE
from pysollib.settings import VERSION, VERSION_TUPLE

View file

@ -26,15 +26,12 @@
import re
import pysol_cards
assert getattr(pysol_cards, 'VERSION', (0, 0, 0)) >= (0, 8, 15), (
assert getattr(pysol_cards, 'VERSION', (0, 0, 0)) >= (0, 8, 16), (
"Newer version of https://pypi.org/project/pysol-cards is required.")
import pysol_cards.random # noqa: I100
import pysol_cards.random_base # noqa: I100
from pysol_cards.random import LCRandom31, match_ms_deal_prefix # noqa: I100
MS_LONG_BIT = (1 << 1000)
CUSTOM_BIT = (1 << 999)
from pysol_cards.random import CUSTOM_BIT, MS_LONG_BIT # noqa: I100
class CustomRandom(pysol_cards.random_base.RandomBase):
@ -85,25 +82,6 @@ def constructRandom(s):
return pysol_cards.random.MTRandom(seed)
def random__str2int(s):
if s == 'Custom':
return CUSTOM_BIT | MS_LONG_BIT
m = match_ms_deal_prefix(s)
if m is not None:
return (m | MS_LONG_BIT)
else:
return int(s)
def random__int2str(l):
if ((l & MS_LONG_BIT) != 0):
if ((l & CUSTOM_BIT) != 0):
return 'Custom'
return "ms" + str(l & (~ MS_LONG_BIT))
else:
return str(l)
# test
if __name__ == '__main__':
r = constructRandom('12345')

View file

@ -56,10 +56,10 @@ import unittest
from pysol_cards.cards import CardRenderer
from pysol_cards.deal_game import Game
from pysol_cards.random_base import RandomBase
from pysol_cards.random import random__int2str, random__str2int
# So the localpaths will be overrided.
from pysollib.pysolrandom import constructRandom, \
random__int2str, random__str2int
from pysollib.pysolrandom import constructRandom
# PySol imports