Exemplo n.º 1
0
 def addConcealedTiles(self, uiTiles, animated=True):
     """add to my tiles and sync the hand board"""
     with MoveImmediate(animated):
         PlayingPlayer.addConcealedTiles(
             self,
             list(x.tile for x in uiTiles))
         self.syncHandBoard(uiTiles)
Exemplo n.º 2
0
 def __init__(self, game, name):
     assert game
     self.handBoard = None  # because Player.init calls clearHand()
     PlayingPlayer.__init__(self, game, name)
     VisiblePlayer.__init__(self)
     self.handBoard = PlayingHandBoard(self)
     self.voice = None
Exemplo n.º 3
0
 def makeTileKnown(self, tile):
     """give an unknown tileItem a name"""
     PlayingPlayer.makeTileKnown(self, tile)
     assert tile.isKnown
     matchingTiles = sorted(self.handBoard.tilesByElement(Tile.unknown),
                            key=lambda x: x.xoffset)
     matchingTiles[-1].tile = tile
Exemplo n.º 4
0
 def __init__(self, game, name):
     assert game
     self.handBoard = None  # because Player.init calls clearHand()
     PlayingPlayer.__init__(self, game, name)
     VisiblePlayer.__init__(self)
     self.handBoard = PlayingHandBoard(self)
     self.voice = None
Exemplo n.º 5
0
 def addConcealedTiles(self, uiTiles, animated=True):
     """add to my tiles and sync the hand board"""
     with AnimationSpeed(
             speed=Internal.Preferences.animationSpeed if animated else 99):
         PlayingPlayer.addConcealedTiles(self,
                                         list(x.tile for x in uiTiles))
         self.syncHandBoard(uiTiles)
Exemplo n.º 6
0
 def makeTileKnown(self, tile):
     """give an unknown tileItem a name"""
     PlayingPlayer.makeTileKnown(self, tile)
     assert tile.isKnown
     matchingTiles = sorted(
         self.handBoard.tilesByElement(Tile.unknown),
         key=lambda x: x.xoffset)
     matchingTiles[-1].tile = tile
Exemplo n.º 7
0
 def robTileFrom(self, tile):
     """used for robbing the kong from this player"""
     PlayingPlayer.robTileFrom(self, tile)
     tile = tile.exposed
     hbTiles = self.handBoard.uiTiles
     lastDiscard = [x for x in hbTiles if x.tile == tile][-1]
     lastDiscard.tile = lastDiscard.tile.concealed
     Internal.scene.discardBoard.lastDiscarded = lastDiscard
     # remove from board of robbed player, otherwise syncHandBoard would
     # not fix display for the robbed player
     lastDiscard.setBoard(None)
     assert lastDiscard.tile.isConcealed
     self.syncHandBoard()
Exemplo n.º 8
0
 def robTileFrom(self, tile):
     """used for robbing the kong from this player"""
     PlayingPlayer.robTileFrom(self, tile)
     tile = tile.exposed
     hbTiles = self.handBoard.uiTiles
     lastDiscard = [x for x in hbTiles if x.tile == tile][-1]
     lastDiscard.tile = lastDiscard.tile.concealed
     Internal.scene.discardBoard.lastDiscarded = lastDiscard
     # remove from board of robbed player, otherwise syncHandBoard would
     # not fix display for the robbed player
     lastDiscard.setBoard(None)
     assert lastDiscard.tile.isConcealed
     self.syncHandBoard()
Exemplo n.º 9
0
 def declaredMahJongg(self, concealed, withDiscard, lastTile, lastMeld):
     """player declared mah jongg. Determine last meld, show
     concealed tiles grouped to melds"""
     PlayingPlayer.declaredMahJongg(self, concealed, withDiscard, lastTile,
                                    lastMeld)
     if withDiscard:
         # withDiscard is a Tile, we need the UITile
         discardTile = Internal.scene.discardBoard.lastDiscarded
         if discardTile.tile is not withDiscard:
             self.game.debug('%s is not %s' %
                             (discardTile.tile, withDiscard))
             assert False
         self.syncHandBoard([discardTile])
     else:
         # show concealed tiles
         self.syncHandBoard()
Exemplo n.º 10
0
 def exposeMeld(self, meldTiles, calledTile=None):
     result = PlayingPlayer.exposeMeld(
         self,
         meldTiles,
         calledTile.tile if calledTile else None)
     adding = [calledTile] if calledTile else None
     self.syncHandBoard(adding=adding)
     return result
Exemplo n.º 11
0
 def declaredMahJongg(self, concealed, withDiscard, lastTile, lastMeld):
     """player declared mah jongg. Determine last meld, show
     concealed tiles grouped to melds"""
     PlayingPlayer.declaredMahJongg(
         self,
         concealed,
         withDiscard,
         lastTile,
         lastMeld)
     if withDiscard:
         # withDiscard is a Tile, we need the UITile
         discardTile = Internal.scene.discardBoard.lastDiscarded
         if discardTile.tile is not withDiscard:
             self.game.debug(
                 '%s is not %s' %
                 (discardTile.tile, withDiscard))
             assert False
         self.syncHandBoard([discardTile])
     else:
         # show concealed tiles
         self.syncHandBoard()
Exemplo n.º 12
0
 def remote_move(self, playerName, command, *dummyArgs, **kwargs):
     """the server sends us info or a question and always wants us to answer"""
     if Internal.scene and not isAlive(Internal.scene):
         return fail()
     if self.game:
         player = self.game.playerByName(playerName)
     elif playerName:
         player = PlayingPlayer(None, playerName)
     else:
         player = None
     move = Move(player, command, kwargs)
     if Debug.traffic:
         if self.isHumanClient():
             if self.game:
                 self.game.debug('got Move: %s' % move)
             else:
                 logDebug('got Move: %s' % move)
     if self.game:
         if move.token:
             if move.token != self.game.handId.token():
                 logException('wrong token: %s, we have %s' %
                              (move.token, self.game.handId.token()))
     with Duration('Move %s:' % move):
         return self.exec_move(move).addCallback(self.__jellyMessage)
Exemplo n.º 13
0
 def removeTile(self, tile):
     """remove from my melds or tiles"""
     PlayingPlayer.removeTile(self, tile)
     self.syncHandBoard()
Exemplo n.º 14
0
 def exposeMeld(self, meldTiles, calledTile=None):
     result = PlayingPlayer.exposeMeld(
         self, meldTiles, calledTile.tile if calledTile else None)
     adding = [calledTile] if calledTile else None
     self.syncHandBoard(adding=adding)
     return result
Exemplo n.º 15
0
 def removeTile(self, tile):
     """remove from my melds or tiles"""
     PlayingPlayer.removeTile(self, tile)
     self.syncHandBoard()