mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8 and other tests.
This commit is contained in:
parent
e0efb8a02c
commit
de93df2de7
26 changed files with 123 additions and 127 deletions
|
@ -58,7 +58,7 @@ from pysollib.pysoltk import SelectCardsetDialogWithPreview
|
|||
from pysollib.pysoltk import SelectDialogTreeData
|
||||
from pysollib.pysoltk import HTMLViewer
|
||||
from pysollib.pysoltk import destroy_find_card_dialog
|
||||
from pysollib.pysoltk import destroy_solver_dialog
|
||||
from pysollib.ui.tktile.solverdialog import destroy_solver_dialog
|
||||
|
||||
from pysollib.actions import PysolMenubar
|
||||
from pysollib.actions import PysolToolbar
|
||||
|
|
|
@ -52,7 +52,7 @@ from pysollib.pysoltk import after, after_idle, after_cancel
|
|||
from pysollib.pysoltk import MfxMessageDialog, MfxExceptionDialog
|
||||
from pysollib.pysoltk import MfxCanvasText, MfxCanvasLine, MfxCanvasRectangle
|
||||
from pysollib.pysoltk import Card
|
||||
from pysollib.pysoltk import reset_solver_dialog
|
||||
from pysollib.ui.tktile.solverdialog import reset_solver_dialog
|
||||
from pysollib.move import AMoveMove, AFlipMove, AFlipAndMoveMove
|
||||
from pysollib.move import ASingleFlipMove, ATurnStackMove
|
||||
from pysollib.move import ANextRoundMove, ASaveSeedMove, AShuffleStackMove
|
||||
|
|
|
@ -62,6 +62,7 @@ from pysollib.stack import \
|
|||
# * Flower Clock
|
||||
# ***********************************************************************/
|
||||
|
||||
|
||||
class FlowerClock(AbstractFlowerGame):
|
||||
|
||||
#
|
||||
|
@ -212,13 +213,13 @@ class Gaji(AbstractFlowerGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
if stack1 in self.s.foundations:
|
||||
return (card1.rank == card2.rank
|
||||
and ((((card1.suit + 1) % 12) == card2.suit)
|
||||
or (((card1.suit - 1) % 12) == card2.suit)))
|
||||
return (card1.rank == card2.rank and
|
||||
((((card1.suit + 1) % 12) == card2.suit) or
|
||||
(((card1.suit - 1) % 12) == card2.suit)))
|
||||
else:
|
||||
return ((card1.suit == card2.suit)
|
||||
and ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank)))
|
||||
return ((card1.suit == card2.suit) and
|
||||
((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank)))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -270,8 +271,8 @@ class Oonsoo(AbstractFlowerGame):
|
|||
if len(self.s.talon.cards):
|
||||
return 0
|
||||
for s in self.s.rows:
|
||||
if (len(s.cards) != 4 or not cardsFaceUp(s.cards)
|
||||
or not s.isHanafudaSequence(s.cards, self.Strictness)):
|
||||
if (len(s.cards) != 4 or not cardsFaceUp(s.cards) or
|
||||
not s.isHanafudaSequence(s.cards, self.Strictness)):
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
@ -557,12 +558,12 @@ class GreatWall(AbstractFlowerGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
if stack1 in self.s.foundations:
|
||||
return (card1.rank == card2.rank
|
||||
and ((((card1.suit + 1) % 12) == card2.suit)
|
||||
or (((card1.suit - 1) % 12) == card2.suit)))
|
||||
return (card1.rank == card2.rank and
|
||||
((((card1.suit + 1) % 12) == card2.suit) or
|
||||
(((card1.suit - 1) % 12) == card2.suit)))
|
||||
else:
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card1.rank - 1 == card2.rank)
|
||||
return (card1.rank + 1 == card2.rank or
|
||||
card1.rank - 1 == card2.rank)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -473,8 +473,7 @@ class HanafudaFourSeasons(AbstractFlowerGame):
|
|||
cards = r.cards
|
||||
if not len(cards) == 4:
|
||||
return 0
|
||||
if not (cards[0].suit == r.id
|
||||
and r.isHanafudaSequence(cards)):
|
||||
if not (cards[0].suit == r.id and r.isHanafudaSequence(cards)):
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
@ -617,8 +616,8 @@ class FlowerArrangement_TableauStack(Flower_OpenStack):
|
|||
return 0
|
||||
# check that the base card is correct
|
||||
suits = list(range(self.cap.mod, (self.cap.mod + 4)))
|
||||
if self.cards and (self.cards[0].rank == 3
|
||||
and self.cards[-1].suit in suits):
|
||||
if self.cards and (self.cards[0].rank == 3 and
|
||||
self.cards[-1].suit in suits):
|
||||
return self.isHanafudaSequence([self.cards[-1], cards[0]])
|
||||
return not self.cards and cards[0].rank == 3 and cards[0].suit in suits
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ class AbstractFlowerGame(Game):
|
|||
_("Chrysanthemum"), _("Maple"), _("Willow"), _("Paulownia"))
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.suit == card2.suit)
|
||||
and ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank)))
|
||||
return ((card1.suit == card2.suit) and
|
||||
((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank)))
|
||||
|
||||
|
||||
class Queue_Hint(DefaultHint):
|
||||
|
@ -139,8 +139,8 @@ class Gaji_Foundation(Flower_FoundationStack):
|
|||
if not self.basicAcceptsCards(from_stack, cards):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
return ((((stackcards[-1].suit + 1) % 12) == cards[0].suit)
|
||||
and (stackcards[-1].rank == cards[0].rank))
|
||||
return ((((stackcards[-1].suit + 1) % 12) == cards[0].suit) and
|
||||
(stackcards[-1].rank == cards[0].rank))
|
||||
|
||||
def getBottomImage(self):
|
||||
return self.game.app.images.getLetter(self.cap.base_rank)
|
||||
|
@ -199,8 +199,8 @@ class GreatWall_FoundationStack(Flower_FoundationStack):
|
|||
return 0
|
||||
stackcards = self.cards
|
||||
if stackcards:
|
||||
return ((stackcards[-1].suit + 1) % 12 == cards[0].suit
|
||||
and cards[0].rank == self.cap.base_rank)
|
||||
return ((stackcards[-1].suit + 1) % 12 == cards[0].suit and
|
||||
cards[0].rank == self.cap.base_rank)
|
||||
else:
|
||||
return cards[0].suit == 0
|
||||
|
||||
|
@ -322,9 +322,9 @@ class Gaji_RowStack(Flower_OpenStack):
|
|||
if not self.basicAcceptsCards(from_stack, cards):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if ((not len(stackcards))
|
||||
or ((stackcards[-1].suit == 10) and (stackcards[-1].rank == 3))
|
||||
or ((cards[0].suit == 10) and (cards[0].rank == 3))):
|
||||
if ((not len(stackcards)) or
|
||||
((stackcards[-1].suit == 10) and (stackcards[-1].rank == 3)) or
|
||||
((cards[0].suit == 10) and (cards[0].rank == 3))):
|
||||
return 1
|
||||
elif stackcards[-1].suit != cards[0].suit:
|
||||
return 0
|
||||
|
@ -445,8 +445,8 @@ class Queue_ReserveStack(ReserveStack):
|
|||
class JapaneseGarden_RowStack(Flower_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or from_stack not in self.game.s.rows):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
from_stack not in self.game.s.rows):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if not len(stackcards):
|
||||
|
@ -457,8 +457,8 @@ class JapaneseGarden_RowStack(Flower_OpenStack):
|
|||
class HanafudaRK_RowStack(Flower_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not isRankSequence(cards, dir=1)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not isRankSequence(cards, dir=1)):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if not len(stackcards):
|
||||
|
|
|
@ -114,8 +114,8 @@ class HexADeck_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if (c1.color < 2 and c1.color == c2.color
|
||||
or not c1.rank + dir == c2.rank):
|
||||
if (c1.color < 2 and c1.color == c2.color or
|
||||
not c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -125,9 +125,8 @@ class HexADeck_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not ((c1.color == 2 or c2.color == 2
|
||||
or c1.suit == c2.suit)
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not ((c1.color == 2 or c2.color == 2 or c1.suit == c2.suit) and
|
||||
c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -136,46 +135,44 @@ class HexADeck_OpenStack(OpenStack):
|
|||
class HexADeck_RK_RowStack(HexADeck_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isRankSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isRankSequence(cards)):
|
||||
return 0
|
||||
if not self.cards:
|
||||
return cards[0].rank == 15 or self.cap.base_rank == ANY_RANK
|
||||
return self.isRankSequence([self.cards[-1], cards[0]])
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
return (self.basicCanMoveCards(cards)
|
||||
and self.isRankSequence(cards))
|
||||
return (self.basicCanMoveCards(cards) and self.isRankSequence(cards))
|
||||
|
||||
|
||||
class HexADeck_AC_RowStack(HexADeck_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isAlternateColorSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isAlternateColorSequence(cards)):
|
||||
return 0
|
||||
if not self.cards:
|
||||
return cards[0].rank == 15 or self.cap.base_rank == ANY_RANK
|
||||
return self.isAlternateColorSequence([self.cards[-1], cards[0]])
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
return (self.basicCanMoveCards(cards)
|
||||
and self.isAlternateColorSequence(cards))
|
||||
return (self.basicCanMoveCards(cards) and
|
||||
self.isAlternateColorSequence(cards))
|
||||
|
||||
|
||||
class HexADeck_SS_RowStack(HexADeck_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isSuitSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isSuitSequence(cards)):
|
||||
return 0
|
||||
if not self.cards:
|
||||
return cards[0].rank == 15 or self.cap.base_rank == ANY_RANK
|
||||
return self.isSuitSequence([self.cards[-1], cards[0]])
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
return (self.basicCanMoveCards(cards)
|
||||
and self.isSuitSequence(cards))
|
||||
return (self.basicCanMoveCards(cards) and self.isSuitSequence(cards))
|
||||
|
||||
|
||||
class Bits_RowStack(ReserveStack):
|
||||
|
@ -190,8 +187,8 @@ class Bits_RowStack(ReserveStack):
|
|||
for r in self.game.s.rows[i * 4:self.id]:
|
||||
if not r.cards:
|
||||
return 0
|
||||
return ((self.game.s.foundations[i].cards[-1].rank + 1
|
||||
>> (self.id % 4)) % 2 == (cards[0].rank + 1) % 2)
|
||||
return ((self.game.s.foundations[i].cards[-1].rank + 1 >>
|
||||
(self.id % 4)) % 2 == (cards[0].rank + 1) % 2)
|
||||
|
||||
|
||||
class Bytes_RowStack(ReserveStack):
|
||||
|
|
|
@ -197,8 +197,8 @@ class Matrix3(Game):
|
|||
return 1
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank))
|
||||
return ((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -116,8 +116,7 @@ class Mughal_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not ((c1.suit + c2.suit) % 2
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not ((c1.suit + c2.suit) % 2 and c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -127,9 +126,9 @@ class Mughal_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not ((c1.suit < 4 and c2.suit > 3
|
||||
or c1.suit > 3 and c2.suit < 4)
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not ((c1.suit < 4 and c2.suit > 3 or
|
||||
c1.suit > 3 and c2.suit < 4) and
|
||||
c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -139,8 +138,7 @@ class Mughal_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not (c1.suit == c2.suit
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not (c1.suit == c2.suit and c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -149,8 +147,8 @@ class Mughal_OpenStack(OpenStack):
|
|||
class Mughal_AC_RowStack(Mughal_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isAlternateColorSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isAlternateColorSequence(cards)):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if not len(stackcards):
|
||||
|
@ -161,8 +159,8 @@ class Mughal_AC_RowStack(Mughal_OpenStack):
|
|||
class Mughal_AF_RowStack(Mughal_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isAlternateForceSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isAlternateForceSequence(cards)):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if not len(stackcards):
|
||||
|
@ -173,8 +171,8 @@ class Mughal_AF_RowStack(Mughal_OpenStack):
|
|||
class Mughal_RK_RowStack(Mughal_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isRankSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isRankSequence(cards)):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if not len(stackcards):
|
||||
|
@ -185,8 +183,8 @@ class Mughal_RK_RowStack(Mughal_OpenStack):
|
|||
class Mughal_SS_RowStack(Mughal_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isSuitSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isSuitSequence(cards)):
|
||||
return 0
|
||||
stackcards = self.cards
|
||||
if not len(stackcards):
|
||||
|
@ -273,8 +271,7 @@ class AbstractMughalGame(Game):
|
|||
pass
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank)
|
||||
return (card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank)
|
||||
|
||||
|
||||
class Triumph_Hint(DefaultHint):
|
||||
|
@ -367,9 +364,9 @@ class MughalCircles(AbstractMughalGame):
|
|||
self.s.talon.dealCards()
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.suit == card2.suit)
|
||||
and ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank)))
|
||||
return ((card1.suit == card2.suit) and
|
||||
((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank)))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -532,9 +529,9 @@ class Ghulam(Shamsher):
|
|||
Shamsher.createGame(self)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.suit == card2.suit)
|
||||
and ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank)))
|
||||
return ((card1.suit == card2.suit) and
|
||||
((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank)))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -612,9 +609,9 @@ class Ashwapati(Tipati):
|
|||
Tipati.createGame(self, max_rounds=-1, num_deal=1)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.suit == card2.suit)
|
||||
and ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank)))
|
||||
return ((card1.suit == card2.suit) and
|
||||
((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank)))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -634,9 +631,9 @@ class Gajapati(Tipati):
|
|||
Tipati.createGame(self, max_rounds=-1, num_deal=3)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.suit == card2.suit)
|
||||
and ((card1.rank + 1 == card2.rank)
|
||||
or (card1.rank - 1 == card2.rank)))
|
||||
return ((card1.suit == card2.suit) and
|
||||
((card1.rank + 1 == card2.rank) or
|
||||
(card1.rank - 1 == card2.rank)))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -1003,8 +1000,8 @@ class Dikapala_ReserveStack(ReserveStack):
|
|||
OpenStack.__init__(self, x, y, game, **cap)
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
return (ReserveStack.acceptsCards(self, from_stack, cards)
|
||||
and self.game.s.talon.cards)
|
||||
return (ReserveStack.acceptsCards(self, from_stack, cards) and
|
||||
self.game.s.talon.cards)
|
||||
|
||||
|
||||
class Dikapala_RowStack(BasicRowStack):
|
||||
|
|
|
@ -71,8 +71,8 @@ class Tarock_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if (c1.color < 2 and c1.color == c2.color
|
||||
or not c1.rank + dir == c2.rank):
|
||||
if (c1.color < 2 and c1.color == c2.color or
|
||||
not c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -82,8 +82,7 @@ class Tarock_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not (c1.suit == c2.suit
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not (c1.suit == c2.suit and c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -98,31 +97,29 @@ class Tarock_OpenStack(OpenStack):
|
|||
class Tarock_RK_RowStack(Tarock_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isRankSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isRankSequence(cards)):
|
||||
return 0
|
||||
if not self.cards:
|
||||
return self.isHighRankCard(cards[0])
|
||||
return self.isRankSequence([self.cards[-1], cards[0]])
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
return (self.basicCanMoveCards(cards)
|
||||
and self.isRankSequence(cards))
|
||||
return (self.basicCanMoveCards(cards) and self.isRankSequence(cards))
|
||||
|
||||
|
||||
class Tarock_SS_RowStack(Tarock_OpenStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if (not self.basicAcceptsCards(from_stack, cards)
|
||||
or not self.isSuitSequence(cards)):
|
||||
if (not self.basicAcceptsCards(from_stack, cards) or
|
||||
not self.isSuitSequence(cards)):
|
||||
return 0
|
||||
if not self.cards:
|
||||
return self.isHighRankCard(cards[0])
|
||||
return self.isSuitSequence([self.cards[-1], cards[0]])
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
return (self.basicCanMoveCards(cards)
|
||||
and self.isSuitSequence(cards))
|
||||
return (self.basicCanMoveCards(cards) and self.isSuitSequence(cards))
|
||||
|
||||
|
||||
class Tarock_AC_RowStack(Tarock_OpenStack):
|
||||
|
@ -136,8 +133,8 @@ class Tarock_AC_RowStack(Tarock_OpenStack):
|
|||
return self.isAlternateColorSequence([self.cards[-1], cards[0]])
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
return (self.basicCanMoveCards(cards)
|
||||
and self.isAlternateColorSequence(cards))
|
||||
return (self.basicCanMoveCards(cards) and
|
||||
self.isAlternateColorSequence(cards))
|
||||
|
||||
# ************************************************************************
|
||||
# *
|
||||
|
|
|
@ -111,10 +111,10 @@ class FontsDialog:
|
|||
fd = pango.FontDescription(font)
|
||||
family = fd.get_family()
|
||||
size = fd.get_size()/pango.SCALE
|
||||
style = (fd.get_style() == pango.STYLE_NORMAL
|
||||
and 'roman' or 'italic')
|
||||
weight = (fd.get_weight() == pango.WEIGHT_NORMAL
|
||||
and 'normal' or 'bold')
|
||||
style = ('roman' if fd.get_style() == pango.STYLE_NORMAL
|
||||
else 'italic')
|
||||
weight = ('normal' if fd.get_weight() == pango.WEIGHT_NORMAL
|
||||
else 'bold')
|
||||
font = (family, size, style, weight)
|
||||
self._setFont(name, font)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#
|
||||
# ---------------------------------------------------------------------------##
|
||||
|
||||
|
||||
def create_solver_dialog(parent, game):
|
||||
pass
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ class PysolToolbarTk:
|
|||
#
|
||||
|
||||
def _busy(self):
|
||||
return not (self.side and self.game and not self.game.busy
|
||||
and self.menubar)
|
||||
return not (self.side and self.game and not self.game.busy and
|
||||
self.menubar)
|
||||
|
||||
def destroy(self):
|
||||
self.toolbar.destroy()
|
||||
|
|
|
@ -126,7 +126,7 @@ class ResourceManager:
|
|||
dir = os.path.normpath(dir)
|
||||
if dir and os.path.isdir(dir) and dir not in result:
|
||||
result.append(dir)
|
||||
except EnvironmentError as ex:
|
||||
except EnvironmentError:
|
||||
pass
|
||||
|
||||
def getSearchDirs(self, app, search, env=None):
|
||||
|
@ -153,7 +153,7 @@ class ResourceManager:
|
|||
self._addDir(result, d)
|
||||
else:
|
||||
self._addDir(result, os.path.join(dir, s))
|
||||
except EnvironmentError as ex:
|
||||
except EnvironmentError:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
if DEBUG >= 6:
|
||||
|
|
|
@ -2275,8 +2275,8 @@ class SS_FoundationStack(AbstractFoundationStack):
|
|||
return False
|
||||
if self.cards:
|
||||
# check the rank
|
||||
if ((self.cards[-1].rank + self.cap.dir) % self.cap.mod
|
||||
!= cards[0].rank):
|
||||
if ((self.cards[-1].rank + self.cap.dir) % self.cap.mod !=
|
||||
cards[0].rank):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -2603,8 +2603,8 @@ class Yukon_AC_RowStack(BasicRowStack):
|
|||
BasicRowStack.__init__(self, x, y, game, **cap)
|
||||
|
||||
def _isSequence(self, c1, c2):
|
||||
return ((c1.rank + self.cap.dir) % self.cap.mod == c2.rank
|
||||
and c1.color != c2.color)
|
||||
return ((c1.rank + self.cap.dir) % self.cap.mod == c2.rank and
|
||||
c1.color != c2.color)
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not self.basicAcceptsCards(from_stack, cards):
|
||||
|
@ -2633,8 +2633,8 @@ class Yukon_AC_RowStack(BasicRowStack):
|
|||
# but can move any face-up cards regardless of sequence.
|
||||
class Yukon_SS_RowStack(Yukon_AC_RowStack):
|
||||
def _isSequence(self, c1, c2):
|
||||
return ((c1.rank + self.cap.dir) % self.cap.mod == c2.rank
|
||||
and c1.suit == c2.suit)
|
||||
return ((c1.rank + self.cap.dir) % self.cap.mod == c2.rank and
|
||||
c1.suit == c2.suit)
|
||||
|
||||
def getHelp(self):
|
||||
if self.cap.dir > 0:
|
||||
|
|
|
@ -36,7 +36,7 @@ from .soundoptionsdialog import SoundOptionsDialog
|
|||
from .selecttile import SelectTileDialogWithPreview
|
||||
from pysollib.ui.tktile.findcarddialog import connect_game_find_card_dialog, \
|
||||
destroy_find_card_dialog
|
||||
from .solverdialog import connect_game_solver_dialog
|
||||
from pysollib.ui.tktile.solverdialog import connect_game_solver_dialog
|
||||
|
||||
from pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon
|
||||
# ************************************************************************
|
||||
|
|
|
@ -36,8 +36,9 @@ from pysollib.resource import CSI
|
|||
from pysollib.ui.tktile.tkutil import loadImage
|
||||
from .tkwidget import MfxDialog, MfxScrolledCanvas, PysolScale
|
||||
from pysollib.ui.tktile.tkcanvas import MfxCanvasImage
|
||||
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
|
||||
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
|
||||
from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
|
||||
from .selecttree import SelectDialogTreeCanvas
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -36,9 +36,10 @@ from pysollib.resource import CSI
|
|||
|
||||
# Toolkit imports
|
||||
from pysollib.ui.tktile.tkutil import unbind_destroy
|
||||
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
|
||||
from .tkwidget import MfxDialog, MfxScrolledCanvas
|
||||
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
|
||||
from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
|
||||
from .selecttree import SelectDialogTreeCanvas
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -33,9 +33,10 @@ from pysollib.mygettext import _
|
|||
from pysollib.mfxutil import KwStruct
|
||||
|
||||
# Toolkit imports
|
||||
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
|
||||
from .tkwidget import MfxDialog, MfxScrolledCanvas
|
||||
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
|
||||
from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
|
||||
from .selecttree import SelectDialogTreeCanvas
|
||||
|
||||
|
||||
if sys.version_info > (3,):
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
from .tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas
|
||||
|
||||
from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, \
|
||||
BaseSelectDialogTreeNode, SelectDialogTreeData, \
|
||||
BaseSelectDialogTreeCanvas
|
||||
BaseSelectDialogTreeNode, BaseSelectDialogTreeCanvas
|
||||
|
||||
# ************************************************************************
|
||||
# * Nodes
|
||||
|
|
|
@ -31,8 +31,7 @@ from pysollib.mfxutil import KwStruct
|
|||
from pysollib.tile.basetilemfxdialog import BaseTileMfxDialog
|
||||
from .tkwidget import PysolCombo
|
||||
from pysollib.ui.tktile.solverdialog import BaseSolverDialog, \
|
||||
connect_game_solver_dialog, destroy_solver_dialog, solver_dialog, \
|
||||
reset_solver_dialog
|
||||
solver_dialog
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -36,7 +36,7 @@ from .selectcardset import SelectCardsetDialogWithPreview
|
|||
from .selecttile import SelectTileDialogWithPreview
|
||||
from pysollib.ui.tktile.findcarddialog import connect_game_find_card_dialog, \
|
||||
destroy_find_card_dialog
|
||||
from .solverdialog import connect_game_solver_dialog
|
||||
from pysollib.ui.tktile.solverdialog import connect_game_solver_dialog
|
||||
|
||||
from pysollib.ui.tktile.menubar import PysolMenubarTkCommon
|
||||
# ************************************************************************
|
||||
|
|
|
@ -36,7 +36,8 @@ from pysollib.ui.tktile.tkutil import loadImage
|
|||
from .tkwidget import MfxDialog, MfxScrolledCanvas
|
||||
from pysollib.ui.tktile.tkcanvas import MfxCanvasImage
|
||||
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
|
||||
from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
|
||||
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
|
||||
from .selecttree import SelectDialogTreeCanvas
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -39,7 +39,8 @@ from pysollib.resource import CSI
|
|||
from pysollib.ui.tktile.tkutil import unbind_destroy
|
||||
from .tkwidget import MfxDialog, MfxScrolledCanvas
|
||||
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
|
||||
from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
|
||||
from .selecttree import SelectDialogTreeCanvas
|
||||
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -33,7 +33,8 @@ from pysollib.mfxutil import KwStruct
|
|||
# Toolkit imports
|
||||
from .tkwidget import MfxDialog, MfxScrolledCanvas
|
||||
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
|
||||
from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas
|
||||
from .selecttree import SelectDialogTreeCanvas
|
||||
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
|
||||
|
||||
|
||||
if sys.version_info > (3,):
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
from .tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas
|
||||
|
||||
from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, \
|
||||
BaseSelectDialogTreeNode, SelectDialogTreeData, \
|
||||
BaseSelectDialogTreeCanvas
|
||||
BaseSelectDialogTreeNode, BaseSelectDialogTreeCanvas
|
||||
|
||||
# ************************************************************************
|
||||
# * Nodes
|
||||
|
|
|
@ -20,6 +20,7 @@ my %skip = (
|
|||
pysollib/games/special/__init__.py
|
||||
pysollib/games/ultra/__init__.py
|
||||
pysollib/htmllib2.py
|
||||
pysollib/mfxutil.py
|
||||
pysollib/pysoltk.py
|
||||
pysollib/tile/ttk.py
|
||||
pysollib/ui/tktile/Canvas2.py
|
||||
|
|
Loading…
Add table
Reference in a new issue