mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-22 03:04:09 -04:00
Use min
/max
(#447)
This commit is contained in:
parent
441b13924f
commit
5bd941a5a4
7 changed files with 19 additions and 40 deletions
|
@ -267,9 +267,7 @@ class SlyFox_Talon(OpenTalonStack):
|
|||
old_state = self.game.enterState(self.game.S_FILL)
|
||||
self.game.saveStateMove(2 | 16) # for undo
|
||||
if old_state == self.game.S_PLAY and to_stack in self.game.s.rows:
|
||||
n = self.game.num_dealled
|
||||
if n < 0:
|
||||
n = 0
|
||||
n = max(self.game.num_dealled, 0)
|
||||
self.game.num_dealled = (n+1) % 20
|
||||
self.game.saveStateMove(1 | 16) # for redo
|
||||
self.game.leaveState(old_state)
|
||||
|
@ -359,9 +357,7 @@ class SlyFox(Game):
|
|||
def updateText(self):
|
||||
if self.preview > 1:
|
||||
return
|
||||
n = self.num_dealled
|
||||
if n < 0:
|
||||
n = 0
|
||||
n = max(self.num_dealled, 0)
|
||||
text = str(n)+'/20'
|
||||
self.texts.misc.config(text=text)
|
||||
|
||||
|
|
|
@ -407,10 +407,8 @@ class DashavataraCircles(AbstractDashavataraGame):
|
|||
for i in range(30):
|
||||
# FIXME:
|
||||
_x, _y = x+l.XS*x0[i], y+l.YS*y0[i]+l.YM*y0[i]*2
|
||||
if _x < 0:
|
||||
_x = 0
|
||||
if _y < 0:
|
||||
_y = 0
|
||||
_x = max(_x, 0)
|
||||
_y = max(_y, 0)
|
||||
s.rows.append(Circles_RowStack(_x, _y, self, base_rank=ANY_RANK))
|
||||
|
||||
# Create reserve stacks
|
||||
|
|
|
@ -305,10 +305,8 @@ class MughalCircles(AbstractMughalGame):
|
|||
for i in range(24):
|
||||
# FIXME:
|
||||
_x, _y = x+l.XS*x0[i]+l.XM*x0[i]*2, y+l.YS*y0[i]+l.YM*y0[i]*2
|
||||
if _x < 0:
|
||||
_x = 0
|
||||
if _y < 0:
|
||||
_y = 0
|
||||
_x = max(_x, 0)
|
||||
_y = max(_y, 0)
|
||||
s.rows.append(
|
||||
Circles_RowStack(_x, _y, self, base_rank=ANY_RANK, yoffset=0))
|
||||
|
||||
|
|
|
@ -115,8 +115,7 @@ class ThreePeaks(Game):
|
|||
# set window
|
||||
# compute best XOFFSET
|
||||
xoffset = int(l.XS * 8 / self.gameinfo.ncards)
|
||||
if xoffset < l.XOFFSET:
|
||||
l.XOFFSET = xoffset
|
||||
l.XOFFSET = min(l.XOFFSET, xoffset)
|
||||
|
||||
# Set window size
|
||||
w, h = l.XM + l.XS * 10, l.YM + l.YS * 4
|
||||
|
@ -353,8 +352,7 @@ class Ricochet(Game):
|
|||
# set window
|
||||
# compute best XOFFSET
|
||||
xoffset = int(l.XS * 8 / self.gameinfo.ncards)
|
||||
if xoffset < l.XOFFSET:
|
||||
l.XOFFSET = xoffset
|
||||
l.XOFFSET = min(l.XOFFSET, xoffset)
|
||||
|
||||
# Set window size
|
||||
w, h = l.XM + l.XS * 6, l.YM + l.YS * 6
|
||||
|
|
|
@ -514,14 +514,10 @@ class LLine(Widget, LBase):
|
|||
print('%s.%s' % (x, y))
|
||||
self.corePoly.append(x)
|
||||
self.corePoly.append(y)
|
||||
if x < xmin:
|
||||
xmin = x
|
||||
if x > xmax:
|
||||
xmax = x
|
||||
if y < ymin:
|
||||
ymin = y
|
||||
if y > ymax:
|
||||
ymax = y
|
||||
xmin = min(xmin, x)
|
||||
xmax = max(xmax, x)
|
||||
ymin = min(ymin, y)
|
||||
ymax = max(ymax, y)
|
||||
else:
|
||||
if ('width' in kw):
|
||||
lwidth = kw['width']
|
||||
|
@ -541,14 +537,10 @@ class LLine(Widget, LBase):
|
|||
y = args[2 * i + 1]
|
||||
self.corePoly.append(x)
|
||||
self.corePoly.append(y)
|
||||
if x < xmin:
|
||||
xmin = x
|
||||
if x > xmax:
|
||||
xmax = x
|
||||
if y < ymin:
|
||||
ymin = y
|
||||
if y > ymax:
|
||||
ymax = y
|
||||
xmin = min(xmin, x)
|
||||
xmax = max(xmax, x)
|
||||
ymin = min(ymin, y)
|
||||
ymax = max(ymax, y)
|
||||
|
||||
print('width = %s' % self.lwidth)
|
||||
print('color = %s' % self.fill)
|
||||
|
|
|
@ -109,8 +109,7 @@ class LPieChart(Widget):
|
|||
self.pos[1] + self.size[1] / 2.0)
|
||||
radius = (self.size[0] * 0.45)
|
||||
radius2 = (self.size[1] * 0.45)
|
||||
if (radius > radius2):
|
||||
radius = radius2
|
||||
radius = min(radius, radius2)
|
||||
|
||||
# Rectangle(pos=pos, size=size)
|
||||
Line(circle=(center[0], center[1], radius), width=2.0, close=True)
|
||||
|
|
|
@ -1316,10 +1316,8 @@ class Stack:
|
|||
# return cards under mouse
|
||||
dx = event.x - (x_offset+cw+sx) - game.canvas.xmargin
|
||||
dy = event.y - (y_offset+ch+sy) - game.canvas.ymargin
|
||||
if dx < 0:
|
||||
dx = 0
|
||||
if dy < 0:
|
||||
dy = 0
|
||||
dx = max(dx, 0)
|
||||
dy = max(dy, 0)
|
||||
for s in drag.shadows:
|
||||
if dx > 0 or dy > 0:
|
||||
s.move(dx, dy)
|
||||
|
|
Loading…
Add table
Reference in a new issue