mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Refactoring
This commit is contained in:
parent
24a927311c
commit
c826799736
2 changed files with 9 additions and 17 deletions
|
@ -1451,7 +1451,7 @@ Please select a %s type %s.
|
||||||
# find all available cardsets
|
# find all available cardsets
|
||||||
dirs = manager.getSearchDirs(self, ("cardsets", ""), "PYSOL_CARDSETS")
|
dirs = manager.getSearchDirs(self, ("cardsets", ""), "PYSOL_CARDSETS")
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
dirs = dirs + manager.getSearchDirs(self, "cardsets-*")
|
dirs += manager.getSearchDirs(self, "cardsets-*")
|
||||||
# print dirs
|
# print dirs
|
||||||
found, t = [], {}
|
found, t = [], {}
|
||||||
fnames = {} # (to check for duplicates)
|
fnames = {} # (to check for duplicates)
|
||||||
|
|
|
@ -525,32 +525,24 @@ class Stack:
|
||||||
mylen = len(cards)
|
mylen = len(cards)
|
||||||
if mylen < cap.min_accept or mylen > cap.max_accept:
|
if mylen < cap.min_accept or mylen > cap.max_accept:
|
||||||
return False
|
return False
|
||||||
mylen = mylen + len(self.cards)
|
mylen += len(self.cards)
|
||||||
# note: we don't check cap.min_cards here
|
# note: we don't check cap.min_cards here
|
||||||
if mylen > cap.max_cards:
|
if mylen > cap.max_cards:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _check(c):
|
||||||
|
return ((cap.suit >= 0 and c.suit != cap.suit) or
|
||||||
|
(cap.color >= 0 and c.color != cap.color) or
|
||||||
|
(cap.rank >= 0 and c.rank != cap.rank))
|
||||||
for c in cards:
|
for c in cards:
|
||||||
if not c.face_up:
|
if not c.face_up or _check(c):
|
||||||
return False
|
|
||||||
if cap.suit >= 0 and c.suit != cap.suit:
|
|
||||||
return False
|
|
||||||
if cap.color >= 0 and c.color != cap.color:
|
|
||||||
return False
|
|
||||||
if cap.rank >= 0 and c.rank != cap.rank:
|
|
||||||
return False
|
return False
|
||||||
if self.cards:
|
if self.cards:
|
||||||
# top card of our stack must be face up
|
# top card of our stack must be face up
|
||||||
return self.cards[-1].face_up
|
return self.cards[-1].face_up
|
||||||
else:
|
else:
|
||||||
# check required base
|
# check required base
|
||||||
c = cards[0]
|
return not _check(cards[0])
|
||||||
if cap.base_suit >= 0 and c.suit != cap.base_suit:
|
|
||||||
return False
|
|
||||||
if cap.base_color >= 0 and c.color != cap.base_color:
|
|
||||||
return False
|
|
||||||
if cap.base_rank >= 0 and c.rank != cap.base_rank:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def basicCanMoveCards(self, cards):
|
def basicCanMoveCards(self, cards):
|
||||||
# Check that the limits are ok and the cards are face up
|
# Check that the limits are ok and the cards are face up
|
||||||
|
|
Loading…
Add table
Reference in a new issue