mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-22 03:04:09 -04:00
Simplify loops (#448)
This commit is contained in:
parent
5bd941a5a4
commit
8434ca1d22
3 changed files with 5 additions and 8 deletions
|
@ -885,7 +885,7 @@ class Game(object):
|
||||||
assert len(self.allstacks) == len(game.loadinfo.stacks)
|
assert len(self.allstacks) == len(game.loadinfo.stacks)
|
||||||
old_state = game.moves.state
|
old_state = game.moves.state
|
||||||
game.moves.state = self.S_RESTORE
|
game.moves.state = self.S_RESTORE
|
||||||
for i in range(len(self.allstacks)):
|
for i, cur_stack in enumerate(self.allstacks):
|
||||||
for t in game.loadinfo.stacks[i]:
|
for t in game.loadinfo.stacks[i]:
|
||||||
card_id, face_up = t
|
card_id, face_up = t
|
||||||
card = self.cards[card_id]
|
card = self.cards[card_id]
|
||||||
|
@ -893,7 +893,7 @@ class Game(object):
|
||||||
card.showFace()
|
card.showFace()
|
||||||
else:
|
else:
|
||||||
card.showBack()
|
card.showBack()
|
||||||
self.allstacks[i].addCard(card)
|
cur_stack.addCard(card)
|
||||||
game.moves.state = old_state
|
game.moves.state = old_state
|
||||||
# 4) update settings
|
# 4) update settings
|
||||||
for stack_id, cap in self.saveinfo.stack_caps:
|
for stack_id, cap in self.saveinfo.stack_caps:
|
||||||
|
@ -1106,9 +1106,8 @@ class Game(object):
|
||||||
x, y = int(round((init_coord[0] + cw) * xf)), \
|
x, y = int(round((init_coord[0] + cw) * xf)), \
|
||||||
int(round((init_coord[1] + ch) * yf))
|
int(round((init_coord[1] + ch) * yf))
|
||||||
self.canvas.coords(item, x, y)
|
self.canvas.coords(item, x, y)
|
||||||
for i in range(len(self.texts.list)):
|
for i, item in enumerate(self.texts.list):
|
||||||
init_coord = self.init_texts.list[i]
|
init_coord = self.init_texts.list[i]
|
||||||
item = self.texts.list[i]
|
|
||||||
x, y = int(round((init_coord[0] + cw) * xf)), \
|
x, y = int(round((init_coord[0] + cw) * xf)), \
|
||||||
int(round((init_coord[1] + ch) * yf))
|
int(round((init_coord[1] + ch) * yf))
|
||||||
self.canvas.coords(item, x, y)
|
self.canvas.coords(item, x, y)
|
||||||
|
|
|
@ -1880,8 +1880,7 @@ class PysolMenubarTk:
|
||||||
short_name=False):
|
short_name=False):
|
||||||
|
|
||||||
# cb = self.__cb_max
|
# cb = self.__cb_max
|
||||||
for i in range(len(games)):
|
for gi in games:
|
||||||
gi = games[i]
|
|
||||||
# columnbreak = i > 0 and (i % cb) == 0
|
# columnbreak = i > 0 and (i % cb) == 0
|
||||||
if short_name:
|
if short_name:
|
||||||
label = gi.short_name
|
label = gi.short_name
|
||||||
|
|
|
@ -493,8 +493,7 @@ class Stack:
|
||||||
images = self.game.app.images
|
images = self.game.app.images
|
||||||
cw, ch = images.getSize()
|
cw, ch = images.getSize()
|
||||||
index = -1
|
index = -1
|
||||||
for i in range(len(cards)):
|
for i, c in enumerate(cards):
|
||||||
c = cards[i]
|
|
||||||
r = (c.x, c.y, c.x + cw, c.y + ch)
|
r = (c.x, c.y, c.x + cw, c.y + ch)
|
||||||
if r[0] <= x < r[2] and r[1] <= y < r[3]:
|
if r[0] <= x < r[2] and r[1] <= y < r[3]:
|
||||||
index = i
|
index = i
|
||||||
|
|
Loading…
Add table
Reference in a new issue