class RelaxedGolf(Golf): Solver_Class = BlackHoleSolverWrapper(preset='golf', base_rank=0, wrap_ranks=True) Waste_Class = StackWrapper(Golf_Waste, mod=13) shallHighlightMatch = Game._shallHighlightMatch_RKW
class DeadKingGolf(Golf): Solver_Class = BlackHoleSolverWrapper(preset='golf', base_rank=0) def getStrictness(self): return 1 def shallHighlightMatch(self, stack1, card1, stack2, card2): if card1.rank == KING: return False return Golf.shallHighlightMatch(self, stack1, card1, stack2, card2)
class AllInARow(BlackHole): Solver_Class = BlackHoleSolverWrapper(preset='all_in_a_row') def createGame(self): # create layout l, s = Layout(self), self.s # set window h = l.YM + l.YS + 4 * l.YOFFSET self.setSize(l.XM + 7 * l.XS, 3 * l.YM + 2 * h + l.YS) # create stacks x, y = l.XM, l.YM for i in range(7): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS x, y = l.XM, l.YM + h for i in range(6): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS for r in s.rows: r.CARD_XOFFSET, r.CARD_YOFFSET = 0, l.YOFFSET x, y = l.XM, self.height - l.YS stack = BlackHole_Foundation(x, y, self, ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=52, base_rank=ANY_RANK) s.foundations.append(stack) stack.CARD_XOFFSET, stack.CARD_YOFFSET = (self.width - l.XS) // 51, 0 l.createText(stack, 'n') x = self.width - l.XS s.talon = InitialDealTalonStack(x, y, self) # define stack-groups l.defaultStackGroups() def startGame(self): for i in range(3): self.s.talon.dealRow(frames=0) self.startDealSample() self.s.talon.dealRow()
class BlackHole(Game): RowStack_Class = StackWrapper( BlackHole_RowStack, max_accept=0, max_cards=3) Hint_Class = Golf_Hint Solver_Class = BlackHoleSolverWrapper(preset='black_hole') # # game layout # def createGame(self, playcards=5): # create layout layout, s = Layout(self), self.s # set window w = max(2*layout.XS, layout.XS+(playcards-1)*layout.XOFFSET) self.setSize(layout.XM + 5*w, layout.YM + 4*layout.YS) # create stacks y = layout.YM for i in range(5): x = layout.XM + i*w s.rows.append(self.RowStack_Class(x, y, self)) for i in range(2): y = y + layout.YS for j in (0, 1, 3, 4): x = layout.XM + j*w s.rows.append(self.RowStack_Class(x, y, self)) y = y + layout.YS for i in range(4): x = layout.XM + i*w s.rows.append(self.RowStack_Class(x, y, self)) for r in s.rows: r.CARD_XOFFSET = layout.XOFFSET r.CARD_YOFFSET = 0 x, y = layout.XM + 2*w, layout.YM + 3*layout.YS//2 s.foundations.append(BlackHole_Foundation(x, y, self, suit=ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=52)) layout.createText(s.foundations[0], "s") x, y = layout.XM + 4*w, self.height - layout.YS s.talon = InitialDealTalonStack(x, y, self) # define stack-groups layout.defaultStackGroups() # # game overrides # def _shuffleHook(self, cards): # move Ace to bottom of the Talon (i.e. last cards to be dealt) return self._shuffleHookMoveToBottom( cards, lambda c: (c.id == 13, c.suit), 1) def startGame(self): self._startDealNumRows(2) self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.foundations) def getAutoStacks(self, event=None): if event is None: # disable auto drop - this would ruin the whole gameplay return ((), (), self.sg.dropstacks) else: # rightclickHandler return ((), self.sg.dropstacks, self.sg.dropstacks)
class Golf(Game): Solver_Class = BlackHoleSolverWrapper(preset='golf', base_rank=0, queens_on_kings=True) Waste_Class = Golf_Waste Hint_Class = Golf_Hint # # game layout # def createGame(self, columns=7): # create layout layout, s = Layout(self), self.s # set window playcards = 5 w1, w2 = (columns + 1) * layout.XS + layout.XM, 2 * layout.XS totalcards = 52 * self.gameinfo.decks if w2 + totalcards * layout.XOFFSET > w1: layout.XOFFSET = int((w1 - w2) / totalcards) self.setSize(w1, layout.YM + 3 * layout.YS + (playcards - 1) * layout.YOFFSET + layout.TEXT_HEIGHT) # create stacks x, y = layout.XM + layout.XS // 2, layout.YM for i in range(columns): s.rows.append(Golf_RowStack(x, y, self)) x = x + layout.XS x, y = layout.XM, self.height - layout.YS s.talon = Golf_Talon(x, y, self, max_rounds=1) layout.createText(s.talon, "n") x = x + layout.XS s.waste = self.Waste_Class(x, y, self) s.waste.CARD_XOFFSET = layout.XOFFSET layout.createText(s.waste, "n") # the Waste is also our only Foundation in this game s.foundations.append(s.waste) # define stack-groups (non default) self.sg.openstacks = [s.waste] self.sg.talonstacks = [s.talon] self.sg.dropstacks = s.rows # # game overrides # def startGame(self, num_rows=5): self._startDealNumRows(num_rows - 1) self.s.talon.dealRow() self.s.talon.dealCards() # deal first card to WasteStack def isGameWon(self): for r in self.s.rows: if r.cards: return False return True shallHighlightMatch = Game._shallHighlightMatch_RK def getHighlightPilesStacks(self): return () def getAutoStacks(self, event=None): if event is None: # disable auto drop - this would ruin the whole gameplay return (self.sg.dropstacks, (), ()) else: # rightclickHandler return (self.sg.dropstacks, self.sg.dropstacks, ())