From be1929a33e9fe5a255a193b1ef2968689049446e Mon Sep 17 00:00:00 2001 From: Joe R Date: Mon, 9 Oct 2023 19:24:52 -0400 Subject: [PATCH] Redeal stack for Archway (discussed in issue #332). --- html-src/rules/archway.html | 5 +++- pysollib/games/sultan.py | 46 +++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/html-src/rules/archway.html b/html-src/rules/archway.html index bbbdac85..4f33e534 100644 --- a/html-src/rules/archway.html +++ b/html-src/rules/archway.html @@ -1,6 +1,6 @@

Archway

-Two-Deck game type. 2 decks. No redeal. +Two-Deck game type. 2 decks. Unlimited redeals.

Object

@@ -15,5 +15,8 @@ four foundations have an ace of each suit dealt to them, and are built up by suit, while the other four foundations have a king dealt to them and are built down by suit.

+Additionally, every card from the reserve piles is available to play. Hitting +the redeal button will shift the topmost card of each reserve. +

As not all aces are dealt to the foundations, a thirteenth reserve pile on the far left is used for extra aces. diff --git a/pysollib/games/sultan.py b/pysollib/games/sultan.py index b8c66d3c..431ca7ea 100644 --- a/pysollib/games/sultan.py +++ b/pysollib/games/sultan.py @@ -33,10 +33,12 @@ from pysollib.stack import \ DealRowRedealTalonStack, \ DealRowTalonStack, \ InitialDealTalonStack, \ + InvisibleStack, \ KingAC_RowStack, \ OpenStack, \ RK_FoundationStack, \ RK_RowStack, \ + RedealTalonStack, \ ReserveStack, \ SS_FoundationStack, \ SS_RowStack, \ @@ -368,6 +370,8 @@ class LadyOfTheManor(Game): Foundation_Class_1 = RK_FoundationStack Foundation_Class_2 = RK_FoundationStack + Talon_Class = InitialDealTalonStack + ACE_STACK = False def createGame(self): @@ -380,8 +384,6 @@ class LadyOfTheManor(Game): l.YM + max(4 * l.YS, 3 * l.YS + 14 * l.YOFFSET)) x, y = l.XM, self.height-l.YS - if self.ACE_STACK: - x += (l.XS / 2) for i in range(4): suit = i if self.Foundation_Class_1 is RK_FoundationStack: @@ -415,8 +417,8 @@ class LadyOfTheManor(Game): x, y = l.XM+i*l.XS, l.YM+j*l.YS s.reserves.append(LadyOfTheManor_Reserve(x, y, self, max_accept=0)) - s.talon = InitialDealTalonStack( - self.width-l.XS, self.height-2*l.YS, self) + s.talon = self.Talon_Class( + self.width-l.XS, self.height-l.YS, self) l.defaultAll() @@ -442,12 +444,46 @@ class LadyOfTheManor(Game): self.moveMove(1, self.s.talon, r, frames=4) +class Archway_Talon(RedealTalonStack): + + def dealCards(self, sound=False): + old_state = self.game.enterState(self.game.S_DEAL) + ncards = 0 + intern1, intern2 = self.game.s.internals + if sound and self.game.app.opt.animations: + self.game.startDealSample() + for r in self.game.s.reserves: + if len(r.cards) <= 1: + continue + ncards += len(r.cards) + # move cards to internal stacks + while len(r.cards) != 1: + self.game.moveMove(1, r, intern1, frames=0) + self.game.moveMove(1, r, intern2, frames=0) + # move back + while intern1.cards: + self.game.moveMove(1, intern1, r, frames=0) + self.game.moveMove(1, intern2, r, frames=0) + self.game.nextRoundMove(self) + if sound: + self.game.stopSamples() + self.game.leaveState(old_state) + return ncards + + class Archway(LadyOfTheManor): Foundation_Class_1 = SS_FoundationStack Foundation_Class_2 = StackWrapper(SS_FoundationStack, dir=-1) + Talon_Class = StackWrapper(Archway_Talon, max_rounds=-1) ACE_STACK = True + def createGame(self): + LadyOfTheManor.createGame(self) + + self.s.internals.append(InvisibleStack(self)) + self.s.internals.append(InvisibleStack(self)) + def _shuffleHook(self, cards): return self._shuffleHookMoveToTop( cards, @@ -1448,4 +1484,4 @@ registerGame(GameInfo(745, DesertIsland, "Desert Island", registerGame(GameInfo(761, CatherineTheGreat, "Catherine the Great", GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED)) registerGame(GameInfo(844, Archway, "Archway", - GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK)) + GI.GT_2DECK_TYPE, 2, -1, GI.SL_MOSTLY_LUCK))