当前位置: 首页>>代码示例>>Python>>正文


Python player.Player方法代码示例

本文整理汇总了Python中player.Player方法的典型用法代码示例。如果您正苦于以下问题:Python player.Player方法的具体用法?Python player.Player怎么用?Python player.Player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在player的用法示例。


在下文中一共展示了player.Player方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def register(self, addr, udp_port):
        """
        Register player
        """
        player = None
        for registered_player in self.players.values():
            if registered_player.addr == addr:
                player = registered_player
                player.udp_addr((addr[0], udp_port))
                break

        if player is None:
            player = Player(addr, udp_port)
            self.players[player.identifier] = player

        return player 
开发者ID:Ganapati,项目名称:Simple-Game-Server,代码行数:18,代码来源:rooms.py

示例2: __packet_callback

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def __packet_callback(self, packet):
    raw_payload = raw(packet.payload.payload.payload)

    if raw_payload[:2] == b'\xf7\x1e':
      self.__set_gateway(packet)

      player = Player()
      player.is_me = True
      self.__parse_player_packet(player, raw_payload, 19)
      BNetStatsScraper.get_stats(player, self.gateway)
      self.player_list.append(player)
    elif raw_payload[:2] == b'\xf7\x06':
      player_offset = 0
      while player_offset is not -1:
        player = Player()
        self.__parse_player_packet(player, raw_payload[player_offset:], 9)
        BNetStatsScraper.get_stats(player, self.gateway)
        self.player_list.append(player)
        player_offset = raw_payload.find(b'\xf7\x06', player_offset + 1) 
开发者ID:dethredic,项目名称:WC3StreamerOverlay,代码行数:21,代码来源:bnet_player_monitor.py

示例3: test_reverse

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def test_reverse(self):
        p0 = Player(self.game, "Player 0")
        p1 = Player(self.game, "Player 1")
        p2 = Player(self.game, "Player 2")
        self.game.reverse()
        p3 = Player(self.game, "Player 3")

        self.assertEqual(p0, p3.next)
        self.assertEqual(p1, p2.next)
        self.assertEqual(p2, p0.next)
        self.assertEqual(p3, p1.next)

        self.assertEqual(p0, p2.prev)
        self.assertEqual(p1, p3.prev)
        self.assertEqual(p2, p1.prev)
        self.assertEqual(p3, p0.prev) 
开发者ID:jh0ker,项目名称:mau_mau_bot,代码行数:18,代码来源:test_player.py

示例4: play

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def play():
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        # Check again since the room could have changed the player's state
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break 
开发者ID:phillipjohnson,项目名称:text-adventure-tut,代码行数:21,代码来源:game.py

示例5: new_player

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def new_player(self, name, ws):
        self._last_id += 1
        player_id = self._last_id
        self.send_personal(ws, "handshake", name, player_id)

        self.send_personal(ws, "world", self._world)
        self.send_personal(ws, *self.top_scores_msg())
        for p in self._players.values():
            if p.alive:
                self.send_personal(ws, "p_joined", p._id, p.name, p.color, p.score)

        player = Player(player_id, name, ws)
        self._players[player_id] = player
        return player 
开发者ID:7WebPages,项目名称:snakepit-game,代码行数:16,代码来源:game.py

示例6: __init__

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def __init__(self):
        self.__dict__ = self._shared_state
        self.api = Api()
        self.player = Player()
        self.state = State() 
开发者ID:im85288,项目名称:service.upnext,代码行数:7,代码来源:playitem.py

示例7: __init__

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def __init__(self):
        self.__dict__ = self._shared_state
        self.api = Api()
        self.play_item = PlayItem()
        self.state = State()
        self.player = Player() 
开发者ID:im85288,项目名称:service.upnext,代码行数:8,代码来源:playbackmanager.py

示例8: command_action

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def command_action(self, bot, update):
        group = update.message.chat_id
        try:
            player = player.Player(update.message.from_user.id)
            player.name = update.message.from_user.first_name + \
                " " + update.message.from_user.last_name
            self.SESSIONS[group].player_add(player)
            self.SESSIONS[update.message.chat_id].messenger.send(
                update, player.name + _(" joined_the_game"))
        except ValueError as e:
            self.SESSIONS[update.message.chat_id].messenger.send(
                update, update.message.from_user.first_name + e.args[0]) 
开发者ID:toymak3r,项目名称:CineMonster,代码行数:14,代码来源:Server.py

示例9: command_cut

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def command_cut(self, bot, update):
        group = update.message.chat_id
        try:
            player = player.Player(update.message.from_user.id)
            self.SESSIONS[group].player_quit(player)
            self.SESSIONS[update.message.chat_id].messenger.send(update,
                                                                 update.message.from_user.first_name + _("_left_the_game!"))
        except ValueError as e:
            self.SESSIONS[update.message.chat_id].messenger.send(
                update, update.message.from_user.first_name + e.args[0]) 
开发者ID:toymak3r,项目名称:CineMonster,代码行数:12,代码来源:Server.py

示例10: block

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def block(self, reason):
        if self.blocked or len(self.player.match.players) == 1:
            return
        print("Player blocked: {0}".format(self.player.name))
        self.blocked = True
        if not self.player.dead:
            self.player.match.broadBin(0x11, Buffer().writeInt16(self.player.id), self.player.id) # KILL_PLAYER_OBJECT
        self.server.blockAddress(self.address, self.player.name, reason) 
开发者ID:Igoorx,项目名称:PyRoyale,代码行数:10,代码来源:server.py

示例11: start_games

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def start_games(amount_of_games):
    player_a_wins = 0
    player_b_wins = 0
    games_played = 0

    logging.info("Starting Open MTG. Playing {0} games".format(amount_of_games))
    for i in range(amount_of_games):
        gold_deck = deck.get_8ed_core_gold_deck()
        silver_deck = deck.get_8ed_core_silver_deck()
        current_game = game.Game([player.Player(gold_deck), player.Player(silver_deck)])
        current_game.start_game()

        if current_game.active_player.index == 0:
            logging.info("Gold player starts game")
        else:
            logging.info("Silver player starts game")
        while not current_game.is_over():
            if current_game.player_with_priority.index is 1:
                move = current_game.player_with_priority.determine_move(method="random", game=current_game)
            else:
                # move = game.player_with_priority.determine_move(method="random", game=game)
                if len(current_game.get_moves()) == 1:
                    move = current_game.get_moves()[0]
                else:
                    move = mcts.uct(current_game, itermax=5)

            current_game.make_move(move, False)

        if current_game.players[1].has_lost:
            player_a_wins += 1
        elif current_game.players[0].has_lost:
            player_b_wins += 1
        games_played += 1
        logging.info("Game {0} is over! current standings: "
                     "{1} - {2}".format(games_played, player_a_wins, player_b_wins))

    logging.info("Player A won {0} out of {1}".format(player_a_wins, games_played))
    logging.info("Player B won {0} out of {1}".format(player_b_wins, games_played))
    logging.info("Quitting Open MTG{0}{0}".format(os.linesep)) 
开发者ID:hlynurd,项目名称:open-mtg,代码行数:41,代码来源:main.py

示例12: join_game

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def join_game(self, user, chat):
        """ Create a player from the Telegram user and add it to the game """
        self.logger.info("Joining game with id " + str(chat.id))

        try:
            game = self.chatid_games[chat.id][-1]
        except (KeyError, IndexError):
            raise NoGameInChatError()

        if not game.open:
            raise LobbyClosedError()

        if user.id not in self.userid_players:
            self.userid_players[user.id] = list()

        players = self.userid_players[user.id]

        # Don not re-add a player and remove the player from previous games in
        # this chat, if he is in one of them
        for player in players:
            if player in game.players:
                raise AlreadyJoinedError()

        try:
            self.leave_game(user, chat)
        except NoGameInChatError:
            pass
        except NotEnoughPlayersError:
            self.end_game(chat, user)

            if user.id not in self.userid_players:
                self.userid_players[user.id] = list()

            players = self.userid_players[user.id]

        player = Player(game, user)
        if game.started:
            player.draw_first_hand()

        players.append(player)
        self.userid_current[user.id] = player 
开发者ID:jh0ker,项目名称:mau_mau_bot,代码行数:43,代码来源:game_manager.py

示例13: test_insert

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def test_insert(self):
        p0 = Player(self.game, "Player 0")
        p1 = Player(self.game, "Player 1")
        p2 = Player(self.game, "Player 2")

        self.assertEqual(p0, p2.next)
        self.assertEqual(p1, p0.next)
        self.assertEqual(p2, p1.next)

        self.assertEqual(p0.prev, p2)
        self.assertEqual(p1.prev, p0)
        self.assertEqual(p2.prev, p1) 
开发者ID:jh0ker,项目名称:mau_mau_bot,代码行数:14,代码来源:test_player.py

示例14: test_leave

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def test_leave(self):
        p0 = Player(self.game, "Player 0")
        p1 = Player(self.game, "Player 1")
        p2 = Player(self.game, "Player 2")

        p1.leave()

        self.assertEqual(p0, p2.next)
        self.assertEqual(p2, p0.next) 
开发者ID:jh0ker,项目名称:mau_mau_bot,代码行数:11,代码来源:test_player.py

示例15: test_draw

# 需要导入模块: import player [as 别名]
# 或者: from player import Player [as 别名]
def test_draw(self):
        p = Player(self.game, "Player 0")

        deck_before = len(self.game.deck.cards)
        top_card = self.game.deck.cards[-1]

        p.draw()

        self.assertEqual(top_card, p.cards[-1])
        self.assertEqual(deck_before, len(self.game.deck.cards) + 1) 
开发者ID:jh0ker,项目名称:mau_mau_bot,代码行数:12,代码来源:test_player.py


注:本文中的player.Player方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。