mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-15 02:54:09 -04:00
Compare commits
6 commits
467a0f14e0
...
478fa82e86
Author | SHA1 | Date | |
---|---|---|---|
|
478fa82e86 | ||
|
7e6cf5694b | ||
|
3653a51176 | ||
|
a219bdb29c | ||
|
e43dcb207c | ||
|
2437c702fd |
5 changed files with 30 additions and 43 deletions
|
@ -555,7 +555,10 @@ class PysolMenubar(PysolMenubarTk):
|
|||
text=text % {'filename': filename})
|
||||
|
||||
def mPlayerStats(self, *args, **kw):
|
||||
self.game.doPause()
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
mode = kw.get("mode", 101)
|
||||
demo = 0
|
||||
gameid = None
|
||||
|
@ -659,7 +662,9 @@ class PysolMenubar(PysolMenubarTk):
|
|||
if d.status != 0:
|
||||
break
|
||||
mode = d.button
|
||||
self.game.doPause()
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
|
||||
#
|
||||
# Assist menu
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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, 17), (
|
||||
"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):
|
||||
|
@ -67,9 +64,6 @@ def constructRandom(s):
|
|||
seed = m
|
||||
if 0 <= seed <= LCRandom31.MAX_SEED:
|
||||
ret = LCRandom31(seed)
|
||||
assert ret.seed
|
||||
assert ret.seedx
|
||||
assert ret.initial_seed
|
||||
# ret.setSeedAsStr(s)
|
||||
return ret
|
||||
else:
|
||||
|
@ -82,31 +76,6 @@ def constructRandom(s):
|
|||
seed = int(s)
|
||||
if 0 <= seed < 32000:
|
||||
return LCRandom31(seed)
|
||||
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')
|
||||
print(r.randint(0, 100))
|
||||
print(r.random())
|
||||
print(type(r))
|
||||
# print("MTRandom", seed)
|
||||
ret = pysol_cards.random.MTRandom(seed)
|
||||
return ret
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -186,3 +186,16 @@ KS 7S 5H 3H TS 3S 5D
|
|||
9C JH 8H 3D 4D QC
|
||||
KH 6H 6C TC 2C 7D
|
||||
''', 'ms100001')
|
||||
|
||||
seed = 24000024
|
||||
rand = constructRandom(str(seed))
|
||||
expected0 = rand.randint(0, 100)
|
||||
expected1 = rand.randint(0, 100)
|
||||
rand.reset()
|
||||
got0 = rand.randint(0, 100)
|
||||
got1 = rand.randint(0, 100)
|
||||
# TEST
|
||||
self.assertEqual(
|
||||
[got0, got1, ],
|
||||
[expected0, expected1, ],
|
||||
"same results after reset()",)
|
||||
|
|
Loading…
Add table
Reference in a new issue