def dealCards(self, sound=True):
     # for demo-mode
     if self.demo:
         r = self.s.reserves[0]
         if r.canDealCards():
             # self.demo.last_deal = [] # don't check last deal
             return r.dealCards(sound=sound)
     return Game.dealCards(self, sound=sound)
Exemple #2
0
 def dealCards(self, sound=True):
     # for demo-mode
     if self.demo:
         r = self.s.reserves[0]
         if r.canDealCards():
             ##self.demo.last_deal = [] # don't check last deal
             return r.dealCards(sound=sound)
     return Game.dealCards(self, sound=sound)
Exemple #3
0
 def getWinStatus(self):
     won, status, updated = Game.getWinStatus(self)
     if status == 2:
         stacks = [r for r in self.s.rows if r.cards]
         assert len(stacks) == 1
         if stacks[0].id != self.EMPTY_STACK_ID:
             # not perfect
             return won, 1, self.U_WON
     return won, status, updated
Exemple #4
0
 def getWinStatus(self):
     won, status, updated = Game.getWinStatus(self)
     if status == 2:
         stacks = [r for r in self.s.rows if r.cards]
         assert len(stacks) == 1
         if stacks[0].id != self.EMPTY_STACK_ID:
             # not perfect
             return won, 1, self.U_WON
     return won, status, updated
Exemple #5
0
    def _highlightCards(self, info, sleep=1.5, delta=(1, 1, 1, 1)):
        if not Image:
            delta = (-self._delta_x, 0, 0, -self._delta_y)
            return Game._highlightCards(self, info, sleep=sleep, delta=delta)

        if not info:
            return 0
        if self.pause:
            return 0
        self.stopWinAnimation()
        items = []
        for s, c1, c2, color in info:
            assert c1 is c2
            assert c1 in s.cards
            tkraise = False
            x, y = s.x, s.y
            img = self.app.images.getHighlightedCard(c1.deck, c1.suit, c1.rank,
                                                     'black')
            if img is None:
                continue
            img = MfxCanvasImage(self.canvas,
                                 x,
                                 y,
                                 image=img,
                                 anchor=ANCHOR_NW,
                                 group=s.group)
            if self.drag.stack and s is self.drag.stack:
                img.tkraise(self.drag.shade_img)
            else:
                img.tkraise(c1.item)
            items.append(img)
        if not items:
            return 0
        self.canvas.update_idletasks()
        if sleep:
            self.sleep(sleep)
            items.reverse()
            for r in items:
                r.delete()
            self.canvas.update_idletasks()
            return EVENT_HANDLED
        else:
            # remove items later (find_card_dialog)
            return items
Exemple #6
0
    def _highlightCards(self, info, sleep=1.5, delta=(1,1,1,1)):
        if not Image:
            delta = (-self._delta_x, 0, 0, -self._delta_y)
            return Game._highlightCards(self, info, sleep=sleep, delta=delta)

        if not info:
            return 0
        if self.pause:
            return 0
        self.stopWinAnimation()
        items = []
        for s, c1, c2, color in info:
            assert c1 is c2
            assert c1 in s.cards
            tkraise = False
            x, y = s.x, s.y
            img = self.app.images.getHighlightCard(c1.deck, c1.suit, c1.rank)
            if img is None:
                continue
            img = MfxCanvasImage(self.canvas, x, y, image=img,
                                 anchor=ANCHOR_NW, group=s.group)
            if self.drag.stack and s is self.drag.stack:
                img.tkraise(self.drag.shade_img)
            else:
                img.tkraise(c1.item)
            items.append(img)
        if not items:
            return 0
        self.canvas.update_idletasks()
        if sleep:
            self.sleep(sleep)
            items.reverse()
            for r in items:
                r.delete()
            self.canvas.update_idletasks()
            return EVENT_HANDLED
        else:
            # remove items later (find_card_dialog)
            return items
Exemple #7
0
 def getQuickPlayScore(self, ncards, from_stack, to_stack):
     if to_stack in self.s.xwastes:
         return 0
     return 1 + Game.getQuickPlayScore(self, ncards, from_stack, to_stack)
Exemple #8
0
 def _createCard(self, id, deck, suit, rank, x, y):
     ##if deck >= 1 and suit == 3 and rank >= 4:
     if deck%4 and suit == 3 and rank >= 4:
         return None
     return Game._createCard(self, id, deck, suit, rank, x, y)
 def _createCard(self, id, deck, suit, rank, x, y):
     # if deck >= 1 and suit == 3 and rank >= 4:
     if deck % 4 and suit == 3 and rank >= 4:
         return None
     return Game._createCard(self, id, deck, suit, rank, x, y)
Exemple #10
0
 def getWinStatus(self):
     won, status, updated = Game.getWinStatus(self)
     if status == 2 and self.score < self.PERFECT_SCORE:
         return won, 1, self.U_WON
     return won, status, updated
Exemple #11
0
 def canDealCards(self):
     return Game.canDealCards(self)
Exemple #12
0
 def getWinStatus(self):
     won, status, updated = Game.getWinStatus(self)
     if status == 2 and self.score < self.PERFECT_SCORE:
         return won, 1, self.U_WON
     return won, status, updated
Exemple #13
0
 def getQuickPlayScore(self, ncards, from_stack, to_stack):
     if to_stack in self.s.xwastes:
         return 0
     return 1+Game.getQuickPlayScore(self, ncards, from_stack, to_stack)
Exemple #14
0
 def getAutoStacks(self, event=None):
     return Game.getAutoStacks(self, event)
Exemple #15
0
 def _shuffleHook(self, cards):
     return Game._shuffleHook(self, cards)
Exemple #16
0
 def _autoDeal(self, sound=True):
     # only autodeal if there are cards in the talon.
     if len(self.s.talon.cards) > 0:
         return Game._autoDeal(self, sound=sound)