def create_hotel_message(self, message): """Someone created a new hotel.""" player_name = message['player'] game = self.game_for_player(player_name) if not game: return try: player = gametools.player_named(game, player_name) hotel = gametools.hotel_named(game, message['hotel']) gametools.create_hotel(game, player, hotel) except gametools.GamePlayNotAllowedError, e: self.send_error(player_name, 'Cannot create hotel', e) return
def play_tile_message(self, message): """Someone played a tile.""" player_name = message['player'] game = self.game_for_player(player_name) if not game: return try: player = gametools.player_named(game, player_name) stock_market_shares = gametools.play_tile(game, player, message['tile']) except gametools.GamePlayNotAllowedError, e: self.send_error(player_name, 'Cannot play tile', e) return
def purchase_message(self, message): """Someone bought some shares and maybe ended the game.""" player_name = message['player'] game = self.game_for_player(player_name) if not game: return order = message['order'] try: player = gametools.player_named(game, player_name) stock_market_shares = gametools.purchase(game, player, order, message['end_game']) except gametools.GamePlayNotAllowedError, e: self.send_error(player_name, 'Cannot complete purchase', e) return
def choose_survivor_message(self, message): """Someome chose which hotel will survive a merge.""" player_name = message['player'] game = self.game_for_player(player_name) if not game: return try: player = gametools.player_named(game, player_name) survivor = gametools.hotel_named(game, message['hotel']) stock_market_shares = gametools.choose_survivor(game, player, survivor) except gametools.GamePlayNotAllowedError, e: self.send_error(player_name, 'Cannot choose survivor', e) return
def disburse_shares_message(self, message): """Someone handled their shares in a disappearing hotel.""" player_name = message['player'] game = self.game_for_player(player_name) if not game: return first_action = game['action_queue'][0] try: player = gametools.player_named(game, player_name) disbursement = { 'hotel': first_action['hotel'], 'sell': message['sell'], 'trade': message['trade'], } survivor = gametools.disburse_shares(game, player, disbursement) except gametools.GamePlayNotAllowedError, e: self.send_error(player_name, 'Cannot disburse shares', e) return