Esempio n. 1
0
    def _update_squad(self, player, squad):

        # Check whether the squad needs to be updated
        if player.squad_id and player.squad_id == squad.id:
            return

        # Remove the player from the previous squad
        if player.squad_id:
            old_squad = model_mgr.get_squad(squad.id)
            if old_squad and old_squad != models.squads.EMPTY:
                old_squad.player_ids.remove(player.id)
                if old_squad.leader_id == player.id:
                    old_squad.leader_id = None

        # Add the player to the new squad
        if squad != models.squads.EMPTY:
            squad.player_ids.add(player.id)

        # Update the squad for the player
        if squad == models.squads.EMPTY:
            player.squad_id = None
            player.squader = False
        else:
            player.squad_id = squad.id
            player.squader = True

        # Remove the squad leader flag from the player if needed
        if not player.squad_id:
            player.leader = False
Esempio n. 2
0
    def _update_squad(self, player, squad):

        # Check whether the squad needs to be updated
        if player.squad_id and player.squad_id == squad.id:
            return

        # Remove the player from the previous squad
        if player.squad_id:
            old_squad = model_mgr.get_squad(squad.id)
            if old_squad and old_squad != models.squads.EMPTY:
                old_squad.player_ids.remove(player.id)
                if old_squad.leader_id == player.id:
                    old_squad.leader_id = None

        # Add the player to the new squad
        if squad != models.squads.EMPTY:
            squad.player_ids.add(player.id)

        # Update the squad for the player
        if squad == models.squads.EMPTY:
            player.squad_id = None
            player.squader = False
        else:
            player.squad_id = squad.id
            player.squader = True

        # Remove the squad leader flag from the player if needed
        if not player.squad_id:
            player.leader = False
Esempio n. 3
0
    def on_death(self, e):

        # Get the leader for the player's squad
        squad = model_mgr.get_squad(e.player.squad_id)
        leader = model_mgr.get_player(squad.leader_id)

        # Give a point to the squad leader
        self.results[leader] += 1
Esempio n. 4
0
    def on_kill(self, e):

        # Ignore team kills and suicides
        if not e.valid_kill:
            return

        # Get the leader for the attacker's squad
        squad = model_mgr.get_squad(e.attacker.squad_id)
        leader = model_mgr.get_player(squad.leader_id)

        # Give a point to the squad leader
        self.results[leader] += 1