Skip to content

pub

Data structures generated from the eo-protocol XML specification.

Warning
  • This subpackage should not be directly imported.
  • Instead, import eolib.protocol.pub (or the top-level eolib).

SkillType

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/skill_type.py
 9
10
11
12
class SkillType(IntEnum, metaclass=ProtocolEnumMeta):
    Heal = 0
    Attack = 1
    Bard = 2

Heal = 0 class-attribute instance-attribute

Attack = 1 class-attribute instance-attribute

Bard = 2 class-attribute instance-attribute

SkillTargetType

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/skill_target_type.py
 9
10
11
12
13
class SkillTargetType(IntEnum, metaclass=ProtocolEnumMeta):
    Normal = 0
    Self = 1
    Reserved2 = 2
    Group = 3

Normal = 0 class-attribute instance-attribute

Self = 1 class-attribute instance-attribute

Reserved2 = 2 class-attribute instance-attribute

Group = 3 class-attribute instance-attribute

SkillTargetRestrict

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/skill_target_restrict.py
 9
10
11
12
class SkillTargetRestrict(IntEnum, metaclass=ProtocolEnumMeta):
    Npc = 0
    Friendly = 1
    Opponent = 2

Npc = 0 class-attribute instance-attribute

Friendly = 1 class-attribute instance-attribute

Opponent = 2 class-attribute instance-attribute

SkillNature

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/skill_nature.py
 9
10
11
class SkillNature(IntEnum, metaclass=ProtocolEnumMeta):
    Spell = 0
    Skill = 1

Spell = 0 class-attribute instance-attribute

Skill = 1 class-attribute instance-attribute

EsfRecord

Record of Skill data in an Endless Skill File

Source code in src/eolib/protocol/_generated/pub/esf_record.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
class EsfRecord:
    """
    Record of Skill data in an Endless Skill File
    """
    _byte_size: int = 0
    _name_length: int
    _chant_length: int
    _name: str
    _chant: str
    _icon_id: int
    _graphic_id: int
    _tp_cost: int
    _sp_cost: int
    _cast_time: int
    _nature: SkillNature
    _type: SkillType
    _element: Element
    _element_power: int
    _target_restrict: SkillTargetRestrict
    _target_type: SkillTargetType
    _target_time: int
    _max_skill_level: int
    _min_damage: int
    _max_damage: int
    _accuracy: int
    _evade: int
    _armor: int
    _return_damage: int
    _hp_heal: int
    _tp_heal: int
    _sp_heal: int
    _str: int
    _intl: int
    _wis: int
    _agi: int
    _con: int
    _cha: int

    def __init__(self, *, name: str, chant: str, icon_id: int, graphic_id: int, tp_cost: int, sp_cost: int, cast_time: int, nature: SkillNature, type: SkillType, element: Element, element_power: int, target_restrict: SkillTargetRestrict, target_type: SkillTargetType, target_time: int, max_skill_level: int, min_damage: int, max_damage: int, accuracy: int, evade: int, armor: int, return_damage: int, hp_heal: int, tp_heal: int, sp_heal: int, str: int, intl: int, wis: int, agi: int, con: int, cha: int):
        """
        Create a new instance of EsfRecord.

        Args:
            name (str): (Length must be 252 or less.)
            chant (str): (Length must be 252 or less.)
            icon_id (int): (Value range is 0-64008.)
            graphic_id (int): (Value range is 0-64008.)
            tp_cost (int): (Value range is 0-64008.)
            sp_cost (int): (Value range is 0-64008.)
            cast_time (int): (Value range is 0-252.)
            nature (SkillNature): 
            type (SkillType): 
            element (Element): 
            element_power (int): (Value range is 0-64008.)
            target_restrict (SkillTargetRestrict): 
            target_type (SkillTargetType): 
            target_time (int): (Value range is 0-252.)
            max_skill_level (int): (Value range is 0-64008.)
            min_damage (int): (Value range is 0-64008.)
            max_damage (int): (Value range is 0-64008.)
            accuracy (int): (Value range is 0-64008.)
            evade (int): (Value range is 0-64008.)
            armor (int): (Value range is 0-64008.)
            return_damage (int): (Value range is 0-252.)
            hp_heal (int): (Value range is 0-64008.)
            tp_heal (int): (Value range is 0-64008.)
            sp_heal (int): (Value range is 0-252.)
            str (int): (Value range is 0-64008.)
            intl (int): (Value range is 0-64008.)
            wis (int): (Value range is 0-64008.)
            agi (int): (Value range is 0-64008.)
            con (int): (Value range is 0-64008.)
            cha (int): (Value range is 0-64008.)
        """
        self._name = name
        self._name_length = len(self._name)
        self._chant = chant
        self._chant_length = len(self._chant)
        self._icon_id = icon_id
        self._graphic_id = graphic_id
        self._tp_cost = tp_cost
        self._sp_cost = sp_cost
        self._cast_time = cast_time
        self._nature = nature
        self._type = type
        self._element = element
        self._element_power = element_power
        self._target_restrict = target_restrict
        self._target_type = target_type
        self._target_time = target_time
        self._max_skill_level = max_skill_level
        self._min_damage = min_damage
        self._max_damage = max_damage
        self._accuracy = accuracy
        self._evade = evade
        self._armor = armor
        self._return_damage = return_damage
        self._hp_heal = hp_heal
        self._tp_heal = tp_heal
        self._sp_heal = sp_heal
        self._str = str
        self._intl = intl
        self._wis = wis
        self._agi = agi
        self._con = con
        self._cha = cha

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def name(self) -> str:
        return self._name

    @property
    def chant(self) -> str:
        return self._chant

    @property
    def icon_id(self) -> int:
        return self._icon_id

    @property
    def graphic_id(self) -> int:
        return self._graphic_id

    @property
    def tp_cost(self) -> int:
        return self._tp_cost

    @property
    def sp_cost(self) -> int:
        return self._sp_cost

    @property
    def cast_time(self) -> int:
        return self._cast_time

    @property
    def nature(self) -> SkillNature:
        return self._nature

    @property
    def type(self) -> SkillType:
        return self._type

    @property
    def element(self) -> Element:
        return self._element

    @property
    def element_power(self) -> int:
        return self._element_power

    @property
    def target_restrict(self) -> SkillTargetRestrict:
        return self._target_restrict

    @property
    def target_type(self) -> SkillTargetType:
        return self._target_type

    @property
    def target_time(self) -> int:
        return self._target_time

    @property
    def max_skill_level(self) -> int:
        return self._max_skill_level

    @property
    def min_damage(self) -> int:
        return self._min_damage

    @property
    def max_damage(self) -> int:
        return self._max_damage

    @property
    def accuracy(self) -> int:
        return self._accuracy

    @property
    def evade(self) -> int:
        return self._evade

    @property
    def armor(self) -> int:
        return self._armor

    @property
    def return_damage(self) -> int:
        return self._return_damage

    @property
    def hp_heal(self) -> int:
        return self._hp_heal

    @property
    def tp_heal(self) -> int:
        return self._tp_heal

    @property
    def sp_heal(self) -> int:
        return self._sp_heal

    @property
    def str(self) -> int:
        return self._str

    @property
    def intl(self) -> int:
        return self._intl

    @property
    def wis(self) -> int:
        return self._wis

    @property
    def agi(self) -> int:
        return self._agi

    @property
    def con(self) -> int:
        return self._con

    @property
    def cha(self) -> int:
        return self._cha

    @staticmethod
    def serialize(writer: EoWriter, data: "EsfRecord") -> None:
        """
        Serializes an instance of `EsfRecord` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (EsfRecord): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            if data._name_length is None:
                raise SerializationError("name_length must be provided.")
            writer.add_char(data._name_length)
            if data._chant_length is None:
                raise SerializationError("chant_length must be provided.")
            writer.add_char(data._chant_length)
            if data._name is None:
                raise SerializationError("name must be provided.")
            if len(data._name) > 252:
                raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
            writer.add_fixed_string(data._name, data._name_length, False)
            if data._chant is None:
                raise SerializationError("chant must be provided.")
            if len(data._chant) > 252:
                raise SerializationError(f"Expected length of chant to be 252 or less, got {len(data._chant)}.")
            writer.add_fixed_string(data._chant, data._chant_length, False)
            if data._icon_id is None:
                raise SerializationError("icon_id must be provided.")
            writer.add_short(data._icon_id)
            if data._graphic_id is None:
                raise SerializationError("graphic_id must be provided.")
            writer.add_short(data._graphic_id)
            if data._tp_cost is None:
                raise SerializationError("tp_cost must be provided.")
            writer.add_short(data._tp_cost)
            if data._sp_cost is None:
                raise SerializationError("sp_cost must be provided.")
            writer.add_short(data._sp_cost)
            if data._cast_time is None:
                raise SerializationError("cast_time must be provided.")
            writer.add_char(data._cast_time)
            if data._nature is None:
                raise SerializationError("nature must be provided.")
            writer.add_char(int(data._nature))
            writer.add_char(1)
            if data._type is None:
                raise SerializationError("type must be provided.")
            writer.add_three(int(data._type))
            if data._element is None:
                raise SerializationError("element must be provided.")
            writer.add_char(int(data._element))
            if data._element_power is None:
                raise SerializationError("element_power must be provided.")
            writer.add_short(data._element_power)
            if data._target_restrict is None:
                raise SerializationError("target_restrict must be provided.")
            writer.add_char(int(data._target_restrict))
            if data._target_type is None:
                raise SerializationError("target_type must be provided.")
            writer.add_char(int(data._target_type))
            if data._target_time is None:
                raise SerializationError("target_time must be provided.")
            writer.add_char(data._target_time)
            writer.add_char(0)
            if data._max_skill_level is None:
                raise SerializationError("max_skill_level must be provided.")
            writer.add_short(data._max_skill_level)
            if data._min_damage is None:
                raise SerializationError("min_damage must be provided.")
            writer.add_short(data._min_damage)
            if data._max_damage is None:
                raise SerializationError("max_damage must be provided.")
            writer.add_short(data._max_damage)
            if data._accuracy is None:
                raise SerializationError("accuracy must be provided.")
            writer.add_short(data._accuracy)
            if data._evade is None:
                raise SerializationError("evade must be provided.")
            writer.add_short(data._evade)
            if data._armor is None:
                raise SerializationError("armor must be provided.")
            writer.add_short(data._armor)
            if data._return_damage is None:
                raise SerializationError("return_damage must be provided.")
            writer.add_char(data._return_damage)
            if data._hp_heal is None:
                raise SerializationError("hp_heal must be provided.")
            writer.add_short(data._hp_heal)
            if data._tp_heal is None:
                raise SerializationError("tp_heal must be provided.")
            writer.add_short(data._tp_heal)
            if data._sp_heal is None:
                raise SerializationError("sp_heal must be provided.")
            writer.add_char(data._sp_heal)
            if data._str is None:
                raise SerializationError("str must be provided.")
            writer.add_short(data._str)
            if data._intl is None:
                raise SerializationError("intl must be provided.")
            writer.add_short(data._intl)
            if data._wis is None:
                raise SerializationError("wis must be provided.")
            writer.add_short(data._wis)
            if data._agi is None:
                raise SerializationError("agi must be provided.")
            writer.add_short(data._agi)
            if data._con is None:
                raise SerializationError("con must be provided.")
            writer.add_short(data._con)
            if data._cha is None:
                raise SerializationError("cha must be provided.")
            writer.add_short(data._cha)
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "EsfRecord":
        """
        Deserializes an instance of `EsfRecord` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            EsfRecord: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            name_length = reader.get_char()
            chant_length = reader.get_char()
            name = reader.get_fixed_string(name_length, False)
            chant = reader.get_fixed_string(chant_length, False)
            icon_id = reader.get_short()
            graphic_id = reader.get_short()
            tp_cost = reader.get_short()
            sp_cost = reader.get_short()
            cast_time = reader.get_char()
            nature = SkillNature(reader.get_char())
            reader.get_char()
            type = SkillType(reader.get_three())
            element = Element(reader.get_char())
            element_power = reader.get_short()
            target_restrict = SkillTargetRestrict(reader.get_char())
            target_type = SkillTargetType(reader.get_char())
            target_time = reader.get_char()
            reader.get_char()
            max_skill_level = reader.get_short()
            min_damage = reader.get_short()
            max_damage = reader.get_short()
            accuracy = reader.get_short()
            evade = reader.get_short()
            armor = reader.get_short()
            return_damage = reader.get_char()
            hp_heal = reader.get_short()
            tp_heal = reader.get_short()
            sp_heal = reader.get_char()
            str = reader.get_short()
            intl = reader.get_short()
            wis = reader.get_short()
            agi = reader.get_short()
            con = reader.get_short()
            cha = reader.get_short()
            result = EsfRecord(name=name, chant=chant, icon_id=icon_id, graphic_id=graphic_id, tp_cost=tp_cost, sp_cost=sp_cost, cast_time=cast_time, nature=nature, type=type, element=element, element_power=element_power, target_restrict=target_restrict, target_type=target_type, target_time=target_time, max_skill_level=max_skill_level, min_damage=min_damage, max_damage=max_damage, accuracy=accuracy, evade=evade, armor=armor, return_damage=return_damage, hp_heal=hp_heal, tp_heal=tp_heal, sp_heal=sp_heal, str=str, intl=intl, wis=wis, agi=agi, con=con, cha=cha)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"EsfRecord(byte_size={repr(self._byte_size)}, name={repr(self._name)}, chant={repr(self._chant)}, icon_id={repr(self._icon_id)}, graphic_id={repr(self._graphic_id)}, tp_cost={repr(self._tp_cost)}, sp_cost={repr(self._sp_cost)}, cast_time={repr(self._cast_time)}, nature={repr(self._nature)}, type={repr(self._type)}, element={repr(self._element)}, element_power={repr(self._element_power)}, target_restrict={repr(self._target_restrict)}, target_type={repr(self._target_type)}, target_time={repr(self._target_time)}, max_skill_level={repr(self._max_skill_level)}, min_damage={repr(self._min_damage)}, max_damage={repr(self._max_damage)}, accuracy={repr(self._accuracy)}, evade={repr(self._evade)}, armor={repr(self._armor)}, return_damage={repr(self._return_damage)}, hp_heal={repr(self._hp_heal)}, tp_heal={repr(self._tp_heal)}, sp_heal={repr(self._sp_heal)}, str={repr(self._str)}, intl={repr(self._intl)}, wis={repr(self._wis)}, agi={repr(self._agi)}, con={repr(self._con)}, cha={repr(self._cha)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

name: str property

chant: str property

icon_id: int property

graphic_id: int property

tp_cost: int property

sp_cost: int property

cast_time: int property

nature: SkillNature property

type: SkillType property

element: Element property

element_power: int property

target_restrict: SkillTargetRestrict property

target_type: SkillTargetType property

target_time: int property

max_skill_level: int property

min_damage: int property

max_damage: int property

accuracy: int property

evade: int property

armor: int property

return_damage: int property

hp_heal: int property

tp_heal: int property

sp_heal: int property

str: int property

intl: int property

wis: int property

agi: int property

con: int property

cha: int property

__init__(*, name, chant, icon_id, graphic_id, tp_cost, sp_cost, cast_time, nature, type, element, element_power, target_restrict, target_type, target_time, max_skill_level, min_damage, max_damage, accuracy, evade, armor, return_damage, hp_heal, tp_heal, sp_heal, str, intl, wis, agi, con, cha)

Create a new instance of EsfRecord.

Parameters:

Name Type Description Default
name str

(Length must be 252 or less.)

required
chant str

(Length must be 252 or less.)

required
icon_id int

(Value range is 0-64008.)

required
graphic_id int

(Value range is 0-64008.)

required
tp_cost int

(Value range is 0-64008.)

required
sp_cost int

(Value range is 0-64008.)

required
cast_time int

(Value range is 0-252.)

required
nature SkillNature
required
type SkillType
required
element Element
required
element_power int

(Value range is 0-64008.)

required
target_restrict SkillTargetRestrict
required
target_type SkillTargetType
required
target_time int

(Value range is 0-252.)

required
max_skill_level int

(Value range is 0-64008.)

required
min_damage int

(Value range is 0-64008.)

required
max_damage int

(Value range is 0-64008.)

required
accuracy int

(Value range is 0-64008.)

required
evade int

(Value range is 0-64008.)

required
armor int

(Value range is 0-64008.)

required
return_damage int

(Value range is 0-252.)

required
hp_heal int

(Value range is 0-64008.)

required
tp_heal int

(Value range is 0-64008.)

required
sp_heal int

(Value range is 0-252.)

required
str int

(Value range is 0-64008.)

required
intl int

(Value range is 0-64008.)

required
wis int

(Value range is 0-64008.)

required
agi int

(Value range is 0-64008.)

required
con int

(Value range is 0-64008.)

required
cha int

(Value range is 0-64008.)

required
Source code in src/eolib/protocol/_generated/pub/esf_record.py
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def __init__(self, *, name: str, chant: str, icon_id: int, graphic_id: int, tp_cost: int, sp_cost: int, cast_time: int, nature: SkillNature, type: SkillType, element: Element, element_power: int, target_restrict: SkillTargetRestrict, target_type: SkillTargetType, target_time: int, max_skill_level: int, min_damage: int, max_damage: int, accuracy: int, evade: int, armor: int, return_damage: int, hp_heal: int, tp_heal: int, sp_heal: int, str: int, intl: int, wis: int, agi: int, con: int, cha: int):
    """
    Create a new instance of EsfRecord.

    Args:
        name (str): (Length must be 252 or less.)
        chant (str): (Length must be 252 or less.)
        icon_id (int): (Value range is 0-64008.)
        graphic_id (int): (Value range is 0-64008.)
        tp_cost (int): (Value range is 0-64008.)
        sp_cost (int): (Value range is 0-64008.)
        cast_time (int): (Value range is 0-252.)
        nature (SkillNature): 
        type (SkillType): 
        element (Element): 
        element_power (int): (Value range is 0-64008.)
        target_restrict (SkillTargetRestrict): 
        target_type (SkillTargetType): 
        target_time (int): (Value range is 0-252.)
        max_skill_level (int): (Value range is 0-64008.)
        min_damage (int): (Value range is 0-64008.)
        max_damage (int): (Value range is 0-64008.)
        accuracy (int): (Value range is 0-64008.)
        evade (int): (Value range is 0-64008.)
        armor (int): (Value range is 0-64008.)
        return_damage (int): (Value range is 0-252.)
        hp_heal (int): (Value range is 0-64008.)
        tp_heal (int): (Value range is 0-64008.)
        sp_heal (int): (Value range is 0-252.)
        str (int): (Value range is 0-64008.)
        intl (int): (Value range is 0-64008.)
        wis (int): (Value range is 0-64008.)
        agi (int): (Value range is 0-64008.)
        con (int): (Value range is 0-64008.)
        cha (int): (Value range is 0-64008.)
    """
    self._name = name
    self._name_length = len(self._name)
    self._chant = chant
    self._chant_length = len(self._chant)
    self._icon_id = icon_id
    self._graphic_id = graphic_id
    self._tp_cost = tp_cost
    self._sp_cost = sp_cost
    self._cast_time = cast_time
    self._nature = nature
    self._type = type
    self._element = element
    self._element_power = element_power
    self._target_restrict = target_restrict
    self._target_type = target_type
    self._target_time = target_time
    self._max_skill_level = max_skill_level
    self._min_damage = min_damage
    self._max_damage = max_damage
    self._accuracy = accuracy
    self._evade = evade
    self._armor = armor
    self._return_damage = return_damage
    self._hp_heal = hp_heal
    self._tp_heal = tp_heal
    self._sp_heal = sp_heal
    self._str = str
    self._intl = intl
    self._wis = wis
    self._agi = agi
    self._con = con
    self._cha = cha

serialize(writer, data) staticmethod

Serializes an instance of EsfRecord to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data EsfRecord

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/esf_record.py
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
@staticmethod
def serialize(writer: EoWriter, data: "EsfRecord") -> None:
    """
    Serializes an instance of `EsfRecord` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (EsfRecord): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        if data._name_length is None:
            raise SerializationError("name_length must be provided.")
        writer.add_char(data._name_length)
        if data._chant_length is None:
            raise SerializationError("chant_length must be provided.")
        writer.add_char(data._chant_length)
        if data._name is None:
            raise SerializationError("name must be provided.")
        if len(data._name) > 252:
            raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
        writer.add_fixed_string(data._name, data._name_length, False)
        if data._chant is None:
            raise SerializationError("chant must be provided.")
        if len(data._chant) > 252:
            raise SerializationError(f"Expected length of chant to be 252 or less, got {len(data._chant)}.")
        writer.add_fixed_string(data._chant, data._chant_length, False)
        if data._icon_id is None:
            raise SerializationError("icon_id must be provided.")
        writer.add_short(data._icon_id)
        if data._graphic_id is None:
            raise SerializationError("graphic_id must be provided.")
        writer.add_short(data._graphic_id)
        if data._tp_cost is None:
            raise SerializationError("tp_cost must be provided.")
        writer.add_short(data._tp_cost)
        if data._sp_cost is None:
            raise SerializationError("sp_cost must be provided.")
        writer.add_short(data._sp_cost)
        if data._cast_time is None:
            raise SerializationError("cast_time must be provided.")
        writer.add_char(data._cast_time)
        if data._nature is None:
            raise SerializationError("nature must be provided.")
        writer.add_char(int(data._nature))
        writer.add_char(1)
        if data._type is None:
            raise SerializationError("type must be provided.")
        writer.add_three(int(data._type))
        if data._element is None:
            raise SerializationError("element must be provided.")
        writer.add_char(int(data._element))
        if data._element_power is None:
            raise SerializationError("element_power must be provided.")
        writer.add_short(data._element_power)
        if data._target_restrict is None:
            raise SerializationError("target_restrict must be provided.")
        writer.add_char(int(data._target_restrict))
        if data._target_type is None:
            raise SerializationError("target_type must be provided.")
        writer.add_char(int(data._target_type))
        if data._target_time is None:
            raise SerializationError("target_time must be provided.")
        writer.add_char(data._target_time)
        writer.add_char(0)
        if data._max_skill_level is None:
            raise SerializationError("max_skill_level must be provided.")
        writer.add_short(data._max_skill_level)
        if data._min_damage is None:
            raise SerializationError("min_damage must be provided.")
        writer.add_short(data._min_damage)
        if data._max_damage is None:
            raise SerializationError("max_damage must be provided.")
        writer.add_short(data._max_damage)
        if data._accuracy is None:
            raise SerializationError("accuracy must be provided.")
        writer.add_short(data._accuracy)
        if data._evade is None:
            raise SerializationError("evade must be provided.")
        writer.add_short(data._evade)
        if data._armor is None:
            raise SerializationError("armor must be provided.")
        writer.add_short(data._armor)
        if data._return_damage is None:
            raise SerializationError("return_damage must be provided.")
        writer.add_char(data._return_damage)
        if data._hp_heal is None:
            raise SerializationError("hp_heal must be provided.")
        writer.add_short(data._hp_heal)
        if data._tp_heal is None:
            raise SerializationError("tp_heal must be provided.")
        writer.add_short(data._tp_heal)
        if data._sp_heal is None:
            raise SerializationError("sp_heal must be provided.")
        writer.add_char(data._sp_heal)
        if data._str is None:
            raise SerializationError("str must be provided.")
        writer.add_short(data._str)
        if data._intl is None:
            raise SerializationError("intl must be provided.")
        writer.add_short(data._intl)
        if data._wis is None:
            raise SerializationError("wis must be provided.")
        writer.add_short(data._wis)
        if data._agi is None:
            raise SerializationError("agi must be provided.")
        writer.add_short(data._agi)
        if data._con is None:
            raise SerializationError("con must be provided.")
        writer.add_short(data._con)
        if data._cha is None:
            raise SerializationError("cha must be provided.")
        writer.add_short(data._cha)
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of EsfRecord from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
EsfRecord EsfRecord

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/esf_record.py
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
@staticmethod
def deserialize(reader: EoReader) -> "EsfRecord":
    """
    Deserializes an instance of `EsfRecord` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        EsfRecord: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        name_length = reader.get_char()
        chant_length = reader.get_char()
        name = reader.get_fixed_string(name_length, False)
        chant = reader.get_fixed_string(chant_length, False)
        icon_id = reader.get_short()
        graphic_id = reader.get_short()
        tp_cost = reader.get_short()
        sp_cost = reader.get_short()
        cast_time = reader.get_char()
        nature = SkillNature(reader.get_char())
        reader.get_char()
        type = SkillType(reader.get_three())
        element = Element(reader.get_char())
        element_power = reader.get_short()
        target_restrict = SkillTargetRestrict(reader.get_char())
        target_type = SkillTargetType(reader.get_char())
        target_time = reader.get_char()
        reader.get_char()
        max_skill_level = reader.get_short()
        min_damage = reader.get_short()
        max_damage = reader.get_short()
        accuracy = reader.get_short()
        evade = reader.get_short()
        armor = reader.get_short()
        return_damage = reader.get_char()
        hp_heal = reader.get_short()
        tp_heal = reader.get_short()
        sp_heal = reader.get_char()
        str = reader.get_short()
        intl = reader.get_short()
        wis = reader.get_short()
        agi = reader.get_short()
        con = reader.get_short()
        cha = reader.get_short()
        result = EsfRecord(name=name, chant=chant, icon_id=icon_id, graphic_id=graphic_id, tp_cost=tp_cost, sp_cost=sp_cost, cast_time=cast_time, nature=nature, type=type, element=element, element_power=element_power, target_restrict=target_restrict, target_type=target_type, target_time=target_time, max_skill_level=max_skill_level, min_damage=min_damage, max_damage=max_damage, accuracy=accuracy, evade=evade, armor=armor, return_damage=return_damage, hp_heal=hp_heal, tp_heal=tp_heal, sp_heal=sp_heal, str=str, intl=intl, wis=wis, agi=agi, con=con, cha=cha)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Esf

Endless Skill File

Source code in src/eolib/protocol/_generated/pub/esf.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
class Esf:
    """
    Endless Skill File
    """
    _byte_size: int = 0
    _rid: tuple[int, ...]
    _total_skills_count: int
    _version: int
    _skills: tuple[EsfRecord, ...]

    def __init__(self, *, rid: Iterable[int], total_skills_count: int, version: int, skills: Iterable[EsfRecord]):
        """
        Create a new instance of Esf.

        Args:
            rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
            total_skills_count (int): (Value range is 0-64008.)
            version (int): (Value range is 0-252.)
            skills (Iterable[EsfRecord]): 
        """
        self._rid = tuple(rid)
        self._total_skills_count = total_skills_count
        self._version = version
        self._skills = tuple(skills)

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def rid(self) -> tuple[int, ...]:
        return self._rid

    @property
    def total_skills_count(self) -> int:
        return self._total_skills_count

    @property
    def version(self) -> int:
        return self._version

    @property
    def skills(self) -> tuple[EsfRecord, ...]:
        return self._skills

    @staticmethod
    def serialize(writer: EoWriter, data: "Esf") -> None:
        """
        Serializes an instance of `Esf` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Esf): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            writer.add_fixed_string("ESF", 3, False)
            if data._rid is None:
                raise SerializationError("rid must be provided.")
            if len(data._rid) != 2:
                raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
            for i in range(2):
                writer.add_short(data._rid[i])
            if data._total_skills_count is None:
                raise SerializationError("total_skills_count must be provided.")
            writer.add_short(data._total_skills_count)
            if data._version is None:
                raise SerializationError("version must be provided.")
            writer.add_char(data._version)
            if data._skills is None:
                raise SerializationError("skills must be provided.")
            for i in range(len(data._skills)):
                EsfRecord.serialize(writer, data._skills[i])
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "Esf":
        """
        Deserializes an instance of `Esf` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Esf: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            rid = []
            for i in range(2):
                rid.append(reader.get_short())
            total_skills_count = reader.get_short()
            version = reader.get_char()
            skills = []
            while reader.remaining > 0:
                skills.append(EsfRecord.deserialize(reader))
            result = Esf(rid=rid, total_skills_count=total_skills_count, version=version, skills=skills)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Esf(byte_size={repr(self._byte_size)}, rid={repr(self._rid)}, total_skills_count={repr(self._total_skills_count)}, version={repr(self._version)}, skills={repr(self._skills)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

rid: tuple[int, ...] property

total_skills_count: int property

version: int property

skills: tuple[EsfRecord, ...] property

__init__(*, rid, total_skills_count, version, skills)

Create a new instance of Esf.

Parameters:

Name Type Description Default
rid Iterable[int]

(Length must be 2.) (Element value range is 0-64008.)

required
total_skills_count int

(Value range is 0-64008.)

required
version int

(Value range is 0-252.)

required
skills Iterable[EsfRecord]
required
Source code in src/eolib/protocol/_generated/pub/esf.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self, *, rid: Iterable[int], total_skills_count: int, version: int, skills: Iterable[EsfRecord]):
    """
    Create a new instance of Esf.

    Args:
        rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
        total_skills_count (int): (Value range is 0-64008.)
        version (int): (Value range is 0-252.)
        skills (Iterable[EsfRecord]): 
    """
    self._rid = tuple(rid)
    self._total_skills_count = total_skills_count
    self._version = version
    self._skills = tuple(skills)

serialize(writer, data) staticmethod

Serializes an instance of Esf to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Esf

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/esf.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@staticmethod
def serialize(writer: EoWriter, data: "Esf") -> None:
    """
    Serializes an instance of `Esf` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Esf): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        writer.add_fixed_string("ESF", 3, False)
        if data._rid is None:
            raise SerializationError("rid must be provided.")
        if len(data._rid) != 2:
            raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
        for i in range(2):
            writer.add_short(data._rid[i])
        if data._total_skills_count is None:
            raise SerializationError("total_skills_count must be provided.")
        writer.add_short(data._total_skills_count)
        if data._version is None:
            raise SerializationError("version must be provided.")
        writer.add_char(data._version)
        if data._skills is None:
            raise SerializationError("skills must be provided.")
        for i in range(len(data._skills)):
            EsfRecord.serialize(writer, data._skills[i])
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of Esf from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Esf 'Esf'

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/esf.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@staticmethod
def deserialize(reader: EoReader) -> "Esf":
    """
    Deserializes an instance of `Esf` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Esf: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        rid = []
        for i in range(2):
            rid.append(reader.get_short())
        total_skills_count = reader.get_short()
        version = reader.get_char()
        skills = []
        while reader.remaining > 0:
            skills.append(EsfRecord.deserialize(reader))
        result = Esf(rid=rid, total_skills_count=total_skills_count, version=version, skills=skills)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

NpcType

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/npc_type.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class NpcType(IntEnum, metaclass=ProtocolEnumMeta):
    Friendly = 0
    Passive = 1
    Aggressive = 2
    Reserved3 = 3
    Reserved4 = 4
    Reserved5 = 5
    Shop = 6
    Inn = 7
    Reserved8 = 8
    Bank = 9
    Barber = 10
    Guild = 11
    Priest = 12
    Lawyer = 13
    Trainer = 14
    Quest = 15

Friendly = 0 class-attribute instance-attribute

Passive = 1 class-attribute instance-attribute

Aggressive = 2 class-attribute instance-attribute

Reserved3 = 3 class-attribute instance-attribute

Reserved4 = 4 class-attribute instance-attribute

Reserved5 = 5 class-attribute instance-attribute

Shop = 6 class-attribute instance-attribute

Inn = 7 class-attribute instance-attribute

Reserved8 = 8 class-attribute instance-attribute

Bank = 9 class-attribute instance-attribute

Barber = 10 class-attribute instance-attribute

Guild = 11 class-attribute instance-attribute

Priest = 12 class-attribute instance-attribute

Lawyer = 13 class-attribute instance-attribute

Trainer = 14 class-attribute instance-attribute

Quest = 15 class-attribute instance-attribute

EnfRecord

Record of NPC data in an Endless NPC File

Source code in src/eolib/protocol/_generated/pub/enf_record.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
class EnfRecord:
    """
    Record of NPC data in an Endless NPC File
    """
    _byte_size: int = 0
    _name_length: int
    _name: str
    _graphic_id: int
    _race: int
    _boss: bool
    _child: bool
    _type: NpcType
    _behavior_id: int
    _hp: int
    _tp: int
    _min_damage: int
    _max_damage: int
    _accuracy: int
    _evade: int
    _armor: int
    _return_damage: int
    _element: Element
    _element_damage: int
    _element_weakness: Element
    _element_weakness_damage: int
    _level: int
    _experience: int

    def __init__(self, *, name: str, graphic_id: int, race: int, boss: bool, child: bool, type: NpcType, behavior_id: int, hp: int, tp: int, min_damage: int, max_damage: int, accuracy: int, evade: int, armor: int, return_damage: int, element: Element, element_damage: int, element_weakness: Element, element_weakness_damage: int, level: int, experience: int):
        """
        Create a new instance of EnfRecord.

        Args:
            name (str): (Length must be 252 or less.)
            graphic_id (int): (Value range is 0-64008.)
            race (int): (Value range is 0-252.)
            boss (bool): 
            child (bool): 
            type (NpcType): 
            behavior_id (int): (Value range is 0-64008.)
            hp (int): (Value range is 0-16194276.)
            tp (int): (Value range is 0-64008.)
            min_damage (int): (Value range is 0-64008.)
            max_damage (int): (Value range is 0-64008.)
            accuracy (int): (Value range is 0-64008.)
            evade (int): (Value range is 0-64008.)
            armor (int): (Value range is 0-64008.)
            return_damage (int): (Value range is 0-252.)
            element (Element): 
            element_damage (int): (Value range is 0-64008.)
            element_weakness (Element): 
            element_weakness_damage (int): (Value range is 0-64008.)
            level (int): (Value range is 0-252.)
            experience (int): (Value range is 0-16194276.)
        """
        self._name = name
        self._name_length = len(self._name)
        self._graphic_id = graphic_id
        self._race = race
        self._boss = boss
        self._child = child
        self._type = type
        self._behavior_id = behavior_id
        self._hp = hp
        self._tp = tp
        self._min_damage = min_damage
        self._max_damage = max_damage
        self._accuracy = accuracy
        self._evade = evade
        self._armor = armor
        self._return_damage = return_damage
        self._element = element
        self._element_damage = element_damage
        self._element_weakness = element_weakness
        self._element_weakness_damage = element_weakness_damage
        self._level = level
        self._experience = experience

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def name(self) -> str:
        return self._name

    @property
    def graphic_id(self) -> int:
        return self._graphic_id

    @property
    def race(self) -> int:
        return self._race

    @property
    def boss(self) -> bool:
        return self._boss

    @property
    def child(self) -> bool:
        return self._child

    @property
    def type(self) -> NpcType:
        return self._type

    @property
    def behavior_id(self) -> int:
        return self._behavior_id

    @property
    def hp(self) -> int:
        return self._hp

    @property
    def tp(self) -> int:
        return self._tp

    @property
    def min_damage(self) -> int:
        return self._min_damage

    @property
    def max_damage(self) -> int:
        return self._max_damage

    @property
    def accuracy(self) -> int:
        return self._accuracy

    @property
    def evade(self) -> int:
        return self._evade

    @property
    def armor(self) -> int:
        return self._armor

    @property
    def return_damage(self) -> int:
        return self._return_damage

    @property
    def element(self) -> Element:
        return self._element

    @property
    def element_damage(self) -> int:
        return self._element_damage

    @property
    def element_weakness(self) -> Element:
        return self._element_weakness

    @property
    def element_weakness_damage(self) -> int:
        return self._element_weakness_damage

    @property
    def level(self) -> int:
        return self._level

    @property
    def experience(self) -> int:
        return self._experience

    @staticmethod
    def serialize(writer: EoWriter, data: "EnfRecord") -> None:
        """
        Serializes an instance of `EnfRecord` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (EnfRecord): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            if data._name_length is None:
                raise SerializationError("name_length must be provided.")
            writer.add_char(data._name_length)
            if data._name is None:
                raise SerializationError("name must be provided.")
            if len(data._name) > 252:
                raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
            writer.add_fixed_string(data._name, data._name_length, False)
            if data._graphic_id is None:
                raise SerializationError("graphic_id must be provided.")
            writer.add_short(data._graphic_id)
            if data._race is None:
                raise SerializationError("race must be provided.")
            writer.add_char(data._race)
            if data._boss is None:
                raise SerializationError("boss must be provided.")
            writer.add_short(1 if data._boss else 0)
            if data._child is None:
                raise SerializationError("child must be provided.")
            writer.add_short(1 if data._child else 0)
            if data._type is None:
                raise SerializationError("type must be provided.")
            writer.add_short(int(data._type))
            if data._behavior_id is None:
                raise SerializationError("behavior_id must be provided.")
            writer.add_short(data._behavior_id)
            if data._hp is None:
                raise SerializationError("hp must be provided.")
            writer.add_three(data._hp)
            if data._tp is None:
                raise SerializationError("tp must be provided.")
            writer.add_short(data._tp)
            if data._min_damage is None:
                raise SerializationError("min_damage must be provided.")
            writer.add_short(data._min_damage)
            if data._max_damage is None:
                raise SerializationError("max_damage must be provided.")
            writer.add_short(data._max_damage)
            if data._accuracy is None:
                raise SerializationError("accuracy must be provided.")
            writer.add_short(data._accuracy)
            if data._evade is None:
                raise SerializationError("evade must be provided.")
            writer.add_short(data._evade)
            if data._armor is None:
                raise SerializationError("armor must be provided.")
            writer.add_short(data._armor)
            if data._return_damage is None:
                raise SerializationError("return_damage must be provided.")
            writer.add_char(data._return_damage)
            if data._element is None:
                raise SerializationError("element must be provided.")
            writer.add_short(int(data._element))
            if data._element_damage is None:
                raise SerializationError("element_damage must be provided.")
            writer.add_short(data._element_damage)
            if data._element_weakness is None:
                raise SerializationError("element_weakness must be provided.")
            writer.add_short(int(data._element_weakness))
            if data._element_weakness_damage is None:
                raise SerializationError("element_weakness_damage must be provided.")
            writer.add_short(data._element_weakness_damage)
            if data._level is None:
                raise SerializationError("level must be provided.")
            writer.add_char(data._level)
            if data._experience is None:
                raise SerializationError("experience must be provided.")
            writer.add_three(data._experience)
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "EnfRecord":
        """
        Deserializes an instance of `EnfRecord` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            EnfRecord: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            name_length = reader.get_char()
            name = reader.get_fixed_string(name_length, False)
            graphic_id = reader.get_short()
            race = reader.get_char()
            boss = reader.get_short() != 0
            child = reader.get_short() != 0
            type = NpcType(reader.get_short())
            behavior_id = reader.get_short()
            hp = reader.get_three()
            tp = reader.get_short()
            min_damage = reader.get_short()
            max_damage = reader.get_short()
            accuracy = reader.get_short()
            evade = reader.get_short()
            armor = reader.get_short()
            return_damage = reader.get_char()
            element = Element(reader.get_short())
            element_damage = reader.get_short()
            element_weakness = Element(reader.get_short())
            element_weakness_damage = reader.get_short()
            level = reader.get_char()
            experience = reader.get_three()
            result = EnfRecord(name=name, graphic_id=graphic_id, race=race, boss=boss, child=child, type=type, behavior_id=behavior_id, hp=hp, tp=tp, min_damage=min_damage, max_damage=max_damage, accuracy=accuracy, evade=evade, armor=armor, return_damage=return_damage, element=element, element_damage=element_damage, element_weakness=element_weakness, element_weakness_damage=element_weakness_damage, level=level, experience=experience)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"EnfRecord(byte_size={repr(self._byte_size)}, name={repr(self._name)}, graphic_id={repr(self._graphic_id)}, race={repr(self._race)}, boss={repr(self._boss)}, child={repr(self._child)}, type={repr(self._type)}, behavior_id={repr(self._behavior_id)}, hp={repr(self._hp)}, tp={repr(self._tp)}, min_damage={repr(self._min_damage)}, max_damage={repr(self._max_damage)}, accuracy={repr(self._accuracy)}, evade={repr(self._evade)}, armor={repr(self._armor)}, return_damage={repr(self._return_damage)}, element={repr(self._element)}, element_damage={repr(self._element_damage)}, element_weakness={repr(self._element_weakness)}, element_weakness_damage={repr(self._element_weakness_damage)}, level={repr(self._level)}, experience={repr(self._experience)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

name: str property

graphic_id: int property

race: int property

boss: bool property

child: bool property

type: NpcType property

behavior_id: int property

hp: int property

tp: int property

min_damage: int property

max_damage: int property

accuracy: int property

evade: int property

armor: int property

return_damage: int property

element: Element property

element_damage: int property

element_weakness: Element property

element_weakness_damage: int property

level: int property

experience: int property

__init__(*, name, graphic_id, race, boss, child, type, behavior_id, hp, tp, min_damage, max_damage, accuracy, evade, armor, return_damage, element, element_damage, element_weakness, element_weakness_damage, level, experience)

Create a new instance of EnfRecord.

Parameters:

Name Type Description Default
name str

(Length must be 252 or less.)

required
graphic_id int

(Value range is 0-64008.)

required
race int

(Value range is 0-252.)

required
boss bool
required
child bool
required
type NpcType
required
behavior_id int

(Value range is 0-64008.)

required
hp int

(Value range is 0-16194276.)

required
tp int

(Value range is 0-64008.)

required
min_damage int

(Value range is 0-64008.)

required
max_damage int

(Value range is 0-64008.)

required
accuracy int

(Value range is 0-64008.)

required
evade int

(Value range is 0-64008.)

required
armor int

(Value range is 0-64008.)

required
return_damage int

(Value range is 0-252.)

required
element Element
required
element_damage int

(Value range is 0-64008.)

required
element_weakness Element
required
element_weakness_damage int

(Value range is 0-64008.)

required
level int

(Value range is 0-252.)

required
experience int

(Value range is 0-16194276.)

required
Source code in src/eolib/protocol/_generated/pub/enf_record.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def __init__(self, *, name: str, graphic_id: int, race: int, boss: bool, child: bool, type: NpcType, behavior_id: int, hp: int, tp: int, min_damage: int, max_damage: int, accuracy: int, evade: int, armor: int, return_damage: int, element: Element, element_damage: int, element_weakness: Element, element_weakness_damage: int, level: int, experience: int):
    """
    Create a new instance of EnfRecord.

    Args:
        name (str): (Length must be 252 or less.)
        graphic_id (int): (Value range is 0-64008.)
        race (int): (Value range is 0-252.)
        boss (bool): 
        child (bool): 
        type (NpcType): 
        behavior_id (int): (Value range is 0-64008.)
        hp (int): (Value range is 0-16194276.)
        tp (int): (Value range is 0-64008.)
        min_damage (int): (Value range is 0-64008.)
        max_damage (int): (Value range is 0-64008.)
        accuracy (int): (Value range is 0-64008.)
        evade (int): (Value range is 0-64008.)
        armor (int): (Value range is 0-64008.)
        return_damage (int): (Value range is 0-252.)
        element (Element): 
        element_damage (int): (Value range is 0-64008.)
        element_weakness (Element): 
        element_weakness_damage (int): (Value range is 0-64008.)
        level (int): (Value range is 0-252.)
        experience (int): (Value range is 0-16194276.)
    """
    self._name = name
    self._name_length = len(self._name)
    self._graphic_id = graphic_id
    self._race = race
    self._boss = boss
    self._child = child
    self._type = type
    self._behavior_id = behavior_id
    self._hp = hp
    self._tp = tp
    self._min_damage = min_damage
    self._max_damage = max_damage
    self._accuracy = accuracy
    self._evade = evade
    self._armor = armor
    self._return_damage = return_damage
    self._element = element
    self._element_damage = element_damage
    self._element_weakness = element_weakness
    self._element_weakness_damage = element_weakness_damage
    self._level = level
    self._experience = experience

serialize(writer, data) staticmethod

Serializes an instance of EnfRecord to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data EnfRecord

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/enf_record.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
@staticmethod
def serialize(writer: EoWriter, data: "EnfRecord") -> None:
    """
    Serializes an instance of `EnfRecord` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (EnfRecord): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        if data._name_length is None:
            raise SerializationError("name_length must be provided.")
        writer.add_char(data._name_length)
        if data._name is None:
            raise SerializationError("name must be provided.")
        if len(data._name) > 252:
            raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
        writer.add_fixed_string(data._name, data._name_length, False)
        if data._graphic_id is None:
            raise SerializationError("graphic_id must be provided.")
        writer.add_short(data._graphic_id)
        if data._race is None:
            raise SerializationError("race must be provided.")
        writer.add_char(data._race)
        if data._boss is None:
            raise SerializationError("boss must be provided.")
        writer.add_short(1 if data._boss else 0)
        if data._child is None:
            raise SerializationError("child must be provided.")
        writer.add_short(1 if data._child else 0)
        if data._type is None:
            raise SerializationError("type must be provided.")
        writer.add_short(int(data._type))
        if data._behavior_id is None:
            raise SerializationError("behavior_id must be provided.")
        writer.add_short(data._behavior_id)
        if data._hp is None:
            raise SerializationError("hp must be provided.")
        writer.add_three(data._hp)
        if data._tp is None:
            raise SerializationError("tp must be provided.")
        writer.add_short(data._tp)
        if data._min_damage is None:
            raise SerializationError("min_damage must be provided.")
        writer.add_short(data._min_damage)
        if data._max_damage is None:
            raise SerializationError("max_damage must be provided.")
        writer.add_short(data._max_damage)
        if data._accuracy is None:
            raise SerializationError("accuracy must be provided.")
        writer.add_short(data._accuracy)
        if data._evade is None:
            raise SerializationError("evade must be provided.")
        writer.add_short(data._evade)
        if data._armor is None:
            raise SerializationError("armor must be provided.")
        writer.add_short(data._armor)
        if data._return_damage is None:
            raise SerializationError("return_damage must be provided.")
        writer.add_char(data._return_damage)
        if data._element is None:
            raise SerializationError("element must be provided.")
        writer.add_short(int(data._element))
        if data._element_damage is None:
            raise SerializationError("element_damage must be provided.")
        writer.add_short(data._element_damage)
        if data._element_weakness is None:
            raise SerializationError("element_weakness must be provided.")
        writer.add_short(int(data._element_weakness))
        if data._element_weakness_damage is None:
            raise SerializationError("element_weakness_damage must be provided.")
        writer.add_short(data._element_weakness_damage)
        if data._level is None:
            raise SerializationError("level must be provided.")
        writer.add_char(data._level)
        if data._experience is None:
            raise SerializationError("experience must be provided.")
        writer.add_three(data._experience)
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of EnfRecord from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
EnfRecord EnfRecord

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/enf_record.py
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
@staticmethod
def deserialize(reader: EoReader) -> "EnfRecord":
    """
    Deserializes an instance of `EnfRecord` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        EnfRecord: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        name_length = reader.get_char()
        name = reader.get_fixed_string(name_length, False)
        graphic_id = reader.get_short()
        race = reader.get_char()
        boss = reader.get_short() != 0
        child = reader.get_short() != 0
        type = NpcType(reader.get_short())
        behavior_id = reader.get_short()
        hp = reader.get_three()
        tp = reader.get_short()
        min_damage = reader.get_short()
        max_damage = reader.get_short()
        accuracy = reader.get_short()
        evade = reader.get_short()
        armor = reader.get_short()
        return_damage = reader.get_char()
        element = Element(reader.get_short())
        element_damage = reader.get_short()
        element_weakness = Element(reader.get_short())
        element_weakness_damage = reader.get_short()
        level = reader.get_char()
        experience = reader.get_three()
        result = EnfRecord(name=name, graphic_id=graphic_id, race=race, boss=boss, child=child, type=type, behavior_id=behavior_id, hp=hp, tp=tp, min_damage=min_damage, max_damage=max_damage, accuracy=accuracy, evade=evade, armor=armor, return_damage=return_damage, element=element, element_damage=element_damage, element_weakness=element_weakness, element_weakness_damage=element_weakness_damage, level=level, experience=experience)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Enf

Endless NPC File

Source code in src/eolib/protocol/_generated/pub/enf.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
class Enf:
    """
    Endless NPC File
    """
    _byte_size: int = 0
    _rid: tuple[int, ...]
    _total_npcs_count: int
    _version: int
    _npcs: tuple[EnfRecord, ...]

    def __init__(self, *, rid: Iterable[int], total_npcs_count: int, version: int, npcs: Iterable[EnfRecord]):
        """
        Create a new instance of Enf.

        Args:
            rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
            total_npcs_count (int): (Value range is 0-64008.)
            version (int): (Value range is 0-252.)
            npcs (Iterable[EnfRecord]): 
        """
        self._rid = tuple(rid)
        self._total_npcs_count = total_npcs_count
        self._version = version
        self._npcs = tuple(npcs)

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def rid(self) -> tuple[int, ...]:
        return self._rid

    @property
    def total_npcs_count(self) -> int:
        return self._total_npcs_count

    @property
    def version(self) -> int:
        return self._version

    @property
    def npcs(self) -> tuple[EnfRecord, ...]:
        return self._npcs

    @staticmethod
    def serialize(writer: EoWriter, data: "Enf") -> None:
        """
        Serializes an instance of `Enf` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Enf): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            writer.add_fixed_string("ENF", 3, False)
            if data._rid is None:
                raise SerializationError("rid must be provided.")
            if len(data._rid) != 2:
                raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
            for i in range(2):
                writer.add_short(data._rid[i])
            if data._total_npcs_count is None:
                raise SerializationError("total_npcs_count must be provided.")
            writer.add_short(data._total_npcs_count)
            if data._version is None:
                raise SerializationError("version must be provided.")
            writer.add_char(data._version)
            if data._npcs is None:
                raise SerializationError("npcs must be provided.")
            for i in range(len(data._npcs)):
                EnfRecord.serialize(writer, data._npcs[i])
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "Enf":
        """
        Deserializes an instance of `Enf` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Enf: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            rid = []
            for i in range(2):
                rid.append(reader.get_short())
            total_npcs_count = reader.get_short()
            version = reader.get_char()
            npcs = []
            while reader.remaining > 0:
                npcs.append(EnfRecord.deserialize(reader))
            result = Enf(rid=rid, total_npcs_count=total_npcs_count, version=version, npcs=npcs)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Enf(byte_size={repr(self._byte_size)}, rid={repr(self._rid)}, total_npcs_count={repr(self._total_npcs_count)}, version={repr(self._version)}, npcs={repr(self._npcs)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

rid: tuple[int, ...] property

total_npcs_count: int property

version: int property

npcs: tuple[EnfRecord, ...] property

__init__(*, rid, total_npcs_count, version, npcs)

Create a new instance of Enf.

Parameters:

Name Type Description Default
rid Iterable[int]

(Length must be 2.) (Element value range is 0-64008.)

required
total_npcs_count int

(Value range is 0-64008.)

required
version int

(Value range is 0-252.)

required
npcs Iterable[EnfRecord]
required
Source code in src/eolib/protocol/_generated/pub/enf.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self, *, rid: Iterable[int], total_npcs_count: int, version: int, npcs: Iterable[EnfRecord]):
    """
    Create a new instance of Enf.

    Args:
        rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
        total_npcs_count (int): (Value range is 0-64008.)
        version (int): (Value range is 0-252.)
        npcs (Iterable[EnfRecord]): 
    """
    self._rid = tuple(rid)
    self._total_npcs_count = total_npcs_count
    self._version = version
    self._npcs = tuple(npcs)

serialize(writer, data) staticmethod

Serializes an instance of Enf to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Enf

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/enf.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@staticmethod
def serialize(writer: EoWriter, data: "Enf") -> None:
    """
    Serializes an instance of `Enf` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Enf): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        writer.add_fixed_string("ENF", 3, False)
        if data._rid is None:
            raise SerializationError("rid must be provided.")
        if len(data._rid) != 2:
            raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
        for i in range(2):
            writer.add_short(data._rid[i])
        if data._total_npcs_count is None:
            raise SerializationError("total_npcs_count must be provided.")
        writer.add_short(data._total_npcs_count)
        if data._version is None:
            raise SerializationError("version must be provided.")
        writer.add_char(data._version)
        if data._npcs is None:
            raise SerializationError("npcs must be provided.")
        for i in range(len(data._npcs)):
            EnfRecord.serialize(writer, data._npcs[i])
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of Enf from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Enf 'Enf'

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/enf.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@staticmethod
def deserialize(reader: EoReader) -> "Enf":
    """
    Deserializes an instance of `Enf` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Enf: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        rid = []
        for i in range(2):
            rid.append(reader.get_short())
        total_npcs_count = reader.get_short()
        version = reader.get_char()
        npcs = []
        while reader.remaining > 0:
            npcs.append(EnfRecord.deserialize(reader))
        result = Enf(rid=rid, total_npcs_count=total_npcs_count, version=version, npcs=npcs)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

ProtocolEnumMeta

Bases: EnumMeta

Source code in src/eolib/protocol/protocol_enum_meta.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
class ProtocolEnumMeta(EnumMeta):
    def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
        if names is not None:
            return super().__call__(
                value, names=names, module=module, qualname=qualname, type=type, start=start
            )
        try:
            return super().__call__(value, module=module, qualname=qualname, type=type, start=start)
        except ValueError:
            unrecognized = int.__new__(cls, value)
            unrecognized._name_ = f"Unrecognized({int(value)})"
            unrecognized._value_ = value
            return unrecognized

__call__(value, names=None, *, module=None, qualname=None, type=None, start=1)

Source code in src/eolib/protocol/protocol_enum_meta.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
    if names is not None:
        return super().__call__(
            value, names=names, module=module, qualname=qualname, type=type, start=start
        )
    try:
        return super().__call__(value, module=module, qualname=qualname, type=type, start=start)
    except ValueError:
        unrecognized = int.__new__(cls, value)
        unrecognized._name_ = f"Unrecognized({int(value)})"
        unrecognized._value_ = value
        return unrecognized

ItemType

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/item_type.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class ItemType(IntEnum, metaclass=ProtocolEnumMeta):
    General = 0
    Reserved1 = 1
    Currency = 2
    Heal = 3
    Teleport = 4
    Reserved5 = 5
    ExpReward = 6
    Reserved7 = 7
    Reserved8 = 8
    Key = 9
    Weapon = 10
    Shield = 11
    Armor = 12
    Hat = 13
    Boots = 14
    Gloves = 15
    Accessory = 16
    Belt = 17
    Necklace = 18
    Ring = 19
    Armlet = 20
    Bracer = 21
    Alcohol = 22
    EffectPotion = 23
    HairDye = 24
    CureCurse = 25
    Reserved26 = 26
    Reserved27 = 27
    Reserved28 = 28
    Reserved29 = 29

General = 0 class-attribute instance-attribute

Reserved1 = 1 class-attribute instance-attribute

Currency = 2 class-attribute instance-attribute

Heal = 3 class-attribute instance-attribute

Teleport = 4 class-attribute instance-attribute

Reserved5 = 5 class-attribute instance-attribute

ExpReward = 6 class-attribute instance-attribute

Reserved7 = 7 class-attribute instance-attribute

Reserved8 = 8 class-attribute instance-attribute

Key = 9 class-attribute instance-attribute

Weapon = 10 class-attribute instance-attribute

Shield = 11 class-attribute instance-attribute

Armor = 12 class-attribute instance-attribute

Hat = 13 class-attribute instance-attribute

Boots = 14 class-attribute instance-attribute

Gloves = 15 class-attribute instance-attribute

Accessory = 16 class-attribute instance-attribute

Belt = 17 class-attribute instance-attribute

Necklace = 18 class-attribute instance-attribute

Ring = 19 class-attribute instance-attribute

Armlet = 20 class-attribute instance-attribute

Bracer = 21 class-attribute instance-attribute

Alcohol = 22 class-attribute instance-attribute

EffectPotion = 23 class-attribute instance-attribute

HairDye = 24 class-attribute instance-attribute

CureCurse = 25 class-attribute instance-attribute

Reserved26 = 26 class-attribute instance-attribute

Reserved27 = 27 class-attribute instance-attribute

Reserved28 = 28 class-attribute instance-attribute

Reserved29 = 29 class-attribute instance-attribute

ItemSubtype

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/item_subtype.py
 9
10
11
12
13
14
class ItemSubtype(IntEnum, metaclass=ProtocolEnumMeta):
    None_ = 0
    Ranged = 1
    Arrows = 2
    Wings = 3
    Reserved4 = 4

None_ = 0 class-attribute instance-attribute

Ranged = 1 class-attribute instance-attribute

Arrows = 2 class-attribute instance-attribute

Wings = 3 class-attribute instance-attribute

Reserved4 = 4 class-attribute instance-attribute

ItemSpecial

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/item_special.py
 9
10
11
12
13
14
15
class ItemSpecial(IntEnum, metaclass=ProtocolEnumMeta):
    Normal = 0
    Rare = 1
    Legendary = 2
    Unique = 3
    Lore = 4
    Cursed = 5

Normal = 0 class-attribute instance-attribute

Rare = 1 class-attribute instance-attribute

Legendary = 2 class-attribute instance-attribute

Unique = 3 class-attribute instance-attribute

Lore = 4 class-attribute instance-attribute

Cursed = 5 class-attribute instance-attribute

ItemSize

Bases: IntEnum

Size of an item in the inventory

Source code in src/eolib/protocol/_generated/pub/item_size.py
 9
10
11
12
13
14
15
16
17
18
19
20
class ItemSize(IntEnum, metaclass=ProtocolEnumMeta):
    """
    Size of an item in the inventory
    """
    Size1x1 = 0
    Size1x2 = 1
    Size1x3 = 2
    Size1x4 = 3
    Size2x1 = 4
    Size2x2 = 5
    Size2x3 = 6
    Size2x4 = 7

Size1x1 = 0 class-attribute instance-attribute

Size1x2 = 1 class-attribute instance-attribute

Size1x3 = 2 class-attribute instance-attribute

Size1x4 = 3 class-attribute instance-attribute

Size2x1 = 4 class-attribute instance-attribute

Size2x2 = 5 class-attribute instance-attribute

Size2x3 = 6 class-attribute instance-attribute

Size2x4 = 7 class-attribute instance-attribute

Element

Bases: IntEnum

Source code in src/eolib/protocol/_generated/pub/element.py
 9
10
11
12
13
14
15
16
class Element(IntEnum, metaclass=ProtocolEnumMeta):
    None_ = 0
    Light = 1
    Dark = 2
    Earth = 3
    Wind = 4
    Water = 5
    Fire = 6

None_ = 0 class-attribute instance-attribute

Light = 1 class-attribute instance-attribute

Dark = 2 class-attribute instance-attribute

Earth = 3 class-attribute instance-attribute

Wind = 4 class-attribute instance-attribute

Water = 5 class-attribute instance-attribute

Fire = 6 class-attribute instance-attribute

EifRecord

Record of Item data in an Endless Item File

Source code in src/eolib/protocol/_generated/pub/eif_record.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
class EifRecord:
    """
    Record of Item data in an Endless Item File
    """
    _byte_size: int = 0
    _name_length: int
    _name: str
    _graphic_id: int
    _type: ItemType
    _subtype: ItemSubtype
    _special: ItemSpecial
    _hp: int
    _tp: int
    _min_damage: int
    _max_damage: int
    _accuracy: int
    _evade: int
    _armor: int
    _return_damage: int
    _str: int
    _intl: int
    _wis: int
    _agi: int
    _con: int
    _cha: int
    _light_resistance: int
    _dark_resistance: int
    _earth_resistance: int
    _air_resistance: int
    _water_resistance: int
    _fire_resistance: int
    _spec1: int
    _spec2: int
    _spec3: int
    _level_requirement: int
    _class_requirement: int
    _str_requirement: int
    _int_requirement: int
    _wis_requirement: int
    _agi_requirement: int
    _con_requirement: int
    _cha_requirement: int
    _element: Element
    _element_damage: int
    _weight: int
    _size: ItemSize

    def __init__(self, *, name: str, graphic_id: int, type: ItemType, subtype: ItemSubtype, special: ItemSpecial, hp: int, tp: int, min_damage: int, max_damage: int, accuracy: int, evade: int, armor: int, return_damage: int, str: int, intl: int, wis: int, agi: int, con: int, cha: int, light_resistance: int, dark_resistance: int, earth_resistance: int, air_resistance: int, water_resistance: int, fire_resistance: int, spec1: int, spec2: int, spec3: int, level_requirement: int, class_requirement: int, str_requirement: int, int_requirement: int, wis_requirement: int, agi_requirement: int, con_requirement: int, cha_requirement: int, element: Element, element_damage: int, weight: int, size: ItemSize):
        """
        Create a new instance of EifRecord.

        Args:
            name (str): (Length must be 252 or less.)
            graphic_id (int): (Value range is 0-64008.)
            type (ItemType): 
            subtype (ItemSubtype): 
            special (ItemSpecial): 
            hp (int): (Value range is 0-64008.)
            tp (int): (Value range is 0-64008.)
            min_damage (int): (Value range is 0-64008.)
            max_damage (int): (Value range is 0-64008.)
            accuracy (int): (Value range is 0-64008.)
            evade (int): (Value range is 0-64008.)
            armor (int): (Value range is 0-64008.)
            return_damage (int): (Value range is 0-252.)
            str (int): (Value range is 0-252.)
            intl (int): (Value range is 0-252.)
            wis (int): (Value range is 0-252.)
            agi (int): (Value range is 0-252.)
            con (int): (Value range is 0-252.)
            cha (int): (Value range is 0-252.)
            light_resistance (int): (Value range is 0-252.)
            dark_resistance (int): (Value range is 0-252.)
            earth_resistance (int): (Value range is 0-252.)
            air_resistance (int): (Value range is 0-252.)
            water_resistance (int): (Value range is 0-252.)
            fire_resistance (int): (Value range is 0-252.)
            spec1 (int): Holds one the following values, depending on item type: scroll_map, doll_graphic, exp_reward, hair_color, effect, key, alcohol_potency (Value range is 0-16194276.)
            spec2 (int): Holds one the following values, depending on item type: scroll_x, gender (Value range is 0-252.)
            spec3 (int): Holds one the following values, depending on item type: scroll_y (Value range is 0-252.)
            level_requirement (int): (Value range is 0-64008.)
            class_requirement (int): (Value range is 0-64008.)
            str_requirement (int): (Value range is 0-64008.)
            int_requirement (int): (Value range is 0-64008.)
            wis_requirement (int): (Value range is 0-64008.)
            agi_requirement (int): (Value range is 0-64008.)
            con_requirement (int): (Value range is 0-64008.)
            cha_requirement (int): (Value range is 0-64008.)
            element (Element): 
            element_damage (int): (Value range is 0-252.)
            weight (int): (Value range is 0-252.)
            size (ItemSize): 
        """
        self._name = name
        self._name_length = len(self._name)
        self._graphic_id = graphic_id
        self._type = type
        self._subtype = subtype
        self._special = special
        self._hp = hp
        self._tp = tp
        self._min_damage = min_damage
        self._max_damage = max_damage
        self._accuracy = accuracy
        self._evade = evade
        self._armor = armor
        self._return_damage = return_damage
        self._str = str
        self._intl = intl
        self._wis = wis
        self._agi = agi
        self._con = con
        self._cha = cha
        self._light_resistance = light_resistance
        self._dark_resistance = dark_resistance
        self._earth_resistance = earth_resistance
        self._air_resistance = air_resistance
        self._water_resistance = water_resistance
        self._fire_resistance = fire_resistance
        self._spec1 = spec1
        self._spec2 = spec2
        self._spec3 = spec3
        self._level_requirement = level_requirement
        self._class_requirement = class_requirement
        self._str_requirement = str_requirement
        self._int_requirement = int_requirement
        self._wis_requirement = wis_requirement
        self._agi_requirement = agi_requirement
        self._con_requirement = con_requirement
        self._cha_requirement = cha_requirement
        self._element = element
        self._element_damage = element_damage
        self._weight = weight
        self._size = size

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def name(self) -> str:
        return self._name

    @property
    def graphic_id(self) -> int:
        return self._graphic_id

    @property
    def type(self) -> ItemType:
        return self._type

    @property
    def subtype(self) -> ItemSubtype:
        return self._subtype

    @property
    def special(self) -> ItemSpecial:
        return self._special

    @property
    def hp(self) -> int:
        return self._hp

    @property
    def tp(self) -> int:
        return self._tp

    @property
    def min_damage(self) -> int:
        return self._min_damage

    @property
    def max_damage(self) -> int:
        return self._max_damage

    @property
    def accuracy(self) -> int:
        return self._accuracy

    @property
    def evade(self) -> int:
        return self._evade

    @property
    def armor(self) -> int:
        return self._armor

    @property
    def return_damage(self) -> int:
        return self._return_damage

    @property
    def str(self) -> int:
        return self._str

    @property
    def intl(self) -> int:
        return self._intl

    @property
    def wis(self) -> int:
        return self._wis

    @property
    def agi(self) -> int:
        return self._agi

    @property
    def con(self) -> int:
        return self._con

    @property
    def cha(self) -> int:
        return self._cha

    @property
    def light_resistance(self) -> int:
        return self._light_resistance

    @property
    def dark_resistance(self) -> int:
        return self._dark_resistance

    @property
    def earth_resistance(self) -> int:
        return self._earth_resistance

    @property
    def air_resistance(self) -> int:
        return self._air_resistance

    @property
    def water_resistance(self) -> int:
        return self._water_resistance

    @property
    def fire_resistance(self) -> int:
        return self._fire_resistance

    @property
    def spec1(self) -> int:
        """
        Holds one the following values, depending on item type:
        scroll_map, doll_graphic, exp_reward, hair_color, effect, key, alcohol_potency
        """
        return self._spec1

    @property
    def spec2(self) -> int:
        """
        Holds one the following values, depending on item type:
        scroll_x, gender
        """
        return self._spec2

    @property
    def spec3(self) -> int:
        """
        Holds one the following values, depending on item type:
        scroll_y
        """
        return self._spec3

    @property
    def level_requirement(self) -> int:
        return self._level_requirement

    @property
    def class_requirement(self) -> int:
        return self._class_requirement

    @property
    def str_requirement(self) -> int:
        return self._str_requirement

    @property
    def int_requirement(self) -> int:
        return self._int_requirement

    @property
    def wis_requirement(self) -> int:
        return self._wis_requirement

    @property
    def agi_requirement(self) -> int:
        return self._agi_requirement

    @property
    def con_requirement(self) -> int:
        return self._con_requirement

    @property
    def cha_requirement(self) -> int:
        return self._cha_requirement

    @property
    def element(self) -> Element:
        return self._element

    @property
    def element_damage(self) -> int:
        return self._element_damage

    @property
    def weight(self) -> int:
        return self._weight

    @property
    def size(self) -> ItemSize:
        return self._size

    @staticmethod
    def serialize(writer: EoWriter, data: "EifRecord") -> None:
        """
        Serializes an instance of `EifRecord` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (EifRecord): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            if data._name_length is None:
                raise SerializationError("name_length must be provided.")
            writer.add_char(data._name_length)
            if data._name is None:
                raise SerializationError("name must be provided.")
            if len(data._name) > 252:
                raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
            writer.add_fixed_string(data._name, data._name_length, False)
            if data._graphic_id is None:
                raise SerializationError("graphic_id must be provided.")
            writer.add_short(data._graphic_id)
            if data._type is None:
                raise SerializationError("type must be provided.")
            writer.add_char(int(data._type))
            if data._subtype is None:
                raise SerializationError("subtype must be provided.")
            writer.add_char(int(data._subtype))
            if data._special is None:
                raise SerializationError("special must be provided.")
            writer.add_char(int(data._special))
            if data._hp is None:
                raise SerializationError("hp must be provided.")
            writer.add_short(data._hp)
            if data._tp is None:
                raise SerializationError("tp must be provided.")
            writer.add_short(data._tp)
            if data._min_damage is None:
                raise SerializationError("min_damage must be provided.")
            writer.add_short(data._min_damage)
            if data._max_damage is None:
                raise SerializationError("max_damage must be provided.")
            writer.add_short(data._max_damage)
            if data._accuracy is None:
                raise SerializationError("accuracy must be provided.")
            writer.add_short(data._accuracy)
            if data._evade is None:
                raise SerializationError("evade must be provided.")
            writer.add_short(data._evade)
            if data._armor is None:
                raise SerializationError("armor must be provided.")
            writer.add_short(data._armor)
            if data._return_damage is None:
                raise SerializationError("return_damage must be provided.")
            writer.add_char(data._return_damage)
            if data._str is None:
                raise SerializationError("str must be provided.")
            writer.add_char(data._str)
            if data._intl is None:
                raise SerializationError("intl must be provided.")
            writer.add_char(data._intl)
            if data._wis is None:
                raise SerializationError("wis must be provided.")
            writer.add_char(data._wis)
            if data._agi is None:
                raise SerializationError("agi must be provided.")
            writer.add_char(data._agi)
            if data._con is None:
                raise SerializationError("con must be provided.")
            writer.add_char(data._con)
            if data._cha is None:
                raise SerializationError("cha must be provided.")
            writer.add_char(data._cha)
            if data._light_resistance is None:
                raise SerializationError("light_resistance must be provided.")
            writer.add_char(data._light_resistance)
            if data._dark_resistance is None:
                raise SerializationError("dark_resistance must be provided.")
            writer.add_char(data._dark_resistance)
            if data._earth_resistance is None:
                raise SerializationError("earth_resistance must be provided.")
            writer.add_char(data._earth_resistance)
            if data._air_resistance is None:
                raise SerializationError("air_resistance must be provided.")
            writer.add_char(data._air_resistance)
            if data._water_resistance is None:
                raise SerializationError("water_resistance must be provided.")
            writer.add_char(data._water_resistance)
            if data._fire_resistance is None:
                raise SerializationError("fire_resistance must be provided.")
            writer.add_char(data._fire_resistance)
            if data._spec1 is None:
                raise SerializationError("spec1 must be provided.")
            writer.add_three(data._spec1)
            if data._spec2 is None:
                raise SerializationError("spec2 must be provided.")
            writer.add_char(data._spec2)
            if data._spec3 is None:
                raise SerializationError("spec3 must be provided.")
            writer.add_char(data._spec3)
            if data._level_requirement is None:
                raise SerializationError("level_requirement must be provided.")
            writer.add_short(data._level_requirement)
            if data._class_requirement is None:
                raise SerializationError("class_requirement must be provided.")
            writer.add_short(data._class_requirement)
            if data._str_requirement is None:
                raise SerializationError("str_requirement must be provided.")
            writer.add_short(data._str_requirement)
            if data._int_requirement is None:
                raise SerializationError("int_requirement must be provided.")
            writer.add_short(data._int_requirement)
            if data._wis_requirement is None:
                raise SerializationError("wis_requirement must be provided.")
            writer.add_short(data._wis_requirement)
            if data._agi_requirement is None:
                raise SerializationError("agi_requirement must be provided.")
            writer.add_short(data._agi_requirement)
            if data._con_requirement is None:
                raise SerializationError("con_requirement must be provided.")
            writer.add_short(data._con_requirement)
            if data._cha_requirement is None:
                raise SerializationError("cha_requirement must be provided.")
            writer.add_short(data._cha_requirement)
            if data._element is None:
                raise SerializationError("element must be provided.")
            writer.add_char(int(data._element))
            if data._element_damage is None:
                raise SerializationError("element_damage must be provided.")
            writer.add_char(data._element_damage)
            if data._weight is None:
                raise SerializationError("weight must be provided.")
            writer.add_char(data._weight)
            writer.add_char(0)
            if data._size is None:
                raise SerializationError("size must be provided.")
            writer.add_char(int(data._size))
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "EifRecord":
        """
        Deserializes an instance of `EifRecord` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            EifRecord: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            name_length = reader.get_char()
            name = reader.get_fixed_string(name_length, False)
            graphic_id = reader.get_short()
            type = ItemType(reader.get_char())
            subtype = ItemSubtype(reader.get_char())
            special = ItemSpecial(reader.get_char())
            hp = reader.get_short()
            tp = reader.get_short()
            min_damage = reader.get_short()
            max_damage = reader.get_short()
            accuracy = reader.get_short()
            evade = reader.get_short()
            armor = reader.get_short()
            return_damage = reader.get_char()
            str = reader.get_char()
            intl = reader.get_char()
            wis = reader.get_char()
            agi = reader.get_char()
            con = reader.get_char()
            cha = reader.get_char()
            light_resistance = reader.get_char()
            dark_resistance = reader.get_char()
            earth_resistance = reader.get_char()
            air_resistance = reader.get_char()
            water_resistance = reader.get_char()
            fire_resistance = reader.get_char()
            spec1 = reader.get_three()
            spec2 = reader.get_char()
            spec3 = reader.get_char()
            level_requirement = reader.get_short()
            class_requirement = reader.get_short()
            str_requirement = reader.get_short()
            int_requirement = reader.get_short()
            wis_requirement = reader.get_short()
            agi_requirement = reader.get_short()
            con_requirement = reader.get_short()
            cha_requirement = reader.get_short()
            element = Element(reader.get_char())
            element_damage = reader.get_char()
            weight = reader.get_char()
            reader.get_char()
            size = ItemSize(reader.get_char())
            result = EifRecord(name=name, graphic_id=graphic_id, type=type, subtype=subtype, special=special, hp=hp, tp=tp, min_damage=min_damage, max_damage=max_damage, accuracy=accuracy, evade=evade, armor=armor, return_damage=return_damage, str=str, intl=intl, wis=wis, agi=agi, con=con, cha=cha, light_resistance=light_resistance, dark_resistance=dark_resistance, earth_resistance=earth_resistance, air_resistance=air_resistance, water_resistance=water_resistance, fire_resistance=fire_resistance, spec1=spec1, spec2=spec2, spec3=spec3, level_requirement=level_requirement, class_requirement=class_requirement, str_requirement=str_requirement, int_requirement=int_requirement, wis_requirement=wis_requirement, agi_requirement=agi_requirement, con_requirement=con_requirement, cha_requirement=cha_requirement, element=element, element_damage=element_damage, weight=weight, size=size)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"EifRecord(byte_size={repr(self._byte_size)}, name={repr(self._name)}, graphic_id={repr(self._graphic_id)}, type={repr(self._type)}, subtype={repr(self._subtype)}, special={repr(self._special)}, hp={repr(self._hp)}, tp={repr(self._tp)}, min_damage={repr(self._min_damage)}, max_damage={repr(self._max_damage)}, accuracy={repr(self._accuracy)}, evade={repr(self._evade)}, armor={repr(self._armor)}, return_damage={repr(self._return_damage)}, str={repr(self._str)}, intl={repr(self._intl)}, wis={repr(self._wis)}, agi={repr(self._agi)}, con={repr(self._con)}, cha={repr(self._cha)}, light_resistance={repr(self._light_resistance)}, dark_resistance={repr(self._dark_resistance)}, earth_resistance={repr(self._earth_resistance)}, air_resistance={repr(self._air_resistance)}, water_resistance={repr(self._water_resistance)}, fire_resistance={repr(self._fire_resistance)}, spec1={repr(self._spec1)}, spec2={repr(self._spec2)}, spec3={repr(self._spec3)}, level_requirement={repr(self._level_requirement)}, class_requirement={repr(self._class_requirement)}, str_requirement={repr(self._str_requirement)}, int_requirement={repr(self._int_requirement)}, wis_requirement={repr(self._wis_requirement)}, agi_requirement={repr(self._agi_requirement)}, con_requirement={repr(self._con_requirement)}, cha_requirement={repr(self._cha_requirement)}, element={repr(self._element)}, element_damage={repr(self._element_damage)}, weight={repr(self._weight)}, size={repr(self._size)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

name: str property

graphic_id: int property

type: ItemType property

subtype: ItemSubtype property

special: ItemSpecial property

hp: int property

tp: int property

min_damage: int property

max_damage: int property

accuracy: int property

evade: int property

armor: int property

return_damage: int property

str: int property

intl: int property

wis: int property

agi: int property

con: int property

cha: int property

light_resistance: int property

dark_resistance: int property

earth_resistance: int property

air_resistance: int property

water_resistance: int property

fire_resistance: int property

spec1: int property

Holds one the following values, depending on item type: scroll_map, doll_graphic, exp_reward, hair_color, effect, key, alcohol_potency

spec2: int property

Holds one the following values, depending on item type: scroll_x, gender

spec3: int property

Holds one the following values, depending on item type: scroll_y

level_requirement: int property

class_requirement: int property

str_requirement: int property

int_requirement: int property

wis_requirement: int property

agi_requirement: int property

con_requirement: int property

cha_requirement: int property

element: Element property

element_damage: int property

weight: int property

size: ItemSize property

__init__(*, name, graphic_id, type, subtype, special, hp, tp, min_damage, max_damage, accuracy, evade, armor, return_damage, str, intl, wis, agi, con, cha, light_resistance, dark_resistance, earth_resistance, air_resistance, water_resistance, fire_resistance, spec1, spec2, spec3, level_requirement, class_requirement, str_requirement, int_requirement, wis_requirement, agi_requirement, con_requirement, cha_requirement, element, element_damage, weight, size)

Create a new instance of EifRecord.

Parameters:

Name Type Description Default
name str

(Length must be 252 or less.)

required
graphic_id int

(Value range is 0-64008.)

required
type ItemType
required
subtype ItemSubtype
required
special ItemSpecial
required
hp int

(Value range is 0-64008.)

required
tp int

(Value range is 0-64008.)

required
min_damage int

(Value range is 0-64008.)

required
max_damage int

(Value range is 0-64008.)

required
accuracy int

(Value range is 0-64008.)

required
evade int

(Value range is 0-64008.)

required
armor int

(Value range is 0-64008.)

required
return_damage int

(Value range is 0-252.)

required
str int

(Value range is 0-252.)

required
intl int

(Value range is 0-252.)

required
wis int

(Value range is 0-252.)

required
agi int

(Value range is 0-252.)

required
con int

(Value range is 0-252.)

required
cha int

(Value range is 0-252.)

required
light_resistance int

(Value range is 0-252.)

required
dark_resistance int

(Value range is 0-252.)

required
earth_resistance int

(Value range is 0-252.)

required
air_resistance int

(Value range is 0-252.)

required
water_resistance int

(Value range is 0-252.)

required
fire_resistance int

(Value range is 0-252.)

required
spec1 int

Holds one the following values, depending on item type: scroll_map, doll_graphic, exp_reward, hair_color, effect, key, alcohol_potency (Value range is 0-16194276.)

required
spec2 int

Holds one the following values, depending on item type: scroll_x, gender (Value range is 0-252.)

required
spec3 int

Holds one the following values, depending on item type: scroll_y (Value range is 0-252.)

required
level_requirement int

(Value range is 0-64008.)

required
class_requirement int

(Value range is 0-64008.)

required
str_requirement int

(Value range is 0-64008.)

required
int_requirement int

(Value range is 0-64008.)

required
wis_requirement int

(Value range is 0-64008.)

required
agi_requirement int

(Value range is 0-64008.)

required
con_requirement int

(Value range is 0-64008.)

required
cha_requirement int

(Value range is 0-64008.)

required
element Element
required
element_damage int

(Value range is 0-252.)

required
weight int

(Value range is 0-252.)

required
size ItemSize
required
Source code in src/eolib/protocol/_generated/pub/eif_record.py
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def __init__(self, *, name: str, graphic_id: int, type: ItemType, subtype: ItemSubtype, special: ItemSpecial, hp: int, tp: int, min_damage: int, max_damage: int, accuracy: int, evade: int, armor: int, return_damage: int, str: int, intl: int, wis: int, agi: int, con: int, cha: int, light_resistance: int, dark_resistance: int, earth_resistance: int, air_resistance: int, water_resistance: int, fire_resistance: int, spec1: int, spec2: int, spec3: int, level_requirement: int, class_requirement: int, str_requirement: int, int_requirement: int, wis_requirement: int, agi_requirement: int, con_requirement: int, cha_requirement: int, element: Element, element_damage: int, weight: int, size: ItemSize):
    """
    Create a new instance of EifRecord.

    Args:
        name (str): (Length must be 252 or less.)
        graphic_id (int): (Value range is 0-64008.)
        type (ItemType): 
        subtype (ItemSubtype): 
        special (ItemSpecial): 
        hp (int): (Value range is 0-64008.)
        tp (int): (Value range is 0-64008.)
        min_damage (int): (Value range is 0-64008.)
        max_damage (int): (Value range is 0-64008.)
        accuracy (int): (Value range is 0-64008.)
        evade (int): (Value range is 0-64008.)
        armor (int): (Value range is 0-64008.)
        return_damage (int): (Value range is 0-252.)
        str (int): (Value range is 0-252.)
        intl (int): (Value range is 0-252.)
        wis (int): (Value range is 0-252.)
        agi (int): (Value range is 0-252.)
        con (int): (Value range is 0-252.)
        cha (int): (Value range is 0-252.)
        light_resistance (int): (Value range is 0-252.)
        dark_resistance (int): (Value range is 0-252.)
        earth_resistance (int): (Value range is 0-252.)
        air_resistance (int): (Value range is 0-252.)
        water_resistance (int): (Value range is 0-252.)
        fire_resistance (int): (Value range is 0-252.)
        spec1 (int): Holds one the following values, depending on item type: scroll_map, doll_graphic, exp_reward, hair_color, effect, key, alcohol_potency (Value range is 0-16194276.)
        spec2 (int): Holds one the following values, depending on item type: scroll_x, gender (Value range is 0-252.)
        spec3 (int): Holds one the following values, depending on item type: scroll_y (Value range is 0-252.)
        level_requirement (int): (Value range is 0-64008.)
        class_requirement (int): (Value range is 0-64008.)
        str_requirement (int): (Value range is 0-64008.)
        int_requirement (int): (Value range is 0-64008.)
        wis_requirement (int): (Value range is 0-64008.)
        agi_requirement (int): (Value range is 0-64008.)
        con_requirement (int): (Value range is 0-64008.)
        cha_requirement (int): (Value range is 0-64008.)
        element (Element): 
        element_damage (int): (Value range is 0-252.)
        weight (int): (Value range is 0-252.)
        size (ItemSize): 
    """
    self._name = name
    self._name_length = len(self._name)
    self._graphic_id = graphic_id
    self._type = type
    self._subtype = subtype
    self._special = special
    self._hp = hp
    self._tp = tp
    self._min_damage = min_damage
    self._max_damage = max_damage
    self._accuracy = accuracy
    self._evade = evade
    self._armor = armor
    self._return_damage = return_damage
    self._str = str
    self._intl = intl
    self._wis = wis
    self._agi = agi
    self._con = con
    self._cha = cha
    self._light_resistance = light_resistance
    self._dark_resistance = dark_resistance
    self._earth_resistance = earth_resistance
    self._air_resistance = air_resistance
    self._water_resistance = water_resistance
    self._fire_resistance = fire_resistance
    self._spec1 = spec1
    self._spec2 = spec2
    self._spec3 = spec3
    self._level_requirement = level_requirement
    self._class_requirement = class_requirement
    self._str_requirement = str_requirement
    self._int_requirement = int_requirement
    self._wis_requirement = wis_requirement
    self._agi_requirement = agi_requirement
    self._con_requirement = con_requirement
    self._cha_requirement = cha_requirement
    self._element = element
    self._element_damage = element_damage
    self._weight = weight
    self._size = size

serialize(writer, data) staticmethod

Serializes an instance of EifRecord to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data EifRecord

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/eif_record.py
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
@staticmethod
def serialize(writer: EoWriter, data: "EifRecord") -> None:
    """
    Serializes an instance of `EifRecord` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (EifRecord): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        if data._name_length is None:
            raise SerializationError("name_length must be provided.")
        writer.add_char(data._name_length)
        if data._name is None:
            raise SerializationError("name must be provided.")
        if len(data._name) > 252:
            raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
        writer.add_fixed_string(data._name, data._name_length, False)
        if data._graphic_id is None:
            raise SerializationError("graphic_id must be provided.")
        writer.add_short(data._graphic_id)
        if data._type is None:
            raise SerializationError("type must be provided.")
        writer.add_char(int(data._type))
        if data._subtype is None:
            raise SerializationError("subtype must be provided.")
        writer.add_char(int(data._subtype))
        if data._special is None:
            raise SerializationError("special must be provided.")
        writer.add_char(int(data._special))
        if data._hp is None:
            raise SerializationError("hp must be provided.")
        writer.add_short(data._hp)
        if data._tp is None:
            raise SerializationError("tp must be provided.")
        writer.add_short(data._tp)
        if data._min_damage is None:
            raise SerializationError("min_damage must be provided.")
        writer.add_short(data._min_damage)
        if data._max_damage is None:
            raise SerializationError("max_damage must be provided.")
        writer.add_short(data._max_damage)
        if data._accuracy is None:
            raise SerializationError("accuracy must be provided.")
        writer.add_short(data._accuracy)
        if data._evade is None:
            raise SerializationError("evade must be provided.")
        writer.add_short(data._evade)
        if data._armor is None:
            raise SerializationError("armor must be provided.")
        writer.add_short(data._armor)
        if data._return_damage is None:
            raise SerializationError("return_damage must be provided.")
        writer.add_char(data._return_damage)
        if data._str is None:
            raise SerializationError("str must be provided.")
        writer.add_char(data._str)
        if data._intl is None:
            raise SerializationError("intl must be provided.")
        writer.add_char(data._intl)
        if data._wis is None:
            raise SerializationError("wis must be provided.")
        writer.add_char(data._wis)
        if data._agi is None:
            raise SerializationError("agi must be provided.")
        writer.add_char(data._agi)
        if data._con is None:
            raise SerializationError("con must be provided.")
        writer.add_char(data._con)
        if data._cha is None:
            raise SerializationError("cha must be provided.")
        writer.add_char(data._cha)
        if data._light_resistance is None:
            raise SerializationError("light_resistance must be provided.")
        writer.add_char(data._light_resistance)
        if data._dark_resistance is None:
            raise SerializationError("dark_resistance must be provided.")
        writer.add_char(data._dark_resistance)
        if data._earth_resistance is None:
            raise SerializationError("earth_resistance must be provided.")
        writer.add_char(data._earth_resistance)
        if data._air_resistance is None:
            raise SerializationError("air_resistance must be provided.")
        writer.add_char(data._air_resistance)
        if data._water_resistance is None:
            raise SerializationError("water_resistance must be provided.")
        writer.add_char(data._water_resistance)
        if data._fire_resistance is None:
            raise SerializationError("fire_resistance must be provided.")
        writer.add_char(data._fire_resistance)
        if data._spec1 is None:
            raise SerializationError("spec1 must be provided.")
        writer.add_three(data._spec1)
        if data._spec2 is None:
            raise SerializationError("spec2 must be provided.")
        writer.add_char(data._spec2)
        if data._spec3 is None:
            raise SerializationError("spec3 must be provided.")
        writer.add_char(data._spec3)
        if data._level_requirement is None:
            raise SerializationError("level_requirement must be provided.")
        writer.add_short(data._level_requirement)
        if data._class_requirement is None:
            raise SerializationError("class_requirement must be provided.")
        writer.add_short(data._class_requirement)
        if data._str_requirement is None:
            raise SerializationError("str_requirement must be provided.")
        writer.add_short(data._str_requirement)
        if data._int_requirement is None:
            raise SerializationError("int_requirement must be provided.")
        writer.add_short(data._int_requirement)
        if data._wis_requirement is None:
            raise SerializationError("wis_requirement must be provided.")
        writer.add_short(data._wis_requirement)
        if data._agi_requirement is None:
            raise SerializationError("agi_requirement must be provided.")
        writer.add_short(data._agi_requirement)
        if data._con_requirement is None:
            raise SerializationError("con_requirement must be provided.")
        writer.add_short(data._con_requirement)
        if data._cha_requirement is None:
            raise SerializationError("cha_requirement must be provided.")
        writer.add_short(data._cha_requirement)
        if data._element is None:
            raise SerializationError("element must be provided.")
        writer.add_char(int(data._element))
        if data._element_damage is None:
            raise SerializationError("element_damage must be provided.")
        writer.add_char(data._element_damage)
        if data._weight is None:
            raise SerializationError("weight must be provided.")
        writer.add_char(data._weight)
        writer.add_char(0)
        if data._size is None:
            raise SerializationError("size must be provided.")
        writer.add_char(int(data._size))
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of EifRecord from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
EifRecord EifRecord

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/eif_record.py
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
@staticmethod
def deserialize(reader: EoReader) -> "EifRecord":
    """
    Deserializes an instance of `EifRecord` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        EifRecord: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        name_length = reader.get_char()
        name = reader.get_fixed_string(name_length, False)
        graphic_id = reader.get_short()
        type = ItemType(reader.get_char())
        subtype = ItemSubtype(reader.get_char())
        special = ItemSpecial(reader.get_char())
        hp = reader.get_short()
        tp = reader.get_short()
        min_damage = reader.get_short()
        max_damage = reader.get_short()
        accuracy = reader.get_short()
        evade = reader.get_short()
        armor = reader.get_short()
        return_damage = reader.get_char()
        str = reader.get_char()
        intl = reader.get_char()
        wis = reader.get_char()
        agi = reader.get_char()
        con = reader.get_char()
        cha = reader.get_char()
        light_resistance = reader.get_char()
        dark_resistance = reader.get_char()
        earth_resistance = reader.get_char()
        air_resistance = reader.get_char()
        water_resistance = reader.get_char()
        fire_resistance = reader.get_char()
        spec1 = reader.get_three()
        spec2 = reader.get_char()
        spec3 = reader.get_char()
        level_requirement = reader.get_short()
        class_requirement = reader.get_short()
        str_requirement = reader.get_short()
        int_requirement = reader.get_short()
        wis_requirement = reader.get_short()
        agi_requirement = reader.get_short()
        con_requirement = reader.get_short()
        cha_requirement = reader.get_short()
        element = Element(reader.get_char())
        element_damage = reader.get_char()
        weight = reader.get_char()
        reader.get_char()
        size = ItemSize(reader.get_char())
        result = EifRecord(name=name, graphic_id=graphic_id, type=type, subtype=subtype, special=special, hp=hp, tp=tp, min_damage=min_damage, max_damage=max_damage, accuracy=accuracy, evade=evade, armor=armor, return_damage=return_damage, str=str, intl=intl, wis=wis, agi=agi, con=con, cha=cha, light_resistance=light_resistance, dark_resistance=dark_resistance, earth_resistance=earth_resistance, air_resistance=air_resistance, water_resistance=water_resistance, fire_resistance=fire_resistance, spec1=spec1, spec2=spec2, spec3=spec3, level_requirement=level_requirement, class_requirement=class_requirement, str_requirement=str_requirement, int_requirement=int_requirement, wis_requirement=wis_requirement, agi_requirement=agi_requirement, con_requirement=con_requirement, cha_requirement=cha_requirement, element=element, element_damage=element_damage, weight=weight, size=size)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Eif

Endless Item File

Source code in src/eolib/protocol/_generated/pub/eif.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
class Eif:
    """
    Endless Item File
    """
    _byte_size: int = 0
    _rid: tuple[int, ...]
    _total_items_count: int
    _version: int
    _items: tuple[EifRecord, ...]

    def __init__(self, *, rid: Iterable[int], total_items_count: int, version: int, items: Iterable[EifRecord]):
        """
        Create a new instance of Eif.

        Args:
            rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
            total_items_count (int): (Value range is 0-64008.)
            version (int): (Value range is 0-252.)
            items (Iterable[EifRecord]): 
        """
        self._rid = tuple(rid)
        self._total_items_count = total_items_count
        self._version = version
        self._items = tuple(items)

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def rid(self) -> tuple[int, ...]:
        return self._rid

    @property
    def total_items_count(self) -> int:
        return self._total_items_count

    @property
    def version(self) -> int:
        return self._version

    @property
    def items(self) -> tuple[EifRecord, ...]:
        return self._items

    @staticmethod
    def serialize(writer: EoWriter, data: "Eif") -> None:
        """
        Serializes an instance of `Eif` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Eif): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            writer.add_fixed_string("EIF", 3, False)
            if data._rid is None:
                raise SerializationError("rid must be provided.")
            if len(data._rid) != 2:
                raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
            for i in range(2):
                writer.add_short(data._rid[i])
            if data._total_items_count is None:
                raise SerializationError("total_items_count must be provided.")
            writer.add_short(data._total_items_count)
            if data._version is None:
                raise SerializationError("version must be provided.")
            writer.add_char(data._version)
            if data._items is None:
                raise SerializationError("items must be provided.")
            for i in range(len(data._items)):
                EifRecord.serialize(writer, data._items[i])
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "Eif":
        """
        Deserializes an instance of `Eif` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Eif: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            rid = []
            for i in range(2):
                rid.append(reader.get_short())
            total_items_count = reader.get_short()
            version = reader.get_char()
            items = []
            while reader.remaining > 0:
                items.append(EifRecord.deserialize(reader))
            result = Eif(rid=rid, total_items_count=total_items_count, version=version, items=items)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Eif(byte_size={repr(self._byte_size)}, rid={repr(self._rid)}, total_items_count={repr(self._total_items_count)}, version={repr(self._version)}, items={repr(self._items)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

rid: tuple[int, ...] property

total_items_count: int property

version: int property

items: tuple[EifRecord, ...] property

__init__(*, rid, total_items_count, version, items)

Create a new instance of Eif.

Parameters:

Name Type Description Default
rid Iterable[int]

(Length must be 2.) (Element value range is 0-64008.)

required
total_items_count int

(Value range is 0-64008.)

required
version int

(Value range is 0-252.)

required
items Iterable[EifRecord]
required
Source code in src/eolib/protocol/_generated/pub/eif.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self, *, rid: Iterable[int], total_items_count: int, version: int, items: Iterable[EifRecord]):
    """
    Create a new instance of Eif.

    Args:
        rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
        total_items_count (int): (Value range is 0-64008.)
        version (int): (Value range is 0-252.)
        items (Iterable[EifRecord]): 
    """
    self._rid = tuple(rid)
    self._total_items_count = total_items_count
    self._version = version
    self._items = tuple(items)

serialize(writer, data) staticmethod

Serializes an instance of Eif to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Eif

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/eif.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@staticmethod
def serialize(writer: EoWriter, data: "Eif") -> None:
    """
    Serializes an instance of `Eif` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Eif): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        writer.add_fixed_string("EIF", 3, False)
        if data._rid is None:
            raise SerializationError("rid must be provided.")
        if len(data._rid) != 2:
            raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
        for i in range(2):
            writer.add_short(data._rid[i])
        if data._total_items_count is None:
            raise SerializationError("total_items_count must be provided.")
        writer.add_short(data._total_items_count)
        if data._version is None:
            raise SerializationError("version must be provided.")
        writer.add_char(data._version)
        if data._items is None:
            raise SerializationError("items must be provided.")
        for i in range(len(data._items)):
            EifRecord.serialize(writer, data._items[i])
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of Eif from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Eif 'Eif'

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/eif.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@staticmethod
def deserialize(reader: EoReader) -> "Eif":
    """
    Deserializes an instance of `Eif` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Eif: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        rid = []
        for i in range(2):
            rid.append(reader.get_short())
        total_items_count = reader.get_short()
        version = reader.get_char()
        items = []
        while reader.remaining > 0:
            items.append(EifRecord.deserialize(reader))
        result = Eif(rid=rid, total_items_count=total_items_count, version=version, items=items)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

SerializationError

Bases: Exception

Represents an error in serializing a protocol data structure.

Source code in src/eolib/protocol/serialization_error.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class SerializationError(Exception):
    """
    Represents an error in serializing a protocol data structure.
    """

    def __init__(self, message: str):
        """
        Constructs a SerializationError with the specified error message.

        Args:
            message (str): The error message.
        """
        super().__init__(message)

__init__(message)

Constructs a SerializationError with the specified error message.

Parameters:

Name Type Description Default
message str

The error message.

required
Source code in src/eolib/protocol/serialization_error.py
 6
 7
 8
 9
10
11
12
13
def __init__(self, message: str):
    """
    Constructs a SerializationError with the specified error message.

    Args:
        message (str): The error message.
    """
    super().__init__(message)

EoWriter

Source code in src/eolib/data/eo_writer.py
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
class EoWriter:
    def __init__(self):
        self.data = bytearray()
        self._string_sanitization_mode = False

    def add_byte(self, value: int) -> None:
        """
        Adds a raw byte to the writer data.

        Args:
            value (int): The byte to add.

        Raises:
            ValueError: If the value is above `0xFF`.
        """
        self._check_number_size(value, 0xFF)
        self.data.append(value)

    def add_bytes(self, bytes: bytes) -> None:
        """
        Adds raw bytes to the writer data.

        Args:
            bytes (bytes): The bytes to add.
        """
        self.data.extend(bytes)

    def add_char(self, number: int) -> None:
        """
        Adds an encoded 1-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `CHAR_MAX`.
        """
        self._check_number_size(number, CHAR_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 1)

    def add_short(self, number: int) -> None:
        """
        Adds an encoded 2-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `SHORT_MAX`.
        """
        self._check_number_size(number, SHORT_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 2)

    def add_three(self, number: int) -> None:
        """
        Adds an encoded 3-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `THREE_MAX`.
        """
        self._check_number_size(number, THREE_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 3)

    def add_int(self, number: int) -> None:
        """
        Adds an encoded 4-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `INT_MAX`.
        """
        self._check_number_size(number, INT_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 4)

    def add_string(self, string: str) -> None:
        """
        Adds a string to the writer data.

        Args:
            string (str): The string to be added.
        """
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        self.add_bytes(string_bytes)

    def add_fixed_string(self, string: str, length: int, padded: bool = False) -> None:
        """
        Adds a fixed-length string to the writer data.

        Args:
            string (str): The string to be added.
            length (int): The expected length of the string.
            padded (bool, optional): True if the string should be padded to the length with
                trailing `0xFF` bytes. Defaults to False.
        """
        self._check_string_length(string, length, padded)
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        if padded:
            string_bytes = self._add_padding(string_bytes, length)
        self.add_bytes(string_bytes)

    def add_encoded_string(self, string: str) -> None:
        """
        Adds an encoded string to the writer data.

        Args:
            string (str): The string to be encoded and added.
        """
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        encode_string(string_bytes)
        self.add_bytes(string_bytes)

    def add_fixed_encoded_string(self, string: str, length: int, padded: bool = False) -> None:
        """
        Adds a fixed-length encoded string to the writer data.

        Args:
            string (str): The string to be encoded and added.
            length (int): The expected length of the string.
            padded (bool, optional): True if the string should be padded to the length with
                trailing `0xFF` bytes. Defaults to False.
        """
        self._check_string_length(string, length, padded)
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        if padded:
            string_bytes = self._add_padding(string_bytes, length)
        encode_string(string_bytes)
        self.add_bytes(string_bytes)

    @property
    def string_sanitization_mode(self) -> bool:
        """
        Gets the string sanitization mode for the writer.

        Returns:
            bool: True if string sanitization is enabled.
        """
        return self._string_sanitization_mode

    @string_sanitization_mode.setter
    def string_sanitization_mode(self, string_sanitization_mode: bool) -> None:
        self._string_sanitization_mode = string_sanitization_mode

    def to_bytearray(self) -> bytearray:
        """
        Gets the writer data as a byte array.

        Returns:
            bytearray: A copy of the writer data as a byte array.
        """
        return self.data.copy()

    def __len__(self) -> int:
        """
        Gets the length of the writer data.

        Returns:
            int: The length of the writer data.
        """
        return len(self.data)

    def _add_bytes_with_length(self, bytes: bytes, bytes_length: int) -> None:
        """
        Adds raw bytes with a specified length to the writer data.

        Args:
            bytes (bytes): The bytes to add.
            bytes_length (int): The number of bytes to add.
        """
        self.data.extend(bytes[:bytes_length])

    def _sanitize_string(self, bytes: bytearray) -> None:
        if self.string_sanitization_mode:
            for i in range(len(bytes)):
                if bytes[i] == 0xFF:  # 'ÿ'
                    bytes[i] = 0x79  # 'y'

    @staticmethod
    def _check_number_size(number: int, max_value: int) -> None:
        if number > max_value:
            raise ValueError(f"Value {number} exceeds maximum of {max_value}.")

    @staticmethod
    def _add_padding(bytes: bytearray, length: int) -> bytearray:
        if len(bytes) == length:
            return bytes

        result = bytearray(length)
        result[: len(bytes)] = bytes
        result[len(bytes) :] = bytearray([0xFF] * (length - len(bytes)))

        return result

    @staticmethod
    def _check_string_length(string: str, length: int, padded: bool) -> None:
        if padded:
            if length >= len(string):
                return
            raise ValueError(f'Padded string "{string}" is too large for a length of {length}.')

        if len(string) != length:
            raise ValueError(f'String "{string}" does not have expected length of {length}.')

    @staticmethod
    def _encode_ansi(string: str) -> bytearray:
        """
        Encodes string to windows-1252 bytes.

        Args:
            string (str): The string to encode.

        Returns:
            bytearray: The encoded string.
        """
        return bytearray(string, 'windows-1252', 'replace')

data = bytearray() instance-attribute

string_sanitization_mode: bool property writable

Gets the string sanitization mode for the writer.

Returns:

Name Type Description
bool bool

True if string sanitization is enabled.

__init__()

Source code in src/eolib/data/eo_writer.py
7
8
9
def __init__(self):
    self.data = bytearray()
    self._string_sanitization_mode = False

add_byte(value)

Adds a raw byte to the writer data.

Parameters:

Name Type Description Default
value int

The byte to add.

required

Raises:

Type Description
ValueError

If the value is above 0xFF.

Source code in src/eolib/data/eo_writer.py
11
12
13
14
15
16
17
18
19
20
21
22
def add_byte(self, value: int) -> None:
    """
    Adds a raw byte to the writer data.

    Args:
        value (int): The byte to add.

    Raises:
        ValueError: If the value is above `0xFF`.
    """
    self._check_number_size(value, 0xFF)
    self.data.append(value)

add_bytes(bytes)

Adds raw bytes to the writer data.

Parameters:

Name Type Description Default
bytes bytes

The bytes to add.

required
Source code in src/eolib/data/eo_writer.py
24
25
26
27
28
29
30
31
def add_bytes(self, bytes: bytes) -> None:
    """
    Adds raw bytes to the writer data.

    Args:
        bytes (bytes): The bytes to add.
    """
    self.data.extend(bytes)

add_char(number)

Adds an encoded 1-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below CHAR_MAX.

Source code in src/eolib/data/eo_writer.py
33
34
35
36
37
38
39
40
41
42
43
44
45
def add_char(self, number: int) -> None:
    """
    Adds an encoded 1-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `CHAR_MAX`.
    """
    self._check_number_size(number, CHAR_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 1)

add_short(number)

Adds an encoded 2-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below SHORT_MAX.

Source code in src/eolib/data/eo_writer.py
47
48
49
50
51
52
53
54
55
56
57
58
59
def add_short(self, number: int) -> None:
    """
    Adds an encoded 2-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `SHORT_MAX`.
    """
    self._check_number_size(number, SHORT_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 2)

add_three(number)

Adds an encoded 3-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below THREE_MAX.

Source code in src/eolib/data/eo_writer.py
61
62
63
64
65
66
67
68
69
70
71
72
73
def add_three(self, number: int) -> None:
    """
    Adds an encoded 3-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `THREE_MAX`.
    """
    self._check_number_size(number, THREE_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 3)

add_int(number)

Adds an encoded 4-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below INT_MAX.

Source code in src/eolib/data/eo_writer.py
75
76
77
78
79
80
81
82
83
84
85
86
87
def add_int(self, number: int) -> None:
    """
    Adds an encoded 4-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `INT_MAX`.
    """
    self._check_number_size(number, INT_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 4)

add_string(string)

Adds a string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be added.

required
Source code in src/eolib/data/eo_writer.py
89
90
91
92
93
94
95
96
97
98
def add_string(self, string: str) -> None:
    """
    Adds a string to the writer data.

    Args:
        string (str): The string to be added.
    """
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    self.add_bytes(string_bytes)

add_fixed_string(string, length, padded=False)

Adds a fixed-length string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be added.

required
length int

The expected length of the string.

required
padded bool

True if the string should be padded to the length with trailing 0xFF bytes. Defaults to False.

False
Source code in src/eolib/data/eo_writer.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
def add_fixed_string(self, string: str, length: int, padded: bool = False) -> None:
    """
    Adds a fixed-length string to the writer data.

    Args:
        string (str): The string to be added.
        length (int): The expected length of the string.
        padded (bool, optional): True if the string should be padded to the length with
            trailing `0xFF` bytes. Defaults to False.
    """
    self._check_string_length(string, length, padded)
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    if padded:
        string_bytes = self._add_padding(string_bytes, length)
    self.add_bytes(string_bytes)

add_encoded_string(string)

Adds an encoded string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be encoded and added.

required
Source code in src/eolib/data/eo_writer.py
117
118
119
120
121
122
123
124
125
126
127
def add_encoded_string(self, string: str) -> None:
    """
    Adds an encoded string to the writer data.

    Args:
        string (str): The string to be encoded and added.
    """
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    encode_string(string_bytes)
    self.add_bytes(string_bytes)

add_fixed_encoded_string(string, length, padded=False)

Adds a fixed-length encoded string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be encoded and added.

required
length int

The expected length of the string.

required
padded bool

True if the string should be padded to the length with trailing 0xFF bytes. Defaults to False.

False
Source code in src/eolib/data/eo_writer.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def add_fixed_encoded_string(self, string: str, length: int, padded: bool = False) -> None:
    """
    Adds a fixed-length encoded string to the writer data.

    Args:
        string (str): The string to be encoded and added.
        length (int): The expected length of the string.
        padded (bool, optional): True if the string should be padded to the length with
            trailing `0xFF` bytes. Defaults to False.
    """
    self._check_string_length(string, length, padded)
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    if padded:
        string_bytes = self._add_padding(string_bytes, length)
    encode_string(string_bytes)
    self.add_bytes(string_bytes)

to_bytearray()

Gets the writer data as a byte array.

Returns:

Name Type Description
bytearray bytearray

A copy of the writer data as a byte array.

Source code in src/eolib/data/eo_writer.py
161
162
163
164
165
166
167
168
def to_bytearray(self) -> bytearray:
    """
    Gets the writer data as a byte array.

    Returns:
        bytearray: A copy of the writer data as a byte array.
    """
    return self.data.copy()

__len__()

Gets the length of the writer data.

Returns:

Name Type Description
int int

The length of the writer data.

Source code in src/eolib/data/eo_writer.py
170
171
172
173
174
175
176
177
def __len__(self) -> int:
    """
    Gets the length of the writer data.

    Returns:
        int: The length of the writer data.
    """
    return len(self.data)

EoReader

Bases: object

A class for reading EO data from a sequence of bytes.

EoReader features a chunked reading mode, which is important for accurate emulation of the official game client.

See documentation for chunked reading: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md

Source code in src/eolib/data/eo_reader.py
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
class EoReader(object):
    """
    A class for reading EO data from a sequence of bytes.

    `EoReader` features a chunked reading mode, which is important for accurate emulation of
    the official game client.

    See documentation for chunked reading:
    https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md
    """

    _data: memoryview
    _position: int
    _chunked_reading_mode: bool
    _chunk_start: int
    _next_break: int

    def __init__(self, data: bytes):
        """
        Creates a new `EoReader` instance for the specified data.

        Args:
            data (bytes): The byte array containing the input data.
        """
        self._data = memoryview(data)
        self._position = 0
        self._chunked_reading_mode = False
        self._chunk_start = 0
        self._next_break = -1

    def slice(self, index: Optional[int] = None, length: Optional[int] = None) -> "EoReader":
        """
        Creates a new `EoReader` whose input data is a shared subsequence of this reader's
        data.

        The input data of the new reader will start at position `index` in this reader and contain
        up to `length` bytes. The two reader's position and chunked reading mode will be
        independent.

        The new reader's position will be zero, and its chunked reading mode will be false.

        Args:
            index (int, optional): The position in this reader at which the data of the new reader
                will start; must be non-negative. Defaults to the current reader position.
            length (int, optional): The length of the shared subsequence of data to supply to the
                new reader; must be non-negative. Defaults to the length of the remaining data
                starting from `index`.

        Returns:
            EoReader: The new reader.

        Raises:
            ValueError: If `index` or `length` is negative.
        """
        if index is None:
            index = self.position
        if length is None:
            length = max(0, len(self._data) - index)

        if index < 0:
            raise ValueError(f"negative index: {index}")

        if length < 0:
            raise ValueError(f"negative length: {length}")

        begin = max(0, min(len(self._data), index))
        end = begin + min(len(self._data) - begin, length)

        return EoReader(self._data[begin:end])

    def get_byte(self) -> int:
        """
        Reads a raw byte from the input data.

        Returns:
            int: A raw byte.
        """
        return self._read_byte()

    def get_bytes(self, length: int) -> bytearray:
        """
        Reads an array of raw bytes from the input data.

        Args:
            length (int): The number of bytes to read.

        Returns:
            bytearray: An array of raw bytes.
        """
        return self._read_bytes(length)

    def get_char(self) -> int:
        """
        Reads an encoded 1-byte integer from the input data.

        Returns:
            int: A decoded 1-byte integer.
        """
        return decode_number(self._read_bytes(1))

    def get_short(self) -> int:
        """
        Reads an encoded 2-byte integer from the input data.

        Returns:
            int: A decoded 2-byte integer.
        """
        return decode_number(self._read_bytes(2))

    def get_three(self) -> int:
        """
        Reads an encoded 3-byte integer from the input data.

        Returns:
            int: A decoded 3-byte integer.
        """
        return decode_number(self._read_bytes(3))

    def get_int(self) -> int:
        """
        Reads an encoded 4-byte integer from the input data.

        Returns:
            int: A decoded 4-byte integer.
        """
        return decode_number(self._read_bytes(4))

    def get_string(self) -> str:
        """
        Reads a string from the input data.

        Returns:
            str: A string.
        """
        string_bytes = self._read_bytes(self.remaining)
        return self._decode_ansi(string_bytes)

    def get_fixed_string(self, length: int, padded: bool = False) -> str:
        """
        Reads a string with a fixed length from the input data.

        Args:
            length (int): The length of the string.
            padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

        Returns:
            str: A decoded string.

        Raises:
            ValueError: If the length is negative.
        """
        if length < 0:
            raise ValueError("Negative length")
        bytes_ = self._read_bytes(length)
        if padded:
            bytes_ = self._remove_padding(bytes_)
        return self._decode_ansi(bytes_)

    def get_encoded_string(self) -> str:
        """
        Reads an encoded string from the input data.

        Returns:
            str: A decoded string.
        """
        bytes_ = self._read_bytes(self.remaining)
        decode_string(bytes_)
        return self._decode_ansi(bytes_)

    def get_fixed_encoded_string(self, length: int, padded: bool = False) -> str:
        """
        Reads an encoded string with a fixed length from the input data.

        Args:
            length (int): The length of the string.
            padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

        Returns:
            str: A decoded string.

        Raises:
            ValueError: If the length is negative.
        """
        if length < 0:
            raise ValueError("Negative length")
        bytes_ = self._read_bytes(length)
        decode_string(bytes_)
        if padded:
            bytes_ = self._remove_padding(bytes_)
        return self._decode_ansi(bytes_)

    @property
    def chunked_reading_mode(self) -> bool:
        """
        bool: Gets or sets the chunked reading mode for the reader.

        In chunked reading mode:
        - The reader will treat `0xFF` bytes as the end of the current chunk.
        - `next_chunk()` can be called to move to the next chunk.
        """
        return self._chunked_reading_mode

    @chunked_reading_mode.setter
    def chunked_reading_mode(self, chunked_reading_mode: bool) -> None:
        self._chunked_reading_mode = chunked_reading_mode
        if self._next_break == -1:
            self._next_break = self._find_next_break_index()

    @property
    def remaining(self) -> int:
        """
        int: If chunked reading mode is enabled, gets the number of bytes remaining in the current
            chunk. Otherwise, gets the total number of bytes remaining in the input data.
        """
        if self.chunked_reading_mode:
            return self._next_break - min(self.position, self._next_break)
        else:
            return len(self._data) - self.position

    def next_chunk(self) -> None:
        """
        Moves the reader position to the start of the next chunk in the input data.

        Raises:
            RuntimeError: If not in chunked reading mode.
        """
        if not self.chunked_reading_mode:
            raise RuntimeError("Not in chunked reading mode.")

        self._position = self._next_break
        if self._position < len(self._data):
            # Skip the break byte
            self._position += 1

        self._chunk_start = self._position
        self._next_break = self._find_next_break_index()

    @property
    def position(self) -> int:
        """
        int: Gets the current position in the input data.
        """
        return self._position

    def _read_byte(self) -> int:
        """
        Reads a raw byte from the input data.

        Returns:
            int: A raw byte.
        """
        if self.remaining > 0:
            byte = self._data[self._position]
            self._position += 1
            return byte
        return 0

    def _read_bytes(self, length) -> bytearray:
        """
        Reads an array of raw bytes from the input data.

        Args:
            length (int): The number of bytes to read.

        Returns:
            bytearray: An array of raw bytes.
        """
        length = min(length, self.remaining)

        result = bytearray(self._data[self._position : self._position + length])
        self._position += length

        return result

    def _find_next_break_index(self) -> int:
        """
        Finds the index of the next break byte (0xFF) in the input data.

        Returns:
            int: The index of the next break byte, or the length of the data if not found.
        """
        for i in range(self._chunk_start, len(self._data)):
            if self._data[i] == 0xFF:
                return i
        return len(self._data)

    @staticmethod
    def _remove_padding(array: bytearray) -> bytearray:
        """
        Removes padding (trailing 0xFF bytes) from a sequence of bytes.

        Args:
            array (bytearray): The sequence of bytes.

        Returns:
            bytearray: The bytes without padding.
        """
        padding_start = array.find(bytes([0xFF]))
        if padding_start != -1:
            return array[:padding_start]
        return array

    @staticmethod
    def _decode_ansi(bytes: bytearray) -> str:
        """
        Decodes windows-1252 bytes to a string.

        Args:
            bytes (bytearray): The sequence of bytes to decode.

        Returns:
            str: The decoded string.
        """
        return bytes.decode('windows-1252', 'replace')

chunked_reading_mode: bool property writable

bool: Gets or sets the chunked reading mode for the reader.

In chunked reading mode: - The reader will treat 0xFF bytes as the end of the current chunk. - next_chunk() can be called to move to the next chunk.

remaining: int property

If chunked reading mode is enabled, gets the number of bytes remaining in the current

chunk. Otherwise, gets the total number of bytes remaining in the input data.

position: int property

int: Gets the current position in the input data.

__init__(data)

Creates a new EoReader instance for the specified data.

Parameters:

Name Type Description Default
data bytes

The byte array containing the input data.

required
Source code in src/eolib/data/eo_reader.py
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(self, data: bytes):
    """
    Creates a new `EoReader` instance for the specified data.

    Args:
        data (bytes): The byte array containing the input data.
    """
    self._data = memoryview(data)
    self._position = 0
    self._chunked_reading_mode = False
    self._chunk_start = 0
    self._next_break = -1

slice(index=None, length=None)

Creates a new EoReader whose input data is a shared subsequence of this reader's data.

The input data of the new reader will start at position index in this reader and contain up to length bytes. The two reader's position and chunked reading mode will be independent.

The new reader's position will be zero, and its chunked reading mode will be false.

Parameters:

Name Type Description Default
index int

The position in this reader at which the data of the new reader will start; must be non-negative. Defaults to the current reader position.

None
length int

The length of the shared subsequence of data to supply to the new reader; must be non-negative. Defaults to the length of the remaining data starting from index.

None

Returns:

Name Type Description
EoReader EoReader

The new reader.

Raises:

Type Description
ValueError

If index or length is negative.

Source code in src/eolib/data/eo_reader.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def slice(self, index: Optional[int] = None, length: Optional[int] = None) -> "EoReader":
    """
    Creates a new `EoReader` whose input data is a shared subsequence of this reader's
    data.

    The input data of the new reader will start at position `index` in this reader and contain
    up to `length` bytes. The two reader's position and chunked reading mode will be
    independent.

    The new reader's position will be zero, and its chunked reading mode will be false.

    Args:
        index (int, optional): The position in this reader at which the data of the new reader
            will start; must be non-negative. Defaults to the current reader position.
        length (int, optional): The length of the shared subsequence of data to supply to the
            new reader; must be non-negative. Defaults to the length of the remaining data
            starting from `index`.

    Returns:
        EoReader: The new reader.

    Raises:
        ValueError: If `index` or `length` is negative.
    """
    if index is None:
        index = self.position
    if length is None:
        length = max(0, len(self._data) - index)

    if index < 0:
        raise ValueError(f"negative index: {index}")

    if length < 0:
        raise ValueError(f"negative length: {length}")

    begin = max(0, min(len(self._data), index))
    end = begin + min(len(self._data) - begin, length)

    return EoReader(self._data[begin:end])

get_byte()

Reads a raw byte from the input data.

Returns:

Name Type Description
int int

A raw byte.

Source code in src/eolib/data/eo_reader.py
76
77
78
79
80
81
82
83
def get_byte(self) -> int:
    """
    Reads a raw byte from the input data.

    Returns:
        int: A raw byte.
    """
    return self._read_byte()

get_bytes(length)

Reads an array of raw bytes from the input data.

Parameters:

Name Type Description Default
length int

The number of bytes to read.

required

Returns:

Name Type Description
bytearray bytearray

An array of raw bytes.

Source code in src/eolib/data/eo_reader.py
85
86
87
88
89
90
91
92
93
94
95
def get_bytes(self, length: int) -> bytearray:
    """
    Reads an array of raw bytes from the input data.

    Args:
        length (int): The number of bytes to read.

    Returns:
        bytearray: An array of raw bytes.
    """
    return self._read_bytes(length)

get_char()

Reads an encoded 1-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 1-byte integer.

Source code in src/eolib/data/eo_reader.py
 97
 98
 99
100
101
102
103
104
def get_char(self) -> int:
    """
    Reads an encoded 1-byte integer from the input data.

    Returns:
        int: A decoded 1-byte integer.
    """
    return decode_number(self._read_bytes(1))

get_short()

Reads an encoded 2-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 2-byte integer.

Source code in src/eolib/data/eo_reader.py
106
107
108
109
110
111
112
113
def get_short(self) -> int:
    """
    Reads an encoded 2-byte integer from the input data.

    Returns:
        int: A decoded 2-byte integer.
    """
    return decode_number(self._read_bytes(2))

get_three()

Reads an encoded 3-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 3-byte integer.

Source code in src/eolib/data/eo_reader.py
115
116
117
118
119
120
121
122
def get_three(self) -> int:
    """
    Reads an encoded 3-byte integer from the input data.

    Returns:
        int: A decoded 3-byte integer.
    """
    return decode_number(self._read_bytes(3))

get_int()

Reads an encoded 4-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 4-byte integer.

Source code in src/eolib/data/eo_reader.py
124
125
126
127
128
129
130
131
def get_int(self) -> int:
    """
    Reads an encoded 4-byte integer from the input data.

    Returns:
        int: A decoded 4-byte integer.
    """
    return decode_number(self._read_bytes(4))

get_string()

Reads a string from the input data.

Returns:

Name Type Description
str str

A string.

Source code in src/eolib/data/eo_reader.py
133
134
135
136
137
138
139
140
141
def get_string(self) -> str:
    """
    Reads a string from the input data.

    Returns:
        str: A string.
    """
    string_bytes = self._read_bytes(self.remaining)
    return self._decode_ansi(string_bytes)

get_fixed_string(length, padded=False)

Reads a string with a fixed length from the input data.

Parameters:

Name Type Description Default
length int

The length of the string.

required
padded bool

True if the string is padded with trailing 0xFF bytes.

False

Returns:

Name Type Description
str str

A decoded string.

Raises:

Type Description
ValueError

If the length is negative.

Source code in src/eolib/data/eo_reader.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def get_fixed_string(self, length: int, padded: bool = False) -> str:
    """
    Reads a string with a fixed length from the input data.

    Args:
        length (int): The length of the string.
        padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

    Returns:
        str: A decoded string.

    Raises:
        ValueError: If the length is negative.
    """
    if length < 0:
        raise ValueError("Negative length")
    bytes_ = self._read_bytes(length)
    if padded:
        bytes_ = self._remove_padding(bytes_)
    return self._decode_ansi(bytes_)

get_encoded_string()

Reads an encoded string from the input data.

Returns:

Name Type Description
str str

A decoded string.

Source code in src/eolib/data/eo_reader.py
164
165
166
167
168
169
170
171
172
173
def get_encoded_string(self) -> str:
    """
    Reads an encoded string from the input data.

    Returns:
        str: A decoded string.
    """
    bytes_ = self._read_bytes(self.remaining)
    decode_string(bytes_)
    return self._decode_ansi(bytes_)

get_fixed_encoded_string(length, padded=False)

Reads an encoded string with a fixed length from the input data.

Parameters:

Name Type Description Default
length int

The length of the string.

required
padded bool

True if the string is padded with trailing 0xFF bytes.

False

Returns:

Name Type Description
str str

A decoded string.

Raises:

Type Description
ValueError

If the length is negative.

Source code in src/eolib/data/eo_reader.py
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
def get_fixed_encoded_string(self, length: int, padded: bool = False) -> str:
    """
    Reads an encoded string with a fixed length from the input data.

    Args:
        length (int): The length of the string.
        padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

    Returns:
        str: A decoded string.

    Raises:
        ValueError: If the length is negative.
    """
    if length < 0:
        raise ValueError("Negative length")
    bytes_ = self._read_bytes(length)
    decode_string(bytes_)
    if padded:
        bytes_ = self._remove_padding(bytes_)
    return self._decode_ansi(bytes_)

next_chunk()

Moves the reader position to the start of the next chunk in the input data.

Raises:

Type Description
RuntimeError

If not in chunked reading mode.

Source code in src/eolib/data/eo_reader.py
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def next_chunk(self) -> None:
    """
    Moves the reader position to the start of the next chunk in the input data.

    Raises:
        RuntimeError: If not in chunked reading mode.
    """
    if not self.chunked_reading_mode:
        raise RuntimeError("Not in chunked reading mode.")

    self._position = self._next_break
    if self._position < len(self._data):
        # Skip the break byte
        self._position += 1

    self._chunk_start = self._position
    self._next_break = self._find_next_break_index()

EcfRecord

Record of Class data in an Endless Class File

Source code in src/eolib/protocol/_generated/pub/ecf_record.py
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class EcfRecord:
    """
    Record of Class data in an Endless Class File
    """
    _byte_size: int = 0
    _name_length: int
    _name: str
    _parent_type: int
    _stat_group: int
    _str: int
    _intl: int
    _wis: int
    _agi: int
    _con: int
    _cha: int

    def __init__(self, *, name: str, parent_type: int, stat_group: int, str: int, intl: int, wis: int, agi: int, con: int, cha: int):
        """
        Create a new instance of EcfRecord.

        Args:
            name (str): (Length must be 252 or less.)
            parent_type (int): (Value range is 0-252.)
            stat_group (int): (Value range is 0-252.)
            str (int): (Value range is 0-64008.)
            intl (int): (Value range is 0-64008.)
            wis (int): (Value range is 0-64008.)
            agi (int): (Value range is 0-64008.)
            con (int): (Value range is 0-64008.)
            cha (int): (Value range is 0-64008.)
        """
        self._name = name
        self._name_length = len(self._name)
        self._parent_type = parent_type
        self._stat_group = stat_group
        self._str = str
        self._intl = intl
        self._wis = wis
        self._agi = agi
        self._con = con
        self._cha = cha

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def name(self) -> str:
        return self._name

    @property
    def parent_type(self) -> int:
        return self._parent_type

    @property
    def stat_group(self) -> int:
        return self._stat_group

    @property
    def str(self) -> int:
        return self._str

    @property
    def intl(self) -> int:
        return self._intl

    @property
    def wis(self) -> int:
        return self._wis

    @property
    def agi(self) -> int:
        return self._agi

    @property
    def con(self) -> int:
        return self._con

    @property
    def cha(self) -> int:
        return self._cha

    @staticmethod
    def serialize(writer: EoWriter, data: "EcfRecord") -> None:
        """
        Serializes an instance of `EcfRecord` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (EcfRecord): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            if data._name_length is None:
                raise SerializationError("name_length must be provided.")
            writer.add_char(data._name_length)
            if data._name is None:
                raise SerializationError("name must be provided.")
            if len(data._name) > 252:
                raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
            writer.add_fixed_string(data._name, data._name_length, False)
            if data._parent_type is None:
                raise SerializationError("parent_type must be provided.")
            writer.add_char(data._parent_type)
            if data._stat_group is None:
                raise SerializationError("stat_group must be provided.")
            writer.add_char(data._stat_group)
            if data._str is None:
                raise SerializationError("str must be provided.")
            writer.add_short(data._str)
            if data._intl is None:
                raise SerializationError("intl must be provided.")
            writer.add_short(data._intl)
            if data._wis is None:
                raise SerializationError("wis must be provided.")
            writer.add_short(data._wis)
            if data._agi is None:
                raise SerializationError("agi must be provided.")
            writer.add_short(data._agi)
            if data._con is None:
                raise SerializationError("con must be provided.")
            writer.add_short(data._con)
            if data._cha is None:
                raise SerializationError("cha must be provided.")
            writer.add_short(data._cha)
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "EcfRecord":
        """
        Deserializes an instance of `EcfRecord` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            EcfRecord: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            name_length = reader.get_char()
            name = reader.get_fixed_string(name_length, False)
            parent_type = reader.get_char()
            stat_group = reader.get_char()
            str = reader.get_short()
            intl = reader.get_short()
            wis = reader.get_short()
            agi = reader.get_short()
            con = reader.get_short()
            cha = reader.get_short()
            result = EcfRecord(name=name, parent_type=parent_type, stat_group=stat_group, str=str, intl=intl, wis=wis, agi=agi, con=con, cha=cha)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"EcfRecord(byte_size={repr(self._byte_size)}, name={repr(self._name)}, parent_type={repr(self._parent_type)}, stat_group={repr(self._stat_group)}, str={repr(self._str)}, intl={repr(self._intl)}, wis={repr(self._wis)}, agi={repr(self._agi)}, con={repr(self._con)}, cha={repr(self._cha)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

name: str property

parent_type: int property

stat_group: int property

str: int property

intl: int property

wis: int property

agi: int property

con: int property

cha: int property

__init__(*, name, parent_type, stat_group, str, intl, wis, agi, con, cha)

Create a new instance of EcfRecord.

Parameters:

Name Type Description Default
name str

(Length must be 252 or less.)

required
parent_type int

(Value range is 0-252.)

required
stat_group int

(Value range is 0-252.)

required
str int

(Value range is 0-64008.)

required
intl int

(Value range is 0-64008.)

required
wis int

(Value range is 0-64008.)

required
agi int

(Value range is 0-64008.)

required
con int

(Value range is 0-64008.)

required
cha int

(Value range is 0-64008.)

required
Source code in src/eolib/protocol/_generated/pub/ecf_record.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def __init__(self, *, name: str, parent_type: int, stat_group: int, str: int, intl: int, wis: int, agi: int, con: int, cha: int):
    """
    Create a new instance of EcfRecord.

    Args:
        name (str): (Length must be 252 or less.)
        parent_type (int): (Value range is 0-252.)
        stat_group (int): (Value range is 0-252.)
        str (int): (Value range is 0-64008.)
        intl (int): (Value range is 0-64008.)
        wis (int): (Value range is 0-64008.)
        agi (int): (Value range is 0-64008.)
        con (int): (Value range is 0-64008.)
        cha (int): (Value range is 0-64008.)
    """
    self._name = name
    self._name_length = len(self._name)
    self._parent_type = parent_type
    self._stat_group = stat_group
    self._str = str
    self._intl = intl
    self._wis = wis
    self._agi = agi
    self._con = con
    self._cha = cha

serialize(writer, data) staticmethod

Serializes an instance of EcfRecord to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data EcfRecord

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/ecf_record.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@staticmethod
def serialize(writer: EoWriter, data: "EcfRecord") -> None:
    """
    Serializes an instance of `EcfRecord` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (EcfRecord): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        if data._name_length is None:
            raise SerializationError("name_length must be provided.")
        writer.add_char(data._name_length)
        if data._name is None:
            raise SerializationError("name must be provided.")
        if len(data._name) > 252:
            raise SerializationError(f"Expected length of name to be 252 or less, got {len(data._name)}.")
        writer.add_fixed_string(data._name, data._name_length, False)
        if data._parent_type is None:
            raise SerializationError("parent_type must be provided.")
        writer.add_char(data._parent_type)
        if data._stat_group is None:
            raise SerializationError("stat_group must be provided.")
        writer.add_char(data._stat_group)
        if data._str is None:
            raise SerializationError("str must be provided.")
        writer.add_short(data._str)
        if data._intl is None:
            raise SerializationError("intl must be provided.")
        writer.add_short(data._intl)
        if data._wis is None:
            raise SerializationError("wis must be provided.")
        writer.add_short(data._wis)
        if data._agi is None:
            raise SerializationError("agi must be provided.")
        writer.add_short(data._agi)
        if data._con is None:
            raise SerializationError("con must be provided.")
        writer.add_short(data._con)
        if data._cha is None:
            raise SerializationError("cha must be provided.")
        writer.add_short(data._cha)
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of EcfRecord from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
EcfRecord EcfRecord

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/ecf_record.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@staticmethod
def deserialize(reader: EoReader) -> "EcfRecord":
    """
    Deserializes an instance of `EcfRecord` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        EcfRecord: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        name_length = reader.get_char()
        name = reader.get_fixed_string(name_length, False)
        parent_type = reader.get_char()
        stat_group = reader.get_char()
        str = reader.get_short()
        intl = reader.get_short()
        wis = reader.get_short()
        agi = reader.get_short()
        con = reader.get_short()
        cha = reader.get_short()
        result = EcfRecord(name=name, parent_type=parent_type, stat_group=stat_group, str=str, intl=intl, wis=wis, agi=agi, con=con, cha=cha)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Ecf

Endless Class File

Source code in src/eolib/protocol/_generated/pub/ecf.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
class Ecf:
    """
    Endless Class File
    """
    _byte_size: int = 0
    _rid: tuple[int, ...]
    _total_classes_count: int
    _version: int
    _classes: tuple[EcfRecord, ...]

    def __init__(self, *, rid: Iterable[int], total_classes_count: int, version: int, classes: Iterable[EcfRecord]):
        """
        Create a new instance of Ecf.

        Args:
            rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
            total_classes_count (int): (Value range is 0-64008.)
            version (int): (Value range is 0-252.)
            classes (Iterable[EcfRecord]): 
        """
        self._rid = tuple(rid)
        self._total_classes_count = total_classes_count
        self._version = version
        self._classes = tuple(classes)

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def rid(self) -> tuple[int, ...]:
        return self._rid

    @property
    def total_classes_count(self) -> int:
        return self._total_classes_count

    @property
    def version(self) -> int:
        return self._version

    @property
    def classes(self) -> tuple[EcfRecord, ...]:
        return self._classes

    @staticmethod
    def serialize(writer: EoWriter, data: "Ecf") -> None:
        """
        Serializes an instance of `Ecf` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Ecf): The data to serialize.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            writer.add_fixed_string("ECF", 3, False)
            if data._rid is None:
                raise SerializationError("rid must be provided.")
            if len(data._rid) != 2:
                raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
            for i in range(2):
                writer.add_short(data._rid[i])
            if data._total_classes_count is None:
                raise SerializationError("total_classes_count must be provided.")
            writer.add_short(data._total_classes_count)
            if data._version is None:
                raise SerializationError("version must be provided.")
            writer.add_char(data._version)
            if data._classes is None:
                raise SerializationError("classes must be provided.")
            for i in range(len(data._classes)):
                EcfRecord.serialize(writer, data._classes[i])
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @staticmethod
    def deserialize(reader: EoReader) -> "Ecf":
        """
        Deserializes an instance of `Ecf` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Ecf: The data to serialize.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            rid = []
            for i in range(2):
                rid.append(reader.get_short())
            total_classes_count = reader.get_short()
            version = reader.get_char()
            classes = []
            while reader.remaining > 0:
                classes.append(EcfRecord.deserialize(reader))
            result = Ecf(rid=rid, total_classes_count=total_classes_count, version=version, classes=classes)
            result._byte_size = reader.position - reader_start_position
            return result
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Ecf(byte_size={repr(self._byte_size)}, rid={repr(self._rid)}, total_classes_count={repr(self._total_classes_count)}, version={repr(self._version)}, classes={repr(self._classes)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

rid: tuple[int, ...] property

total_classes_count: int property

version: int property

classes: tuple[EcfRecord, ...] property

__init__(*, rid, total_classes_count, version, classes)

Create a new instance of Ecf.

Parameters:

Name Type Description Default
rid Iterable[int]

(Length must be 2.) (Element value range is 0-64008.)

required
total_classes_count int

(Value range is 0-64008.)

required
version int

(Value range is 0-252.)

required
classes Iterable[EcfRecord]
required
Source code in src/eolib/protocol/_generated/pub/ecf.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self, *, rid: Iterable[int], total_classes_count: int, version: int, classes: Iterable[EcfRecord]):
    """
    Create a new instance of Ecf.

    Args:
        rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
        total_classes_count (int): (Value range is 0-64008.)
        version (int): (Value range is 0-252.)
        classes (Iterable[EcfRecord]): 
    """
    self._rid = tuple(rid)
    self._total_classes_count = total_classes_count
    self._version = version
    self._classes = tuple(classes)

serialize(writer, data) staticmethod

Serializes an instance of Ecf to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Ecf

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/ecf.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@staticmethod
def serialize(writer: EoWriter, data: "Ecf") -> None:
    """
    Serializes an instance of `Ecf` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Ecf): The data to serialize.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        writer.add_fixed_string("ECF", 3, False)
        if data._rid is None:
            raise SerializationError("rid must be provided.")
        if len(data._rid) != 2:
            raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
        for i in range(2):
            writer.add_short(data._rid[i])
        if data._total_classes_count is None:
            raise SerializationError("total_classes_count must be provided.")
        writer.add_short(data._total_classes_count)
        if data._version is None:
            raise SerializationError("version must be provided.")
        writer.add_char(data._version)
        if data._classes is None:
            raise SerializationError("classes must be provided.")
        for i in range(len(data._classes)):
            EcfRecord.serialize(writer, data._classes[i])
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

deserialize(reader) staticmethod

Deserializes an instance of Ecf from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Ecf 'Ecf'

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/ecf.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@staticmethod
def deserialize(reader: EoReader) -> "Ecf":
    """
    Deserializes an instance of `Ecf` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Ecf: The data to serialize.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        rid = []
        for i in range(2):
            rid.append(reader.get_short())
        total_classes_count = reader.get_short()
        version = reader.get_char()
        classes = []
        while reader.remaining > 0:
            classes.append(EcfRecord.deserialize(reader))
        result = Ecf(rid=rid, total_classes_count=total_classes_count, version=version, classes=classes)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode