本文整理汇总了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
示例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)
示例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)
示例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
示例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
示例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()
示例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()
示例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])
示例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])
示例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)
示例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))
示例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
示例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)
示例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)
示例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)