From dbdd0f392c8a45c499bbbd17a0f36bf3257f25bb Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 11 Jul 2017 19:49:44 +0300 Subject: [PATCH] division sanity --- pysollib/game.py | 30 ++++++++++----------- pysollib/games/acesup.py | 10 +++---- pysollib/games/algerian.py | 8 +++--- pysollib/games/auldlangsyne.py | 4 +-- pysollib/games/bakersgame.py | 18 ++++++------- pysollib/games/beleagueredcastle.py | 20 +++++++------- pysollib/games/bisley.py | 12 ++++----- pysollib/games/braid.py | 22 +++++++-------- pysollib/games/bristol.py | 8 +++--- pysollib/games/calculation.py | 14 +++++----- pysollib/games/camelot.py | 2 +- pysollib/games/canfield.py | 10 +++---- pysollib/games/capricieuse.py | 9 ++++--- pysollib/games/curdsandwhey.py | 2 +- pysollib/games/daddylonglegs.py | 2 +- pysollib/games/dieboesesieben.py | 6 ++--- pysollib/games/doublets.py | 8 +++--- pysollib/games/eiffeltower.py | 2 +- pysollib/games/fan.py | 10 +++---- pysollib/games/fortythieves.py | 30 ++++++++++----------- pysollib/games/freecell.py | 4 +-- pysollib/games/glenwood.py | 4 +-- pysollib/games/golf.py | 32 +++++++++++----------- pysollib/games/grandduchess.py | 4 +-- pysollib/games/grandfathersclock.py | 12 ++++----- pysollib/games/gypsy.py | 12 ++++----- pysollib/games/harp.py | 4 +-- pysollib/games/headsandtails.py | 16 +++++------ pysollib/games/katzenschwanz.py | 22 +++++++-------- pysollib/games/klondike.py | 18 ++++++------- pysollib/games/larasgame.py | 4 +-- pysollib/games/mahjongg/mahjongg.py | 16 +++++------ pysollib/games/matriarchy.py | 18 ++++++------- pysollib/games/montana.py | 4 +-- pysollib/games/montecarlo.py | 4 +-- pysollib/games/napoleon.py | 14 +++++----- pysollib/games/needle.py | 4 +-- pysollib/games/numerica.py | 28 +++++++++---------- pysollib/games/osmosis.py | 2 +- pysollib/games/parallels.py | 4 +-- pysollib/games/pasdedeux.py | 12 ++++----- pysollib/games/picturegallery.py | 20 +++++++------- pysollib/games/pileon.py | 4 +-- pysollib/games/pyramid.py | 24 ++++++++--------- pysollib/games/royalcotillion.py | 18 ++++++------- pysollib/games/royaleast.py | 6 ++--- pysollib/games/simplex.py | 2 +- pysollib/games/special/memory.py | 2 +- pysollib/games/special/pegged.py | 8 +++--- pysollib/games/special/tarock.py | 11 ++++---- pysollib/games/spider.py | 10 +++---- pysollib/games/sultan.py | 36 ++++++++++++------------- pysollib/games/terrace.py | 2 +- pysollib/games/tournament.py | 4 +-- pysollib/games/ultra/dashavatara.py | 26 +++++++++--------- pysollib/games/ultra/hanafuda.py | 27 ++++++++++--------- pysollib/games/ultra/hanafuda1.py | 34 +++++++++++------------ pysollib/games/ultra/hanafuda_common.py | 4 +-- pysollib/games/ultra/hexadeck.py | 22 +++++++-------- pysollib/games/ultra/mughal.py | 24 ++++++++--------- pysollib/games/ultra/tarock.py | 10 +++---- pysollib/games/unionsquare.py | 4 +-- pysollib/games/wavemotion.py | 4 +-- pysollib/games/yukon.py | 2 +- pysollib/games/zodiac.py | 2 +- pysollib/hint.py | 6 ++--- pysollib/mfxutil.py | 4 +-- pysollib/resource.py | 2 +- pysollib/stack.py | 24 ++++++++--------- pysollib/tk/progressbar.py | 4 +-- pysollib/tk/selectgame.py | 2 +- pysollib/tk/solverdialog.py | 4 +-- pysollib/tk/tkstats.py | 20 +++++++------- pysollib/tk/tktree.py | 14 +++++----- pysollib/ui/tktile/menubar.py | 2 +- pysollib/ui/tktile/selecttree.py | 2 +- pysollib/ui/tktile/tkcanvas.py | 4 +-- pysollib/ui/tktile/tkutil.py | 6 ++--- 78 files changed, 434 insertions(+), 431 deletions(-) diff --git a/pysollib/game.py b/pysollib/game.py index 3c31bb2a..63b36a4f 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -904,7 +904,7 @@ class Game(object): def shuffleSeparateDecks(self): cards = [] self.random.reset() - n = self.gameinfo.ncards / self.gameinfo.decks + n = self.gameinfo.ncards // self.gameinfo.decks for deck in range(self.gameinfo.decks): i = deck * n deck_cards = list(self.cards)[i:i+n] @@ -1242,7 +1242,7 @@ class Game(object): # this is used internally in game preview to speed up # the initial dealing if self.moves.state == self.S_INIT and frames > 4: - frames = frames / 2 + frames //= 2 if shadow < 0: shadow = self.app.opt.shadow shadows = () @@ -1606,7 +1606,7 @@ class Game(object): # animation if c in acards or len(cards) <= 2: self.animatedMoveTo( - s, None, [c], w/2, h/2, tkraise=0, shadow=0) + s, None, [c], w//2, h//2, tkraise=0, shadow=0) self.animatedMoveTo(s, None, [c], sx, sy, tkraise=0, shadow=0) else: c.moveTo(sx, sy) @@ -2200,8 +2200,8 @@ Congratulations, you did it ! if self.preview: width = 4 xmargin, ymargin = 0, 0 - x0, y0 = x+width/2-xmargin, y+width/2-ymargin - x1, y1 = x+w-width/2-xmargin, y+h-width/2-ymargin + x0, y0 = x+width//2-xmargin, y+width//2-ymargin + x1, y1 = x+w-width//2-xmargin, y+h-width//2-ymargin r = MfxCanvasRectangle(self.canvas, x0, y0, x1, y1, width=width, fill=None, outline=color) self.canvas.update_idletasks() @@ -2425,16 +2425,16 @@ Congratulations, you did it ! x1, y1 = x1 + dx, y1 + dy x2, y2 = x2 + dx, y2 + dy if ncards == 1: - x1 += cw / 2 - y1 += ch / 2 + x1 += cw // 2 + y1 += ch // 2 elif from_stack.CARD_XOFFSET[0]: - x1 += from_stack.CARD_XOFFSET[0] / 2 - y1 += ch / 2 + x1 += from_stack.CARD_XOFFSET[0] // 2 + y1 += ch // 2 else: - x1 += cw / 2 - y1 += from_stack.CARD_YOFFSET[0] / 2 - x2 += cw / 2 - y2 += ch / 2 + x1 += cw // 2 + y1 += from_stack.CARD_YOFFSET[0] // 2 + x2 += cw // 2 + y2 += ch // 2 # draw the hint arrow = MfxCanvasLine(self.canvas, x1, y1, x2, y2, width=7, fill=self.app.opt.colors['hintarrow'], @@ -2690,8 +2690,8 @@ Congratulations, you did it ! def __checkFreeSpaceForDemoInfoText(self, items): CW, CH = self.app.images.CARDW, self.app.images.CARDH # note: these are translated by (-CW/2, -CH/2) - x1, x2 = 3*CW/2, self.width - 5*CW/2 - y1, y2 = CH/2, self.height - 3*CH/2 + x1, x2 = 3*CW//2, self.width - 5*CW//2 + y1, y2 = CH//2, self.height - 3*CH//2 # m = [1, 1, 1, 1] for c in items: diff --git a/pysollib/games/acesup.py b/pysollib/games/acesup.py index 8c903566..88c99052 100644 --- a/pysollib/games/acesup.py +++ b/pysollib/games/acesup.py @@ -97,11 +97,11 @@ class AcesUp(Game): l.createText(s.talon, "ne") else: l.createText(s.talon, "s") - x = x + 3*l.XS/2 + x = x + 3*l.XS//2 for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - x = x + l.XS/2 + x = x + l.XS//2 stack = self.Foundation_Class(x, y, self, suit=ANY_SUIT, max_move=0, dir=0, base_rank=ANY_RANK, max_cards=48) l.createText(stack, "s") @@ -232,7 +232,7 @@ class PerpetualMotion(Game): x, y, = l.XM, l.YM s.talon = PerpetualMotion_Talon(x, y, self, max_rounds=-1) l.createText(s.talon, "s") - x = x + 3*l.XS/2 + x = x + 3*l.XS//2 for i in range(4): s.rows.append( PerpetualMotion_RowStack(x, y, self, dir=0, base_rank=NO_RANK)) @@ -388,13 +388,13 @@ class TabbyCat(Game): s.rows.append(stack) stack.canDropCards = stack.spiderCanDropCards x += l.XS - x += l.XS/2 + x += l.XS//2 s.reserves.append(self.ReserveStack_Class(x, y, self)) x += 1.5*l.XS s.talon = self.Talon_Class(x, y, self) l.createText(s.talon, "s") - self.setRegion(s.foundations, (-999, -999, l.YS*decks-l.CH/2, 999999)) + self.setRegion(s.foundations, (-999, -999, l.YS*decks-l.CH//2, 999999)) # define stack-groups l.defaultStackGroups() diff --git a/pysollib/games/algerian.py b/pysollib/games/algerian.py index 7d4e1f55..6453a306 100644 --- a/pysollib/games/algerian.py +++ b/pysollib/games/algerian.py @@ -82,20 +82,20 @@ class Carthage(Game): self.setSize(w, h) # create stacks - x, y = l.XM+l.XS+(max_rows-foundations)*l.XS/2, l.YM + x, y = l.XM+l.XS+(max_rows-foundations)*l.XS//2, l.YM for fclass in self.Foundation_Classes: for i in range(4): s.foundations.append(fclass(x, y, self, suit=i)) x += l.XS - x, y = l.XM+l.XS+(max_rows-rows)*l.XS/2, l.YM+l.YS + x, y = l.XM+l.XS+(max_rows-rows)*l.XS//2, l.YM+l.YS for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self, max_move=1, max_accept=1)) x += l.XS - self.setRegion(s.rows, (-999, y-l.CH/2, 999999, h-l.YS-l.CH/2)) + self.setRegion(s.rows, (-999, y-l.CH//2, 999999, h-l.YS-l.CH//2)) - d = (w-reserves*l.XS)/reserves + d = (w-reserves*l.XS)//reserves x, y = l.XM, h-l.YS for i in range(reserves): stack = ReserveStack(x, y, self) diff --git a/pysollib/games/auldlangsyne.py b/pysollib/games/auldlangsyne.py index cf1ab245..0e86728d 100644 --- a/pysollib/games/auldlangsyne.py +++ b/pysollib/games/auldlangsyne.py @@ -71,7 +71,7 @@ class TamOShanter(Game): # create stacks if texts: - x, y, = l.XM, l.YM+l.YS/2 + x, y, = l.XM, l.YM+l.YS//2 else: x, y, = l.XM, l.YM s.talon = self.Talon_Class(x, y, self) @@ -277,7 +277,7 @@ class Interregnum(Game): s.foundations.append( Interregnum_Foundation(x, y, self, mod=13, max_move=0)) for i in range(rows): - x, y, = l.XM + (2*i+8-rows)*l.XS/2, l.YM + 2*l.YS + x, y, = l.XM + (2*i+8-rows)*l.XS//2, l.YM + 2*l.YS s.rows.append(self.RowStack_Class(x, y, self)) s.talon = self.Talon_Class(self.width-l.XS, self.height-l.YS, self) if texts: diff --git a/pysollib/games/bakersgame.py b/pysollib/games/bakersgame.py index 489ffbd0..954dda48 100644 --- a/pysollib/games/bakersgame.py +++ b/pysollib/games/bakersgame.py @@ -88,19 +88,19 @@ class EightOff(KingOnlyBakersGame): self.setSize(l.XM + maxrows*l.XS, l.YM + l.YS + h + l.YS) # create stacks - x, y = l.XM + (maxrows-4)*l.XS/2, l.YM + x, y = l.XM + (maxrows-4)*l.XS//2, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, i)) x = x + l.XS - x, y = l.XM + (maxrows-rows)*l.XS/2, y + l.YS + x, y = l.XM + (maxrows-rows)*l.XS//2, y + l.YS for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows-reserves)*l.XS/2, self.height - l.YS + x, y = l.XM + (maxrows-reserves)*l.XS//2, self.height - l.YS for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x = x + l.XS - self.setRegion(s.reserves, (-999, y - l.CH / 2, 999999, 999999)) + self.setRegion(s.reserves, (-999, y - l.CH // 2, 999999, 999999)) s.talon = InitialDealTalonStack(l.XM, l.YM, self) # define stack-groups @@ -149,7 +149,7 @@ class SeahavenTowers(KingOnlyBakersGame): for i in range(10): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - self.setRegion(s.rows, (-999, y - l.CH / 2, 999999, 999999)) + self.setRegion(s.rows, (-999, y - l.CH // 2, 999999, 999999)) s.talon = InitialDealTalonStack(l.XM, self.height-l.YS, self) # define stack-groups @@ -213,16 +213,16 @@ class Tuxedo(Game): for i in range(4): s.foundations.append(self.Foundation_Class(x, y, self, suit=i)) y = y + l.YS - self.setRegion(s.foundations, (x - l.CW/2, -999, 999999, 999999)) - x, y = l.XM + (maxrows-rows)*l.XS/2, l.YM + self.setRegion(s.foundations, (x - l.CW//2, -999, 999999, 999999)) + x, y = l.XM + (maxrows-rows)*l.XS//2, l.YM for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows-reserves)*l.XS/2, self.height - l.YS + x, y = l.XM + (maxrows-reserves)*l.XS//2, self.height - l.YS for i in range(reserves): s.reserves.append(self.ReserveStack_Class(x, y, self)) x = x + l.XS - self.setRegion(s.reserves, (-999, y - l.CH / 2, 999999, 999999)) + self.setRegion(s.reserves, (-999, y - l.CH // 2, 999999, 999999)) s.talon = InitialDealTalonStack(l.XM+1, y, self) # define stack-groups diff --git a/pysollib/games/beleagueredcastle.py b/pysollib/games/beleagueredcastle.py index 4ec41012..ffc3cf83 100644 --- a/pysollib/games/beleagueredcastle.py +++ b/pysollib/games/beleagueredcastle.py @@ -119,9 +119,9 @@ class StreetsAndAlleys(Game): s.talon = InitialDealTalonStack(x, y, self) if reserves: l.setRegion( - s.rows[:4], (-999, l.YM+l.YS-l.CH/2, x1-l.CW/2, 999999)) + s.rows[:4], (-999, l.YM+l.YS-l.CH//2, x1-l.CW//2, 999999)) else: - l.setRegion(s.rows[:4], (-999, -999, x1-l.CW/2, 999999)) + l.setRegion(s.rows[:4], (-999, -999, x1-l.CW//2, 999999)) # default l.defaultAll() @@ -487,7 +487,7 @@ class Zerline(Game): # set window # (set size so that at least 13 cards are fully playable) w = max(3*l.XS, l.XS+playcards*l.XOFFSET) - self.setSize(l.XM+2*w+decks*l.XS, l.YM+l.TEXT_HEIGHT+(rows/2+1)*l.YS) + self.setSize(l.XM+2*w+decks*l.XS, l.YM+l.TEXT_HEIGHT+(rows//2+1)*l.YS) # create stacks y = l.YM @@ -515,7 +515,7 @@ class Zerline(Game): x = l.XM for j in range(2): y = l.YM+l.TEXT_HEIGHT+l.YS - for i in range(rows/2): + for i in range(rows//2): stack = RK_RowStack( x, y, self, max_move=1, max_accept=1, base_rank=QUEEN) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 @@ -524,8 +524,8 @@ class Zerline(Game): x += l.XM+w+decks*l.XS l.setRegion( - s.rows[:4], (-999, l.YM+l.YS+l.TEXT_HEIGHT-l.CH/2, - w-l.CW/2, 999999)) + s.rows[:4], (-999, l.YM+l.YS+l.TEXT_HEIGHT-l.CH//2, + w-l.CW//2, 999999)) # define stack-groups l.defaultStackGroups() @@ -575,7 +575,7 @@ class Chequers(Fortress): x, y = l.XM, l.YM s.talon = TalonStack(x, y, self) l.createText(s.talon, "se") - x = max(l.XS+3*l.XM, (self.width-l.XM-8*l.XS)/2) + x = max(l.XS+3*l.XM, (self.width-l.XM-8*l.XS)//2) for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS @@ -649,7 +649,7 @@ class CastleOfIndolence(Game): stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) y += l.YS - l.setRegion(s.rows[:4], (-999, -999, w-l.CW/2, l.YM+4*l.YS-l.CH/2)) + l.setRegion(s.rows[:4], (-999, -999, w-l.CW//2, l.YM+4*l.YS-l.CH//2)) # define stack-groups l.defaultStackGroups() @@ -763,13 +763,13 @@ class Lightweight(StreetsAndAlleys): max_rows = max(decks*4, rows) self.setSize(l.XM+max_rows*l.XS, l.YM+2*l.YS+playcards*l.YOFFSET) - x, y = l.XM+(max_rows-decks*4)*l.XS/2, l.YM + x, y = l.XM+(max_rows-decks*4)*l.XS//2, l.YM for i in range(4): for j in range(decks): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, max_move=0)) x += l.XS - x, y = l.XM+(max_rows-rows)*l.XS/2, l.YM+l.YS + x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+l.YS for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS diff --git a/pysollib/games/bisley.py b/pysollib/games/bisley.py index 7bdde992..99054655 100644 --- a/pysollib/games/bisley.py +++ b/pysollib/games/bisley.py @@ -134,12 +134,12 @@ class DoubleBisley(Bisley): for i in range(4): x = l.XM+8*l.XS s.foundations.append(SS_FoundationStack(x, y, self, - suit=j*2+i/2, max_move=0)) + suit=j*2+i//2, max_move=0)) x += l.XS s.foundations.append( SS_FoundationStack( x, y, self, - suit=j*2+i/2, base_rank=KING, max_move=0, dir=-1)) + suit=j*2+i//2, base_rank=KING, max_move=0, dir=-1)) y += l.YS s.talon = InitialDealTalonStack(l.XM, h-l.YS, self) @@ -176,10 +176,10 @@ class Gloria(Game): for i in range(4): y = l.YM s.foundations.append( - SS_FoundationStack(x, y, self, suit=j*2+i/2)) + SS_FoundationStack(x, y, self, suit=j*2+i//2)) y += l.YS s.foundations.append(SS_FoundationStack(x, y, self, - suit=j*2+i/2, base_rank=KING, dir=-1)) + suit=j*2+i//2, base_rank=KING, dir=-1)) x += l.XS s.reserves.append(ReserveStack(l.XM, l.YM, self)) @@ -384,7 +384,7 @@ class Cringle(Game): for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS - x += l.XS/2 + x += l.XS//2 for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1)) @@ -394,7 +394,7 @@ class Cringle(Game): for j in range(4): s.rows.append(AC_RowStack(x, y, self)) x += l.XS - x += l.XS/2 + x += l.XS//2 for j in range(4): s.rows.append(AC_RowStack(x, y, self, dir=1)) x += l.XS diff --git a/pysollib/games/braid.py b/pysollib/games/braid.py index d86f5e5e..13d08548 100644 --- a/pysollib/games/braid.py +++ b/pysollib/games/braid.py @@ -159,9 +159,9 @@ class Braid(Game): s.rows.append(Braid_ReserveStack(x, y + l.YS, self)) s.rows.append(Braid_ReserveStack(x + l.XS, y + l.YS, self)) x = x + 4 * l.XS - x, y = l.XM + l.XS * 5/2, l.YM + x, y = l.XM + l.XS * 5//2, l.YM s.braid = Braid_BraidStack(x, y, self) - x, y = l.XM + 7 * l.XS, l.YM + l.YS * 3/2 + x, y = l.XM + 7 * l.XS, l.YM + l.YS * 3//2 s.talon = WasteTalonStack(x, y, self, max_rounds=3) l.createText(s.talon, "s") l.createRoundText(s.talon, 'nn') @@ -175,7 +175,7 @@ class Braid(Game): s.foundations.append(cl(x, y, self, suit=i)) x += l.XS y = y + l.YS - x = l.XM+8*l.XS+decks*l.XS/2 + x = l.XM+8*l.XS+decks*l.XS//2 self.texts.info = MfxCanvasText(self.canvas, x, y, anchor="n", font=font) @@ -321,28 +321,28 @@ class Backbone(Game): # create stacks y = l.YM for i in range(4): - x = l.XM+(rows-8)*l.XS/2 + i*l.XS + x = l.XM+(rows-8)*l.XS//2 + i*l.XS s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) - x = l.XM+(rows/2+2)*l.XS + i*l.XS + x = l.XM+(rows//2+2)*l.XS + i*l.XS s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) - x, y = l.XM+rows*l.XS/2, l.YM + x, y = l.XM+rows*l.XS//2, l.YM s.reserves.append(Backbone_BraidStack(x, y, self, max_accept=0)) x += l.XS s.reserves.append(Backbone_BraidStack(x, y, self, max_accept=0)) - x, y = l.XM+(rows+1)*l.XS/2, l.YM+11*l.YOFFSET + x, y = l.XM+(rows+1)*l.XS//2, l.YM+11*l.YOFFSET s.reserves.append(BasicRowStack(x, y, self, max_accept=0)) x, y = l.XM, l.YM+l.YS - for i in range(rows/2): + for i in range(rows//2): s.rows.append(SS_RowStack(x, y, self, max_move=1)) x += l.XS - x, y = l.XM+(rows/2+2)*l.XS, l.YM+l.YS - for i in range(rows/2): + x, y = l.XM+(rows//2+2)*l.XS, l.YM+l.YS + for i in range(rows//2): s.rows.append(SS_RowStack(x, y, self, max_move=1)) x += l.XS - x, y = l.XM+rows*l.XS/2, h-l.YS + x, y = l.XM+rows*l.XS//2, h-l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, "n") x += l.XS diff --git a/pysollib/games/bristol.py b/pysollib/games/bristol.py index 5350ba04..ed6f5d31 100644 --- a/pysollib/games/bristol.py +++ b/pysollib/games/bristol.py @@ -100,9 +100,9 @@ class Bristol(Game): s.foundations.append(RK_FoundationStack(x, y, self, max_move=0)) x += l.XS for i in range(2): - y = l.YM + (i*2+3)*l.YS/2 + y = l.YM + (i*2+3)*l.YS//2 for j in range(4): - x = l.XM + (j*5)*l.XS/2 + x = l.XM + (j*5)*l.XS//2 stack = RK_RowStack(x, y, self, base_rank=NO_RANK, max_move=1) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) @@ -208,7 +208,7 @@ class Dover(Bristol): # set window max_rows = max(rows, self.gameinfo.decks*4) - w, h = 2*l.XM+l.XS+max_rows*l.XS+l.XS/2, l.YM+l.TEXT_HEIGHT+5*l.YS + w, h = 2*l.XM+l.XS+max_rows*l.XS+l.XS//2, l.YM+l.TEXT_HEIGHT+5*l.YS self.setSize(w, h) # create stacks @@ -453,7 +453,7 @@ class Interment(Game): l.createText(s.talon, 'ne') x += 1.5*l.XS for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM, l.YM+l.YS for i in range(3): diff --git a/pysollib/games/calculation.py b/pysollib/games/calculation.py index 07283345..6c15b6a0 100644 --- a/pysollib/games/calculation.py +++ b/pysollib/games/calculation.py @@ -119,7 +119,7 @@ class Calculation(Game): self.setSize(w, l.YM + l.YS + l.TEXT_HEIGHT + h) # create stacks - x0 = l.XM + l.XS * 3 / 2 + x0 = l.XM + l.XS * 3 // 2 x, y = x0, l.YM for i in range(4): stack = self.Foundation_Class(x, y, self, @@ -131,14 +131,14 @@ class Calculation(Game): anchor=ta, font=font) x = x + l.XS self.texts.help = MfxCanvasText( - self.canvas, x + l.XM, y + l.CH / 2, text=help, + self.canvas, x + l.XM, y + l.CH // 2, text=help, anchor="w", font=self.app.getFont("canvas_fixed")) x = x0 y = l.YM + l.YS + l.TEXT_HEIGHT for i in range(4): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - self.setRegion(s.rows, (-999, y-l.CH/2, 999999, 999999)) + self.setRegion(s.rows, (-999, y-l.CH//2, 999999, 999999)) x = l.XM s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, "n") @@ -207,7 +207,7 @@ class BetsyRoss(Calculation): self.setSize(5.5*l.XS+l.XM+text_width, l.YM+3*l.YS+l.TEXT_HEIGHT) # create stacks - x0 = l.XM + l.XS * 3 / 2 + x0 = l.XM + l.XS * 3 // 2 x, y = x0, l.YM for i in range(4): stack = BetsyRoss_Foundation(x, y, self, base_rank=i, @@ -226,7 +226,7 @@ class BetsyRoss(Calculation): anchor=ta, font=font) s.foundations.append(stack) x += l.XS - self.texts.help = MfxCanvasText(self.canvas, x + l.XM, y + l.CH / 2, + self.texts.help = MfxCanvasText(self.canvas, x + l.XM, y + l.CH // 2, text=help, anchor="w", font=self.app.getFont("canvas_fixed")) x = l.XM @@ -252,7 +252,7 @@ class BetsyRoss(Calculation): topcards[c.rank] = c cards.remove(c) elif c.rank in (1, 3, 5, 7): - i = 4 + (c.rank - 1) / 2 + i = 4 + (c.rank - 1) // 2 if topcards[i] is None: topcards[i] = c cards.remove(c) @@ -307,7 +307,7 @@ class One234(Calculation): anchor=ta, font=font) x = x + l.XS self.texts.help = MfxCanvasText( - self.canvas, x + l.XM, y + l.CH / 2, text=help, + self.canvas, x + l.XM, y + l.CH // 2, text=help, anchor="w", font=self.app.getFont("canvas_fixed")) x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT for i in range(8): diff --git a/pysollib/games/camelot.py b/pysollib/games/camelot.py index bbb9d435..2241e1d0 100644 --- a/pysollib/games/camelot.py +++ b/pysollib/games/camelot.py @@ -402,7 +402,7 @@ class PrincessPatience_RowStack(SS_RowStack): # index = list(self.game.s.rows).index(self) index = self.id col = index % 4 - row = index / 4 + row = index // 4 if index < 16: # left for i in range(col+1, 4): r = self.game.s.rows[row*4+i] diff --git a/pysollib/games/canfield.py b/pysollib/games/canfield.py index 0953bbb1..5a3232a5 100644 --- a/pysollib/games/canfield.py +++ b/pysollib/games/canfield.py @@ -426,11 +426,11 @@ class Gate(Game): stack = OpenStack(x, y, self, max_accept=0) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.reserves.append(stack) - x, y = l.XM+(w-4*l.XS)/2, l.YM + x, y = l.XM+(w-4*l.XS)//2, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS - x, y = l.XM+(w-8*l.XS)/2, l.YM+l.YS + x, y = l.XM+(w-8*l.XS)//2, l.YM+l.YS for i in range(8): s.rows.append(AC_RowStack(x, y, self)) x += l.XS @@ -497,7 +497,7 @@ class LittleGate(Gate): for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS - x, y = l.XM+(max_rows-rows)*l.XS/2, l.YM+l.YS+l.TEXT_HEIGHT + x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+l.YS+l.TEXT_HEIGHT for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS @@ -746,7 +746,7 @@ class Skippy(Canfield): # set window playcards = 8 w0 = l.XS+playcards*l.XOFFSET - w = l.XM+l.XS/2+max(10*l.XS, l.XS+4*w0) + w = l.XM+l.XS//2+max(10*l.XS, l.XS+4*w0) h = l.YM+5*l.YS+l.TEXT_HEIGHT self.setSize(w, h) @@ -776,7 +776,7 @@ class Skippy(Canfield): y += l.YS y = l.YM+l.YS+l.TEXT_HEIGHT for i in range(4): - x = l.XM+l.XS+l.XS/2 + x = l.XM+l.XS+l.XS//2 for j in range(4): stack = RK_RowStack(x, y, self, max_move=1, mod=13) s.rows.append(stack) diff --git a/pysollib/games/capricieuse.py b/pysollib/games/capricieuse.py index 519bb3f9..44fc09f0 100644 --- a/pysollib/games/capricieuse.py +++ b/pysollib/games/capricieuse.py @@ -67,7 +67,7 @@ class Capricieuse(Game): self.setSize(l.XM+rows*l.XS, l.YM+2*l.YS+15*l.YOFFSET) # create stacks - x, y, = l.XM+(rows-8)*l.XS/2, l.YM + x, y, = l.XM+(rows-8)*l.XS//2, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS @@ -149,7 +149,7 @@ class Strata(Game): for i in range(8): s.rows.append(AC_RowStack(x, y, self, max_move=1, max_accept=1)) x += l.XS - s.talon = RedealTalonStack(l.XM, l.YM+l.YS/2, self, max_rounds=3) + s.talon = RedealTalonStack(l.XM, l.YM+l.YS//2, self, max_rounds=3) l.createRoundText(s.talon, 'nn') # define stack-groups @@ -220,7 +220,7 @@ class Choice(Game): l.YM + 2*l.YS + (playcards+4*decks)*l.YOFFSET) # create stacks - x, y = l.XM + (max_rows-8)*l.XS/2, l.YM + x, y = l.XM + (max_rows-8)*l.XS//2, l.YM for i in range(8): stack = Choice_Foundation(x, y, self, base_rank=(i+5), dir=0, suit=ANY_SUIT, max_cards=(4*decks)) @@ -228,7 +228,8 @@ class Choice(Game): s.foundations.append(stack) x += l.XS - x, y = l.XM + (max_rows-rows)*l.XS/2, l.YM + l.YS + (4*decks)*l.YOFFSET + x = l.XM + (max_rows-rows)*l.XS//2 + y = l.YM + l.YS + (4*decks)*l.YOFFSET for i in range(rows): s.rows.append(AC_RowStack(x, y, self)) x += l.XS diff --git a/pysollib/games/curdsandwhey.py b/pysollib/games/curdsandwhey.py index 0857524a..8ea111bd 100644 --- a/pysollib/games/curdsandwhey.py +++ b/pysollib/games/curdsandwhey.py @@ -448,7 +448,7 @@ class Glacier(Game): l, s = Layout(self), self.s self.setSize(l.XM+rows*l.XS, l.YM+2*l.YS+l.TEXT_HEIGHT+20*l.YOFFSET) - x, y = l.XM+(rows-4)/2*l.XS, l.YM + x, y = l.XM+(rows-4)//2*l.XS, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, mod=13, max_cards=26)) diff --git a/pysollib/games/daddylonglegs.py b/pysollib/games/daddylonglegs.py index 285ebe72..6fd986e4 100644 --- a/pysollib/games/daddylonglegs.py +++ b/pysollib/games/daddylonglegs.py @@ -37,7 +37,7 @@ class DaddyLonglegs(Game): x, y, = l.XM, l.YM s.talon = self.Talon_Class(x, y, self) l.createText(s.talon, "ss") - x = x + 3*l.XS/2 + x = x + 3*l.XS//2 for i in range(4): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS diff --git a/pysollib/games/dieboesesieben.py b/pysollib/games/dieboesesieben.py index 206ea02d..3fe4a9b8 100644 --- a/pysollib/games/dieboesesieben.py +++ b/pysollib/games/dieboesesieben.py @@ -62,7 +62,7 @@ class DieBoeseSieben_Talon(DieKoenigsbergerin_Talon): # redeal game.nextRoundMove(self) n = len(game.s.rows) - flip = (num_cards / n) & 1 + flip = (num_cards // n) & 1 while self.cards: if len(self.cards) <= n: flip = 1 @@ -91,9 +91,9 @@ class DieBoeseSieben(Game): x, y, = l.XM + i*l.XS, l.YM s.foundations.append( DieRussische_Foundation( - x, y, self, i/2, max_move=0, max_cards=8)) + x, y, self, i//2, max_move=0, max_cards=8)) for i in range(rows): - x, y, = l.XM + (2*i+8-rows)*l.XS/2, l.YM + l.YS + x, y, = l.XM + (2*i+8-rows)*l.XS//2, l.YM + l.YS s.rows.append(AC_RowStack(x, y, self)) s.talon = DieBoeseSieben_Talon( l.XM, self.height-l.YS, self, max_rounds=2) diff --git a/pysollib/games/doublets.py b/pysollib/games/doublets.py index 73a69a4b..81fda169 100644 --- a/pysollib/games/doublets.py +++ b/pysollib/games/doublets.py @@ -71,18 +71,18 @@ class Doublets(Game): # create stacks for dx, dy in ((0, 0), (1, 0), (2, 0), (0, 1), (2, 1), (0, 2), (2, 2)): - x, y = l.XM + (2*dx+5)*l.XS/2, l.YM + (2*dy+1)*l.YS/2 + x, y = l.XM + (2*dx+5)*l.XS//2, l.YM + (2*dy+1)*l.YS//2 s.rows.append(ReserveStack(x, y, self)) dx, dy = 1, 2 - x, y = l.XM + (2*dx+5)*l.XS/2, l.YM + (2*dy+1)*l.YS/2 + x, y = l.XM + (2*dx+5)*l.XS//2, l.YM + (2*dy+1)*l.YS//2 s.foundations.append(Doublets_Foundation(x, y, self, ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=48)) l.createText(s.foundations[0], "s") # help = "A, 2, 4, 8, 3, 6, Q, J, 9, 5, 10, 7, A, ..." # self.texts.help = MfxCanvasText( -# self.canvas, x + l.CW/2, y + l.YS + l.YM, anchor="n", text=help) - x, y = l.XM, l.YM + 3*l.YS/2 +# self.canvas, x + l.CW//2, y + l.YS + l.YM, anchor="n", text=help) + x, y = l.XM, l.YM + 3*l.YS//2 s.talon = WasteTalonStack(x, y, self, max_rounds=3) l.createText(s.talon, "s") x = x + l.XS diff --git a/pysollib/games/eiffeltower.py b/pysollib/games/eiffeltower.py index 1351070e..8e4241c0 100644 --- a/pysollib/games/eiffeltower.py +++ b/pysollib/games/eiffeltower.py @@ -78,7 +78,7 @@ class EiffelTower(Game): x = x + l.XS y = y + l.YS x = l.XM + 6 * l.XS - y = l.YM + 5 * l.YS / 2 + y = l.YM + 5 * l.YS // 2 s.waste = self.Waste_Class(x, y, self) l.createText(s.waste, "s") x = x + l.XS diff --git a/pysollib/games/fan.py b/pysollib/games/fan.py index d84b325b..a5092d84 100644 --- a/pysollib/games/fan.py +++ b/pysollib/games/fan.py @@ -103,10 +103,10 @@ class Fan(Game): for r in range(reserves): s.reserves.append(self.ReserveStack_Class(x, y, self)) x += l.XS - x = (self.width - decks*4*l.XS) # - 2*l.XS) / 2 + x = (self.width - decks*4*l.XS) # - 2*l.XS) // 2 dx = l.XS else: - dx = (self.width - decks*4*l.XS)/(decks*4+1) + dx = (self.width - decks*4*l.XS)//(decks*4+1) x, y = l.XM + dx, l.YM dx += l.XS for fnd_cls in self.Foundation_Classes: @@ -243,7 +243,7 @@ class LaBelleLucie_Talon(TalonStack): to_stacks = self.game.s.rows n = min(len(self.cards), 3*len(to_stacks)) for i in range(3): - j = (n/3, (n+1)/3, (n+2)/3)[i] + j = (n//3, (n+1)//3, (n+2)//3)[i] frames = (0, 0, 4)[i] for r in to_stacks[:j]: if self.cards[-1].face_up != face_up: @@ -332,7 +332,7 @@ class ThreeShufflesAndADraw_ReserveStack(ReserveStack): if not self.is_visible or self.game.preview > 1: return images = self.game.app.images - x, y = self.x + images.CARDW/2, self.y + images.CARDH/2 + x, y = self.x + images.CARDW//2, self.y + images.CARDH//2 self.texts.misc = MfxCanvasText( self.game.canvas, x, y, anchor="center", @@ -707,7 +707,7 @@ class FascinationFan(Fan): self.s.talon.dealRow() def redealCards(self): - r0 = r1 = len(self.s.talon.cards)/3 + r0 = r1 = len(self.s.talon.cards)//3 m = len(self.s.talon.cards) % 3 if m >= 1: r1 += 1 diff --git a/pysollib/games/fortythieves.py b/pysollib/games/fortythieves.py index ff1fbace..932cc420 100644 --- a/pysollib/games/fortythieves.py +++ b/pysollib/games/fortythieves.py @@ -106,16 +106,16 @@ class FortyThieves(Game): # create stacks # foundations - x = l.XM + (maxrows - 4*decks) * l.XS / 2 + x = l.XM + (maxrows - 4*decks) * l.XS // 2 y = l.YM for i in range(4*decks): s.foundations.append( self.Foundation_Class( x, y, self, - suit=i/decks, max_move=self.FOUNDATION_MAX_MOVE)) + suit=i//decks, max_move=self.FOUNDATION_MAX_MOVE)) x = x + l.XS # rows - x = l.XM + (maxrows - rows) * l.XS / 2 + x = l.XM + (maxrows - rows) * l.XS // 2 y = l.YM + l.YS for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self, @@ -584,13 +584,13 @@ class Octave(Game): self.setSize(w, h) # create stacks - x, y = l.XM+l.XS/2, l.YM + x, y = l.XM+l.XS2, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, - suit=int(i/2), max_cards=10)) + suit=int(i//2), max_cards=10)) x += l.XS - x, y = l.XM+l.XS/2, l.YM+l.YS + x, y = l.XM+l.XS//2, l.YM+l.YS for i in range(8): s.rows.append(AC_RowStack(x, y, self, base_rank=ANY_RANK, max_move=1)) @@ -734,10 +734,10 @@ class Octagon(Game): i = 0 for x, y in ((l.XM+w1, l.YM), (l.XM+w1+l.XS, l.YM), - (l.XM+w1-2*l.XS-l.XS/2-l.XM, l.YM+1.5*l.YS), - (l.XM+w1-l.XS-l.XS/2-l.XM, l.YM+1.5*l.YS), - (l.XM+w1+2*l.XS+l.XS/2+l.XM, l.YM+1.5*l.YS), - (l.XM+w1+3*l.XS+l.XS/2+l.XM, l.YM+1.5*l.YS), + (l.XM+w1-2*l.XS-l.XS//2-l.XM, l.YM+1.5*l.YS), + (l.XM+w1-l.XS-l.XS//2-l.XM, l.YM+1.5*l.YS), + (l.XM+w1+2*l.XS+l.XS//2+l.XM, l.YM+1.5*l.YS), + (l.XM+w1+3*l.XS+l.XS//2+l.XM, l.YM+1.5*l.YS), (l.XM+w1, l.YM+3*l.YS), (l.XM+w1+l.XS, l.YM+3*l.YS),): s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4)) @@ -793,9 +793,9 @@ class Squadron(FortyThieves): l.createText(s.waste, 's') x += 2*l.XS for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS - x, y = l.XM, l.YM+l.YS*3/2 + x, y = l.XM, l.YM+l.YS*3//2 for i in range(3): s.reserves.append(ReserveStack(x, y, self)) y += l.YS @@ -867,7 +867,7 @@ class Junction(Game): x += l.XS y += l.YS - x, y = l.XM+(10-rows)*l.XS/2, l.YM+2*l.YS + x, y = l.XM+(10-rows)*l.XS//2, l.YM+2*l.YS for i in range(rows): s.rows.append(AC_RowStack(x, y, self)) x += l.XS @@ -940,7 +940,7 @@ class TheSpark(Game): x, y = l.XM, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, - suit=i/2, base_rank=KING, mod=13)) + suit=i//2, base_rank=KING, mod=13)) x += l.XS x, y = l.XM, l.YM+l.YS s.talon = TheSpark_Talon(x, y, self, max_rounds=1, num_deal=3) @@ -951,7 +951,7 @@ class TheSpark(Game): s.reserves.append(stack) l.createText(stack, 'se') y += l.YS - y = l.YM+l.YS*3/2 + y = l.YM+l.YS*3//2 for i in range(2): x = l.XM+2*l.XS for j in range(6): diff --git a/pysollib/games/freecell.py b/pysollib/games/freecell.py index c2086c71..b4a3b192 100644 --- a/pysollib/games/freecell.py +++ b/pysollib/games/freecell.py @@ -640,7 +640,7 @@ class Limpopo(Game): self.setSize(l.XM+10.5*l.XS, l.YM+2*l.YS+20*l.YOFFSET) # create stacks - x, y = l.XM, l.YM+l.YS/2 + x, y = l.XM, l.YM+l.YS//2 for i in (0, 1): stack = ReserveStack(x, y, self, max_cards=4) s.reserves.append(stack) @@ -650,7 +650,7 @@ class Limpopo(Game): x, y = l.XM+2.5*l.XS, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM+2.5*l.XS, l.YM+l.YS diff --git a/pysollib/games/glenwood.py b/pysollib/games/glenwood.py index 28fb88a9..8c3b9b46 100644 --- a/pysollib/games/glenwood.py +++ b/pysollib/games/glenwood.py @@ -305,7 +305,7 @@ class DoubleFives(Glenwood): # x += 2*l.XS for i in range(8): - s.foundations.append(Glenwood_Foundation(x, y, self, suit=i/2, + s.foundations.append(Glenwood_Foundation(x, y, self, suit=i//2, mod=13, base_rank=ANY_RANK, max_move=0)) x += l.XS tx, ty, ta, tf = l.getTextAttr(None, "ss") @@ -313,7 +313,7 @@ class DoubleFives(Glenwood): font = self.app.getFont("canvas_default") self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font) - x, y = l.XM+l.XS/2, l.YM+l.YS+l.TEXT_HEIGHT + x, y = l.XM+l.XS//2, l.YM+l.YS+l.TEXT_HEIGHT for i in range(10): s.rows.append(DoubleFives_RowStack(x, y, self, mod=13, max_move=1)) x += l.XS diff --git a/pysollib/games/golf.py b/pysollib/games/golf.py index a6d5919a..f1687e8e 100644 --- a/pysollib/games/golf.py +++ b/pysollib/games/golf.py @@ -158,7 +158,7 @@ class Golf(Game): self.setSize(w1, l.YM+3*l.YS+(playcards-1)*l.YOFFSET+l.TEXT_HEIGHT) # create stacks - x, y = l.XM + l.XS / 2, l.YM + x, y = l.XM + l.XS // 2, l.YM for i in range(7): s.rows.append(Golf_RowStack(x, y, self)) x = x + l.XS @@ -262,8 +262,8 @@ class Elevator(RelaxedGolf): # create stacks for i in range(7): - x = l.XM + (8-i) * l.XS / 2 - y = l.YM + i * l.YS / 2 + x = l.XM + (8-i) * l.XS // 2 + y = l.YM + i * l.YS // 2 for j in range(i+1): s.rows.append(Elevator_RowStack(x, y, self)) x = x + l.XS @@ -361,7 +361,7 @@ class BlackHole(Game): for r in s.rows: r.CARD_XOFFSET = l.XOFFSET r.CARD_YOFFSET = 0 - x, y = l.XM + 2*w, l.YM + 3*l.YS/2 + x, y = l.XM + 2*w, l.YM + 3*l.YS//2 s.foundations.append(BlackHole_Foundation(x, y, self, suit=ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=52)) l.createText(s.foundations[0], "s") @@ -494,7 +494,7 @@ class AllInARow(BlackHole): x, y, self, ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=52, base_rank=ANY_RANK) s.foundations.append(stack) - stack.CARD_XOFFSET, stack.CARD_YOFFSET = (self.width-l.XS)/51, 0 + stack.CARD_XOFFSET, stack.CARD_YOFFSET = (self.width-l.XS)//51, 0 l.createText(stack, 'n') x = self.width-l.XS s.talon = InitialDealTalonStack(x, y, self) @@ -519,7 +519,7 @@ class Robert(Game): def createGame(self, max_rounds=3, num_deal=1): l, s = Layout(self), self.s self.setSize(l.XM+4*l.XS, l.YM+2*l.YS) - x, y = l.XM+3*l.XS/2, l.YM + x, y = l.XM+3*l.XS//2, l.YM stack = BlackHole_Foundation(x, y, self, ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=52) s.foundations.append(stack) @@ -619,7 +619,7 @@ class Dolphin(Game): l, s = Layout(self), self.s self.setSize(l.XM+rows*l.XS, l.YM+3*l.YS+playcards*l.YOFFSET) - dx = (self.width-l.XM-(reserves+1)*l.XS)/3 + dx = (self.width-l.XM-(reserves+1)*l.XS)//3 x, y = l.XM+dx, l.YM for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) @@ -690,7 +690,7 @@ class Waterfall(Game): for i in range(rows): s.rows.append(RK_RowStack(x, y, self)) x += l.XS - x, y = l.XM+(rows-1)*l.XS/2, self.height-l.YS + x, y = l.XM+(rows-1)*l.XS//2, self.height-l.YS s.foundations.append(Waterfall_Foundation(x, y, self, suit=ANY_SUIT, max_cards=104)) stack = s.foundations[0] @@ -761,7 +761,7 @@ class Vague(Game): y = l.YM+l.YS for i in range(rows): - x = l.XM + (maxrows-columns)*l.XS/2 + x = l.XM + (maxrows-columns)*l.XS//2 for j in range(columns): s.rows.append(Vague_RowStack(x, y, self)) x += l.XS @@ -931,8 +931,8 @@ class FirTree_GameMethods: rows = [] # create stacks for i in range(11): - x = x0 + ((i+1) % 2) * l.XS / 2 - y = y0 + i * l.YS / 4 + x = x0 + ((i+1) % 2) * l.XS // 2 + y = y0 + i * l.YS // 4 for j in range((i % 2) + 1): rows.append(ThreeFirTrees_RowStack(x, y, self)) x += l.XS @@ -958,7 +958,7 @@ class ThreeFirTrees(Golf, FirTree_GameMethods): l, s = Layout(self), self.s self.setSize(l.XM+max(7*l.XS, 2*l.XS+26*l.XOFFSET), l.YM+5*l.YS) - x0, y0 = (self.width-7*l.XS)/2, l.YM + x0, y0 = (self.width-7*l.XS)//2, l.YM for i in range(3): s.rows += self._createFirTree(l, x0, y0) x0 += 2.5*l.XS @@ -968,7 +968,7 @@ class ThreeFirTrees(Golf, FirTree_GameMethods): l.createText(s.talon, 'n') x += l.XS s.waste = self.Waste_Class(x, y, self) - s.waste.CARD_XOFFSET = l.XOFFSET/4 + s.waste.CARD_XOFFSET = l.XOFFSET//4 l.createText(s.waste, 'n') # the Waste is also our only Foundation in this game s.foundations.append(s.waste) @@ -1004,7 +1004,7 @@ class NapoleonTakesMoscow(Game, FirTree_GameMethods): x, y = l.XM+l.XS, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM, l.YM+l.YS @@ -1074,7 +1074,7 @@ class Flake(Game): s.rows.append(UD_RK_RowStack(x, y, self, mod=13)) x += l.XS - x, y = l.XM + (rows-1)*l.XS/2, l.YM + x, y = l.XM + (rows-1)*l.XS//2, l.YM stack = BlackHole_Foundation(x, y, self, max_move=0, suit=ANY_SUIT, base_rank=ANY_RANK, dir=0, mod=13, max_cards=52*self.gameinfo.decks) @@ -1123,7 +1123,7 @@ class Beacon(Game): self.setSize(l.XM+rows*l.XS, l.YM+3*l.YS+playcards*l.YOFFSET) # create stacks - x, y = l.XM + (rows-1)*l.XS/2, l.YM + x, y = l.XM + (rows-1)*l.XS//2, l.YM stack = RK_FoundationStack(x, y, self, base_rank=ANY_RANK, max_cards=52, mod=13) s.foundations.append(stack) diff --git a/pysollib/games/grandduchess.py b/pysollib/games/grandduchess.py index 3fb4ebd0..048012b3 100644 --- a/pysollib/games/grandduchess.py +++ b/pysollib/games/grandduchess.py @@ -105,13 +105,13 @@ class GrandDuchess(Game): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1)) x += l.XS - x, y = l.XM+(max_rows-rows)*l.XS/2, l.YM+l.YS + x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+l.YS for i in range(rows): stack = BasicRowStack(x, y, self, max_move=1, max_accept=0) stack.CARD_YOFFSET = l.YOFFSET s.rows.append(stack) x += l.XS - dx = (max_rows-rows)*l.XS/4-l.XS/2 + dx = (max_rows-rows)*l.XS//4-l.XS//2 x, y = l.XM+dx, l.YM+l.YS s.reserves.append(GrandDuchess_Reserve(x, y, self)) x, y = self.width-dx-l.XS, l.YM+l.YS diff --git a/pysollib/games/grandfathersclock.py b/pysollib/games/grandfathersclock.py index cf096bcf..42fda9fd 100644 --- a/pysollib/games/grandfathersclock.py +++ b/pysollib/games/grandfathersclock.py @@ -76,7 +76,7 @@ class GrandfathersClock(Game): # set window # (piles up to 9 cards are fully playable in default window size) - dh = max(3*l.YS/2+l.CH, l.YS+(9-1)*l.YOFFSET) + dh = max(3*l.YS//2+l.CH, l.YS+(9-1)*l.YOFFSET) self.setSize(10*l.XS+l.XM, l.YM+2*dh) # create stacks @@ -86,9 +86,9 @@ class GrandfathersClock(Game): s.rows.append( RK_RowStack(x, y, self, max_move=1, max_accept=1)) x = x + l.XS - y = l.YM + dh - l.CH / 2 - self.setRegion(s.rows[:4], (-999, -999, x - l.XM / 2, y)) - self.setRegion(s.rows[4:], (-999, y, x - l.XM / 2, 999999)) + y = l.YM + dh - l.CH // 2 + self.setRegion(s.rows[:4], (-999, -999, x - l.XM // 2, y)) + self.setRegion(s.rows[4:], (-999, y, x - l.XM // 2, 999999)) d = [(0, 0), (1, 0.15), (2, 0.5), (2.5, 1.5), (2, 2.5), (1, 2.85)] for i in range(len(d)): d.append((0 - d[i][0], 3 - d[i][1])) @@ -312,12 +312,12 @@ class Hemispheres(Game): # foundations x, y = x0+2*l.XS, y0+1.5*l.YS for i in range(4): - s.foundations.append(SS_FoundationStack(x, y, self, suit=2+i/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=2+i//2, max_move=0)) x += l.XS x, y = x0+2*l.XS, y+l.YS for i in range(4): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2, max_move=0, base_rank=KING, dir=-1)) x += l.XS diff --git a/pysollib/games/gypsy.py b/pysollib/games/gypsy.py index a19571b4..36daa970 100644 --- a/pysollib/games/gypsy.py +++ b/pysollib/games/gypsy.py @@ -256,7 +256,7 @@ class MissMilligan(Gypsy): x = x + l.XS s.foundations.append(self.Foundation_Class(x, y, self, suit=i/2)) x, y = l.XM, y + l.YS - rx, ry = x + l.XS - l.CW/2, y - l.CH/2 + rx, ry = x + l.XS - l.CW//2, y - l.CH//2 for i in range(reserves): s.reserves.append( self.ReserveStack_Class(x, y+l.TEXT_HEIGHT, self)) @@ -266,7 +266,7 @@ class MissMilligan(Gypsy): self.setRegion(s.reserves, (-999, ry+l.TEXT_HEIGHT, rx-1, 999999)) else: rx = -999 - x, y = l.XM + (8-rows)*l.XS/2, l.YM + l.YS + x, y = l.XM + (8-rows)*l.XS//2, l.YM + l.YS for i in range(rows): x = x + l.XS s.rows.append(self.RowStack_Class(x, y, self)) @@ -501,12 +501,12 @@ class Surprise(Gypsy): l.createText(s.talon, 's') x += l.XS stack = Surprise_ReserveStack(x, y, self, max_cards=3) - xoffset = min(l.XOFFSET, l.XS/3) + xoffset = min(l.XOFFSET, l.XS//3) stack.CARD_XOFFSET = xoffset s.reserves.append(stack) x += 2*l.XS for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT for i in range(11): @@ -799,7 +799,7 @@ class Leprechaun(Game): x, y = l.XM+1.5*l.XS, l.YS+l.TEXT_HEIGHT for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM+1.5*l.XS, 2*l.YS+l.TEXT_HEIGHT @@ -963,7 +963,7 @@ class Thirty(Game): suit=i, max_cards=8)) x += l.XS - x, y = l.XM+l.XS/2, l.YM+l.YS + x, y = l.XM+l.XS//2, l.YM+l.YS for i in range(6): s.rows.append(Thirty_RowStack(x, y, self, max_move=UNLIMITED_MOVES, diff --git a/pysollib/games/harp.py b/pysollib/games/harp.py index e4e67228..0dccbb2e 100644 --- a/pysollib/games/harp.py +++ b/pysollib/games/harp.py @@ -257,7 +257,7 @@ class BigDeal(DoubleKlondike): l.createText(s.waste, 'n') if max_rounds > 1: l.createRoundText(s.talon, 'nnn') - self.setRegion(s.rows, (-999, -999, l.XM+rows*l.XS-l.CW/2, 999999), + self.setRegion(s.rows, (-999, -999, l.XM+rows*l.XS-l.CW//2, 999999), priority=1) l.defaultStackGroups() @@ -271,7 +271,7 @@ class Delivery(BigDeal): RowStack_Class = StackWrapper(SS_RowStack, max_move=1) def createGame(self): - dx = self.app.images.CARDW/10 + dx = self.app.images.CARDW//10 BigDeal.createGame(self, rows=12, max_rounds=1, XOFFSET=dx) shallHighlightMatch = Game._shallHighlightMatch_SS diff --git a/pysollib/games/headsandtails.py b/pysollib/games/headsandtails.py index 2ca354b5..1d47cb2e 100644 --- a/pysollib/games/headsandtails.py +++ b/pysollib/games/headsandtails.py @@ -160,23 +160,23 @@ class Barrier(Game): s.addattr(reserves2=[]) # register extra stack variables - x, y = l.XM+(max_rows-reserves)*l.XS/2+l.XS/2, l.YM - for i in range(reserves/2): + x, y = l.XM+(max_rows-reserves)*l.XS//2+l.XS//2, l.YM + for i in range(reserves//2): stack = Barrier_ReserveStack(x, y, self) s.reserves2.append(stack) l.createText(stack, "ne") x += 2*l.XS - x, y = l.XM+(max_rows-reserves)*l.XS/2, l.YM+l.YS + x, y = l.XM+(max_rows-reserves)*l.XS//2, l.YM+l.YS for i in range(reserves): s.reserves.append(OpenStack(x, y, self)) x += l.XS - x, y = l.XM+(max_rows-rows)*l.XS/2, l.YM+2*l.YS + x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+2*l.YS for i in range(rows): s.rows.append(AC_RowStack(x, y, self)) x += l.XS - x, y = l.XM+(max_rows-8)*l.XS/2, self.height-l.YS + x, y = l.XM+(max_rows-8)*l.XS//2, self.height-l.YS for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM, self.height-l.YS s.talon = InitialDealTalonStack(x, y, self) @@ -186,7 +186,7 @@ class Barrier(Game): def startGame(self): rows = len(self.s.rows) reserves = len(self.s.reserves) - n = (104-reserves-2*rows)/(reserves/2) + n = (104-reserves-2*rows)//(reserves//2) for i in range(n): self.s.talon.dealRow(rows=self.s.reserves2, frames=0, flip=0) self.s.talon.dealRow(rows=self.s.reserves, frames=0) @@ -197,7 +197,7 @@ class Barrier(Game): def fillStack(self, stack): if stack in self.s.reserves and not stack.cards: si = list(self.s.reserves).index(stack) - from_stack = self.s.reserves2[si/2] + from_stack = self.s.reserves2[si//2] if not from_stack.cards: return old_state = self.enterState(self.S_FILL) diff --git a/pysollib/games/katzenschwanz.py b/pysollib/games/katzenschwanz.py index 67bd345e..5c4dc23c 100644 --- a/pysollib/games/katzenschwanz.py +++ b/pysollib/games/katzenschwanz.py @@ -89,7 +89,7 @@ class DerKatzenschwanz(Game): self.setSize(l.XM + (maxrows+2)*l.XS, l.YM + 6*l.YS) # - playcards = 4*l.YS / l.YOFFSET + playcards = 4*l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -99,12 +99,12 @@ class DerKatzenschwanz(Game): yoffset.append(0) # create stacks - x, y = l.XM + (maxrows-reserves)*l.XS/2, l.YM + x, y = l.XM + (maxrows-reserves)*l.XS//2, l.YM for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows-rows)*l.XS/2, l.YM + l.YS - self.setRegion(s.reserves, (-999, -999, 999999, y - l.CH / 2)) + x, y = l.XM + (maxrows-rows)*l.XS//2, l.YM + l.YS + self.setRegion(s.reserves, (-999, -999, 999999, y - l.CH // 2)) for i in range(rows): stack = self.RowStack_Class(x, y, self) stack.CARD_XOFFSET = xoffset @@ -118,9 +118,9 @@ class DerKatzenschwanz(Game): SS_FoundationStack(x+i*l.XS, y, self, suit=suit)) y = y + l.YS self.setRegion( - self.s.foundations, (x - l.CW / 2, -999, 999999, y), priority=1) + self.s.foundations, (x - l.CW // 2, -999, 999999, y), priority=1) s.talon = InitialDealTalonStack( - self.width-3*l.XS/2, self.height-l.YS, self) + self.width-3*l.XS//2, self.height-l.YS, self) # define stack-groups l.defaultStackGroups() @@ -319,7 +319,7 @@ class SalicLaw(DerKatzenschwanz): self.setSize(l.XM+10*l.XS, l.YM+(5+len(self.Foundation_Classes))*l.YS) # - playcards = 4*l.YS / l.YOFFSET + playcards = 4*l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -339,7 +339,7 @@ class SalicLaw(DerKatzenschwanz): y += l.YS x, y = l.XM, l.YM+l.YS*len(self.Foundation_Classes) - self.setRegion(s.foundations, (-999, -999, 999999, y - l.XM / 2)) + self.setRegion(s.foundations, (-999, -999, 999999, y - l.XM // 2)) for i in range(8): stack = self.RowStack_Class(x, y, self, max_move=1) stack.CARD_XOFFSET = xoffset @@ -657,7 +657,7 @@ class Kentish(Kings): self.setSize(l.XM + (rows+2)*l.XS, l.YM + 5*l.YS) # - playcards = 4*l.YS / l.YOFFSET + playcards = 4*l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -681,8 +681,8 @@ class Kentish(Kings): suit=suit)) y += l.YS self.setRegion(self.s.foundations, - (x - l.CW / 2, -999, 999999, y), priority=1) - x, y = self.width-3*l.XS/2, self.height-l.YS + (x - l.CW // 2, -999, 999999, y), priority=1) + x, y = self.width-3*l.XS//2, self.height-l.YS s.talon = InitialDealTalonStack(x, y, self) # define stack-groups diff --git a/pysollib/games/klondike.py b/pysollib/games/klondike.py index 187c4104..a1d87694 100644 --- a/pysollib/games/klondike.py +++ b/pysollib/games/klondike.py @@ -489,7 +489,7 @@ class Batsford(Klondike): x, y = l.XM, self.height - l.YS s.reserves.append(Batsford_ReserveStack(x, y, self, max_cards=3)) self.setRegion( - s.reserves, (-999, y - l.YM - l.CH/2, x + l.XS - l.CW/2, 999999), + s.reserves, (-999, y - l.YM - l.CH//2, x + l.XS - l.CW//2, 999999), priority=1) l.createText(s.reserves[0], "se") if round_text: @@ -697,11 +697,11 @@ class Jane(Klondike): for i in range(reserves): x = x0 + ((i+1) & 1) * l.XS stack = OpenStack(x, y, self, max_accept=0) - stack.CARD_YOFFSET = l.YM / 3 + stack.CARD_YOFFSET = l.YM // 3 s.reserves.append(stack) - y = y + l.YS / 2 + y = y + l.YS // 2 # not needed, as no cards may be placed on the reserves - # self.setRegion(s.reserves, (x0-l.XM/2, -999, 999999, 999999), + # self.setRegion(s.reserves, (x0-l.XM//2, -999, 999999, 999999), # priority=1) l.defaultStackGroups() self.sg.dropstacks.append(s.talon) @@ -759,7 +759,7 @@ class Senate(Jane): x += l.XS for y in l.YM, l.YM+l.YS+playcards*l.YOFFSET: - x = l.XM+rows*l.XS+l.XS/2 + x = l.XM+rows*l.XS+l.XS//2 for i in range(4): stack = OpenStack(x, y, self, max_accept=0) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET @@ -1051,9 +1051,9 @@ class SevenDevils(Klondike): x, y = l.XM, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS - x, y = l.XM+l.XS/2, l.YM+l.YS + x, y = l.XM+l.XS//2, l.YM+l.YS for i in range(7): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS @@ -1061,7 +1061,7 @@ class SevenDevils(Klondike): for i in range(7): x = x0 + ((i+1) & 1) * l.XS s.reserves.append(OpenStack(x, y, self, max_accept=0)) - y = y + l.YS / 2 + y += l.YS // 2 x, y = l.XM, self.height-l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'n') @@ -1260,7 +1260,7 @@ class LuckyThirteen(Game): stack.CARD_XOFFSET = xoffset stack.CARD_YOFFSET = 0 x += w0 - x, y = (self.width-4*l.XS)/2, l.YM + x, y = (self.width-4*l.XS)//2, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS diff --git a/pysollib/games/larasgame.py b/pysollib/games/larasgame.py index 12c0b305..805b49cb 100644 --- a/pysollib/games/larasgame.py +++ b/pysollib/games/larasgame.py @@ -281,7 +281,7 @@ class LarasGame(Game): max_accept=1, max_cards=self.Reserve_Cards)) self.sg.openstacks = self.sg.openstacks + s.reserves[19:] self.sg.dropstacks = self.sg.dropstacks + s.reserves[19:] - self.setRegion(s.reserves[19:], (x - l.XM / 2, 0, 99999, 99999)) + self.setRegion(s.reserves[19:], (x - l.XM // 2, 0, 99999, 99999)) # # Game extras @@ -315,7 +315,7 @@ class LarasGame(Game): for i in range(8): if not self.s.talon.cards: break - if i == 4 or len(self.s.talon.cards) <= ncards / 2: + if i == 4 or len(self.s.talon.cards) <= ncards // 2: self.startDealSample() frames = 4 self.s.talon.dealRow( diff --git a/pysollib/games/mahjongg/mahjongg.py b/pysollib/games/mahjongg/mahjongg.py index 740c5800..566e790b 100644 --- a/pysollib/games/mahjongg/mahjongg.py +++ b/pysollib/games/mahjongg/mahjongg.py @@ -368,7 +368,7 @@ class AbstractMahjonggGame(Game): d_y = cs.SHADOW_YOFFSET if self.preview: # Fixme - dx, dy, d_x, d_y = dx/2, dy/2, d_x/2, d_y/2 + dx, dy, d_x, d_y = dx//2, dy//2, d_x//2, d_y//2 self._delta_x, self._delta_y = dx, -dy else: dx = 3 @@ -398,10 +398,10 @@ class AbstractMahjonggGame(Game): left_margin = l.XM + 4*cardw+fdxx+d_x + l.XM else: left_margin = l.XM - tableau_width = (max_tx+2)*cardw/2+dxx+d_x + tableau_width = (max_tx+2)*cardw//2+dxx+d_x right_margin = l.XM+ti_width+l.XM w = left_margin + tableau_width + right_margin - h = l.YM + dyy + (max_ty + 2) * cardh / 2 + d_y + l.YM + h = l.YM + dyy + (max_ty + 2) * cardh // 2 + d_y + l.YM if show_removed: h = max(h, l.YM+fdyy+cardh*9+d_y+l.YM) self.setSize(w, h) @@ -418,8 +418,8 @@ class AbstractMahjonggGame(Game): y0 = l.YM + dyy for level, tx, ty in tiles: # print level, tx, ty - x = x0 + (tx * cardw) / 2 + level * dx - y = y0 + (ty * cardh) / 2 + level * dy + x = x0 + (tx * cardw) // 2 + level * dx + y = y0 + (ty * cardh) // 2 + level * dy stack = self.RowStack_Class(x, y, self) # stack.G = (level, tx, ty) stack.CARD_XOFFSET = dx @@ -599,7 +599,7 @@ class AbstractMahjonggGame(Game): if len(free_stacks) < 2: return None # try another way # - i = factorial(len(free_stacks))/2/factorial(len(free_stacks)-2) + i = factorial(len(free_stacks))//2//factorial(len(free_stacks)-2) old_pairs = [] for j in xrange(i): nc = new_cards[:] @@ -699,8 +699,8 @@ class AbstractMahjonggGame(Game): if nc[r.id] is None and is_suitable(r, nc)] old_pairs = [] - i = factorial(len(suitable_stacks))/2 \ - / factorial(len(suitable_stacks)-2) + i = factorial(len(suitable_stacks))//2 \ + // factorial(len(suitable_stacks)-2) for j in xrange(i): if iters[0] > max_iters: return None diff --git a/pysollib/games/matriarchy.py b/pysollib/games/matriarchy.py index 8d40eea4..72798aad 100644 --- a/pysollib/games/matriarchy.py +++ b/pysollib/games/matriarchy.py @@ -173,26 +173,26 @@ class Matriarchy(Game): # set window # (set piles so that at least 2/3 of a card is visible with 12 cards) - h = max(2*l.YS, (12-1)*l.YOFFSET + l.CH*2/3) + h = max(2*l.YS, (12-1)*l.YOFFSET + l.CH*2//3) self.setSize(10*l.XS+l.XM, h + l.YM + h) # create stacks - # center, c1, c2 = self.height / 2, h, self.height - h - center = self.height / 2 - c1, c2 = center-l.TEXT_HEIGHT/2, center+l.TEXT_HEIGHT/2 + # center, c1, c2 = self.height // 2, h, self.height - h + center = self.height // 2 + c1, c2 = center-l.TEXT_HEIGHT//2, center+l.TEXT_HEIGHT//2 x, y = l.XM, c1 - l.CH for i in range(8): - s.rows.append(Matriarchy_UpRowStack(x, y, self, i/2)) + s.rows.append(Matriarchy_UpRowStack(x, y, self, i//2)) x = x + l.XS x, y = l.XM, c2 for i in range(8): - s.rows.append(Matriarchy_DownRowStack(x, y, self, i/2)) + s.rows.append(Matriarchy_DownRowStack(x, y, self, i//2)) x = x + l.XS - x, y = x + l.XS / 2, c1 - l.CH / 2 - l.CH - tx = x + l.CW / 2 + x, y = x + l.XS // 2, c1 - l.CH // 2 - l.CH + tx = x + l.CW // 2 s.waste = Matriarchy_Waste(x, y, self) l.createText(s.waste, "s") - y = c2 + l.CH / 2 + y = c2 + l.CH // 2 s.talon = Matriarchy_Talon(x, y, self, max_rounds=VARIABLE_REDEALS) l.createText(s.talon, "n") l.createRoundText(s.talon, 'ss') diff --git a/pysollib/games/montana.py b/pysollib/games/montana.py index 3f11e285..7a4a832e 100644 --- a/pysollib/games/montana.py +++ b/pysollib/games/montana.py @@ -194,7 +194,7 @@ class Montana(Game): max_accept=1, max_cards=1)) x += l.XS if round_text: - x, y = l.XM + (self.RSTEP-1)*l.XS/2, self.height-l.YS + x, y = l.XM + (self.RSTEP-1)*l.XS//2, self.height-l.YS s.talon = self.Talon_Class(x, y, self) l.createRoundText(s.talon, 'se') else: @@ -555,7 +555,7 @@ class Spoilt(Game): s.rows.append(Spoilt_RowStack(x, y, self, max_accept=1, max_cards=2, min_cards=1)) x += l.XS - x, y = self.width/2 - l.XS, self.height-l.YS + x, y = self.width//2 - l.XS, self.height-l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'n') x += l.XS diff --git a/pysollib/games/montecarlo.py b/pysollib/games/montecarlo.py index b081094f..0a7e365d 100644 --- a/pysollib/games/montecarlo.py +++ b/pysollib/games/montecarlo.py @@ -284,11 +284,11 @@ class SimplePairs(MonteCarlo): # create stacks for i in range(3): for j in range(3): - x, y = l.XM + (2*j+3)*l.XS/2, l.YM + (2*i+1)*l.YS/2 + x, y = l.XM + (2*j+3)*l.XS//2, l.YM + (2*i+1)*l.YS//2 s.rows.append(self.RowStack_Class(x, y, self, max_accept=1, max_cards=2, dir=0, base_rank=NO_RANK)) - x, y = l.XM, l.YM + 3*l.YS/2 + x, y = l.XM, l.YM + 3*l.YS//2 s.talon = TalonStack(x, y, self, max_rounds=1) l.createText(s.talon, "s") x = x + 5*l.XS diff --git a/pysollib/games/napoleon.py b/pysollib/games/napoleon.py index 2d122487..30d4b293 100644 --- a/pysollib/games/napoleon.py +++ b/pysollib/games/napoleon.py @@ -209,7 +209,7 @@ class DerFreieNapoleon(DerKleineNapoleon): # set window # set size so that at least 2/3 of a card is visible with 15 cards - h = l.CH*2/3 + (15-1)*l.YOFFSET + h = l.CH*2//3 + (15-1)*l.YOFFSET h = l.YS + max(h, 3*l.YS) max_rows = 8+max(cells, reserves) self.setSize(l.XM + 2*l.XM + max_rows*l.XS, l.YM + h) @@ -223,9 +223,9 @@ class DerFreieNapoleon(DerKleineNapoleon): for j in range(reserves): x = x1 + j*l.XS s.rows.append(self.ReserveStack_Class(x, y, self)) - self.setRegion(s.rows, (-999, y - l.CH/2, 999999, 999999)) + self.setRegion(s.rows, (-999, y - l.CH//2, 999999, 999999)) y = l.YM - x = x1+(max(cells, reserves)-cells)*l.XS/2 + x = x1+(max(cells, reserves)-cells)*l.XS//2 for i in range(cells): s.reserves.append(self.FreeCell_Class(x, y, self)) x += l.XS @@ -298,7 +298,7 @@ class TheLittleCorporal(DerFreieNapoleon): def createGame(self, rows=10): l, s = Layout(self), self.s # set size so that at least 2/3 of a card is visible with 15 cards - h = l.CH*2/3 + (15-1)*l.YOFFSET + h = l.CH*2//3 + (15-1)*l.YOFFSET h = l.YS + max(h, 3*l.YS) self.setSize(l.XM+rows*l.XS, l.YM + h) @@ -376,7 +376,7 @@ class BusyCards(Game): l, s = Layout(self), self.s self.setSize(l.XM+rows*l.XS, l.YM + 3*l.YS+16*l.YOFFSET) - x, y = l.XM+(rows-8)*l.XS/2, l.YM + x, y = l.XM+(rows-8)*l.XS//2, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS @@ -385,8 +385,8 @@ class BusyCards(Game): base_rank=KING, dir=-1)) x += l.XS - x, y = l.XM+l.XS/2, l.YM+l.YS - for i in range(rows/2): + x, y = l.XM+l.XS//2, l.YM+l.YS + for i in range(rows//2): s.reserves.append(BusyCards_FreeCell(x, y, self)) x += 2*l.XS diff --git a/pysollib/games/needle.py b/pysollib/games/needle.py index 2697cade..498568e8 100644 --- a/pysollib/games/needle.py +++ b/pysollib/games/needle.py @@ -71,14 +71,14 @@ class Needle(Game): stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.reserves.append(stack) self.setRegion( - s.reserves, (-999, -999, w-4*l.XS-l.CW/2, l.YM+l.YS-l.CH/2)) + s.reserves, (-999, -999, w-4*l.XS-l.CW//2, l.YM+l.YS-l.CH//2)) x = w-4*l.XS for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS - x, y = l.XM+(w-(l.XM+9*l.XS))/2, l.YM+l.YS + x, y = l.XM+(w-(l.XM+9*l.XS))//2, l.YM+l.YS for i in range(9): s.rows.append(AC_RowStack(x, y, self, max_move=1)) x += l.XS diff --git a/pysollib/games/numerica.py b/pysollib/games/numerica.py index 7f60e4d7..1fb0540e 100644 --- a/pysollib/games/numerica.py +++ b/pysollib/games/numerica.py @@ -130,9 +130,9 @@ class Numerica(Game): self.setSize(l.XM+(1.5+max_rows)*l.XS+l.XM, l.YM + l.YS + h) # create stacks - x0 = l.XM + l.XS * 3 / 2 + x0 = l.XM + l.XS * 3 // 2 if decks == 1: - x = x0 + (rows-4)*l.XS/2 + x = x0 + (rows-4)*l.XS//2 else: x = x0 y = l.YM @@ -143,8 +143,8 @@ class Numerica(Game): for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - self.setRegion(s.rows, (x0-l.XS/2, y-l.CH/2, 999999, 999999)) - x, y = l.XM, l.YM+l.YS+l.YS/2*int(reserve) + self.setRegion(s.rows, (x0-l.XS//2, y-l.CH//2, 999999, 999999)) + x, y = l.XM, l.YM+l.YS+l.YS//2*int(reserve) s.talon = WasteTalonStack(x, y, self, max_rounds=max_rounds) if reserve or waste_max_cards > 1: l.createText(s.talon, 'ne') @@ -359,7 +359,7 @@ class Frog(Game): if self.Foundation_Class is RK_FoundationStack: suit = ANY_SUIT else: - suit = int(i/2) + suit = int(i//2) s.foundations.append(self.Foundation_Class(x, y, self, suit=suit, max_move=0)) x += l.XS @@ -462,7 +462,7 @@ class Gnat(Game): x += l.XS x = l.XM+6*l.XS for i in range(2): - y = l.YM + l.YS/2 + y = l.YM + l.YS//2 for j in range(3): s.reserves.append(OpenStack(x, y, self, max_accept=0)) y += l.YS @@ -523,12 +523,12 @@ class Gloaming(Game): l, s = Layout(self), self.s # set window - n = 52/reserves+1 + n = 52//reserves+1 w, h = l.XM + (reserves+rows+1)*l.XS, l.YM + 2*l.YS+n*l.YOFFSET self.setSize(w, h) # create stacks - x, y = l.XM+(reserves+rows+1-4)*l.XS/2, l.YM + x, y = l.XM+(reserves+rows+1-4)*l.XS//2, l.YM for i in range(4): if self.Foundation_Class is RK_FoundationStack: suit = ANY_SUIT @@ -557,7 +557,7 @@ class Gloaming(Game): l.defaultAll() def startGame(self): - n = 52/len(self.s.reserves)+1 + n = 52//len(self.s.reserves)+1 for i in range(n-3): self.s.talon.dealRow(rows=self.s.reserves, frames=0) self.startDealSample() @@ -608,14 +608,14 @@ class Toad(Game): l.createText(s.talon, "n") x, y = l.XM, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS - x, y = l.XM+3*l.XS/2, l.YM+l.YS + x, y = l.XM+3*l.XS//2, l.YM+l.YS for i in range(5): s.rows.append( Gloaming_RowStack(x, y, self, max_accept=UNLIMITED_ACCEPTS)) x += l.XS - y = l.YM+l.YS/2 + y = l.YM+l.YS//2 for i in (3, 3, 3, 3, 1): x = l.XM+8*l.XS for j in range(i): @@ -909,12 +909,12 @@ class Amphibian(Game): s.foundations.append(RK_FoundationStack(x, y, self, suit=ANY_SUIT)) x += l.XS - x, y = l.XM+(8-rows)*l.XS/2, l.YM + l.YS + x, y = l.XM+(8-rows)*l.XS//2, l.YM + l.YS for i in range(rows): s.rows.append(Gloaming_RowStack(x, y, self, max_accept=1)) x += l.XS - x, y = l.XM+(8-reserves-1)*l.XS/2, self.height-l.YS + x, y = l.XM+(8-reserves-1)*l.XS//2, self.height-l.YS for i in range(reserves): s.reserves.append(OpenStack(x, y, self, max_accept=0)) x += l.XS diff --git a/pysollib/games/osmosis.py b/pysollib/games/osmosis.py index 3280e229..9ed31ec6 100644 --- a/pysollib/games/osmosis.py +++ b/pysollib/games/osmosis.py @@ -266,7 +266,7 @@ class Genesis(Game): self.setSize(w, h) # create stacks - x, y, = l.XM+(rows-4)*l.XS/2, l.YM + x, y, = l.XM+(rows-4)*l.XS//2, l.YM for i in range(4): stack = Osmosis_Foundation( x, y, self, i, base_rank=ANY_RANK, max_move=0) diff --git a/pysollib/games/parallels.py b/pysollib/games/parallels.py index 9171ac6a..298044c8 100644 --- a/pysollib/games/parallels.py +++ b/pysollib/games/parallels.py @@ -153,11 +153,11 @@ class Parallels(Game): n += 1 x += l.XS y += l.YS - x, y = l.XM, l.YM+l.YS+l.YS/2 + x, y = l.XM, l.YM+l.YS+l.YS//2 for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) y += l.YS - x, y = l.XM+11*l.XS, l.YM+l.YS+l.YS/2 + x, y = l.XM+11*l.XS, l.YM+l.YS+l.YS//2 for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1)) diff --git a/pysollib/games/pasdedeux.py b/pysollib/games/pasdedeux.py index d6a8831b..7d41ed87 100644 --- a/pysollib/games/pasdedeux.py +++ b/pysollib/games/pasdedeux.py @@ -49,7 +49,7 @@ class PasDeDeux_Hint(AbstractHint): d = 0 if card.rank != stack.id % 13: d = d + 1 - if card.suit != stack.id / 13: + if card.suit != stack.id // 13: d = d + 1 return d @@ -63,7 +63,7 @@ class PasDeDeux_Hint(AbstractHint): # for each stack for r in rows: r1_d = self.getDistance(r, r.cards[-1]) - column, row = r.id % 13, r.id / 13 + column, row = r.id % 13, r.id // 13 stack_ids = list(range(column, 52, 13)) + \ list(range(13*row, 13*row+13)) for i in stack_ids: @@ -134,7 +134,7 @@ class PasDeDeux_RowStack(ReserveStack): game.leaveState(old_state) def getBottomImage(self): - suit = self.id / 13 + suit = self.id // 13 return self.game.app.images.getSuitBottom(suit) def quickPlayHandler(self, event, from_stacks=None, to_stacks=None): @@ -200,7 +200,7 @@ class PasDeDeux(Game): if len(r.cards) != 1: return False c = r.cards[-1] - if c.suit != r.id / 13 or c.rank != r.id % 13: + if c.suit != r.id // 13 or c.rank != r.id % 13: return False return True @@ -209,8 +209,8 @@ class PasDeDeux(Game): # def isNeighbour(self, stack1, stack2): - column1, row1 = stack1.id % 13, stack1.id / 13 - column2, row2 = stack2.id % 13, stack2.id / 13 + column1, row1 = stack1.id % 13, stack1.id // 13 + column2, row2 = stack2.id % 13, stack2.id // 13 return column1 == column2 or row1 == row2 def getHighlightPilesStacks(self): diff --git a/pysollib/games/picturegallery.py b/pysollib/games/picturegallery.py index 57bc5230..fcd8b843 100644 --- a/pysollib/games/picturegallery.py +++ b/pysollib/games/picturegallery.py @@ -215,18 +215,18 @@ class PictureGallery(Game): rows = len(self.TableauStack_Classes) # create layout l, s = Layout(self), self.s - TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET / 3)) + TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET // 3)) # set window - th = l.YS + (12/rows-1) * TABLEAU_YOFFSET + th = l.YS + (12//rows-1) * TABLEAU_YOFFSET # (set piles so that at least 2/3 of a card is visible with 10 cards) - h = (10-1)*l.YOFFSET + l.CH*2/3 + h = (10-1)*l.YOFFSET + l.CH*2//3 self.setSize(10*l.XS+l.XM, l.YM + 3*th + l.YM + h) # create stacks s.addattr(tableaux=[]) # register extra stack variable - x = l.XM + 8 * l.XS + l.XS / 2 - y = l.YM + l.CH / 2 + x = l.XM + 8 * l.XS + l.XS // 2 + y = l.YM + l.CH // 2 s.foundations.append(self.Foundation_Class(x, y, self)) y = l.YM for cl in self.TableauStack_Classes: @@ -239,8 +239,8 @@ class PictureGallery(Game): for i in range(8): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS - # self.setRegion(s.rows, (-999, -999, x - l.CW / 2, 999999)) - x = l.XM + 8 * l.XS + l.XS / 2 + # self.setRegion(s.rows, (-999, -999, x - l.CW // 2, 999999)) + x = l.XM + 8 * l.XS + l.XS // 2 y = self.height - l.YS s.talon = self.Talon_Class(x, y, self) l.createText(s.talon, "se") @@ -248,7 +248,7 @@ class PictureGallery(Game): y -= l.YS s.waste = WasteStack(x, y, self) l.createText(s.waste, "se") - self.setRegion(s.foundations, (x - l.CW / 2, -999, 999999, y - l.CH)) + self.setRegion(s.foundations, (x - l.CW // 2, -999, 999999, y - l.CH)) # define stack-groups if waste: @@ -406,14 +406,14 @@ class MountOlympus(Game): s.foundations.append( MountOlympus_Foundation( x, y, self, - suit=i/2, base_rank=ACE, dir=2, max_move=0, max_cards=7)) + suit=i//2, base_rank=ACE, dir=2, max_move=0, max_cards=7)) x += l.XS x, y = l.XM+l.XS, l.YM+l.YS for i in range(8): s.foundations.append( MountOlympus_Foundation( x, y, self, - suit=i/2, base_rank=1, dir=2, max_move=0, max_cards=6)) + suit=i//2, base_rank=1, dir=2, max_move=0, max_cards=6)) x += l.XS x, y = l.XM, l.YM+2*l.YS for i in range(9): diff --git a/pysollib/games/pileon.py b/pysollib/games/pileon.py index 284b67f0..acfd7f68 100644 --- a/pysollib/games/pileon.py +++ b/pysollib/games/pileon.py @@ -158,7 +158,7 @@ class Foursome(Game): l, s = Layout(self), self.s max_rows = max(8, rows) self.setSize(l.XM+max_rows*l.XS, l.YM+2*l.YS+13*l.YOFFSET) - x, y = l.XM+l.XS*(max_rows-4)/2, l.YM + x, y = l.XM+l.XS*(max_rows-4)//2, l.YM for i in range(4): s.reserves.append(ReserveStack(x, y, self)) x += l.XS @@ -166,7 +166,7 @@ class Foursome(Game): s.foundations.append(AbstractFoundationStack(x, y, self, suit=ANY_SUIT, max_cards=52, max_accept=0)) l.createText(s.foundations[0], 'nw') - x, y = l.XM+l.XS*(max_rows-rows)/2, l.YM+l.YS + x, y = l.XM+l.XS*(max_rows-rows)//2, l.YM+l.YS for i in range(rows): s.rows.append(UD_AC_RowStack(x, y, self, mod=13)) x += l.XS diff --git a/pysollib/games/pyramid.py b/pysollib/games/pyramid.py index 28bddbb9..c5738506 100644 --- a/pysollib/games/pyramid.py +++ b/pysollib/games/pyramid.py @@ -199,8 +199,8 @@ class Pyramid(Game): rows = [] # create stacks for i in range(size): - x = x0 + (size-1-i) * l.XS / 2 - y = y0 + i * l.YS / self.PYRAMID_Y_FACTOR + x = x0 + (size-1-i) * l.XS // 2 + y = y0 + i * l.YS // self.PYRAMID_Y_FACTOR for j in range(i+1): stack = self.RowStack_Class(x, y, self) rows.append(stack) @@ -218,8 +218,8 @@ class Pyramid(Game): rows = [] # create stacks for i in range(size): - x = x0 + i * l.XS / 2 - y = y0 + i * l.YS / self.PYRAMID_Y_FACTOR + x = x0 + i * l.XS // 2 + y = y0 + i * l.YS // self.PYRAMID_Y_FACTOR for j in range(size-i): stack = self.RowStack_Class(x, y, self) rows.append(stack) @@ -245,7 +245,7 @@ class Pyramid(Game): # set window max_rows = max(pyramid_len+2, reserves) w = l.XM + max_rows*l.XS - h = l.YM + l.YS + (pyramid_len-1)*l.YS/self.PYRAMID_Y_FACTOR + h = l.YM + l.YS + (pyramid_len-1)*l.YS//self.PYRAMID_Y_FACTOR if reserves: h += l.YS+2*l.YOFFSET self.setSize(w, h) @@ -272,7 +272,7 @@ class Pyramid(Game): max_move=0, max_cards=52*decks)) l.createText(s.foundations[0], 's') if reserves: - x, y = l.XM+(max_rows-reserves)*l.XS/2, l.YM+4*l.YS + x, y = l.XM+(max_rows-reserves)*l.XS//2, l.YM+4*l.YS for i in range(reserves): stack = self.Reserve_Class(x, y, self) s.reserves.append(stack) @@ -358,8 +358,8 @@ class Thirteen(Pyramid): # create stacks for i in range(7): - x = l.XM + (6-i) * l.XS / 2 - y = l.YM + l.YS + i * l.YS / 2 + x = l.XM + (6-i) * l.XS // 2 + y = l.YM + l.YS + i * l.YS // 2 for j in range(i+1): s.rows.append(Pyramid_RowStack(x, y, self)) x = x + l.XS @@ -1130,7 +1130,7 @@ class KingTut(RelaxedPyramid): h = l.YM + 5.5*l.YS self.setSize(w, h) - x, y = l.XM+(w-7*l.XS)/2, l.YM + x, y = l.XM+(w-7*l.XS)//2, l.YM s.rows = self._createPyramid(l, x, y, 7) x, y = l.XM, self.height-l.YS @@ -1216,7 +1216,7 @@ class UpAndDown(Pyramid): self.setSize(w, h) # create stacks - x, y = l.XM+l.XS/2, l.YM + x, y = l.XM+l.XS//2, l.YM s.rows = self._createPyramid(l, x, y, 7) x += 5.5*l.XS s.rows += self._createInvertedPyramid(l, x, y, 7) @@ -1296,7 +1296,7 @@ class Hurricane(Pyramid): l, s = Layout(self), self.s # set window - ww = l.XS + max(2*l.XOFFSET, l.XS/2) + ww = l.XS + max(2*l.XOFFSET, l.XS//2) w = l.XM + 1.5*l.XS + 4*ww h = l.YM + 3*l.YS self.setSize(w, h) @@ -1312,7 +1312,7 @@ class Hurricane(Pyramid): s.reserves.append(stack) d = 3*ww - 4*l.XS - 2*l.XOFFSET - x = l.XM + 1.5*l.XS + l.XS+2*l.XOFFSET + d/2 + x = l.XM + 1.5*l.XS + l.XS+2*l.XOFFSET + d//2 y = l.YM+l.YS for i in range(3): stack = Hurricane_RowStack(x, y, self, max_accept=1) diff --git a/pysollib/games/royalcotillion.py b/pysollib/games/royalcotillion.py index 7818de0b..5bef5e98 100644 --- a/pysollib/games/royalcotillion.py +++ b/pysollib/games/royalcotillion.py @@ -326,13 +326,13 @@ class Alhambra(Game): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, max_move=0, base_rank=KING, dir=-1)) x = x + l.XS - x, y, = l.XM+(8-reserves)*l.XS/2, y+l.YS + x, y, = l.XM+(8-reserves)*l.XS//2, y+l.YS for i in range(reserves): stack = OpenStack(x, y, self, max_accept=0) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET s.reserves.append(stack) x = x + l.XS - x, y = l.XM+(8-1-rows)*l.XS/2, self.height-l.YS + x, y = l.XM+(8-1-rows)*l.XS//2, self.height-l.YS s.talon = Alhambra_Talon(x, y, self, max_rounds=3) if rows == 1: l.createText(s.talon, 'sw') @@ -538,7 +538,7 @@ class BritishConstitution(Game): x, y = l.XM+l.XS, l.YM for i in range(8): s.foundations.append(BritishConstitution_Foundation(x, y, self, - suit=int(i/2), max_cards=11)) + suit=int(i//2), max_cards=11)) x += l.XS y = l.YM+l.YS @@ -684,7 +684,7 @@ class ThreePirates(Game): x, y, = l.XM+l.XS, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x = x + l.XS x, y, = l.XM, l.YM+l.YS @@ -965,8 +965,8 @@ class ShadyLanes(Game): x, y = l.XM, l.YM for i in range(8): - suit = i/2 - color = suit/2 + suit = i//2 + color = suit//2 s.foundations.append( ShadyLanes_Foundation( x, y, self, @@ -1151,7 +1151,7 @@ class Colonel(Game): x, y = l.XM+2*l.XS, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2, max_move=0)) x += l.XS @@ -1216,7 +1216,7 @@ class TheRedAndTheBlack(Game): x, y = l.XM, l.YM for i in range(8): s.foundations.append(TheRedAndTheBlack_Foundation(x, y, self, - suit=i/2)) + suit=i//2)) x += l.XS x, y = l.XM+2*l.XS, l.YM+l.YS for i in range(4): @@ -1329,7 +1329,7 @@ class TwilightZone(Game): s.reserves.append(OpenStack(x, y, self)) x += l.XS - x, y = l.XM, l.YM+l.YS/2 + x, y = l.XM, l.YM+l.YS//2 s.talon = TwilightZone_Talon(x, y, self, max_move=1, max_rounds=2) l.createText(s.talon, 's') l.createRoundText(s.talon, 'nn') diff --git a/pysollib/games/royaleast.py b/pysollib/games/royaleast.py index 8e33c614..3b026f8a 100644 --- a/pysollib/games/royaleast.py +++ b/pysollib/games/royaleast.py @@ -62,17 +62,17 @@ class RoyalEast(Game): # create stacks for i in range(4): dx, dy = ((0, 0), (2, 0), (0, 2), (2, 2))[i] - x, y = l.XM + (2*dx+5)*l.XS/2, l.YM + (2*dy+1)*l.YS/2 + x, y = l.XM + (2*dx+5)*l.XS//2, l.YM + (2*dy+1)*l.YS//2 stack = SS_FoundationStack(x, y, self, i, mod=13, max_move=0) stack.CARD_YOFFSET = 0 s.foundations.append(stack) for i in range(5): dx, dy = ((1, 0), (0, 1), (1, 1), (2, 1), (1, 2))[i] - x, y = l.XM + (2*dx+5)*l.XS/2, l.YM + (2*dy+1)*l.YS/2 + x, y = l.XM + (2*dx+5)*l.XS//2, l.YM + (2*dy+1)*l.YS//2 stack = RK_RowStack(x, y, self, mod=13, max_move=1) stack.CARD_YOFFSET = 0 s.rows.append(stack) - x, y = l.XM, l.YM + 3*l.YS/2 + x, y = l.XM, l.YM + 3*l.YS//2 s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, "s") x = x + l.XS diff --git a/pysollib/games/simplex.py b/pysollib/games/simplex.py index 7f127a71..cdaecfc3 100644 --- a/pysollib/games/simplex.py +++ b/pysollib/games/simplex.py @@ -92,7 +92,7 @@ class Simplex(Game): stack = Simplex_Foundation( x, y, self, suit=ANY_SUIT, base_rank=ANY_RANK, max_cards=52) - xoffset = (self.width-3*l.XS)/51 + xoffset = (self.width-3*l.XS)//51 stack.CARD_XOFFSET, stack.CARD_YOFFSET = xoffset, 0 s.foundations.append(stack) x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT diff --git a/pysollib/games/special/memory.py b/pysollib/games/special/memory.py index 4f18fc67..b0450302 100644 --- a/pysollib/games/special/memory.py +++ b/pysollib/games/special/memory.py @@ -287,7 +287,7 @@ class Concentration(Memory24): x, y = l.XM + j*l.XS, l.YM + i*l.YS s.rows.append(Concentration_RowStack(x, y, self, max_move=0, max_accept=0, max_cards=1)) - x, y = l.XM + self.COLUMNS*l.XS/2, self.height - l.YS + x, y = l.XM + self.COLUMNS*l.XS//2, self.height - l.YS s.talon = InitialDealTalonStack(x, y, self) l.createText(s.talon, dx=-10, anchor="sw", text_format="%D") diff --git a/pysollib/games/special/pegged.py b/pysollib/games/special/pegged.py index 236e0d22..e680a314 100644 --- a/pysollib/games/special/pegged.py +++ b/pysollib/games/special/pegged.py @@ -90,7 +90,7 @@ class Pegged_RowStack(ReserveStack): from_stack.pos[1] - self.pos[1] if not self.game.STEP_MAP.get((dx, dy)): return None - s = self.game.map.get((self.pos[0] + dx/2, self.pos[1] + dy/2)) + s = self.game.map.get((self.pos[0] + dx//2, self.pos[1] + dy//2)) if not s or not s.cards: return None return s @@ -133,7 +133,7 @@ class Pegged(Game): r = self.ROWS[i] for j in range(r): d = m - r + 2*j - x, y = l.XM + d*l.XS/2, l.YM + i*l.YS + x, y = l.XM + d*l.XS//2, l.YM + i*l.YS stack = Pegged_RowStack(x, y, self) stack.pos = (d, 2*i) # print stack.id, stack.pos @@ -154,7 +154,7 @@ class Pegged(Game): for step in self.STEPS: self.STEP_MAP[step] = 1 if self.EMPTY_STACK_ID < 0: - self.EMPTY_STACK_ID = len(s.rows) / 2 + self.EMPTY_STACK_ID = len(s.rows) // 2 # Define stack groups l.defaultStackGroups() @@ -210,7 +210,7 @@ class Pegged(Game): for dx, dy in self.STEPS: s = self.map.get((rx + dx, ry + dy)) if s and not s.cards: - m = self.map.get((rx + dx/2, ry + dy/2)) + m = self.map.get((rx + dx//2, ry + dy//2)) if m and m.cards: rows.append(r) return ((rows, 1),) diff --git a/pysollib/games/special/tarock.py b/pysollib/games/special/tarock.py index 647f410e..902c50dc 100644 --- a/pysollib/games/special/tarock.py +++ b/pysollib/games/special/tarock.py @@ -259,7 +259,8 @@ class WheelOfFortune(AbstractTarockGame): for i in range(21): x0 = x + xoffset[i] * l.XS y0 = y + yoffset[i] * l.YS - s.rows.append(WheelOfFortune_RowStack(x0, y0, self, yoffset=l.CH/4, + s.rows.append(WheelOfFortune_RowStack(x0, y0, self, + yoffset=l.CH//4, max_cards=2, max_move=1, max_accept=1)) self.setRegion(s.rows, (-999, -999, l.XS * 9, 999999)) @@ -676,7 +677,7 @@ class Grasshopper(AbstractTarockGame): # Set window size decks = self.gameinfo.decks self.setSize(2*l.XM + (2 + 5*decks)*l.XS, 3*l.YM + 5*l.YS) - yoffset = min(l.YOFFSET, max(10, l.YOFFSET / 2)) + yoffset = min(l.YOFFSET, max(10, l.YOFFSET // 2)) # Create talon x = l.XM @@ -792,7 +793,7 @@ class Ponytail(Tarock_GameMethods, Braid): s.rows.append(Ponytail_ReserveStack(x, y + 2 * l.YS, self)) s.rows.append(Ponytail_ReserveStack(x + l.XS, y + 2 * l.YS, self)) x = x + 4 * l.XS - x = l.XM + 5*l.XS/2 + x = l.XM + 5*l.XS//2 y = l.YM s.braid = Ponytail_PonytailStack(x, y, self, sine=1) x = l.XM + 7 * l.XS @@ -801,7 +802,7 @@ class Ponytail(Tarock_GameMethods, Braid): l.createText(s.talon, "s") s.talon.texts.rounds = MfxCanvasText( self.canvas, - x + l.CW / 2, y - l.YM, + x + l.CW // 2, y - l.YM, anchor="s", font=self.app.getFont("canvas_default")) x = x - l.XS @@ -823,7 +824,7 @@ class Ponytail(Tarock_GameMethods, Braid): # ??? self.texts.info = MfxCanvasText( self.canvas, - x + l.CW + l.XM / 2, y + l.YS, + x + l.CW + l.XM // 2, y + l.YS, anchor="n", font=self.app.getFont("canvas_default")) diff --git a/pysollib/games/spider.py b/pysollib/games/spider.py index a3276663..7403b9fa 100644 --- a/pysollib/games/spider.py +++ b/pysollib/games/spider.py @@ -598,8 +598,8 @@ class Cicely(Game): x += l.XS s.talon = Cicely_Talon(l.XM, l.YM, self) l.createText(s.talon, "ne") - l.setRegion(s.rows, (l.XM+1.5*l.XS-l.CW/2, l.YM+l.YS-l.CH/2, - w-1.5*l.XS-l.CW/2, 999999)) + l.setRegion(s.rows, (l.XM+1.5*l.XS-l.CW//2, l.YM+l.YS-l.CH//2, + w-1.5*l.XS-l.CW//2, 999999)) # define stack-groups l.defaultStackGroups() @@ -639,7 +639,7 @@ class Trillium(Game): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS - s.talon = DealRowTalonStack(l.XM+(rows-1)*l.XS/2, h-l.YS, self) + s.talon = DealRowTalonStack(l.XM+(rows-1)*l.XS//2, h-l.YS, self) l.createText(s.talon, "se") # define stack-groups @@ -957,7 +957,7 @@ class Spider4Decks(BigSpider): for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS - l.setRegion(s.rows, (-999, -999, l.XM+rows*l.XS-l.CW/2, 999999)) + l.setRegion(s.rows, (-999, -999, l.XM+rows*l.XS-l.CW//2, 999999)) x = l.XM+rows*l.XS for i in range(2): y = l.YM @@ -1263,7 +1263,7 @@ class Bebop(Game): x, y = l.XM+2*l.XS, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = l.XM+l.XS, l.YM+l.YS for i in range(8): diff --git a/pysollib/games/sultan.py b/pysollib/games/sultan.py index e0e603a4..2b5e4507 100644 --- a/pysollib/games/sultan.py +++ b/pysollib/games/sultan.py @@ -94,12 +94,12 @@ class Sultan(Game): s.foundations.append(stack) x, y = l.XM, l.YM - for i in range(reserves/2): + for i in range(reserves//2): s.rows.append(ReserveStack(x, y, self)) y += l.YS x, y = 3*l.XM+4*l.XS, l.YM - for i in range(reserves/2): + for i in range(reserves//2): s.rows.append(ReserveStack(x, y, self)) y += l.YS @@ -216,7 +216,7 @@ class CaptiveQueens(Game): l, s = Layout(self), self.s self.setSize(l.XM+5.5*l.XS, l.YM+3*l.YS) - x, y = l.XM, l.YM+l.YS/2 + x, y = l.XM, l.YM+l.YS//2 s.talon = WasteTalonStack(x, y, self, max_rounds=3) l.createText(s.talon, "se") l.createRoundText(s.talon, 'nn') @@ -265,12 +265,12 @@ class Contradance(Game): x, y = l.XM, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2, base_rank=4, dir=-1, mod=13, max_cards=6)) x += l.XS x, y = l.XM, l.YM+l.YS for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2, base_rank=5, max_cards=7)) x += l.XS @@ -550,7 +550,7 @@ class PicturePatience(Game): max_cards=1, max_accept=1)) x += l.XS y += l.YS - x, y = 2*l.XM+l.XS+l.XS/2, l.YM+3*l.YS + x, y = 2*l.XM+l.XS+l.XS//2, l.YM+3*l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=max_rounds) x += l.XS s.waste = WasteStack(x, y, self) @@ -671,14 +671,14 @@ class TwoRings(Game): x0, y0 = l.XM+l.XS, l.YM for xx, yy in lay: x, y = x0+xx*l.XS, y0+yy*l.YS - s.foundations.append(SS_FoundationStack(x, y, self, suit=suit/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=suit//2, base_rank=6, max_cards=7)) suit += 1 suit = 0 x0, y0 = l.XM+5*l.XS, l.YM for xx, yy in lay: x, y = x0+xx*l.XS, y0+yy*l.YS - s.foundations.append(SS_FoundationStack(x, y, self, suit=suit/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=suit//2, base_rank=5, dir=-1, max_cards=6)) suit += 1 @@ -734,7 +734,7 @@ class CornerSuite(Game): s.foundations.append(SS_FoundationStack(x, y, self, suit=suit)) suit += 1 - x, y = l.XM+3*l.XS/2, l.YM + x, y = l.XM+3*l.XS//2, l.YM s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'nw') x += l.XS @@ -787,12 +787,12 @@ class Marshal(Game): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1)) y += l.YS - x, y = (self.width-l.XS)/2, self.height-l.YS + x, y = (self.width-l.XS)//2, self.height-l.YS s.talon = DealRowTalonStack(x, y, self) l.createText(s.talon, 'se') y = l.YM for i in range(4): - x = l.XM+l.XS*3/2 + x = l.XM+l.XS*3//2 for j in range(6): stack = UD_SS_RowStack(x, y, self, base_rank=NO_RANK) s.rows.append(stack) @@ -965,7 +965,7 @@ class Adela(Game): x, y = l.XM, l.YM+l.YS s.talon = DealRowTalonStack(x, y, self) l.createText(s.talon, 'n') - x, y = l.XM+l.XS/2, l.YM+3*l.YS + x, y = l.XM+l.XS//2, l.YM+3*l.YS for i in range(9): stack = SS_RowStack(x, y, self, max_move=1, dir=1) s.rows.append(stack) @@ -1101,7 +1101,7 @@ class Phalanx(Game): y = l.YM for i in range(5): - x = l.XM+(8-i)*l.XS/2 + x = l.XM+(8-i)*l.XS//2 for j in range(i+1): s.rows.append(ReserveStack(x, y, self)) x += l.XS @@ -1149,11 +1149,11 @@ class Grandee(Game): # set window decks = self.gameinfo.decks - w = max(decks*4, rows/2) + w = max(decks*4, rows//2) self.setSize(l.XM+w*l.XS, l.YM+5*l.YS) # create stacks - x, y = l.XM + (w-decks*4)*l.XS/2, l.YM + x, y = l.XM + (w-decks*4)*l.XS//2, l.YM for i in range(4): for j in range(decks): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) @@ -1161,8 +1161,8 @@ class Grandee(Game): y = l.YM+1.5*l.YS for i in range(2): - x = l.XM + (w-rows/2)*l.XS/2 - for j in range(rows/2): + x = l.XM + (w-rows//2)*l.XS//2 + for j in range(rows//2): stack = self.RowStack_Class(x, y, self, max_move=1) stack.CARD_YOFFSET = 0 s.rows.append(stack) @@ -1248,7 +1248,7 @@ class DesertIsland(Game): x, y = l.XM, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, - suit=i/2, max_cards=10)) + suit=i//2, max_cards=10)) x += l.XS y = l.YM+l.YS diff --git a/pysollib/games/terrace.py b/pysollib/games/terrace.py index 1d088b00..079bec27 100644 --- a/pysollib/games/terrace.py +++ b/pysollib/games/terrace.py @@ -154,7 +154,7 @@ class Terrace(Game): # (piles up to 16 cards are playable in default window size) decks = self.gameinfo.decks maxrows = max(rows, decks*4+1) - w1, w2 = (maxrows - decks*4)*l.XS/2, (maxrows - rows)*l.XS/2 + w1, w2 = (maxrows - decks*4)*l.XS//2, (maxrows - rows)*l.XS//2 h = max(3*l.YS, playcards*l.YOFFSET) self.setSize(l.XM + maxrows*l.XS + l.XM, l.YM + 3*l.YS + h) diff --git a/pysollib/games/tournament.py b/pysollib/games/tournament.py index a96c4476..82fc46ae 100644 --- a/pysollib/games/tournament.py +++ b/pysollib/games/tournament.py @@ -298,11 +298,11 @@ class LadiesBattle(Game): s.rows.append(LadiesBattle_RowStack(x, y, self, max_move=1, mod=13)) x = x + l.XS - x, y = l.XM, l.YM+l.YS/2 + x, y = l.XM, l.YM+l.YS//2 for i in range(4): s.reserves.append(OpenStack(x, y, self, max_accept=0)) y += l.YS - x, y = self.width-l.XS, l.YM+l.YS/2 + x, y = self.width-l.XS, l.YM+l.YS//2 for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, base_rank=QUEEN, mod=13)) diff --git a/pysollib/games/ultra/dashavatara.py b/pysollib/games/ultra/dashavatara.py index 77074a67..19238985 100644 --- a/pysollib/games/ultra/dashavatara.py +++ b/pysollib/games/ultra/dashavatara.py @@ -403,8 +403,8 @@ class DashavataraCircles(AbstractDashavataraGame): self.setSize(w, h) # Create row stacks - x = w / 2 - l.CW / 2 - y = h / 2 - l.YS / 2 + x = w // 2 - l.CW // 2 + y = h // 2 - l.YS // 2 x0 = (-.7, .3, .7, -.3, -1.7, -1.5, -.6, .6, 1.5, 1.7, 1.5, .6, -.6, -1.5, -2.7, -2.5, -1.9, -1, 0, 1, 1.9, 2.5, 2.7, 2.5, 1.9, @@ -882,7 +882,7 @@ class Journey(AbstractDashavataraGame): y = y + l.YS self.texts.info = MfxCanvasText( self.canvas, - self.width / 2, h - l.YM / 2, + self.width // 2, h - l.YM // 2, anchor="center", font=self.app.getFont("canvas_default")) @@ -900,7 +900,7 @@ class Journey(AbstractDashavataraGame): l.createText(s.talon, "s") s.talon.texts.rounds = MfxCanvasText( self.canvas, - self.width / 2, h - l.YM * 2.5, + self.width // 2, h - l.YM * 2.5, anchor="center", font=self.app.getFont("canvas_default")) x = x + l.XS * 2 @@ -1015,7 +1015,7 @@ class AppachansWaterfall(AbstractDashavataraGame): self.setRegion(s.rows, (-999, -999, 999999, l.YM + l.YS * 5)) # Create foundation - x, y = w / 2 - l.CW / 2, h - l.YS + x, y = w // 2 - l.CW // 2, h - l.YS s.foundations.append(AppachansWaterfall_Foundation(x, y, self, -1)) # Create reserves @@ -1064,7 +1064,7 @@ class Hiranyaksha(AbstractDashavataraGame): self.setSize(l.XM + (maxrows + 2) * l.XS, l.YM + 6 * l.YS) # - playcards = 4 * l.YS / l.YOFFSET + playcards = 4 * l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -1074,12 +1074,12 @@ class Hiranyaksha(AbstractDashavataraGame): yoffset.append(0) # create stacks - x, y = l.XM + (maxrows - reserves) * l.XS / 2, l.YM + x, y = l.XM + (maxrows - reserves) * l.XS // 2, l.YM for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows - rows) * l.XS / 2, l.YM + l.YS - self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM / 2)) + x, y = l.XM + (maxrows - rows) * l.XS // 2, l.YM + l.YS + self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM // 2)) for i in range(rows): stack = self.RowStack_Class(x, y, self, yoffset=l.YOFFSET) stack.CARD_XOFFSET = xoffset @@ -1096,7 +1096,7 @@ class Hiranyaksha(AbstractDashavataraGame): self.setRegion(self.s.foundations, (x - l.XS * 2, -999, 999999, self.height - (l.YS + l.YM)), priority=1) s.talon = InitialDealTalonStack( - self.width - 3 * l.XS / 2, self.height - l.YS, self) + self.width - 3 * l.XS // 2, self.height - l.YS, self) # define stack-groups l.defaultStackGroups() @@ -1215,17 +1215,17 @@ class Dashavatara(Game): def createGame(self): # create layout l, s = Layout(self), self.s - TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET / 3)) + TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET // 3)) # set window th = l.YS + 3 * TABLEAU_YOFFSET # (set piles so that at least 2/3 of a card is visible with 10 cards) - h = 10 * l.YOFFSET + l.CH * 2/3 + h = 10 * l.YOFFSET + l.CH * 2//3 self.setSize(11 * l.XS + l.XM * 2, l.YM + 3 * th + l.YM + h) # create stacks s.addattr(tableaux=[]) # register extra stack variable - x = l.XM + 8 * l.XS + l.XS / 2 + x = l.XM + 8 * l.XS + l.XS // 2 y = l.YM for i in range(3, 0, -1): x = l.XM diff --git a/pysollib/games/ultra/hanafuda.py b/pysollib/games/ultra/hanafuda.py index fcf7a719..7871b042 100644 --- a/pysollib/games/ultra/hanafuda.py +++ b/pysollib/games/ultra/hanafuda.py @@ -82,13 +82,13 @@ class FlowerClock(AbstractFlowerGame): xoffset = (1, 2, 2.5, 2, 1, 0, -1, -2, -2.5, -2, -1, 0) yoffset = (0.25, 0.75, 1.9, 3, 3.5, 3.75, 3.5, 3, 1.9, 0.75, 0.25, 0) x = l.XM + l.XS * 7 - y = l.CH / 3 + y = l.CH // 3 for i in range(12): x0 = x + xoffset[i] * l.XS y0 = y + yoffset[i] * l.YS stack = FlowerClock_Foundation(x0, y0, self, ANY_SUIT, base_rank=3) s.foundations.append(stack) - t = MfxCanvasText(self.canvas, x0 + l.CW / 2, y0 + l.YS, + t = MfxCanvasText(self.canvas, x0 + l.CW // 2, y0 + l.YS, anchor="center", font=font, text=self.SUITS[i]) stack.texts.misc = t @@ -97,7 +97,8 @@ class FlowerClock(AbstractFlowerGame): for j in range(2): x, y = l.XM, l.YM + l.YS * j * 2.7 for i in range(4): - s.rows.append(FlowerClock_RowStack(x, y, self, yoffset=l.CH/4, + s.rows.append(FlowerClock_RowStack(x, y, self, + yoffset=l.CH//4, max_cards=8, max_accept=8)) x = x + l.XS self.setRegion(s.rows, (0, 0, l.XS * 4, 999999)) @@ -168,7 +169,7 @@ class Gaji(AbstractFlowerGame): # Create row stacks x = l.XS * 2.5 + l.XM for i in range(8): - s.rows.append(Gaji_RowStack(x, y, self, yoffset=l.CH/2, + s.rows.append(Gaji_RowStack(x, y, self, yoffset=l.CH//2, max_cards=12, max_accept=12)) x += l.XS self.setRegion( @@ -337,7 +338,7 @@ class Pagoda(AbstractFlowerGame): for i in range(3): stack = Pagoda_Foundation(x, y, self, id) s.foundations.append(stack) - t = MfxCanvasText(self.canvas, x + l.CW / 2, y - 12, + t = MfxCanvasText(self.canvas, x + l.CW // 2, y - 12, anchor="center", font=font) stack.texts.misc = t x = x + l.XS @@ -433,7 +434,7 @@ class MatsuKiri(AbstractFlowerGame): x = l.XM y = l.YM for i in range(8): - s.rows.append(Matsukiri_RowStack(x, y, self, yoffset=l.CH/2, + s.rows.append(Matsukiri_RowStack(x, y, self, yoffset=l.CH//2, max_cards=12, max_accept=12)) x = x + l.XS self.setRegion(s.rows, (-999, -999, l.XM + (l.XS * 8) + 10, 999999)) @@ -492,20 +493,20 @@ class GreatWall(AbstractFlowerGame): self.setSize(w, h) # Create foundations - x, y = (l.XM, l.XM, w - l.XS, w - l.XS), (l.YM, h / 2, l.YM, h / 2) + x, y = (l.XM, l.XM, w - l.XS, w - l.XS), (l.YM, h // 2, l.YM, h // 2) for i in range(4): stack = GreatWall_FoundationStack(x[i], y[i] + l.YM, self, -1, base_rank=i) s.foundations.append(stack) stack.texts.misc = MfxCanvasText(self.canvas, - x[i] + l.CW / 2, y[i], + x[i] + l.CW // 2, y[i], anchor="center", font=font) # Create row stacks x = l.XM + l.XS * 1.5 y = l.YM for i in range(12): - s.rows.append(GreatWall_RowStack(x, y, self, yoffset=l.CH/4, + s.rows.append(GreatWall_RowStack(x, y, self, yoffset=l.CH//4, max_cards=26, max_accept=26)) x = x + l.XS self.setRegion( @@ -513,7 +514,7 @@ class GreatWall(AbstractFlowerGame): 999999)) # Create talon - x = self.width / 2 - l.CW / 2 + x = self.width // 2 - l.CW // 2 y = self.height - l.YS * 1.2 s.talon = InitialDealTalonStack(x, y, self) @@ -529,7 +530,7 @@ class GreatWall(AbstractFlowerGame): return for i in range(4): stack = self.s.foundations[i] - l = len(stack.cards) / 12 + l = len(stack.cards) // 12 if l == 0: text = "" elif l == 4: @@ -600,7 +601,7 @@ class FourWinds(AbstractFlowerGame): max_cards=12, max_accept=1, base_rank=i) s.foundations.append(stack) - t = MfxCanvasText(self.canvas, x0 + l.CW / 2, y0 + l.YS + 5, + t = MfxCanvasText(self.canvas, x0 + l.CW // 2, y0 + l.YS + 5, anchor="center", font=font, text=TEXTS[i]) stack.texts.misc = t @@ -615,7 +616,7 @@ class FourWinds(AbstractFlowerGame): max_cards=3, max_accept=1, base_rank=ANY_RANK) s.rows.append(stack) - t = MfxCanvasText(self.canvas, x0 + l.CW / 2, y0 + l.YS + 5, + t = MfxCanvasText(self.canvas, x0 + l.CW // 2, y0 + l.YS + 5, anchor="center", font=font, text=TEXTS[i+4]) stack.texts.misc = t diff --git a/pysollib/games/ultra/hanafuda1.py b/pysollib/games/ultra/hanafuda1.py index 76ab3863..19934d46 100644 --- a/pysollib/games/ultra/hanafuda1.py +++ b/pysollib/games/ultra/hanafuda1.py @@ -162,7 +162,7 @@ class LesserQueue(AbstractFlowerGame): # Create rows, reserves s.addattr(braid=None) x, x0 = l.XM + l.XS * 2, (decks - 1.5) % 2.5 - for j in range(decks / 2): + for j in range(decks // 2): y = l.YM for i in range(2): s.rows.append(Queue_RowStack(x + l.XS * (x0 + j), y, self)) @@ -190,7 +190,7 @@ class LesserQueue(AbstractFlowerGame): l.createText(s.talon, "n") s.talon.texts.rounds = MfxCanvasText( self.canvas, - self.width/2, h-2*l.TEXT_MARGIN, + self.width//2, h-2*l.TEXT_MARGIN, anchor="center", font=self.app.getFont("canvas_default")) x = x + l.XS @@ -199,7 +199,7 @@ class LesserQueue(AbstractFlowerGame): # Create foundations x = l.XM - for j in range(decks / 2): + for j in range(decks // 2): y = l.YM for i in range(4): s.foundations.append(Queue_Foundation( @@ -214,7 +214,7 @@ class LesserQueue(AbstractFlowerGame): x = x + l.XS self.texts.info = MfxCanvasText( self.canvas, - self.width/2, h-l.TEXT_MARGIN, + self.width//2, h-l.TEXT_MARGIN, anchor="center", font=self.app.getFont("canvas_default")) @@ -327,7 +327,7 @@ class JapaneseGarden(AbstractFlowerGame): self.setSize(l.XM + l.XS * self.WIDTH, l.YM * 3 + l.YS * self.HEIGHT) # Create foundations - x = self.width / 2 + l.XM / 2 - l.XS * 3 + x = self.width // 2 + l.XM // 2 - l.XS * 3 y = l.YM for j in range(2): for i in range(6): @@ -336,7 +336,7 @@ class JapaneseGarden(AbstractFlowerGame): x, y, self, i + (j * 6), max_cards=4, max_accept=1, base_rank=3)) x = x + l.XS - x = self.width / 2 + l.XM / 2 - l.XS * 3 + x = self.width // 2 + l.XM // 2 - l.XS * 3 y = y + l.YS # Create flower beds @@ -348,21 +348,21 @@ class JapaneseGarden(AbstractFlowerGame): x, y, self, yoffset=0, max_accept=self.MAX_MOVE, max_move=self.MAX_MOVE, max_cards=self.MAX_CARDS, base_rank=0) - row.CARD_XOFFSET = l.CW / 2 + row.CARD_XOFFSET = l.CW // 2 s.rows.append(row) - x = x + self.width / self.XROWS + x = x + self.width // self.XROWS x = l.XM y = y + l.YS self.setRegion(s.rows, (l.XM, l.YS * 2, 999999, y)) # Create pool - x = self.width / 2 + l.XM / 2 - (l.XS * self.XRESERVES) / 2 + x = self.width // 2 + l.XM // 2 - (l.XS * self.XRESERVES) // 2 for j in range(self.YRESERVES): for i in range(self.XRESERVES): s.reserves.append( ReserveStack(x, y, self, max_accept=self.MAX_RESERVE)) x = x + l.XS - x = self.width / 2 + l.XM / 2 - l.XS * (self.XRESERVES / 2) + x = self.width // 2 + l.XM // 2 - l.XS * (self.XRESERVES // 2) y = y + l.YS if s.reserves: self.setRegion( @@ -500,14 +500,14 @@ class Wisteria(AbstractFlowerGame): self.setSize(l.XM + rows * l.XS, l.YM + 6 * l.YS) # create stacks - x, y = self.width / 2 - l.XS * 3, l.YM + x, y = self.width // 2 - l.XS * 3, l.YM for i in range(2): for suit in range(6): s.foundations.append( Hanafuda_SS_FoundationStack( x, y, self, suit=suit + (6 * i))) x = x + l.XS - x, y = self.width / 2 - l.XS * 3, y + l.YS + x, y = self.width // 2 - l.XS * 3, y + l.YS self.setRegion( self.s.foundations, (-999, -999, 999999, l.YM + l.YS * 2), priority=1) @@ -516,7 +516,7 @@ class Wisteria(AbstractFlowerGame): stack = self.RowStack_Class(x, y, self, yoffset=l.YOFFSET) s.rows.append(stack) x = x + l.XS - s.talon = InitialDealTalonStack(l.XS, l.YS / 2, self) + s.talon = InitialDealTalonStack(l.XS, l.YS // 2, self) # define stack-groups l.defaultStackGroups() @@ -654,17 +654,17 @@ class FlowerArrangement(Game): def createGame(self): # create layout l, s = Layout(self), self.s - TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET / 3)) + TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET // 3)) # set window th = l.YS + 3 * TABLEAU_YOFFSET # (set piles so that at least 2/3 of a card is visible with 10 cards) - h = (10-1)*l.YOFFSET + l.CH*2/3 + h = (10-1)*l.YOFFSET + l.CH*2//3 self.setSize(10*l.XS+l.XM, l.YM + 3*th + l.YM + h) # create stacks s.addattr(tableaux=[]) # register extra stack variable - x = l.XM + 8 * l.XS + l.XS / 2 + x = l.XM + 8 * l.XS + l.XS // 2 y = l.YM for i in range(3): x = l.XM @@ -678,7 +678,7 @@ class FlowerArrangement(Game): for i in range(8): s.rows.append(FlowerArrangement_RowStack(x, y, self, max_accept=1)) x = x + l.XS - x = l.XM + 8 * l.XS + l.XS / 2 + x = l.XM + 8 * l.XS + l.XS // 2 y = self.height - l.YS s.talon = DealRowTalonStack(x, y, self) l.createText(s.talon, "se") diff --git a/pysollib/games/ultra/hanafuda_common.py b/pysollib/games/ultra/hanafuda_common.py index c4615f23..b3001a2a 100644 --- a/pysollib/games/ultra/hanafuda_common.py +++ b/pysollib/games/ultra/hanafuda_common.py @@ -200,7 +200,7 @@ class MatsuKiri_Foundation(Flower_FoundationStack): def __init__(self, x, y, game, suit, **cap): kwdefault(cap, max_move=0, max_cards=48, max_accept=4, min_accept=4) AbstractFoundationStack.__init__(self, x, y, game, suit, **cap) - self.CARD_YOFFSET = self.game.app.images.CARDH / 10 + self.CARD_YOFFSET = self.game.app.images.CARDH // 10 def acceptsCards(self, from_stack, cards): if not self.basicAcceptsCards(from_stack, cards): @@ -221,7 +221,7 @@ class GreatWall_FoundationStack(Flower_FoundationStack): def __init__(self, x, y, game, suit, **cap): kwdefault(cap, max_cards=48, max_move=1, min_accept=1, max_accept=1) Flower_FoundationStack.__init__(self, x, y, game, suit, **cap) - self.CARD_YOFFSET = self.game.app.images.CARDH / 20 + self.CARD_YOFFSET = self.game.app.images.CARDH // 20 def acceptsCards(self, from_stack, cards): if not self.basicAcceptsCards(from_stack, cards): diff --git a/pysollib/games/ultra/hexadeck.py b/pysollib/games/ultra/hexadeck.py index e345cd15..eb0d9348 100644 --- a/pysollib/games/ultra/hexadeck.py +++ b/pysollib/games/ultra/hexadeck.py @@ -188,7 +188,7 @@ class Bits_RowStack(ReserveStack): stackcards = self.cards if stackcards or cards[0].suit == 4: return 0 - i = int(self.id / 4) + i = int(self.id // 4) for r in self.game.s.rows[i * 4:self.id]: if not r.cards: return 0 @@ -204,7 +204,7 @@ class Bytes_RowStack(ReserveStack): if stackcards or cards[0].suit == 4: return 0 id = self.id - 16 - i = int(id / 2) + i = int(id // 2) for r in self.game.s.rows[16 + i * 2:self.id]: if not r.cards: return 0 @@ -315,7 +315,7 @@ class BitsNBytes(Game): base_suit=j, max_move=0) s.rows.append(stack) stack.texts.misc = MfxCanvasText(self.canvas, - x + l.CW / 2, y + l.CH / 2, + x + l.CW // 2, y + l.CH // 2, anchor="center", font=font) x = x - l.XS y = y + l.YS @@ -369,7 +369,7 @@ class BitsNBytes(Game): for i in range(4): stack = self.s.rows[i + j * 4] stack.texts.misc.config(text=str(s % 2)) - s = int(s / 2) + s = int(s // 2) def _shuffleHook(self, cards): topcards, ranks = [None] * 4, [None] * 4 @@ -1166,7 +1166,7 @@ class MerlinsMeander(AbstractHexADeckGame): l.createText(s.talon, "s") s.talon.texts.rounds = MfxCanvasText( self.canvas, - x + l.CW / 2, y - l.YM, + x + l.CW // 2, y - l.YM, anchor="s", font=self.app.getFont("canvas_default")) x -= l.XS @@ -1187,7 +1187,7 @@ class MerlinsMeander(AbstractHexADeckGame): y = y + l.YS self.texts.info = MfxCanvasText( self.canvas, - x + l.CW + l.XM / 2, y, + x + l.CW + l.XM // 2, y, anchor="n", font=self.app.getFont("canvas_default")) @@ -1349,7 +1349,7 @@ class Convolution(AbstractHexADeckGame): self.setSize(l.XM + (maxrows + 2) * l.XS, l.YM + 6 * l.YS) # - playcards = 4 * l.YS / l.YOFFSET + playcards = 4 * l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -1359,12 +1359,12 @@ class Convolution(AbstractHexADeckGame): yoffset.append(0) # create stacks - x, y = l.XM + (maxrows - reserves) * l.XS / 2, l.YM + x, y = l.XM + (maxrows - reserves) * l.XS // 2, l.YM for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows - rows) * l.XS / 2, l.YM + l.YS - self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM / 2)) + x, y = l.XM + (maxrows - rows) * l.XS // 2, l.YM + l.YS + self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM // 2)) for i in range(rows): stack = self.RowStack_Class(x, y, self, yoffset=yoffset) stack.CARD_XOFFSET = xoffset @@ -1381,7 +1381,7 @@ class Convolution(AbstractHexADeckGame): self.setRegion(self.s.foundations, (x - l.XS * 2, -999, 999999, self.height - (l.YS + l.YM)), priority=1) s.talon = InitialDealTalonStack( - self.width - 3 * l.XS / 2, self.height - l.YS, self) + self.width - 3 * l.XS // 2, self.height - l.YS, self) # define stack-groups l.defaultStackGroups() diff --git a/pysollib/games/ultra/mughal.py b/pysollib/games/ultra/mughal.py index 14e8380a..6f9f6c83 100644 --- a/pysollib/games/ultra/mughal.py +++ b/pysollib/games/ultra/mughal.py @@ -302,8 +302,8 @@ class MughalCircles(AbstractMughalGame): self.setSize(w, h) # Create row stacks - x = w / 2 - l.CW / 2 - y = h / 2 - l.YS / 2 + x = w // 2 - l.CW // 2 + y = h // 2 - l.YS // 2 x0 = (-1, -.8, 0, .8, 1, .8, 0, -.8, -2, -1.9, -1.5, -.8, 0, .8, 1.5, 1.9, 2, 1.9, 1.5, .8, 0, -.8, -1.5, -1.9) @@ -738,7 +738,7 @@ class AkbarsTriumph(AbstractMughalGame): y = y + l.YS self.texts.info = MfxCanvasText( self.canvas, - self.width / 2, h - l.YM / 2, + self.width // 2, h - l.YM // 2, anchor="center", font=self.app.getFont("canvas_default")) @@ -756,7 +756,7 @@ class AkbarsTriumph(AbstractMughalGame): l.createText(s.talon, "s") s.talon.texts.rounds = MfxCanvasText( self.canvas, - self.width / 2, h - l.YM * 2.5, + self.width // 2, h - l.YM * 2.5, anchor="center", font=self.app.getFont("canvas_default")) x += l.XS * 2 @@ -863,7 +863,7 @@ class Vajra(AbstractMughalGame): self.setSize(l.XM + (maxrows + 2) * l.XS, l.YM + 6 * l.YS) # - playcards = 4 * l.YS / l.YOFFSET + playcards = 4 * l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -873,12 +873,12 @@ class Vajra(AbstractMughalGame): yoffset.append(0) # create stacks - x, y = l.XM + (maxrows - reserves) * l.XS / 2, l.YM + x, y = l.XM + (maxrows - reserves) * l.XS // 2, l.YM for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows - rows) * l.XS / 2, l.YM + l.YS - self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM / 2)) + x, y = l.XM + (maxrows - rows) * l.XS // 2, l.YM + l.YS + self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM // 2)) for i in range(rows): stack = self.RowStack_Class(x, y, self, yoffset=l.YOFFSET) stack.CARD_XOFFSET = xoffset @@ -895,7 +895,7 @@ class Vajra(AbstractMughalGame): self.setRegion(self.s.foundations, (x - l.XS * 2, -999, 999999, self.height - (l.YS + l.YM)), priority=1) s.talon = InitialDealTalonStack( - self.width - 3 * l.XS / 2, self.height - l.YS, self) + self.width - 3 * l.XS // 2, self.height - l.YS, self) # define stack-groups l.defaultStackGroups() @@ -1106,17 +1106,17 @@ class AshtaDikapala(Game): def createGame(self): # create layout l, s = Layout(self), self.s - TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET / 3)) + TABLEAU_YOFFSET = min(9, max(3, l.YOFFSET // 3)) # set window th = l.YS + 3 * TABLEAU_YOFFSET # (set piles so that at least 2/3 of a card is visible with 10 cards) - h = 8 * l.YOFFSET + l.CH * 2/3 + h = 8 * l.YOFFSET + l.CH * 2//3 self.setSize(9 * l.XS + l.XM * 2, l.YM + 3 * th + l.YM + h) # create stacks s.addattr(tableaux=[]) # register extra stack variable - x = l.XM + 8 * l.XS + l.XS / 2 + x = l.XM + 8 * l.XS + l.XS // 2 y = l.YM for i in range(3, 0, -1): x = l.XM diff --git a/pysollib/games/ultra/tarock.py b/pysollib/games/ultra/tarock.py index 12a19011..3a9c415d 100644 --- a/pysollib/games/ultra/tarock.py +++ b/pysollib/games/ultra/tarock.py @@ -174,7 +174,7 @@ class Corkscrew(AbstractTarockGame): self.setSize(l.XM + (maxrows + 2) * l.XS, l.YM + 6 * l.YS) # - playcards = 4 * l.YS / l.YOFFSET + playcards = 4 * l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) @@ -184,12 +184,12 @@ class Corkscrew(AbstractTarockGame): yoffset.append(0) # create stacks - x, y = l.XM + (maxrows - reserves) * l.XS / 2, l.YM + x, y = l.XM + (maxrows - reserves) * l.XS // 2, l.YM for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x = x + l.XS - x, y = l.XM + (maxrows - rows) * l.XS / 2, l.YM + l.YS - self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM / 2)) + x, y = l.XM + (maxrows - rows) * l.XS // 2, l.YM + l.YS + self.setRegion(s.reserves, (-999, -999, 999999, y - l.YM // 2)) for i in range(rows): stack = self.RowStack_Class(x, y, self, yoffset=l.YOFFSET) stack.CARD_XOFFSET = xoffset @@ -210,7 +210,7 @@ class Corkscrew(AbstractTarockGame): (x - l.XS * 2, -999, 999999, self.height - (l.YS + l.YM)), priority=1) s.talon = InitialDealTalonStack( - self.width - 3 * l.XS / 2, self.height - l.YS, self) + self.width - 3 * l.XS // 2, self.height - l.YS, self) # define stack-groups l.defaultStackGroups() diff --git a/pysollib/games/unionsquare.py b/pysollib/games/unionsquare.py index e607188d..47578adf 100644 --- a/pysollib/games/unionsquare.py +++ b/pysollib/games/unionsquare.py @@ -104,7 +104,7 @@ class UnionSquare(Game): l, s = Layout(self, card_y_space=20), self.s # set window - self.setSize(l.XM + (5+rows/4)*l.XS, l.YM + 4*l.YS) + self.setSize(l.XM + (5+rows//4)*l.XS, l.YM + 4*l.YS) # create stacks x, y, = l.XM, l.YM @@ -115,7 +115,7 @@ class UnionSquare(Game): l.createText(s.waste, "s") for i in range(4): x = 3*l.XS - for j in range(rows/4): + for j in range(rows//4): stack = self.RowStack_Class(x, y, self) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 1 s.rows.append(stack) diff --git a/pysollib/games/wavemotion.py b/pysollib/games/wavemotion.py index 384e9f7e..f647ffee 100644 --- a/pysollib/games/wavemotion.py +++ b/pysollib/games/wavemotion.py @@ -62,13 +62,13 @@ class WaveMotion(Game): self.setSize(w, h) # create stacks - x, y = l.XM + (max_rows-rows)*l.XS/2, l.YM + x, y = l.XM + (max_rows-rows)*l.XS//2, l.YM for i in range(rows): stack = self.RowStack_Class(x, y, self, base_rank=ANY_RANK) stack.getBottomImage = stack._getReserveBottomImage s.rows.append(stack) x += l.XS - x, y = l.XM + (max_rows-reserves)*l.XS/2, l.YM+l.YS+12*l.YOFFSET + x, y = l.XM + (max_rows-reserves)*l.XS//2, l.YM+l.YS+12*l.YOFFSET for i in range(reserves): stack = OpenStack(x, y, self, max_accept=0) s.reserves.append(stack) diff --git a/pysollib/games/yukon.py b/pysollib/games/yukon.py index 7658dd74..cdd80ccf 100644 --- a/pysollib/games/yukon.py +++ b/pysollib/games/yukon.py @@ -653,7 +653,7 @@ class Hawaiian(Game): l.createText(stack, 'ne') x, y = self.width-8*l.XS, l.YM for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2)) + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2)) x += l.XS x, y = self.width-rows*l.XS, l.YM+l.YS for i in range(rows): diff --git a/pysollib/games/zodiac.py b/pysollib/games/zodiac.py index 2b9d0a75..8f622c80 100644 --- a/pysollib/games/zodiac.py +++ b/pysollib/games/zodiac.py @@ -166,7 +166,7 @@ class TwelveSleepingMaids(Game): x, y = l.XM+2*l.XS, l.YM+l.YS+3*l.YOFFSET for i in range(8): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2, + s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2, base_rank=KING, mod=13)) x += l.XS diff --git a/pysollib/hint.py b/pysollib/hint.py index 55e5acc0..ef240c4e 100644 --- a/pysollib/hint.py +++ b/pysollib/hint.py @@ -142,7 +142,7 @@ class AbstractHint(HintInterface): self.max_score = max(self.max_score, score) # add an atomic hint if self.score_flatten_value > 0: - score = (score / self.score_flatten_value) * \ + score = (score // self.score_flatten_value) * \ self.score_flatten_value if text_color is None: text_color = self.BLACK @@ -417,7 +417,7 @@ class DefaultHint(AbstractHint): d = len(t.cards) else: d = (c.rank - t.cap.base_rank) % t.cap.mod - if d > t.cap.mod / 2: + if d > t.cap.mod // 2: d = d - t.cap.mod if abs(d) <= 1: # drop Ace and 2 immediately @@ -696,7 +696,7 @@ class Yukon_Hint(YukonType_Hint): rr = self.ClonedStack(r, stackcards=[cr]) for ct in tpile: if rr.acceptsCards(t, [ct]): - d = bonus / 1000 + d = bonus // 1000 bonus = (d * 1000) + bonus % 100 break return score + bonus, color diff --git a/pysollib/mfxutil.py b/pysollib/mfxutil.py index d57bad5c..c4992d02 100644 --- a/pysollib/mfxutil.py +++ b/pysollib/mfxutil.py @@ -105,8 +105,8 @@ def format_time(t): if t <= 0: return "0:00" if t < 3600: - return "%d:%02d" % (t / 60, t % 60) - return "%d:%02d:%02d" % (t / 3600, (t % 3600) / 60, t % 60) + return "%d:%02d" % (t // 60, t % 60) + return "%d:%02d:%02d" % (t // 3600, (t % 3600) // 60, t % 60) def print_err(s, level=1): diff --git a/pysollib/resource.py b/pysollib/resource.py index 6ea850c9..0baf1793 100644 --- a/pysollib/resource.py +++ b/pysollib/resource.py @@ -493,7 +493,7 @@ class CardsetManager(ResourceManager): for s in cs.si.nationalities: self.registered_nationalities[s] = \ self.registered_nationalities.get(s, 0) + 1 - keys = (cs.year / 100,) + keys = (cs.year // 100,) cs.si.dates = tuple([s for s in keys if s in CSI.DATE]) for s in cs.si.dates: self.registered_dates[s] = self.registered_dates.get(s, 0) + 1 diff --git a/pysollib/stack.py b/pysollib/stack.py index 422fec76..2591c41b 100644 --- a/pysollib/stack.py +++ b/pysollib/stack.py @@ -409,9 +409,9 @@ class Stack: isinstance(oy, (int, float))): # no shrink if xoffset/yoffset too small f = self.SHRINK_FACTOR - if ((ox == 0 and oy >= self.game.app.images.CARD_YOFFSET/f) or + if ((ox == 0 and oy >= self.game.app.images.CARD_YOFFSET//f) or (oy == 0 and - ox >= self.game.app.images.CARD_XOFFSET/f)): + ox >= self.game.app.images.CARD_XOFFSET//f)): self.shrink_face_down = f # bottom image if self.is_visible: @@ -576,7 +576,7 @@ class Stack: if len(cards) < 2: return 0 dir = (cards[-1].rank - cards[-2].rank) % self.cap.mod - if dir > self.cap.mod / 2: + if dir > self.cap.mod // 2: return dir - self.cap.mod return dir @@ -761,8 +761,8 @@ class Stack: x += self.CARD_XOFFSET[ix] y += self.CARD_YOFFSET[iy] else: - x += self.CARD_XOFFSET[ix]/d - y += self.CARD_YOFFSET[iy]/d + x += self.CARD_XOFFSET[ix]//d + y += self.CARD_YOFFSET[iy]//d ix = (ix + 1) % lx iy = (iy + 1) % ly return int(x), int(y) @@ -781,8 +781,8 @@ class Stack: x += self.CARD_XOFFSET[ix] y += self.CARD_YOFFSET[iy] else: - x += self.CARD_XOFFSET[ix]/d - y += self.CARD_YOFFSET[iy]/d + x += self.CARD_XOFFSET[ix]//d + y += self.CARD_YOFFSET[iy]//d ix = (ix + 1) % lx iy = (iy + 1) % ly return int(x), int(y) @@ -881,11 +881,11 @@ class Stack: return False yoffset = self.CARD_YOFFSET[0] # 1/2 of a card is visible - cardh = self.game.app.images.getSize()[0] / 2 + cardh = self.game.app.images.getSize()[0] // 2 num_face_up = len([c for c in self.cards if c.face_up]) num_face_down = len(self.cards) - num_face_up stack_height = int(self.y + - num_face_down * yoffset / self.shrink_face_down + + num_face_down * yoffset // self.shrink_face_down + num_face_up * yoffset + cardh) visible_height = self.canvas.winfo_height() @@ -899,7 +899,7 @@ class Stack: # visible_height, game_height if stack_height > height: # compact stack - n = num_face_down / self.shrink_face_down + num_face_up + n = num_face_down // self.shrink_face_down + num_face_up dy = float(height - self.y - cardh) / n if dy < yoffset: # print 'compact:', dy @@ -909,7 +909,7 @@ class Stack: # expande stack if self.CARD_YOFFSET == self.INIT_CARD_YOFFSET: return False - n = num_face_down / self.shrink_face_down + num_face_up + n = num_face_down // self.shrink_face_down + num_face_up dy = float(height - self.y - cardh) / n dy = min(dy, self.INIT_CARD_YOFFSET[0]) # print 'expande:', dy @@ -1973,7 +1973,7 @@ class TalonStack(Stack, return images = self.game.app.images self.init_redeal.top_bottom = self.top_bottom - cx, cy = self.x + images.CARDW/2, self.y + images.CARDH/2 + cx, cy = self.x + images.CARDW//2, self.y + images.CARDH//2 ty = self.y + images.CARDH - 4 self.init_redeal.img_coord = cx, cy self.init_redeal.txt_coord = cx, ty diff --git a/pysollib/tk/progressbar.py b/pysollib/tk/progressbar.py index cd36c1dd..acf63d76 100644 --- a/pysollib/tk/progressbar.py +++ b/pysollib/tk/progressbar.py @@ -94,7 +94,7 @@ class PysolProgressBar: def update(self, percent=None, step=1): self.steps_sum += step # print self.steps_sum - step /= self.norm + step //= self.norm if self.top is None: # already destroyed return if percent is None: @@ -109,7 +109,7 @@ class PysolProgressBar: c.coords(self.scale, -10, -10, (self.percent * width) / 100.0, height) if self.text >= 0: - c.coords(self.text, width/2, height/2) + c.coords(self.text, width//2, height//2) c.itemconfig(self.text, text="%d %%" % int(round(self.percent))) c.update() diff --git a/pysollib/tk/selectgame.py b/pysollib/tk/selectgame.py index 5e4ac1cd..53c6d1fb 100644 --- a/pysollib/tk/selectgame.py +++ b/pysollib/tk/selectgame.py @@ -371,7 +371,7 @@ class SelectGameDialogWithPreview(SelectGameDialog): w2 = max(200, min(w2, 10 + 12*(app.subsampled_images.CARDW+10))) # print sw, w1, w2 # padx, pady = kw.padx, kw.pady - padx, pady = kw.padx/2, kw.pady/2 + padx, pady = kw.padx//2, kw.pady//2 # PanedWindow paned_window = tkinter.PanedWindow(top_frame) paned_window.pack(expand=True, fill='both') diff --git a/pysollib/tk/solverdialog.py b/pysollib/tk/solverdialog.py index a568da03..5dd09fbc 100644 --- a/pysollib/tk/solverdialog.py +++ b/pysollib/tk/solverdialog.py @@ -61,8 +61,8 @@ class SolverDialog(BaseSolverDialog, BaseTkMfxDialog): *(self.gamenames)) om.grid(row=row, column=1, sticky='ew', padx=2, pady=2) n = len(self.gamenames) - cb_max = int(self.top.winfo_screenheight()/23) - cb_max = n / (n/cb_max+1) + cb_max = int(self.top.winfo_screenheight()//23) + cb_max = n // (n//cb_max+1) for i in xrange(cb_max, n, cb_max): om['menu'].entryconfig(i, columnbreak=True) return var diff --git a/pysollib/tk/tkstats.py b/pysollib/tk/tkstats.py index d6341faa..b0cea38a 100644 --- a/pysollib/tk/tkstats.py +++ b/pysollib/tk/tkstats.py @@ -142,7 +142,7 @@ class SingleGame_StatsDialog(MfxDialog): c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f") l = tkinter.Label(c, text=text, font=self.font, bd=0, padx=3, pady=1) dy = int(self.font_metrics['ascent']) - 10 - dy = dy/2 + dy //= 2 c.create_window(20, -dy, window=l, anchor="nw") def _createChartTexts(self, tx, ty, won, lost): @@ -151,7 +151,7 @@ class SingleGame_StatsDialog(MfxDialog): # x = tx[0] dy = int(self.font_metrics['ascent']) - 10 - dy = dy/2 + dy //= 2 c.create_text( x, ty[0]-dy, text=_("Won:"), anchor="nw", font=tfont, fill=fg) c.create_text( @@ -235,7 +235,7 @@ class SingleGame_StatsDialog(MfxDialog): # pwon, plost = self._getPwon(won, lost) # # # tx = (iw+20, iw+110, iw+140) -# yy = ih/2 # + 7 +# yy = ih//2 # + 7 # ty = (yy+21-46, yy+41-46, yy+75-46) # # # c.create_image(0, 7, image=image, anchor="nw") @@ -879,8 +879,8 @@ class ProgressionDialog(MfxDialog): tw = max(measure(_('Games/day')), measure(_('Games/week')), measure(_('% won'))) - self.left_margin = self.xmargin+tw/2 - self.right_margin = self.xmargin+tw/2 + self.left_margin = self.xmargin+tw//2 + self.right_margin = self.xmargin+tw//2 self.top_margin = 15+self.text_height self.bottom_margin = 15+self.text_height+10+self.text_height # @@ -1003,12 +1003,12 @@ class ProgressionDialog(MfxDialog): graph_width = self.canvas_width-self.left_margin-self.right_margin graph_height = self.canvas_height-self.top_margin-self.bottom_margin - dx = (graph_width-2*self.graph_dx)/(len(result)-1) - graph_dx = (graph_width-(len(result)-1)*dx)/2 - dy = (graph_height-self.graph_dy)/5 + dx = (graph_width-2*self.graph_dx)//(len(result)-1) + graph_dx = (graph_width-(len(result)-1)*dx)//2 + dy = (graph_height-self.graph_dy)//5 x0, y0 = self.left_margin, self.canvas_height-self.bottom_margin x1, y1 = self.canvas_width-self.right_margin, self.top_margin - td = self.text_height/2 + td = self.text_height//2 # vertical scale x = x0+graph_dx @@ -1029,7 +1029,7 @@ class ProgressionDialog(MfxDialog): # horizontal scale max_games = max([i[1] for i in result]) - games_delta = max_games/5+1 + games_delta = max_games//5+1 percent = 0 games = 0 for y in range(y0, y1, -dy): diff --git a/pysollib/tk/tktree.py b/pysollib/tk/tktree.py index 8efb65c1..fb3f5e47 100644 --- a/pysollib/tk/tktree.py +++ b/pysollib/tk/tktree.py @@ -63,7 +63,7 @@ class MfxTreeBaseNode: def draw(self, x, y, lastx=None, lasty=None): canvas, style = self.tree.canvas, self.tree.style topleftx = x + style.distx - toplefty = y - style.height / 2 # +++ + toplefty = y - style.height // 2 # +++ # draw the horizontal line if lastx is not None: canvas.create_line( @@ -175,8 +175,8 @@ class MfxTreeNode(MfxTreeBaseNode): # draw the vertical line if self.subnodes: style = self.tree.style - dy = (style.disty-style.width)/2 - y = y-style.disty/2-dy + dy = (style.disty-style.width)//2 + y = y-style.disty//2-dy self.tree.canvas.create_line(x, y, nx, ly, stipple=style.linestyle, fill=style.linecolor) @@ -187,10 +187,10 @@ class MfxTreeNode(MfxTreeBaseNode): lx, ly, nx, ny = MfxTreeBaseNode.draw(self, x, y, ilastx, ilasty) if self.expanded: style = self.tree.style - childx = nx + style.distx + style.width / 2 + childx = nx + style.distx + style.width // 2 childy = ny - clastx = nx + style.distx + style.width / 2 - clasty = ly + style.height / 2 + clastx = nx + style.distx + style.width // 2 + clasty = ly + style.height // 2 ny = self.drawChildren(childx, childy, clastx, clasty) return lx, ly, x, ny @@ -272,7 +272,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas): # We do this so that our bounding box always starts at (0,0) # and the yscrollincrement works nicely. nx = nx - self.style.distx - ny = ny + self.style.height / 2 + ny = ny + self.style.height // 2 for node in self.rootnodes: # update tree node.tree = self diff --git a/pysollib/ui/tktile/menubar.py b/pysollib/ui/tktile/menubar.py index 7f716447..cba84da4 100644 --- a/pysollib/ui/tktile/menubar.py +++ b/pysollib/ui/tktile/menubar.py @@ -128,7 +128,7 @@ class PysolMenubarTkCommon: self._createTkOpt() self._setOptions() # init columnbreak - self.cb_max = int(self.top.winfo_screenheight()/23) + self.cb_max = int(self.top.winfo_screenheight()//23) # sh = self.top.winfo_screenheight() # self.cb_max = 22 # if sh >= 600: self.cb_max = 27 diff --git a/pysollib/ui/tktile/selecttree.py b/pysollib/ui/tktile/selecttree.py index 9bba218c..730db7cf 100644 --- a/pysollib/ui/tktile/selecttree.py +++ b/pysollib/ui/tktile/selecttree.py @@ -99,7 +99,7 @@ class BaseSelectDialogTreeCanvas: height = 25 * disty if parent and parent.winfo_screenheight() >= 800: height = 30 * disty - self.lines = height / disty + self.lines = height // disty self._calc_MfxTreeInCanvas().__init__( self, parent, self.data.rootnodes, width=width, height=height, diff --git a/pysollib/ui/tktile/tkcanvas.py b/pysollib/ui/tktile/tkcanvas.py index 644a8f6e..fe31607e 100644 --- a/pysollib/ui/tktile/tkcanvas.py +++ b/pysollib/ui/tktile/tkcanvas.py @@ -361,8 +361,8 @@ class MfxCanvas(tkinter.Canvas): # ch = max(int(self.cget("height")), self.winfo_height()) ch = self.winfo_height() # print iw, ih, cw, ch - x = (cw-iw)/2-self.xmargin+self.xview()[0]*int(self.cget('width')) - y = (ch-ih)/2-self.ymargin+self.yview()[0]*int(self.cget('height')) + x = (cw-iw)//2-self.xmargin+self.xview()[0]*int(self.cget('width')) + y = (ch-ih)//2-self.ymargin+self.yview()[0]*int(self.cget('height')) id = self._x_create("image", x, y, image=image, anchor="nw") self.tk.call(self._w, "raise", id) self.__tops.append(id) diff --git a/pysollib/ui/tktile/tkutil.py b/pysollib/ui/tktile/tkutil.py index 5359eecb..f2f5083f 100644 --- a/pysollib/ui/tktile/tkutil.py +++ b/pysollib/ui/tktile/tkutil.py @@ -189,11 +189,11 @@ def __getWidgetXY(widget, parent, relx=None, rely=None, if x < 0: x = 0 elif x + w_width + 32 > s_width: - x = max(0, (s_width - w_width) / 2) + x = max(0, (s_width - w_width) // 2) if y < 0: y = 0 elif y + w_height + 32 > s_height: - y = max(0, (s_height - w_height) / 2) + y = max(0, (s_height - w_height) // 2) return x, y @@ -420,7 +420,7 @@ def _createBottomImage(image, color='white', backfile=None): a = a*0.9 w0, h0 = int(w0*a), int(h0*a) back = back.resize((w0, h0), Image.ANTIALIAS) - x, y = (w1 - w0) / 2, (h1 - h0) / 2 + x, y = (w1 - w0) // 2, (h1 - h0) // 2 out.paste(back, (x, y), back) return out