def endHand(self, dummyResults=None): """hand is over, show all concealed tiles to all players""" if not self.game: return if self.game.playOpen: self.saveHand() else: block = DeferredBlock(self) for player in self.game.players: # there might be no winner, winner.others() would be wrong if player != self.game.winner: # the winner tiles are already shown in claimMahJongg block.tellOthers(player, Message.ShowConcealedTiles, show=True, source=player.concealedTileNames) block.callback(self.saveHand)
def endHand(self, dummyResults=None): """hand is over, show all concealed tiles to all players""" if not self.running: return if self.game.playOpen: self.saveHand() else: block = DeferredBlock(self) for player in self.game.players: # there might be no winner, winner.others() would be wrong if player != self.game.winner: # the winner tiles are already shown in claimMahJongg block.tellOthers(player, Message.ShowConcealedTiles, show=True, tiles=TileList(player.concealedTiles)) block.callback(self.saveHand)
def pickTile(self, dummyResults=None, deadEnd=False): """the active player gets a tile from wall. Tell all clients.""" if not self.game: return player = self.game.activePlayer try: tile = player.pickedTile(deadEnd) except WallEmpty: self.endHand() else: tileName = tile.element self.game.lastDiscard = None block = DeferredBlock(self) block.tellPlayer(player, Message.PickedTile, source=tileName, deadEnd=deadEnd) if tileName[0] in 'fy' or self.game.playOpen: block.tellOthers(player, Message.PickedTile, source=tileName, deadEnd=deadEnd) else: block.tellOthers(player, Message.PickedTile, source= 'Xy', deadEnd=deadEnd) block.callback(self.moved)
def pickTile(self, dummyResults=None, deadEnd=False): """the active player gets a tile from wall. Tell all clients.""" if not self.running: return player = self.game.activePlayer try: tile = player.pickedTile(deadEnd) except WallEmpty: self.endHand() else: self.game.lastDiscard = None block = DeferredBlock(self) block.tellPlayer(player, Message.PickedTile, tile=tile, deadEnd=deadEnd) showTile = tile if tile.isBonus or self.game.playOpen else Tile.unknown block.tellOthers(player, Message.PickedTile, tile=showTile, deadEnd=deadEnd) block.callback(self.moved)
def tellOthers(self, player, command, callback=None, **kwargs): """tell something about player to all other players""" block = DeferredBlock(self) block.tellOthers(player, command, **kwargs) block.callback(callback) return block