mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-15 02:54:09 -04:00
Refactoring: extract a closure.
This commit is contained in:
parent
58f458f58a
commit
bc25ff5574
1 changed files with 8 additions and 14 deletions
|
@ -857,27 +857,21 @@ class Game(object):
|
||||||
if progress:
|
if progress:
|
||||||
pstep = (100.0 - progress.percent) / gi.ncards
|
pstep = (100.0 - progress.percent) / gi.ncards
|
||||||
cards = []
|
cards = []
|
||||||
id = 0
|
id = [0]
|
||||||
x, y = self.s.talon.x, self.s.talon.y
|
x, y = self.s.talon.x, self.s.talon.y
|
||||||
for deck in range(gi.decks):
|
for deck in range(gi.decks):
|
||||||
|
def _iter_ranks(ranks, suit):
|
||||||
|
for rank in ranks:
|
||||||
|
card = self._createCard(id[0], deck, suit, rank, x=x, y=y)
|
||||||
|
if card is None:
|
||||||
|
continue
|
||||||
|
cards.append(card)
|
||||||
|
id[0] += 1
|
||||||
|
if progress:
|
||||||
|
progress.update(step=pstep)
|
||||||
for suit in gi.suits:
|
for suit in gi.suits:
|
||||||
for rank in gi.ranks:
|
_iter_ranks(gi.ranks, suit)
|
||||||
card = self._createCard(id, deck, suit, rank, x=x, y=y)
|
_iter_ranks(gi.trumps, len(gi.suits))
|
||||||
if card is None:
|
|
||||||
continue
|
|
||||||
cards.append(card)
|
|
||||||
id = id + 1
|
|
||||||
if progress:
|
|
||||||
progress.update(step=pstep)
|
|
||||||
trump_suit = len(gi.suits)
|
|
||||||
for rank in gi.trumps:
|
|
||||||
card = self._createCard(id, deck, trump_suit, rank, x=x, y=y)
|
|
||||||
if card is None:
|
|
||||||
continue
|
|
||||||
cards.append(card)
|
|
||||||
id = id + 1
|
|
||||||
if progress:
|
|
||||||
progress.update(step=pstep)
|
|
||||||
if progress:
|
if progress:
|
||||||
progress.update(percent=100)
|
progress.update(percent=100)
|
||||||
assert len(cards) == gi.ncards
|
assert len(cards) == gi.ncards
|
||||||
|
|
Loading…
Add table
Reference in a new issue