mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Actually, *this* fixes the last bug.
This commit is contained in:
parent
1b2b53a25d
commit
a0dc1c4a61
1 changed files with 7 additions and 2 deletions
|
@ -446,6 +446,9 @@ def randperm(n):
|
||||||
|
|
||||||
class OpenStack(Stack):
|
class OpenStack(Stack):
|
||||||
|
|
||||||
|
def acceptable(self, cards):
|
||||||
|
return 0
|
||||||
|
|
||||||
def usermovehandler(self, cards):
|
def usermovehandler(self, cards):
|
||||||
card = cards[0]
|
card = cards[0]
|
||||||
stack = self.game.closeststack(card)
|
stack = self.game.closeststack(card)
|
||||||
|
@ -561,6 +564,8 @@ class Solitaire:
|
||||||
for i in range(NROWS):
|
for i in range(NROWS):
|
||||||
self.rows.append(RowStack(x, y, self))
|
self.rows.append(RowStack(x, y, self))
|
||||||
x = x + XSPACING
|
x = x + XSPACING
|
||||||
|
|
||||||
|
self.openstacks = [self.opendeck] + self.suits + self.rows
|
||||||
|
|
||||||
self.deck.fill()
|
self.deck.fill()
|
||||||
self.deal()
|
self.deal()
|
||||||
|
@ -591,7 +596,7 @@ class Solitaire:
|
||||||
cdist = 999999999
|
cdist = 999999999
|
||||||
# Since we only compare distances,
|
# Since we only compare distances,
|
||||||
# we don't bother to take the square root.
|
# we don't bother to take the square root.
|
||||||
for stack in self.rows + self.suits:
|
for stack in self.openstacks:
|
||||||
dist = (stack.x - card.x)**2 + (stack.y - card.y)**2
|
dist = (stack.x - card.x)**2 + (stack.y - card.y)**2
|
||||||
if dist < cdist:
|
if dist < cdist:
|
||||||
closest = stack
|
closest = stack
|
||||||
|
@ -609,7 +614,7 @@ class Solitaire:
|
||||||
r.showtop()
|
r.showtop()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
for stack in [self.opendeck] + self.suits + self.rows:
|
for stack in self.openstacks:
|
||||||
while 1:
|
while 1:
|
||||||
card = stack.deal()
|
card = stack.deal()
|
||||||
if not card:
|
if not card:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue