Example #1
0
 def remove_observer(self, user):
     Observed.remove_observer(self, user)
     playername = user.name
     if playername in self.playernames:
         self.playernames.remove(playername)
         action = Action.DelUsername(playername)
         self.notify(action)
Example #2
0
 def __init__(self, playername, game, join_order, player_class="Human",
              player_info=""):
     logging.info("%s %s %s %s %s", playername, game, join_order,
                  player_class, player_info)
     Observed.__init__(self)
     self.name = playername
     self.player_class = player_class
     self.player_info = player_info or playername
     self.game = game
     self.join_order = join_order
     self.starting_tower = None    # a numeric hex label
     self.created_starting_legion = False
     self.score = 0
     self.color = None
     # Currently available markers
     self.markerids_left = set()
     # Private to this instance; not shown to others until a
     # legion is actually split off with this marker.
     self.selected_markerid = None
     # {str markerid : Legion}
     self.markerid_to_legion = {}
     self.mulligans_left = 1
     self.movement_roll = None
     self.summoned = False
     self.eliminated_colors = set()
     self.last_donor = None
     self.has_titan = True
Example #3
0
 def __init__(self, no_passwd, passwd_path, port, log_path):
     Observed.__init__(self)
     self.no_passwd = no_passwd
     self.passwd_path = passwd_path
     self.port = port
     self.games = []
     self.playernames = set()
     self.results = Results.Results()
     # {game_name: set(ainame) we're waiting for
     self.game_to_waiting_ais = {}
     self._setup_logging(log_path)
Example #4
0
    def __init__(
        self,
        playername,
        password,
        host,
        port,
        delay,
        game_name,
        log_path,
        ai_time_limit,
        player_time_limit,
        form_game,
        min_players,
        max_players,
    ):
        Observed.__init__(self)
        self.playername = playername
        self.password = password
        self.host = host
        self.port = port
        self.delay = delay
        self.aiclass = "CleverBot"
        self.factory = pb.PBClientFactory()
        self.factory.unsafeTracebacks = True
        self.user = None
        self.games = []
        self.log_path = log_path
        self._setup_logging()

        bp = None
        # Using Results means we need to be on the server.
        results = Results.Results()
        if not re.match(r"^ai\d+$", playername):
            raise AssertionError("invalid playername for AI")
        player_id = int(playername[2:])
        player_info = results.get_player_info(player_id)
        if player_info is None:
            player_id = results.get_weighted_random_player_id()
            playername = "ai%d" % player_id
            player_info = results.get_player_info(player_id)
        bp = BotParams.BotParams.fromstring(player_info)
        self.ai = CleverBot.CleverBot(self.playername, ai_time_limit, bot_params=bp)
        self.game_name = game_name
        self.ai_time_limit = ai_time_limit
        self.player_time_limit = player_time_limit
        self.form_game = form_game
        self.min_players = min_players
        self.max_players = max_players
        self.paused = False
        self.last_actions = []
        self.aps = predictsplits.AllPredictSplits()
Example #5
0
 def __init__(self, playername, password, host="localhost",
              port=config.DEFAULT_PORT):
     Observed.__init__(self)
     self.playername = playername
     self.playername = playername  # In case the same user logs in twice
     self.password = password
     self.host = host
     self.port = port
     self.factory = pb.PBClientFactory()
     self.factory.unsafeTracebacks = True
     self.user = None
     self.playernames = set()
     self.games = []
     self.guiboards = {}   # Maps game to guiboard
     self.pickcolor = None
Example #6
0
 def __init__(self, player, markerid, creatures, hexlabel):
     Observed.__init__(self)
     assert isinstance(hexlabel, types.IntType)
     self.markerid = markerid
     self.picname = find_picname(markerid)
     self.creatures = creatures
     for creature in self.creatures:
         creature.legion = self
     self.hexlabel = hexlabel  # an int not a str
     self.player = player
     self.moved = False
     self.teleported = False
     self.teleporting_lord = None
     self.entry_side = None
     self.previous_hexlabel = None
     self.recruited = False
     # List of tuples of recruiter names
     self.recruiter_names_list = []
     self._angels_pending = 0
     self._archangels_pending = 0
Example #7
0
 def add_observer(self, user):
     playername = user.name
     Observed.add_observer(self, user, playername)
     self.playernames.add(playername)
     action = Action.AddUsername(playername)
     self.notify(action)