Exemplo n.º 1
0
    def assign_roles(self):
        shuffle(self.players)

        temp_characters = []

        werewolves_count = ceil(0.3*self.config['max_players'])

        if self.config['witch_enabled']:
            witch_count = ceil(0.1*self.config['max_players'])
        else:
            witch_count = 0

        for x in range(werewolves_count):
            temp_characters.append(CharacterFactory.create_character("werewolf", p_id=self.players[x]))

        for x in range(werewolves_count, werewolves_count+witch_count):
            temp_characters.append(CharacterFactory.create_character("witch", p_id=self.players[x]))

        for x in range(werewolves_count+witch_count, len(self.players)):
            temp_characters.append(CharacterFactory.create_character("human", p_id=self.players[x]))

        for player in temp_characters:
            player.save()
            log_type    = "INFO"
            log_code    = "Player"
            log_message = "After assigning the roles, this player is " + player.character
            log_detail  = 3
            context_id  = player.p_id

            log_handler.log(log_type=log_type, log_code=log_code, log_message=log_message, log_detail=log_detail, context_id=context_id)

        log_type    = "INFO"
        log_message = "Character roles assigned"
        context_id  = self.g_id
        log_code    = "Game"

        log_handler.log(log_type, log_code, log_message, context_id=context_id)
Exemplo n.º 2
0
    def get_players(self):
        players = []
        for p_id in self.players:
            players.append(CharacterFactory.create_character(character=None, p_id=p_id))

        return players