def register_player(self, uuid, player): if not isinstance(player, BasePokerPlayer): raise TypeError("player must inherit %s class." % BasePokerPlayer) # Wrap the function with a timeout default_action_info = ("fold",0) # Fold player.declare_action = timeout2(0.5,default_action_info)(player.declare_action) self.players_holder[uuid] = player
def register_player(self, name, algorithm): if not isinstance(algorithm, BasePokerPlayer): base_msg = 'Poker player must be child class of "BasePokerPlayer". But its parent was "%s"' raise TypeError(base_msg % algorithm.__class__.__bases__) # Wrap the function with a timeout default_action_info = "fold" algorithm.declare_action = timeout2(0.5,default_action_info)(algorithm.declare_action) info = { "name" : name, "algorithm" : algorithm } self.players_info.append(info)