Skip to content

Commit

Permalink
Refactoring/cleanup of Aces and Kings game file.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Aug 23, 2023
1 parent 29f737c commit d93ad0d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions pysollib/games/acesandkings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,9 @@
# * Aces and Kings
# ************************************************************************

class AcesAndKings_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
return len(cards) == 1 and len(self.cards) == 0


class AcesAndKings_FoundationStack(RK_FoundationStack):
getBottomImage = RK_FoundationStack._getReserveBottomImage


class AcesAndKings(Game):
RowStack_Class = BasicRowStack

NUM_RESERVES = 2
NUM_TABLEAU = 4
FOUNDATION_SETS = ((ACE, KING),)
Expand Down Expand Up @@ -83,9 +76,9 @@ def createGame(self, max_rounds=1, num_deal=1):

for i in self.FOUNDATION_SETS:
for j in range(4):
stack = AcesAndKings_FoundationStack(x, y, self, suit=j,
base_rank=i[0], dir=1,
max_cards=(13 - i[0]))
stack = RK_FoundationStack(x, y, self, suit=j, base_rank=i[0],
dir=1, max_cards=(13 - i[0]))
stack.getBottomImage = stack._getReserveBottomImage
if self.preview <= 1:
stack.texts.misc = MfxCanvasText(self.canvas,
x + l.CW // 2,
Expand All @@ -98,9 +91,9 @@ def createGame(self, max_rounds=1, num_deal=1):
x = x + l.XS
x = x + (l.XS / 2)
for j in range(4):
stack = AcesAndKings_FoundationStack(x, y, self, suit=j,
base_rank=i[1], dir=-1,
max_cards=(i[1] + 1))
stack = RK_FoundationStack(x, y, self, suit=j, base_rank=i[1],
dir=-1, max_cards=(i[1] + 1))
stack.getBottomImage = stack._getReserveBottomImage
if self.preview <= 1:
stack.texts.misc = MfxCanvasText(self.canvas,
x + l.CW // 2,
Expand All @@ -121,7 +114,8 @@ def createGame(self, max_rounds=1, num_deal=1):
l.createText(s.waste, "se", text_format="%D")
x = ((8.5 - self.NUM_TABLEAU) * l.XS) + l.XM
for i in range(self.NUM_TABLEAU):
s.rows.append(AcesAndKings_RowStack(x, y, self, max_accept=1))
s.rows.append(self.RowStack_Class(x, y, self, max_accept=1,
max_cards=1))
x = x + l.XS

# define stack-groups
Expand All @@ -136,7 +130,9 @@ def startGame(self):

def fillStack(self, stack):
if not stack.cards and stack in self.s.rows and self.s.talon.cards:
old_state = self.enterState(self.S_FILL)
self.s.talon.moveMove(1, stack)
self.leaveState(old_state)


# ************************************************************************
Expand Down

0 comments on commit d93ad0d

Please sign in to comment.