From 2bec58be2d34453e90179f94d7fcd3f9a14a0f07 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 23 May 2019 19:10:57 +0300 Subject: [PATCH] Fix next deal / Ctrl+N for ms deals. --- pysollib/pysolrandom.py | 6 +++++- tests/lib/pysol_tests/ms_deals1/__init__.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pysollib/pysolrandom.py b/pysollib/pysolrandom.py index 747fc66e..a7b186cd 100644 --- a/pysollib/pysolrandom.py +++ b/pysollib/pysolrandom.py @@ -225,11 +225,15 @@ class CustomRandom(BasicRandom): class LCRandom31(MFXRandom): MAX_SEED = int('0x1ffffffff', 0) # 33 bits + def increaseSeed(self, seed): + ret = super(LCRandom31, self).increaseSeed(seed) + return "ms{}".format(ret) + def getSeedStr(self): return "ms" + str(self.initial_seed) def str(self, seed): - return "%05d" % int(seed) + return "%05d" % int(seed) if not _match_ms(seed) else seed def setSeed(self, seed): seed = int(seed) diff --git a/tests/lib/pysol_tests/ms_deals1/__init__.py b/tests/lib/pysol_tests/ms_deals1/__init__.py index 037b7e22..6e1c63f6 100644 --- a/tests/lib/pysol_tests/ms_deals1/__init__.py +++ b/tests/lib/pysol_tests/ms_deals1/__init__.py @@ -665,3 +665,21 @@ QH 9H 9D 5S 7S 6C # TEST self.assertEqual(got, inp, 'str2long PySolFC roundtrip.') + + rand = constructRandom('ms100000') + seed = rand.increaseSeed(rand.initial_seed) + seed = rand.str(seed) + # TEST + self.assertEqual(seed, 'ms100001', 'increaseSeed for ms deals') + rand = constructRandom(seed) + game = Game("freecell", rand, True) + # TEST + self._cmp_board(game.print_layout(), '''5S AH 4H TD 4S JD JS +3C 8C 4C AC JC AS QS +7C QH 2D QD 8S 9D AD +KS 7S 5H 3H TS 3S 5D +9S 7H KC TH 8D 6S +5C KD 9H 2H 2S 6D +9C JH 8H 3D 4D QC +KH 6H 6C TC 2C 7D +''', 'ms100001')