Skip to content

Commit bfad115

Browse files
authored
Simplify logic in comparisons (#462)
1 parent 7f89547 commit bfad115

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

pysollib/game/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,8 +1893,7 @@ def _getClosestStack(self, cx, cy, stacks, dragstack):
18931893
def getClosestStack(self, card, dragstack):
18941894
cx, cy = card.x, card.y
18951895
for stacks, rect in self.regions.info:
1896-
if cx >= rect[0] and cx < rect[2] \
1897-
and cy >= rect[1] and cy < rect[3]:
1896+
if rect[0] <= cx < rect[2] and rect[1] <= cy < rect[3]:
18981897
return self._getClosestStack(cx, cy, stacks, dragstack)
18991898
return self._getClosestStack(cx, cy, self.regions.remaining, dragstack)
19001899

pysollib/games/larasgame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def createGame(self):
242242
for i in range(20):
243243
s.reserves.append(LarasGame_ReserveStack(x, y, self, max_cards=2))
244244
x += l.XS * (i < (ROW_LENGTH + 4)) - l.XS * (i == (ROW_LENGTH + 9))
245-
y = y - l.YS * (i > (ROW_LENGTH + 3) and i < (ROW_LENGTH + 9)) \
245+
y = y - l.YS * ((ROW_LENGTH + 3) < i < (ROW_LENGTH + 9)) \
246246
+ l.YS * (i > (ROW_LENGTH + 9))
247247

248248
# Create talon

pysollib/games/special/dashavatara.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(self, x, y, game, yoffset, **cap):
122122
def currentForce(self, card):
123123
force = self._getForce(card)
124124
hour = time.localtime(time.time())[3]
125-
if not (hour >= 7 and hour <= 19):
125+
if not (7 <= hour <= 19):
126126
force = not force
127127
return force
128128

pysollib/kivy/tkutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,13 @@ def _scaleTextureToSize(texture, size):
440440

441441
for bi in range(height):
442442
bline = bi * width
443-
if (bi >= offy) and (bi < (height - offy)):
443+
if offy <= bi < (height - offy):
444444
# transfer
445445
ai = gh - int((bi - offy) / scale) - 1
446446
aline = ai * gw
447447
for bk in range(width):
448448
bpos = (bline + bk) * 4
449-
if (bk >= offx) and (bk < (width - offx)):
449+
if offx <= bk < (width - offx):
450450
# transfer
451451
ak = int((bk - offx) / scale)
452452
apos = (aline + ak) * 4

pysollib/kivy/tkwidget.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ def _updatepos(self,instance,value):
436436
def collide_point(self,x,y):
437437
px,py = self.parent.pos
438438
sx,sy = self.parent.size
439-
if (px<=x and x<(px+sx) and py<=y and y<(py+sy)):
440-
return True
441-
return False
439+
return px <= x < px + sx and py <= y < py + sy
442440

443441
def on_touch_down(self, touch):
444442
ret = False

0 commit comments

Comments
 (0)