Exemplo n.º 1
0
 def encode(self, out_packet: Packet):
     out_packet.encode_short(self._charisma)
     out_packet.encode_short(self._insight)
     out_packet.encode_short(self._will)
     out_packet.encode_short(self._craft)
     out_packet.encode_short(self._sense)
     out_packet.encode_short(self._charm)
     out_packet.encode_byte(self._charm_by_cash_pr)
     out_packet.encode_ft(self._last_update_charm_by_cash_pr)
Exemplo n.º 2
0
    def check_password_result(success: bool, login_type: LoginType,
                              user: User) -> Packet:

        send_packet = Packet(opcode=OutPacket.CHECK_PASSWORD_RESULT)

        if success:
            send_packet.encode_byte(LoginType.Success.value)
            send_packet.encode_byte(0)
            send_packet.encode_int(0)
            send_packet.encode_string(user.name)
            send_packet.encode_int(user.user_id)
            send_packet.encode_byte(user.gender)
            send_packet.encode_byte(user.msg2)
            send_packet.encode_int(user.acc_type.value)
            send_packet.encode_int(user.age)

            has_censored = user.has_censored_nx_login_id

            send_packet.encode_byte(not has_censored)
            if has_censored:
                send_packet.encode_string(user.censored_nx_login_id)

            send_packet.encode_string(user.name)
            send_packet.encode_byte(user.p_block_reason)
            send_packet.encode_byte(0)  # unknown
            send_packet.encode_long(user.chat_unblock_date)
            send_packet.encode_long(user.chat_unblock_date)
            send_packet.encode_int(user.character_slots + 3)
            job_constants.encode(send_packet)
            send_packet.encode_byte(user.grade_code)
            send_packet.encode_int(-1)  # Enable Star Planet
            send_packet.encode_byte(0)  # Unknown
            send_packet.encode_byte(0)  # Unknown
            send_packet.encode_ft(user.creation_date)
        elif login_type == LoginType.Blocked:
            send_packet.encode_byte(login_type.value)
            send_packet.encode_byte(0)
            send_packet.encode_int(0)
            send_packet.encode_byte(0)
            send_packet.encode_ft(None)  # FileTime is not handled atm
        else:
            send_packet.encode_byte(login_type.value)
            send_packet.encode_byte(0)
            send_packet.encode_int(0)

        return send_packet
Exemplo n.º 3
0
    def select_world_result(user: User, account: Account, success_code: int,
                            special_server: str,
                            burning_event_block: bool) -> Packet:
        """
        The packet that is sent to client when they Select a World (scania, etc)
        Parameters
        ----------
        user: User
        account: Account
        success_code: int
        special_server: string
        burning_event_block: bool

        Returns: Packet
        -------

        """
        send_packet = Packet(opcode=OutPacket.SELECT_WORLD_RESULT)

        send_packet.encode_byte(success_code)
        send_packet.encode_string(special_server)
        send_packet.encode_int(14)  # trunk/storage slot count
        send_packet.encode_byte(burning_event_block)

        reserved = 0
        send_packet.encode_int(reserved)  # Reserved size
        send_packet.encode_ft(FileTime(FileTimeType.ZERO_TIME))

        for i in range(reserved):
            # FileTime
            send_packet.encode_int(0)
            # ft.encode()

        is_edited = False
        send_packet.encode_byte(is_edited)

        chars = account.characters
        chars.sort(key=lambda x: x.chr_id)  # Sort by character ID
        char_size = len(chars)

        send_packet.encode_int(char_size)

        for char in chars:
            send_packet.encode_int(char.chr_id)

        send_packet.encode_byte(char_size)

        for char in chars:
            char.cosmetic_info.encode_cosmetic(send_packet)
            send_packet.encode_byte(False)  # Family Stuff
            has_ranking = char.ranking is not None and not job_constants.is_gm_job(
                char.job_id)
            send_packet.encode_byte(False)
            if has_ranking:
                char.ranking.encode(send_packet)  # TODO: Rankings encode

        send_packet.encode_byte(user.get_pic_status().value)  # bLoginOpt
        send_packet.encode_byte(False)  # bQuerySSNOnCreateNewCharacter
        send_packet.encode_int(user.character_slots)
        send_packet.encode_int(0)
        send_packet.encode_int(-1)  # nEventNewCharJob
        send_packet.encode_ft(FileTime(FileTimeType.ZERO_TIME))

        send_packet.encode_byte(0)  # RenameCount
        send_packet.encode_byte(0)

        return send_packet
Exemplo n.º 4
0
    def encode(self, out_packet: Packet):
        out_packet.encode_int(self.chr_id)
        out_packet.encode_int(self.chr_id_for_log)
        out_packet.encode_int(self.world_id_for_log)
        out_packet.encode_fixed_string(self.name, 13)
        out_packet.encode_byte(self.gender)
        out_packet.encode_byte(self.skin)
        out_packet.encode_int(self.face)
        out_packet.encode_int(self.hair)
        out_packet.encode_byte(self.mix_base_hair_color)
        out_packet.encode_byte(self.mix_add_hair_color)
        out_packet.encode_byte(self.mix_hair_base_prob)
        out_packet.encode_byte(self.level)
        out_packet.encode_short(self.job)
        out_packet.encode_short(self.strength)
        out_packet.encode_short(self.dex)
        out_packet.encode_short(self.inte)
        out_packet.encode_short(self.luk)
        out_packet.encode_int(self.hp)
        out_packet.encode_int(self.max_hp)
        out_packet.encode_int(self.mp)
        out_packet.encode_int(self.max_hp)
        out_packet.encode_short(self.ap)

        if is_extend_sp_job(self.job):
            self.extend_sp.encode(out_packet)
        else:
            out_packet.encode_short(self.sp)

        out_packet.encode_long(int(self.exp))
        out_packet.encode_int(self.pop)
        out_packet.encode_int(self.wp)
        out_packet.encode_int(int(self.pos_map))
        out_packet.encode_int(self.gach_exp)
        out_packet.encode_byte(self.portal)
        out_packet.encode_int(0)  # TODO: Figure out
        out_packet.encode_short(self.sub_job)

        job_id = self.job

        if is_demon(job_id) or is_xenon(job_id) or is_beast_tamer(job_id):
            out_packet.encode_int(self.def_face_acc)

        out_packet.encode_byte(self.fatigue)
        out_packet.encode_int(self.last_fatigue_update_time)
        out_packet.encode_int(self.charisma_exp)
        out_packet.encode_int(self.insight_exp)
        out_packet.encode_int(self.will_exp)
        out_packet.encode_int(self.craft_exp)
        out_packet.encode_int(self.sense_exp)
        out_packet.encode_int(self.charm_exp)

        self.non_combat_stat_day_limit.encode(out_packet)

        out_packet.encode_int(self.pvp_exp)
        out_packet.encode_byte(self.pvp_grade)
        out_packet.encode_int(self.pvp_point)
        out_packet.encode_byte(2)

        out_packet.encode_byte(self.pvp_mode_type)
        out_packet.encode_int(self.event_point)
        out_packet.encode_byte(self.alba_activity_id)
        out_packet.encode_ft(FileTime(
            FileTimeType.ZERO_TIME))  # self.alba_start_time
        out_packet.encode_int(self.alba_duration)
        out_packet.encode_byte(self.alba_special_reward)

        self.character_card.encode(out_packet)

        out_packet.encode_ft(FileTime(
            FileTimeType.ZERO_TIME))  # self.last_logout
        out_packet.encode_byte(self.burning)