[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kajongg/sid] src: rename all "tile" attributes holding a uiTile to "uiTile"
From: Wolfgang Rohdewald <wolfgang () rohdewald ! de>
Date: 2013-10-31 21:21:10
Message-ID: E1Vbzfy-0002lj-Tq () scm ! kde ! org
[Download RAW message or body]
Git commit 51c6776cdb589d159d55e0c232c368e3109b0f83 by Wolfgang Rohdewald.
Committed on 31/10/2013 at 10:31.
Pushed by wrohdewald into branch 'sid'.
rename all "tile" attributes holding a uiTile to "uiTile"
M +23 -28 src/animation.py
M +111 -111 src/board.py
M +30 -30 src/handboard.py
M +8 -8 src/humanclient.py
M +11 -13 src/playfield.py
M +25 -26 src/uiwall.py
M +3 -3 src/visible.py
http://commits.kde.org/kajongg/51c6776cdb589d159d55e0c232c368e3109b0f83
diff --git a/src/animation.py b/src/animation.py
index ff4a603..32677e4 100644
--- a/src/animation.py
+++ b/src/animation.py
@@ -31,16 +31,16 @@ class Animation(QPropertyAnimation):
nextAnimations = []
- def __init__(self, target, propName, endValue, parent=None):
- QPropertyAnimation.__init__(self, target, propName, parent)
+ def __init__(self, uiTile, propName, endValue, parent=None):
+ QPropertyAnimation.__init__(self, uiTile, propName, parent)
QPropertyAnimation.setEndValue(self, endValue)
duration = Preferences.animationDuration()
self.setDuration(duration)
self.setEasingCurve(QEasingCurve.InOutQuad)
- target.queuedAnimations.append(self)
+ uiTile.queuedAnimations.append(self)
Animation.nextAnimations.append(self)
- if target.tile in Debug.animation:
- oldAnimation = target.activeAnimation.get(propName, None)
+ if uiTile.tile in Debug.animation:
+ oldAnimation = uiTile.activeAnimation.get(propName, None)
if isAlive(oldAnimation):
logDebug('new animation %s (after %s is done)' % (self, \
oldAnimation.ident())) else:
@@ -48,11 +48,11 @@ class Animation(QPropertyAnimation):
def setEndValue(self, endValue):
"""wrapper with debugging code"""
- tile = self.targetObject()
- if tile.tile in Debug.animation:
+ uiTile = self.targetObject()
+ if uiTile.tile in Debug.animation:
pName = self.pName()
logDebug('%s: change endValue for %s: %s->%s %s' % (self.ident(), \
pName, self.formatValue(self.endValue()),
- self.formatValue(endValue), tile))
+ self.formatValue(endValue), uiTile))
QPropertyAnimation.setEndValue(self, endValue)
def ident(self):
@@ -95,9 +95,7 @@ class Animation(QPropertyAnimation):
def __str__(self):
"""for debug messages"""
- pName = self.pName()
- tile = self.targetObject()
- return '%s: %s->%s for %s' % (self.ident(), pName, \
self.formatValue(self.endValue()), tile) + return '%s: %s->%s for %s' % \
(self.ident(), self.pName(), self.formatValue(self.endValue()), self.targetObject()) \
class ParallelAnimationGroup(QParallelAnimationGroup):
"""override __init__"""
@@ -130,34 +128,32 @@ class ParallelAnimationGroup(QParallelAnimationGroup):
# periodically check if the board still exists.
# if not (game end), we do not want to go on
for animation in self.animations:
- tile = animation.targetObject()
- if not isAlive(tile.board):
- tile.clearActiveAnimation(animation)
+ uiTile = animation.targetObject()
+ if not isAlive(uiTile.board):
+ uiTile.clearActiveAnimation(animation)
self.removeAnimation(animation)
QParallelAnimationGroup.updateCurrentTime(self, value)
def start(self, dummyResults='DIREKT'):
"""start the animation, returning its deferred"""
assert self.state() != QAbstractAnimation.Running
- tiles = set()
for animation in self.animations:
- tile = animation.targetObject()
- self.debug |= tile.tile in Debug.animation
- tiles.add(tile)
- tile.setActiveAnimation(animation)
+ uiTile = animation.targetObject()
+ self.debug |= uiTile.tile in Debug.animation
+ uiTile.setActiveAnimation(animation)
self.addAnimation(animation)
propName = animation.pName()
- animation.setStartValue(tile.getValue(propName))
+ animation.setStartValue(uiTile.getValue(propName))
if propName == 'rotation':
# change direction if that makes the difference smaller
endValue = animation.unpackEndValue()
- currValue = tile.rotation
+ currValue = uiTile.rotation
if endValue - currValue > 180:
animation.setStartValue(currValue + 360)
if currValue - endValue > 180:
animation.setStartValue(currValue - 360)
- for tile in tiles:
- tile.setDrawingOrder()
+ for animation in self.animations:
+ animation.targetObject().setDrawingOrder()
self.finished.connect(self.allFinished)
scene = Internal.field.centralScene
scene.disableFocusRect = True
@@ -188,9 +184,9 @@ class ParallelAnimationGroup(QParallelAnimationGroup):
def fixAllBoards(self):
"""set correct drawing order for all moved tiles"""
for animation in self.children():
- tile = animation.targetObject()
- if tile:
- tile.clearActiveAnimation(animation)
+ uiTile = animation.targetObject()
+ if uiTile:
+ uiTile.clearActiveAnimation(animation)
scene = Internal.field.centralScene
scene.disableFocusRect = False
return
@@ -252,8 +248,7 @@ def animate():
shortcutMe = duration == 0
if shortcutMe:
for animation in Animation.nextAnimations:
- tile = animation.targetObject()
- tile.shortcutAnimation(animation)
+ animation.targetObject().shortcutAnimation(animation)
Animation.nextAnimations = []
scene = Internal.field.centralScene
scene.disableFocusRect = False
diff --git a/src/board.py b/src/board.py
index c235b24..9d8dd08 100644
--- a/src/board.py
+++ b/src/board.py
@@ -185,9 +185,9 @@ class Board(QGraphicsRectItem):
return 'board'
def hide(self):
- """remove all tile references so they can be garbage collected"""
- for tile in self.tiles:
- tile.hide()
+ """remove all uiTile references so they can be garbage collected"""
+ for uiTile in self.tiles:
+ uiTile.hide()
self.tiles = []
self._focusTile = None
if isAlive(self):
@@ -195,7 +195,7 @@ class Board(QGraphicsRectItem):
def autoSelectTile(self):
"""call this when kajongg should automatically focus
- on an appropriate tile"""
+ on an appropriate uiTile"""
focusCandidates = self._focusableTiles()
if focusCandidates:
firstCandidate = focusCandidates[0]
@@ -211,24 +211,24 @@ class Board(QGraphicsRectItem):
@property
def focusTile(self):
- """the tile of this board with focus. This is per Board!"""
+ """the uiTile of this board with focus. This is per Board!"""
if self._focusTile is None:
self.autoSelectTile()
return self._focusTile
@focusTile.setter
- def focusTile(self, tile):
- """the tile of this board with focus. This is per Board!"""
- if tile is self._focusTile:
+ def focusTile(self, uiTile):
+ """the uiTile of this board with focus. This is per Board!"""
+ if uiTile is self._focusTile:
return
- if tile:
- assert tile.tile != 'Xy', tile
- if not isinstance(tile.board, DiscardBoard):
- assert tile.focusable, tile
- self.__prevPos = tile.sortKey()
- self._focusTile = tile
+ if uiTile:
+ assert uiTile.tile != 'Xy', uiTile
+ if not isinstance(uiTile.board, DiscardBoard):
+ assert uiTile.focusable, uiTile
+ self.__prevPos = uiTile.sortKey()
+ self._focusTile = uiTile
if self._focusTile and self._focusTile.tile in Debug.focusable:
- logDebug('%s: new focus tile %s from %s' % (
+ logDebug('%s: new focus uiTile %s from %s' % (
self.name(), self._focusTile.tile if self._focusTile else 'None', \
stack('')[-1])) if (self.isHandBoard and self.player
and not self.player.game.isScoringGame()
@@ -236,7 +236,7 @@ class Board(QGraphicsRectItem):
Internal.field.clientDialog.focusTileChanged()
if self.hasFocus:
self.scene().focusBoard = self
- assert tile is self._focusTile
+ assert uiTile is self._focusTile
def setEnabled(self, enabled):
"""enable/disable this board"""
@@ -307,7 +307,7 @@ class Board(QGraphicsRectItem):
return Meld(uiTile)
def meldVariants(self, uiTile, lowerHalf): # pylint: disable=unused-argument
- """all possible melds that could be meant by dragging/dropping tile"""
+ """all possible melds that could be meant by dragging/dropping uiTile"""
return [Meld(uiTile)]
def chooseVariant(self, uiTile, lowerHalf=False):
@@ -345,23 +345,23 @@ class Board(QGraphicsRectItem):
self.setPen(QPen(Qt.NoPen))
def tileAt(self, xoffset, yoffset, level=0):
- """if there is a tile at this place, return it"""
- for tile in self.tiles:
- if (tile.xoffset, tile.yoffset, tile.level) == (xoffset, yoffset, \
level):
- return tile
+ """if there is a uiTile at this place, return it"""
+ for uiTile in self.tiles:
+ if (uiTile.xoffset, uiTile.yoffset, uiTile.level) == (xoffset, yoffset, \
level): + return uiTile
def tilesByElement(self, element):
- """returns all child items holding a tile for element"""
+ """returns all child items holding a uiTile for element"""
return list(x for x in self.tiles if x.tile == element)
def rotatedLightSource(self):
- """the light source we need for the original tile before it is rotated"""
+ """the light source we need for the original uiTile before it is rotated"""
lightSourceIndex = LIGHTSOURCES.index(self.lightSource)
lightSourceIndex = (lightSourceIndex+self.sceneRotation() // 90)%4
return LIGHTSOURCES[lightSourceIndex]
def tileFacePos(self):
- """the face pos of a tile relative to the tile origin"""
+ """the face pos of a uiTile relative to its origin"""
if not self.showShadows:
return QPointF()
lightSource = self.rotatedLightSource()
@@ -370,7 +370,7 @@ class Board(QGraphicsRectItem):
return QPointF(xoffset, yoffset)
def tileFaceRect(self):
- """the face rect of a tile relative to the tile origin"""
+ """the face rect of a uiTile relative its origin"""
return QRectF(self.tileFacePos(), self.tileset.faceSize)
def sceneRotation(self):
@@ -392,7 +392,7 @@ class Board(QGraphicsRectItem):
self.setGeometry()
def setRect(self, width, height):
- """gives the board a fixed size in tile coordinates"""
+ """gives the board a fixed size in uiTile coordinates"""
self.__fixedWidth = width
self.__fixedHeight = height
self.computeRect()
@@ -445,8 +445,8 @@ class Board(QGraphicsRectItem):
def showShadows(self, value):
"""set active lightSource"""
if self._showShadows != value:
- for tile in self.tiles:
- tile.setClippingFlags()
+ for uiTile in self.tiles:
+ uiTile.setClippingFlags()
self._reload(self.tileset, showShadows=value)
@property
@@ -491,9 +491,9 @@ class Board(QGraphicsRectItem):
child.tileset = tileset
child.lightSource = lightSource
child.showShadows = showShadows
- for tile in self.tiles:
- self.placeTile(tile)
- tile.update()
+ for uiTile in self.tiles:
+ self.placeTile(uiTile)
+ uiTile.update()
self.computeRect()
if self.hasFocus:
self.scene().focusBoard = self
@@ -503,9 +503,9 @@ class Board(QGraphicsRectItem):
return 1
def shiftZ(self, level):
- """used for 3D: compute the needed shift for the tile.
+ """used for 3D: compute the needed shift for the uiTile.
level is the vertical position. 0 is the face position on
- ground level, -1 is the imprint a tile makes on the
+ ground level, -1 is the imprint a uiTile makes on the
surface it stands on"""
if not self.showShadows:
return QPointF()
@@ -526,46 +526,46 @@ class Board(QGraphicsRectItem):
return QPointF(shiftX, shiftY)
def tileSize(self):
- """the current tile size"""
+ """the current uiTile size"""
return self._tileset.tileSize
def faceSize(self):
"""the current face size"""
return self._tileset.faceSize
- def __tilePlace(self, tile):
- """compute all properties for tile in this board: pos, scale, rotation
+ def __tilePlace(self, uiTile):
+ """compute all properties for uiTile in this board: pos, scale, rotation
and return them in a dict"""
- assert isinstance(tile, UITile)
- if not tile.scene():
- self.scene().addItem(tile)
+ assert isinstance(uiTile, UITile)
+ if not uiTile.scene():
+ self.scene().addItem(uiTile)
width = self.tileset.faceSize.width()
height = self.tileset.faceSize.height()
- shiftZ = self.shiftZ(tile.level)
- boardPos = QPointF(tile.xoffset*width, tile.yoffset*height) + shiftZ
+ shiftZ = self.shiftZ(uiTile.level)
+ boardPos = QPointF(uiTile.xoffset*width, uiTile.yoffset*height) + shiftZ
scenePos = self.mapToScene(boardPos)
- tile.setDrawingOrder()
+ uiTile.setDrawingOrder()
return {'pos': scenePos, 'rotation': self.sceneRotation(), 'scale': \
self.scale()}
- def placeTile(self, tile):
- """places the tile in the scene. With direct=False, animate"""
- assert isinstance(tile, UITile)
- for pName, newValue in self.__tilePlace(tile).items():
- animation = tile.queuedAnimation(pName)
+ def placeTile(self, uiTile):
+ """places the uiTile in the scene. With direct=False, animate"""
+ assert isinstance(uiTile, UITile)
+ for pName, newValue in self.__tilePlace(uiTile).items():
+ animation = uiTile.queuedAnimation(pName)
if animation:
curValue = animation.unpackValue(animation.endValue())
if curValue != newValue:
# change a queued animation
animation.setEndValue(newValue)
else:
- animation = tile.activeAnimation.get(pName, None)
+ animation = uiTile.activeAnimation.get(pName, None)
if isAlive(animation):
curValue = animation.unpackValue(animation.endValue())
else:
- curValue = tile.getValue(pName)
+ curValue = uiTile.getValue(pName)
if pName != 'scale' or abs(curValue - newValue) > 0.00001:
if curValue != newValue:
- Animation(tile, pName, newValue)
+ Animation(uiTile, pName, newValue)
def addUITile(self, uiTile):
"""add uiTile to this board"""
@@ -607,8 +607,8 @@ class CourtBoard(Board):
yScaleFactor = yAvail / yNeeded
QGraphicsRectItem.setPos(self, newSceneX, newSceneY)
Board.setScale(self, min(xScaleFactor, yScaleFactor))
- for tile in self.tiles:
- tile.board.placeTile(tile)
+ for uiTile in self.tiles:
+ uiTile.board.placeTile(uiTile)
class SelectorBoard(CourtBoard):
"""a board containing all possible tiles for selection"""
@@ -624,8 +624,8 @@ class SelectorBoard(CourtBoard):
def load(self, game):
"""load the tiles according to game.ruleset"""
- for tile in self.tiles:
- tile.setBoard(None)
+ for uiTile in self.tiles:
+ uiTile.setBoard(None)
self.tiles = []
self.allSelectorTiles = list(UITile(x) for x in elements.all(game.ruleset))
self.refill()
@@ -633,11 +633,11 @@ class SelectorBoard(CourtBoard):
def refill(self):
"""move all tiles back into the selector"""
with Animated(False):
- for tileItem in self.allSelectorTiles:
- tileItem.tile = Tile(tileItem.tile.lower())
- self.__placeAvailable(tileItem)
- tileItem.dark = False
- tileItem.focusable = True
+ for uiTile in self.allSelectorTiles:
+ uiTile.tile = Tile(uiTile.tile.lower())
+ self.__placeAvailable(uiTile)
+ uiTile.dark = False
+ uiTile.focusable = True
self.focusTile = self.tilesByElement(Tile('c1'))[0]
# pylint: disable=no-self-use
@@ -647,22 +647,22 @@ class SelectorBoard(CourtBoard):
def dragMoveEvent(self, event):
"""allow dropping only from handboards, not from self"""
- tile = event.mimeData().tile
- event.setAccepted(tile.board != self)
+ uiTile = event.mimeData().uiTile
+ event.setAccepted(uiTile.board != self)
def dropEvent(self, event):
- """drop a tile into the selector"""
- tile = event.mimeData().tile
- self.dropTile(tile)
+ """drop a uiTile into the selector"""
+ uiTile = event.mimeData().uiTile
+ self.dropTile(uiTile)
event.accept()
- def dropTile(self, tile, lowerHalf=False): # pylint: disable=unused-argument
- """drop tile or meld into selector board"""
- senderHand = tile.board
+ def dropTile(self, uiTile, lowerHalf=False): # pylint: disable=unused-argument
+ """drop uiTile into selector board"""
+ senderHand = uiTile.board
if senderHand == self:
return
- meld = tile.board.uiMeldWithTile(tile)
- self.lastReceived = tile
+ meld = uiTile.board.uiMeldWithTile(uiTile)
+ self.lastReceived = uiTile
for myTile in meld:
self.__placeAvailable(myTile)
myTile.focusable = True
@@ -683,16 +683,16 @@ class SelectorBoard(CourtBoard):
def deselect(self, meld):
"""we are going to lose those tiles or melds"""
- def __placeAvailable(self, tile):
- """place the tile in the selector at its place"""
+ def __placeAvailable(self, uiTile):
+ """place the uiTile in the selector at its place"""
# define coordinates and order for tiles:
offsets = {'d': (3, 6, 'bgr'), 'f': (4, 5, 'eswn'), 'y': (4, 0, 'eswn'),
'w': (3, 0, 'eswn'), 'b': (1, 0, '123456789'), 's': (2, 0, '123456789'),
'c': (0, 0, '123456789')}
- row, baseColumn, order = offsets[tile.tile[0].lower()]
- column = baseColumn + order.index(tile.tile[1])
- tile.dark = False
- tile.setBoard(self, column, row)
+ row, baseColumn, order = offsets[uiTile.tile[0].lower()]
+ column = baseColumn + order.index(uiTile.tile[1])
+ uiTile.dark = False
+ uiTile.setBoard(self, column, row)
def meldVariants(self, uiTile, lowerHalf):
"""returns a list of possible variants based on meld. Those are logical \
melds.""" @@ -735,7 +735,7 @@ class MimeData(QMimeData):
"""we also want to pass a reference to the moved meld"""
def __init__(self, uiTile):
QMimeData.__init__(self)
- self.tile = uiTile
+ self.uiTile = uiTile
self.setText(str(uiTile))
class FittingView(QGraphicsView):
@@ -783,15 +783,15 @@ class FittingView(QGraphicsView):
self.fitInView(self.scene().itemsBoundingRect(), Qt.KeepAspectRatio)
self.setFocus()
- def __matchingTile(self, position, item):
- """is position in the clickableRect of this tile?"""
- if not isinstance(item, UITile):
+ def __matchingTile(self, position, uiTile):
+ """is position in the clickableRect of this uiTile?"""
+ if not isinstance(uiTile, UITile):
return False
- itemPos = item.mapFromScene(self.mapToScene(position))
- return item.board.tileFaceRect().contains(itemPos)
+ itemPos = uiTile.mapFromScene(self.mapToScene(position))
+ return uiTile.board.tileFaceRect().contains(itemPos)
def tileAt(self, position):
- """find out which tile is clickable at this position. Always
+ """find out which uiTile is clickable at this position. Always
returns a list. If there are several tiles above each other,
return all of them, highest first"""
allTiles = [x for x in self.items(position) if isinstance(x, UITile)]
@@ -810,19 +810,19 @@ class FittingView(QGraphicsView):
tiles = self.tileAt(event.pos())
if tiles:
if event.modifiers() & Qt.ShiftModifier:
- for tile in tiles:
- kprint('%s: board.level:%s' % (str(tile), tile.board.level))
- tile = tiles[0]
- board = tile.board
+ for uiTile in tiles:
+ kprint('%s: board.level:%s' % (str(uiTile), uiTile.board.level))
+ uiTile = tiles[0]
+ board = uiTile.board
isRemote = board.isHandBoard and board.player and not \
board.player.game.isScoringGame()
- if board.isHandBoard and not isRemote and not tile.isBonus():
- tile = tile.board.uiMeldWithTile(tile)[0]
- if tile.focusable:
- board.focusTile = tile
+ if board.isHandBoard and not isRemote and not uiTile.isBonus():
+ uiTile = uiTile.board.uiMeldWithTile(uiTile)[0]
+ if uiTile.focusable:
+ board.focusTile = uiTile
board.hasFocus = True
if isRemote:
Internal.field.clientDialog.buttons[0].setFocus()
- self.tilePressed = tile
+ self.tilePressed = uiTile
else:
event.ignore()
else:
@@ -835,7 +835,7 @@ class FittingView(QGraphicsView):
return QGraphicsView.mouseReleaseEvent(self, event)
def mouseMoveEvent(self, event):
- """selects the correct tile"""
+ """selects the correct uiTile"""
tilePressed = self.tilePressed
self.tilePressed = None
if tilePressed:
@@ -847,15 +847,15 @@ class FittingView(QGraphicsView):
return
return QGraphicsView.mouseMoveEvent(self, event)
- def drag(self, tile):
+ def drag(self, uiTile):
"""returns a drag object"""
drag = QDrag(self)
- mimeData = MimeData(tile)
+ mimeData = MimeData(uiTile)
drag.setMimeData(mimeData)
- tRect = tile.boundingRect()
+ tRect = uiTile.boundingRect()
tRect = self.viewportTransform().mapRect(tRect)
- pmapSize = QSize(tRect.width() * tile.scale, tRect.height() * tile.scale)
- pMap = tile.pixmapFromSvg(pmapSize)
+ pmapSize = QSize(tRect.width() * uiTile.scale, tRect.height() * \
uiTile.scale) + pMap = uiTile.pixmapFromSvg(pmapSize)
drag.setPixmap(pMap)
drag.setHotSpot(QPoint(pMap.width()/2, pMap.height()/2))
return drag
@@ -911,7 +911,7 @@ class DiscardBoard(CourtBoard):
return "discardBoard"
def hide(self):
- """remove all tile references so they can be garbage collected"""
+ """remove all uiTile references so they can be garbage collected"""
self.lastDiscarded = None
CourtBoard.hide(self)
@@ -920,23 +920,23 @@ class DiscardBoard(CourtBoard):
self.__places = [(x, y) for x in range(self.width) for y in \
range(self.height)] randomGenerator.shuffle(self.__places)
- def discardTile(self, tile):
- """add tile to a random position"""
- assert isinstance(tile, UITile)
- tile.setBoard(self, *self.__places.pop(0))
- tile.dark = False
- tile.focusable = False
- self.focusTile = tile
+ def discardTile(self, uiTile):
+ """add uiTile to a random position"""
+ assert isinstance(uiTile, UITile)
+ uiTile.setBoard(self, *self.__places.pop(0))
+ uiTile.dark = False
+ uiTile.focusable = False
+ self.focusTile = uiTile
self.hasFocus = True
- self.lastDiscarded = tile
+ self.lastDiscarded = uiTile
def dropEvent(self, event):
- """drop a tile into the discard board"""
+ """drop a uiTile into the discard board"""
# TODO: now that tiles are top level scene items, maybe drag them
# directly. Draggings melds: QGraphicsItemGroup?
- tile = event.mimeData().tile
- assert isinstance(tile, UITile), tile
- tile.setPos(event.scenePos() - tile.boundingRect().center())
+ uiTile = event.mimeData().uiTile
+ assert isinstance(uiTile, UITile), uiTile
+ uiTile.setPos(event.scenePos() - uiTile.boundingRect().center())
Internal.field.clientDialog.selectButton(Message.Discard)
event.accept()
self._noPen()
@@ -1011,7 +1011,7 @@ class MJScene(QGraphicsScene):
self.focusRect.setVisible(self.__focusRectVisible())
def placeFocusRect(self):
- """show a blue rect around tile"""
+ """show a blue rect around uiTile"""
board = self._focusBoard
if isAlive(board) and board.isVisible() and board.focusTile:
rect = board.tileFaceRect()
diff --git a/src/handboard.py b/src/handboard.py
index bda471e..dacf166 100644
--- a/src/handboard.py
+++ b/src/handboard.py
@@ -54,7 +54,7 @@ class TileAttr(object):
if scoring:
self.focusable = idx == 0
else:
- self.focusable = (self.tile[0] not in 'fy'
+ self.focusable = (not self.tile.isBonus()
and self.tile != 'Xy'
and player == player.game.activePlayer
and player == player.game.myself
@@ -230,12 +230,12 @@ class HandBoard(Board):
for newBonusPosition in self.newBonusPositions(list(x for x in tiles if \
x.isBonus()), newPositions):
result[oldBonusTiles[newBonusPosition.tile][0]] = newBonusPosition # \
TODO: testen self._avoidCrossingMovements(result)
- for tile, newPos in result.items():
- tile.level = 0 # for tiles coming from the wall
- tile.tile = newPos.tile
- tile.setBoard(self, newPos.xoffset, newPos.yoffset)
- tile.dark = newPos.dark
- tile.focusable = newPos.focusable
+ for uiTile, newPos in result.items():
+ uiTile.level = 0 # for tiles coming from the wall
+ uiTile.tile = newPos.tile
+ uiTile.setBoard(self, newPos.xoffset, newPos.yoffset)
+ uiTile.dark = newPos.dark
+ uiTile.focusable = newPos.focusable
return result
def _avoidCrossingMovements(self, places):
@@ -262,11 +262,11 @@ class HandBoard(Board):
physConcealed = list()
for tile in self.player.bonusTiles:
logExposed.append(tile)
- for tile in self.tiles:
- if tile.yoffset == 0 or tile.isBonus():
- physExposed.append(tile.tile)
+ for uiTile in self.tiles:
+ if uiTile.yoffset == 0 or uiTile.isBonus():
+ physExposed.append(uiTile.tile)
else:
- physConcealed.append(tile.tile)
+ physConcealed.append(uiTile.tile)
for meld in self.player.exposedMelds:
logExposed.extend(meld)
if self.player.concealedMelds:
@@ -321,10 +321,10 @@ class ScoringHandBoard(HandBoard):
if Meld(result) == meld:
return result
- def assignUITiles(self, tile, meld): # pylint: disable=unused-argument
- """generate a UIMeld. First tile is given, the rest should be as defined by \
meld"""
- assert isinstance(tile, UITile), tile
- return self.uiMeldWithTile(tile)
+ def assignUITiles(self, uiTile, meld): # pylint: disable=unused-argument
+ """generate a UIMeld. First uiTile is given, the rest should be as defined \
by meld""" + assert isinstance(uiTile, UITile), uiTile
+ return self.uiMeldWithTile(uiTile)
def sync(self, adding=None): # pylint: disable=unused-argument
"""place all tiles in ScoringHandBoard"""
@@ -340,44 +340,44 @@ class ScoringHandBoard(HandBoard):
Internal.field.handSelectorChanged(self)
def dragMoveEvent(self, event):
- """allow dropping of tile from ourself only to other state \
(open/concealed)"""
- tile = event.mimeData().tile
+ """allow dropping of uiTile from ourself only to other state \
(open/concealed)""" + uiTile = event.mimeData().uiTile
localY = self.mapFromScene(QPointF(event.scenePos())).y()
centerY = self.rect().height()/2.0
newLowerHalf = localY >= centerY
noMansLand = centerY / 6
- if -noMansLand < localY - centerY < noMansLand and not tile.isBonus():
+ if -noMansLand < localY - centerY < noMansLand and not uiTile.isBonus():
doAccept = False
- elif tile.board != self:
+ elif uiTile.board != self:
doAccept = True
- elif tile.isBonus():
+ elif uiTile.isBonus():
doAccept = False
else:
- oldLowerHalf = tile.board.isHandBoard and tile in \
tile.board.lowerHalfTiles() + oldLowerHalf = uiTile.board.isHandBoard and \
uiTile in uiTile.board.lowerHalfTiles() doAccept = oldLowerHalf != newLowerHalf
event.setAccepted(doAccept)
def dropEvent(self, event):
"""drop into this handboard"""
- tile = event.mimeData().tile
+ uiTile = event.mimeData().uiTile
lowerHalf = self.mapFromScene(QPointF(event.scenePos())).y() >= \
self.rect().height()/2.0
- if self.dropTile(tile, lowerHalf):
+ if self.dropTile(uiTile, lowerHalf):
event.accept()
else:
event.ignore()
self._noPen()
- def dropTile(self, tile, lowerHalf):
- """drop meld or tile into lower or upper half of our hand"""
- senderBoard = tile.board
+ def dropTile(self, uiTile, lowerHalf):
+ """drop meld or uiTile into lower or upper half of our hand"""
+ senderBoard = uiTile.board
self.checkTiles()
senderBoard.checkTiles()
- newMeld = senderBoard.chooseVariant(tile, lowerHalf)
+ newMeld = senderBoard.chooseVariant(uiTile, lowerHalf)
if not newMeld:
self.checkTiles()
senderBoard.checkTiles()
return False
- uiMeld = senderBoard.assignUITiles(tile, newMeld)
+ uiMeld = senderBoard.assignUITiles(uiTile, newMeld)
senderBoard.deselect(uiMeld)
for uiTile, tile in zip(uiMeld, newMeld):
uiTile.tile = tile
@@ -544,5 +544,5 @@ class PlayingHandBoard(HandBoard):
# thus minimizing tile movement within the hand
lastDiscard = matchingTiles[-1]
Internal.field.discardBoard.discardTile(lastDiscard)
- for tile in self.tiles:
- tile.focusable = False
+ for uiTile in self.tiles:
+ uiTile.focusable = False
diff --git a/src/humanclient.py b/src/humanclient.py
index a2039c9..cb5e6ad 100644
--- a/src/humanclient.py
+++ b/src/humanclient.py
@@ -121,9 +121,9 @@ class DlgButton(QPushButton):
self.client = parent.client
self.setText(message.buttonCaption())
- def decorate(self, tile):
+ def decorate(self, uiTile):
"""give me caption, shortcut, tooltip, icon"""
- txt, warn, _ = self.message.toolTip(self, tile.tile if tile else None)
+ txt, warn, _ = self.message.toolTip(self, uiTile.tile if uiTile else None)
if not txt:
txt = self.message.i18nName # .replace(i18nShortcut, '&'+i18nShortcut, \
1) self.setToolTip(txt)
@@ -197,14 +197,14 @@ class ClientDialog(QDialog):
return
for button in self.buttons:
button.decorate(self.client.game.myself.handBoard.focusTile)
- for tile in self.client.game.myself.handBoard.lowerHalfTiles():
+ for uiTile in self.client.game.myself.handBoard.lowerHalfTiles():
txt = []
for button in self.buttons:
- _, _, tileTxt = button.message.toolTip(button, tile.tile)
+ _, _, tileTxt = button.message.toolTip(button, uiTile.tile)
if tileTxt:
txt.append(tileTxt)
txt = '<br><br>'.join(txt)
- tile.setToolTip(txt)
+ uiTile.setToolTip(txt)
if self.client.game.activePlayer == self.client.game.myself:
Internal.field.handSelectorChanged(self.client.game.myself.handBoard)
@@ -228,9 +228,9 @@ class ClientDialog(QDialog):
result = [x for x in self.buttons if x.message == answer][0]
result.setFocus()
if answer in [Message.Discard, Message.OriginalCall]:
- for tileItem in game.myself.handBoard.tiles:
- if tileItem.tile == parameter:
- game.myself.handBoard.focusTile = tileItem
+ for uiTile in game.myself.handBoard.tiles:
+ if uiTile.tile == parameter:
+ game.myself.handBoard.focusTile = uiTile
return result
def askHuman(self, move, answers, deferred):
diff --git a/src/playfield.py b/src/playfield.py
index d6ed7a2..5905b0a 100644
--- a/src/playfield.py
+++ b/src/playfield.py
@@ -70,7 +70,6 @@ try:
from games import Games
from statesaver import StateSaver
from hand import Hand
- from uitile import UITile
from meld import Meld, CONCEALED
from scoring import ExplainView, ScoringDialog, ScoreTable
from tables import SelectRuleset
@@ -741,22 +740,21 @@ class PlayField(KXmlGuiWindow):
"""ignore failure to abort"""
self.abort().addCallback(HumanClient.shutdownHumanClients).addCallbacks(Client.quitProgram, \
doNotQuit)
- def __moveTile(self, tile, wind, lowerHalf):
- """the user pressed a wind letter or X for center, wanting to move a tile \
there""" + def __moveTile(self, uiTile, wind, lowerHalf):
+ """the user pressed a wind letter or X for center, wanting to move a uiTile \
there"""
# this tells the receiving board that this is keyboard, not mouse \
navigation> # needed for useful placement of the popup menu
assert self.game.isScoringGame()
- assert isinstance(tile, UITile), (tile, str(tile))
- currentBoard = tile.board
+ currentBoard = uiTile.board
if wind == 'X':
receiver = self.selectorBoard
else:
receiver = self.game.players[wind].handBoard
- if receiver != currentBoard or bool(lowerHalf) != bool(tile.yoffset):
- movingLastMeld = tile.tile in self.computeLastMeld()
+ if receiver != currentBoard or bool(lowerHalf) != bool(uiTile.yoffset):
+ movingLastMeld = uiTile.tile in self.computeLastMeld()
if movingLastMeld:
self.scoringDialog.clearLastTileCombo()
- receiver.dropTile(tile, lowerHalf)
+ receiver.dropTile(uiTile, lowerHalf)
if movingLastMeld and receiver == currentBoard:
self.scoringDialog.fillLastTileCombo()
@@ -904,9 +902,9 @@ class PlayField(KXmlGuiWindow):
self.discardBoard.maximize()
if self.selectorBoard:
self.selectorBoard.maximize()
- for tile in self.game.wall.tiles:
- if tile.board:
- tile.board.placeTile(tile)
+ for uiTile in self.game.wall.tiles:
+ if uiTile.board:
+ uiTile.board.placeTile(uiTile)
view, scene = self.centralView, self.centralScene
oldRect = view.sceneRect()
view.setSceneRect(scene.itemsBoundingRect())
@@ -984,8 +982,8 @@ class PlayField(KXmlGuiWindow):
self.selectorBoard.showShadows = self.showShadows
if self.discardBoard:
self.discardBoard.showShadows = self.showShadows
- for tile in self.centralScene.graphicsTileItems():
- tile.setClippingFlags()
+ for uiTile in self.centralScene.graphicsTileItems():
+ uiTile.setClippingFlags()
self.adjustView()
Sound.enabled = Preferences.useSounds
self.centralScene.placeFocusRect()
diff --git a/src/uiwall.py b/src/uiwall.py
index f733b2f..8afe6a4 100644
--- a/src/uiwall.py
+++ b/src/uiwall.py
@@ -66,17 +66,17 @@ class UIKongBox(KongBox):
def fill(self, tiles):
"""fill the box"""
- for tile in self._tiles:
- tile.cross = False
+ for uiTile in self._tiles:
+ uiTile.cross = False
KongBox.fill(self, tiles)
- for tile in self._tiles:
- tile.cross = True
+ for uiTile in self._tiles:
+ uiTile.cross = True
def pop(self, count):
"""get count tiles from kong box"""
result = KongBox.pop(self, count)
- for tile in result:
- tile.cross = False
+ for uiTile in result:
+ uiTile.cross = False
return result
class UIWall(Wall):
@@ -150,24 +150,23 @@ class UIWall(Wall):
discardBoard = Internal.field.discardBoard
places = [(x, y) for x in range(-3, discardBoard.width+3) for y in range(-3, \
discardBoard.height+3)]
places = self.game.randomGenerator.sample(places, len(self.tiles))
- for idx, tile in enumerate(self.tiles):
- assert isinstance(tile, UITile)
- tile.dark = True
- tile.setBoard(discardBoard, *places[idx])
+ for idx, uiTile in enumerate(self.tiles):
+ uiTile.dark = True
+ uiTile.setBoard(discardBoard, *places[idx])
def build(self):
"""builds the wall without dividing"""
# recycle used tiles
- for tile in self.tiles:
- tile.tile = Tile('Xy')
- tile.dark = True
+ for uiTile in self.tiles:
+ uiTile.tile = Tile('Xy')
+ uiTile.dark = True
# field = Internal.field
# animateBuild = not field.game.isScoringGame() and not \
self.game.isFirstHand() animateBuild = False
with Animated(animateBuild):
self.__shuffleTiles()
- for tile in self.tiles:
- tile.focusable = False
+ for uiTile in self.tiles:
+ uiTile.focusable = False
return animate().addCallback(self.__placeWallTiles)
def __placeWallTiles(self, dummyResult=None):
@@ -177,8 +176,8 @@ class UIWall(Wall):
for side in (self.__sides[0], self.__sides[3], self.__sides[2], \
self.__sides[1]): upper = True # upper tile is played first
for position in range(tilesPerSide-1, -1, -1):
- tile = tileIter.next()
- tile.setBoard(side, position//2, 0, level=int(upper))
+ uiTile = tileIter.next()
+ uiTile.setBoard(side, position//2, 0, level=int(upper))
upper = not upper
self.__setDrawingOrder()
return animate()
@@ -240,16 +239,16 @@ class UIWall(Wall):
for idx, side in enumerate(self.__sides):
side.level = (levels[side.lightSource][idx] + 1) * \
ZValues.boardLevelFactor
- def __moveDividedTile(self, tile, offset):
- """moves a tile from the divide hole to its new place"""
- board = tile.board
- newOffset = tile.xoffset + offset
+ def __moveDividedTile(self, uiTile, offset):
+ """moves a uiTile from the divide hole to its new place"""
+ board = uiTile.board
+ newOffset = uiTile.xoffset + offset
sideLength = len(self.tiles) // 8
if newOffset >= sideLength:
- sideIdx = self.__sides.index(tile.board)
+ sideIdx = self.__sides.index(uiTile.board)
board = self.__sides[(sideIdx+1) % 4]
- tile.setBoard(board, newOffset % sideLength, 0, level=2)
- tile.update()
+ uiTile.setBoard(board, newOffset % sideLength, 0, level=2)
+ uiTile.update()
def _placeLooseTiles(self):
"""place the last 2 tiles on top of kong box"""
@@ -269,12 +268,12 @@ class UIWall(Wall):
"""divides a wall, building a living and and a dead end"""
with Animated(False):
Wall.divide(self)
- for tile in self.tiles:
+ for uiTile in self.tiles:
# update graphics because tiles having been
# in kongbox in a previous game
# might not be there anymore. This gets rid
# of the cross on them.
- tile.update()
+ uiTile.update()
# move last two tiles onto the dead end:
return animate().addCallback(self.__placeLooseTiles2)
diff --git a/src/visible.py b/src/visible.py
index 06e612a..4f9abe0 100644
--- a/src/visible.py
+++ b/src/visible.py
@@ -147,11 +147,11 @@ class VisiblePlayingPlayer(PlayingPlayer):
assert lastDiscard.tile.istitle()
self.syncHandBoard()
- def addConcealedTiles(self, tileItems, animated=True):
+ def addConcealedTiles(self, uiTiles, animated=True):
"""add to my tiles and sync the hand board"""
with Animated(animated):
- PlayingPlayer.addConcealedTiles(self, list(x.tile for x in tileItems))
- self.syncHandBoard(tileItems)
+ PlayingPlayer.addConcealedTiles(self, list(x.tile for x in uiTiles))
+ self.syncHandBoard(uiTiles)
def removeTile(self, tile):
"""remove from my melds or tiles"""
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic