def __init__(self, address): super().__init__() self.logger = logging.getLogger(__name__) self.unique_id: int = None self.login_name: str = None self.display_name: str = None self.password_hash: str = None self.port = address[1] self.verified = False self.last_received_seq = 0 self.vote = None self.state = None self.is_modded: bool = False self.login_server = None self.game_server = None self.loadouts: Dict[Loadouts] = { mode: Loadouts(mode) for mode in get_game_setting_modes() } self.friends = Friends(self) self.player_settings = PlayerSettings() self.team = None self.pings = {} self.activity_since_last_check = True detected_ip = IPv4Address(address[0]) if detected_ip.is_global: self.address_pair = IPAddressPair(detected_ip, None) else: assert detected_ip.is_private self.address_pair = IPAddressPair(None, detected_ip)
def save(self): if self.verified: for mode in get_game_setting_modes(): self.loadouts[mode].save(self.loadout_file_path % (self.login_name, mode)) self.friends.save(self.friends_file_path % self.login_name) self.player_settings.save(self.settings_file_path % self.login_name)
def load(self): if self.registered: for mode in get_game_setting_modes(): self.loadouts[mode].load(self.loadout_file_path % (self.login_name, mode)) self.friends.load(self.friends_file_path % self.login_name) self.player_settings.load(self.settings_file_path % self.login_name)
def handle_client2login_switchmode(self, message: Client2LoginSwitchMode): modes = list(get_game_setting_modes()) next_mode = modes[(modes.index(self.player.player_settings.game_setting_mode) + 1) % len(modes)] self.player.player_settings.game_setting_mode = next_mode # Send the player a message confirming their mode self._send_private_msg_from_server(self.player, 'You are now in %s mode' % self.player.player_settings.game_setting_mode) self._send_game_mode_data()