def _cleanup_removed_player(self, player: ClientManager.Client): self.listener.unsubscribe(player) # Restore their gamemode if needed (if player moved to a new zone, this zone will # be in charge of updating the gamemode) if not player.area.in_zone or player.area.in_zone == self: player.send_gamemode(name='') # Remove handicap if self.is_property('Handicap'): # Avoid double notification try: player.change_handicap(False) except ClientError: # If the player no longer had a handicap, no need to do anything # This can happen if /unhandicap was run with a client in an area part of # a zone with a handicap pass # Remove chat tick rate if self.is_property('Chat_tick_rate'): player.send_chat_tick_rate(chat_tick_rate=None)
def _add_player(self, user: ClientManager.Client): if user in self._players: raise ZoneError.PlayerConflictError( 'User is already a player in the zone.') if user.area not in self._areas: raise ZoneError.PlayerNotInZoneError( 'User is in an area not part of the zone.') self._players.add(user) self.listener.subscribe(user) user.send_gamemode(name=self.get_mode()) if self.is_property('Handicap'): length, name, announce_if_over = self.get_property('Handicap') user.change_handicap(True, length=length, name=name, announce_if_over=announce_if_over) if self.is_property('Chat_tick_rate'): chat_tick_rate = self.get_property('Chat_tick_rate') user.send_chat_tick_rate(chat_tick_rate=chat_tick_rate)