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
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
class EsfRecord:
    """
    Record of Skill data in an Endless Skill File
    """
    _byte_size: int = 0
    _name_length: int = None # type: ignore [assignment]
    _chant_length: int = None # type: ignore [assignment]
    _name: str = None # type: ignore [assignment]
    _chant: str = None # type: ignore [assignment]
    _icon_id: int = None # type: ignore [assignment]
    _graphic_id: int = None # type: ignore [assignment]
    _tp_cost: int = None # type: ignore [assignment]
    _sp_cost: int = None # type: ignore [assignment]
    _cast_time: int = None # type: ignore [assignment]
    _nature: SkillNature = None # type: ignore [assignment]
    _type: SkillType = None # type: ignore [assignment]
    _element: Element = None # type: ignore [assignment]
    _element_power: int = None # type: ignore [assignment]
    _target_restrict: SkillTargetRestrict = None # type: ignore [assignment]
    _target_type: SkillTargetType = None # type: ignore [assignment]
    _target_time: int = None # type: ignore [assignment]
    _max_skill_level: int = None # type: ignore [assignment]
    _min_damage: int = None # type: ignore [assignment]
    _max_damage: int = None # type: ignore [assignment]
    _accuracy: int = None # type: ignore [assignment]
    _evade: int = None # type: ignore [assignment]
    _armor: int = None # type: ignore [assignment]
    _return_damage: int = None # type: ignore [assignment]
    _hp_heal: int = None # type: ignore [assignment]
    _tp_heal: int = None # type: ignore [assignment]
    _sp_heal: int = None # type: ignore [assignment]
    _str: int = None # type: ignore [assignment]
    _intl: int = None # type: ignore [assignment]
    _wis: int = None # type: ignore [assignment]
    _agi: int = None # type: ignore [assignment]
    _con: int = None # type: ignore [assignment]
    _cha: int = None # type: ignore [assignment]

    @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:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._name

    @name.setter
    def name(self, name: str) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._name = name
        self._name_length = len(self._name)

    @property
    def chant(self) -> str:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._chant

    @chant.setter
    def chant(self, chant: str) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._chant = chant
        self._chant_length = len(self._chant)

    @property
    def icon_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._icon_id

    @icon_id.setter
    def icon_id(self, icon_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._icon_id = icon_id

    @property
    def graphic_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._graphic_id

    @graphic_id.setter
    def graphic_id(self, graphic_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._graphic_id = graphic_id

    @property
    def tp_cost(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._tp_cost

    @tp_cost.setter
    def tp_cost(self, tp_cost: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._tp_cost = tp_cost

    @property
    def sp_cost(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._sp_cost

    @sp_cost.setter
    def sp_cost(self, sp_cost: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._sp_cost = sp_cost

    @property
    def cast_time(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._cast_time

    @cast_time.setter
    def cast_time(self, cast_time: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._cast_time = cast_time

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

    @nature.setter
    def nature(self, nature: SkillNature) -> None:
        self._nature = nature

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

    @type.setter
    def type(self, type: SkillType) -> None:
        self._type = type

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

    @element.setter
    def element(self, element: Element) -> None:
        self._element = element

    @property
    def element_power(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._element_power

    @element_power.setter
    def element_power(self, element_power: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._element_power = element_power

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

    @target_restrict.setter
    def target_restrict(self, target_restrict: SkillTargetRestrict) -> None:
        self._target_restrict = target_restrict

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

    @target_type.setter
    def target_type(self, target_type: SkillTargetType) -> None:
        self._target_type = target_type

    @property
    def target_time(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._target_time

    @target_time.setter
    def target_time(self, target_time: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._target_time = target_time

    @property
    def max_skill_level(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._max_skill_level

    @max_skill_level.setter
    def max_skill_level(self, max_skill_level: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._max_skill_level = max_skill_level

    @property
    def min_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._min_damage

    @min_damage.setter
    def min_damage(self, min_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._min_damage = min_damage

    @property
    def max_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._max_damage

    @max_damage.setter
    def max_damage(self, max_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._max_damage = max_damage

    @property
    def accuracy(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._accuracy

    @accuracy.setter
    def accuracy(self, accuracy: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._accuracy = accuracy

    @property
    def evade(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._evade

    @evade.setter
    def evade(self, evade: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._evade = evade

    @property
    def armor(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._armor

    @armor.setter
    def armor(self, armor: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._armor = armor

    @property
    def return_damage(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._return_damage

    @return_damage.setter
    def return_damage(self, return_damage: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._return_damage = return_damage

    @property
    def hp_heal(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._hp_heal

    @hp_heal.setter
    def hp_heal(self, hp_heal: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._hp_heal = hp_heal

    @property
    def tp_heal(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._tp_heal

    @tp_heal.setter
    def tp_heal(self, tp_heal: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._tp_heal = tp_heal

    @property
    def sp_heal(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._sp_heal

    @sp_heal.setter
    def sp_heal(self, sp_heal: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._sp_heal = sp_heal

    @property
    def str(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._str

    @str.setter
    def str(self, str: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._str = str

    @property
    def intl(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._intl

    @intl.setter
    def intl(self, intl: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._intl = intl

    @property
    def wis(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._wis

    @wis.setter
    def wis(self, wis: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._wis = wis

    @property
    def agi(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._agi

    @agi.setter
    def agi(self, agi: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._agi = agi

    @property
    def con(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._con

    @con.setter
    def con(self, con: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._con = con

    @property
    def cha(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._cha

    @cha.setter
    def cha(self, cha: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._cha = 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.
        """
        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)

    @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.
        """
        data: EsfRecord = EsfRecord()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._name_length = reader.get_char()
            data._chant_length = reader.get_char()
            data._name = reader.get_fixed_string(data._name_length, False)
            data._chant = reader.get_fixed_string(data._chant_length, False)
            data._icon_id = reader.get_short()
            data._graphic_id = reader.get_short()
            data._tp_cost = reader.get_short()
            data._sp_cost = reader.get_short()
            data._cast_time = reader.get_char()
            data._nature = SkillNature(reader.get_char())
            reader.get_char()
            data._type = SkillType(reader.get_three())
            data._element = Element(reader.get_char())
            data._element_power = reader.get_short()
            data._target_restrict = SkillTargetRestrict(reader.get_char())
            data._target_type = SkillTargetType(reader.get_char())
            data._target_time = reader.get_char()
            reader.get_char()
            data._max_skill_level = reader.get_short()
            data._min_damage = reader.get_short()
            data._max_damage = reader.get_short()
            data._accuracy = reader.get_short()
            data._evade = reader.get_short()
            data._armor = reader.get_short()
            data._return_damage = reader.get_char()
            data._hp_heal = reader.get_short()
            data._tp_heal = reader.get_short()
            data._sp_heal = reader.get_char()
            data._str = reader.get_short()
            data._intl = reader.get_short()
            data._wis = reader.get_short()
            data._agi = reader.get_short()
            data._con = reader.get_short()
            data._cha = reader.get_short()
            data._byte_size = reader.position - reader_start_position
            return data
        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 writable

Note
  • Length must be 252 or less.

chant: str property writable

Note
  • Length must be 252 or less.

icon_id: int property writable

Note
  • Value range is 0-64008.

graphic_id: int property writable

Note
  • Value range is 0-64008.

tp_cost: int property writable

Note
  • Value range is 0-64008.

sp_cost: int property writable

Note
  • Value range is 0-64008.

cast_time: int property writable

Note
  • Value range is 0-252.

nature: SkillNature property writable

type: SkillType property writable

element: Element property writable

element_power: int property writable

Note
  • Value range is 0-64008.

target_restrict: SkillTargetRestrict property writable

target_type: SkillTargetType property writable

target_time: int property writable

Note
  • Value range is 0-252.

max_skill_level: int property writable

Note
  • Value range is 0-64008.

min_damage: int property writable

Note
  • Value range is 0-64008.

max_damage: int property writable

Note
  • Value range is 0-64008.

accuracy: int property writable

Note
  • Value range is 0-64008.

evade: int property writable

Note
  • Value range is 0-64008.

armor: int property writable

Note
  • Value range is 0-64008.

return_damage: int property writable

Note
  • Value range is 0-252.

hp_heal: int property writable

Note
  • Value range is 0-64008.

tp_heal: int property writable

Note
  • Value range is 0-64008.

sp_heal: int property writable

Note
  • Value range is 0-252.

str: int property writable

Note
  • Value range is 0-64008.

intl: int property writable

Note
  • Value range is 0-64008.

wis: int property writable

Note
  • Value range is 0-64008.

agi: int property writable

Note
  • Value range is 0-64008.

con: int property writable

Note
  • Value range is 0-64008.

cha: int property writable

Note
  • Value range is 0-64008.

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
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
@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.
    """
    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)

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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@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.
    """
    data: EsfRecord = EsfRecord()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._name_length = reader.get_char()
        data._chant_length = reader.get_char()
        data._name = reader.get_fixed_string(data._name_length, False)
        data._chant = reader.get_fixed_string(data._chant_length, False)
        data._icon_id = reader.get_short()
        data._graphic_id = reader.get_short()
        data._tp_cost = reader.get_short()
        data._sp_cost = reader.get_short()
        data._cast_time = reader.get_char()
        data._nature = SkillNature(reader.get_char())
        reader.get_char()
        data._type = SkillType(reader.get_three())
        data._element = Element(reader.get_char())
        data._element_power = reader.get_short()
        data._target_restrict = SkillTargetRestrict(reader.get_char())
        data._target_type = SkillTargetType(reader.get_char())
        data._target_time = reader.get_char()
        reader.get_char()
        data._max_skill_level = reader.get_short()
        data._min_damage = reader.get_short()
        data._max_damage = reader.get_short()
        data._accuracy = reader.get_short()
        data._evade = reader.get_short()
        data._armor = reader.get_short()
        data._return_damage = reader.get_char()
        data._hp_heal = reader.get_short()
        data._tp_heal = reader.get_short()
        data._sp_heal = reader.get_char()
        data._str = reader.get_short()
        data._intl = reader.get_short()
        data._wis = reader.get_short()
        data._agi = reader.get_short()
        data._con = reader.get_short()
        data._cha = reader.get_short()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Esf

Endless Skill File

Source code in src/eolib/protocol/_generated/pub/esf.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
class Esf:
    """
    Endless Skill File
    """
    _byte_size: int = 0
    _rid: list[int] = None # type: ignore [assignment]
    _total_skills_count: int = None # type: ignore [assignment]
    _version: int = None # type: ignore [assignment]
    _skills: list[EsfRecord] = None # type: ignore [assignment]

    @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) -> list[int]:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        return self._rid

    @rid.setter
    def rid(self, rid: list[int]) -> None:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        self._rid = rid

    @property
    def total_skills_count(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._total_skills_count

    @total_skills_count.setter
    def total_skills_count(self, total_skills_count: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._total_skills_count = total_skills_count

    @property
    def version(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._version

    @version.setter
    def version(self, version: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._version = version

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

    @skills.setter
    def skills(self, skills: list[EsfRecord]) -> None:
        self._skills = 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.
        """
        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])

    @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.
        """
        data: Esf = Esf()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            data._rid = []
            for i in range(2):
                data._rid.append(reader.get_short())
            data._total_skills_count = reader.get_short()
            data._version = reader.get_char()
            data._skills = []
            while reader.remaining > 0:
                data._skills.append(EsfRecord.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        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: list[int] property writable

Note
  • Length must be 2.
  • Element value range is 0-64008.

total_skills_count: int property writable

Note
  • Value range is 0-64008.

version: int property writable

Note
  • Value range is 0-252.

skills: list[EsfRecord] property writable

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
 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
@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.
    """
    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])

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
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
@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.
    """
    data: Esf = Esf()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        data._rid = []
        for i in range(2):
            data._rid.append(reader.get_short())
        data._total_skills_count = reader.get_short()
        data._version = reader.get_char()
        data._skills = []
        while reader.remaining > 0:
            data._skills.append(EsfRecord.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    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
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
class EnfRecord:
    """
    Record of NPC data in an Endless NPC File
    """
    _byte_size: int = 0
    _name_length: int = None # type: ignore [assignment]
    _name: str = None # type: ignore [assignment]
    _graphic_id: int = None # type: ignore [assignment]
    _race: int = None # type: ignore [assignment]
    _boss: bool = None # type: ignore [assignment]
    _child: bool = None # type: ignore [assignment]
    _type: NpcType = None # type: ignore [assignment]
    _behavior_id: int = None # type: ignore [assignment]
    _hp: int = None # type: ignore [assignment]
    _tp: int = None # type: ignore [assignment]
    _min_damage: int = None # type: ignore [assignment]
    _max_damage: int = None # type: ignore [assignment]
    _accuracy: int = None # type: ignore [assignment]
    _evade: int = None # type: ignore [assignment]
    _armor: int = None # type: ignore [assignment]
    _return_damage: int = None # type: ignore [assignment]
    _element: Element = None # type: ignore [assignment]
    _element_damage: int = None # type: ignore [assignment]
    _element_weakness: Element = None # type: ignore [assignment]
    _element_weakness_damage: int = None # type: ignore [assignment]
    _level: int = None # type: ignore [assignment]
    _experience: int = None # type: ignore [assignment]

    @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:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._name

    @name.setter
    def name(self, name: str) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._name = name
        self._name_length = len(self._name)

    @property
    def graphic_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._graphic_id

    @graphic_id.setter
    def graphic_id(self, graphic_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._graphic_id = graphic_id

    @property
    def race(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._race

    @race.setter
    def race(self, race: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._race = race

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

    @boss.setter
    def boss(self, boss: bool) -> None:
        self._boss = boss

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

    @child.setter
    def child(self, child: bool) -> None:
        self._child = child

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

    @type.setter
    def type(self, type: NpcType) -> None:
        self._type = type

    @property
    def behavior_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._behavior_id

    @behavior_id.setter
    def behavior_id(self, behavior_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._behavior_id = behavior_id

    @property
    def hp(self) -> int:
        """
        Note:
          - Value range is 0-16194276.
        """
        return self._hp

    @hp.setter
    def hp(self, hp: int) -> None:
        """
        Note:
          - Value range is 0-16194276.
        """
        self._hp = hp

    @property
    def tp(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._tp

    @tp.setter
    def tp(self, tp: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._tp = tp

    @property
    def min_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._min_damage

    @min_damage.setter
    def min_damage(self, min_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._min_damage = min_damage

    @property
    def max_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._max_damage

    @max_damage.setter
    def max_damage(self, max_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._max_damage = max_damage

    @property
    def accuracy(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._accuracy

    @accuracy.setter
    def accuracy(self, accuracy: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._accuracy = accuracy

    @property
    def evade(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._evade

    @evade.setter
    def evade(self, evade: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._evade = evade

    @property
    def armor(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._armor

    @armor.setter
    def armor(self, armor: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._armor = armor

    @property
    def return_damage(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._return_damage

    @return_damage.setter
    def return_damage(self, return_damage: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._return_damage = return_damage

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

    @element.setter
    def element(self, element: Element) -> None:
        self._element = element

    @property
    def element_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._element_damage

    @element_damage.setter
    def element_damage(self, element_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._element_damage = element_damage

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

    @element_weakness.setter
    def element_weakness(self, element_weakness: Element) -> None:
        self._element_weakness = element_weakness

    @property
    def element_weakness_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._element_weakness_damage

    @element_weakness_damage.setter
    def element_weakness_damage(self, element_weakness_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._element_weakness_damage = element_weakness_damage

    @property
    def level(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._level

    @level.setter
    def level(self, level: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._level = level

    @property
    def experience(self) -> int:
        """
        Note:
          - Value range is 0-16194276.
        """
        return self._experience

    @experience.setter
    def experience(self, experience: int) -> None:
        """
        Note:
          - Value range is 0-16194276.
        """
        self._experience = 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.
        """
        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)

    @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.
        """
        data: EnfRecord = EnfRecord()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._name_length = reader.get_char()
            data._name = reader.get_fixed_string(data._name_length, False)
            data._graphic_id = reader.get_short()
            data._race = reader.get_char()
            data._boss = reader.get_short() != 0
            data._child = reader.get_short() != 0
            data._type = NpcType(reader.get_short())
            data._behavior_id = reader.get_short()
            data._hp = reader.get_three()
            data._tp = reader.get_short()
            data._min_damage = reader.get_short()
            data._max_damage = reader.get_short()
            data._accuracy = reader.get_short()
            data._evade = reader.get_short()
            data._armor = reader.get_short()
            data._return_damage = reader.get_char()
            data._element = Element(reader.get_short())
            data._element_damage = reader.get_short()
            data._element_weakness = Element(reader.get_short())
            data._element_weakness_damage = reader.get_short()
            data._level = reader.get_char()
            data._experience = reader.get_three()
            data._byte_size = reader.position - reader_start_position
            return data
        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 writable

Note
  • Length must be 252 or less.

graphic_id: int property writable

Note
  • Value range is 0-64008.

race: int property writable

Note
  • Value range is 0-252.

boss: bool property writable

child: bool property writable

type: NpcType property writable

behavior_id: int property writable

Note
  • Value range is 0-64008.

hp: int property writable

Note
  • Value range is 0-16194276.

tp: int property writable

Note
  • Value range is 0-64008.

min_damage: int property writable

Note
  • Value range is 0-64008.

max_damage: int property writable

Note
  • Value range is 0-64008.

accuracy: int property writable

Note
  • Value range is 0-64008.

evade: int property writable

Note
  • Value range is 0-64008.

armor: int property writable

Note
  • Value range is 0-64008.

return_damage: int property writable

Note
  • Value range is 0-252.

element: Element property writable

element_damage: int property writable

Note
  • Value range is 0-64008.

element_weakness: Element property writable

element_weakness_damage: int property writable

Note
  • Value range is 0-64008.

level: int property writable

Note
  • Value range is 0-252.

experience: int property writable

Note
  • Value range is 0-16194276.

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
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
@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.
    """
    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)

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
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
@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.
    """
    data: EnfRecord = EnfRecord()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._name_length = reader.get_char()
        data._name = reader.get_fixed_string(data._name_length, False)
        data._graphic_id = reader.get_short()
        data._race = reader.get_char()
        data._boss = reader.get_short() != 0
        data._child = reader.get_short() != 0
        data._type = NpcType(reader.get_short())
        data._behavior_id = reader.get_short()
        data._hp = reader.get_three()
        data._tp = reader.get_short()
        data._min_damage = reader.get_short()
        data._max_damage = reader.get_short()
        data._accuracy = reader.get_short()
        data._evade = reader.get_short()
        data._armor = reader.get_short()
        data._return_damage = reader.get_char()
        data._element = Element(reader.get_short())
        data._element_damage = reader.get_short()
        data._element_weakness = Element(reader.get_short())
        data._element_weakness_damage = reader.get_short()
        data._level = reader.get_char()
        data._experience = reader.get_three()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Enf

Endless NPC File

Source code in src/eolib/protocol/_generated/pub/enf.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
class Enf:
    """
    Endless NPC File
    """
    _byte_size: int = 0
    _rid: list[int] = None # type: ignore [assignment]
    _total_npcs_count: int = None # type: ignore [assignment]
    _version: int = None # type: ignore [assignment]
    _npcs: list[EnfRecord] = None # type: ignore [assignment]

    @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) -> list[int]:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        return self._rid

    @rid.setter
    def rid(self, rid: list[int]) -> None:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        self._rid = rid

    @property
    def total_npcs_count(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._total_npcs_count

    @total_npcs_count.setter
    def total_npcs_count(self, total_npcs_count: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._total_npcs_count = total_npcs_count

    @property
    def version(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._version

    @version.setter
    def version(self, version: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._version = version

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

    @npcs.setter
    def npcs(self, npcs: list[EnfRecord]) -> None:
        self._npcs = 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.
        """
        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])

    @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.
        """
        data: Enf = Enf()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            data._rid = []
            for i in range(2):
                data._rid.append(reader.get_short())
            data._total_npcs_count = reader.get_short()
            data._version = reader.get_char()
            data._npcs = []
            while reader.remaining > 0:
                data._npcs.append(EnfRecord.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        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: list[int] property writable

Note
  • Length must be 2.
  • Element value range is 0-64008.

total_npcs_count: int property writable

Note
  • Value range is 0-64008.

version: int property writable

Note
  • Value range is 0-252.

npcs: list[EnfRecord] property writable

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
 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
@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.
    """
    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])

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
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
@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.
    """
    data: Enf = Enf()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        data._rid = []
        for i in range(2):
            data._rid.append(reader.get_short())
        data._total_npcs_count = reader.get_short()
        data._version = reader.get_char()
        data._npcs = []
        while reader.remaining > 0:
            data._npcs.append(EnfRecord.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    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
17
18
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, names=names, 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
17
18
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, names=names, 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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
class EifRecord:
    """
    Record of Item data in an Endless Item File
    """
    _byte_size: int = 0
    _name_length: int = None # type: ignore [assignment]
    _name: str = None # type: ignore [assignment]
    _graphic_id: int = None # type: ignore [assignment]
    _type: ItemType = None # type: ignore [assignment]
    _subtype: ItemSubtype = None # type: ignore [assignment]
    _special: ItemSpecial = None # type: ignore [assignment]
    _hp: int = None # type: ignore [assignment]
    _tp: int = None # type: ignore [assignment]
    _min_damage: int = None # type: ignore [assignment]
    _max_damage: int = None # type: ignore [assignment]
    _accuracy: int = None # type: ignore [assignment]
    _evade: int = None # type: ignore [assignment]
    _armor: int = None # type: ignore [assignment]
    _return_damage: int = None # type: ignore [assignment]
    _str: int = None # type: ignore [assignment]
    _intl: int = None # type: ignore [assignment]
    _wis: int = None # type: ignore [assignment]
    _agi: int = None # type: ignore [assignment]
    _con: int = None # type: ignore [assignment]
    _cha: int = None # type: ignore [assignment]
    _light_resistance: int = None # type: ignore [assignment]
    _dark_resistance: int = None # type: ignore [assignment]
    _earth_resistance: int = None # type: ignore [assignment]
    _air_resistance: int = None # type: ignore [assignment]
    _water_resistance: int = None # type: ignore [assignment]
    _fire_resistance: int = None # type: ignore [assignment]
    _spec1: int = None # type: ignore [assignment]
    _spec2: int = None # type: ignore [assignment]
    _spec3: int = None # type: ignore [assignment]
    _level_requirement: int = None # type: ignore [assignment]
    _class_requirement: int = None # type: ignore [assignment]
    _str_requirement: int = None # type: ignore [assignment]
    _int_requirement: int = None # type: ignore [assignment]
    _wis_requirement: int = None # type: ignore [assignment]
    _agi_requirement: int = None # type: ignore [assignment]
    _con_requirement: int = None # type: ignore [assignment]
    _cha_requirement: int = None # type: ignore [assignment]
    _element: Element = None # type: ignore [assignment]
    _element_damage: int = None # type: ignore [assignment]
    _weight: int = None # type: ignore [assignment]
    _size: ItemSize = None # type: ignore [assignment]

    @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:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._name

    @name.setter
    def name(self, name: str) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._name = name
        self._name_length = len(self._name)

    @property
    def graphic_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._graphic_id

    @graphic_id.setter
    def graphic_id(self, graphic_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._graphic_id = graphic_id

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

    @type.setter
    def type(self, type: ItemType) -> None:
        self._type = type

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

    @subtype.setter
    def subtype(self, subtype: ItemSubtype) -> None:
        self._subtype = subtype

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

    @special.setter
    def special(self, special: ItemSpecial) -> None:
        self._special = special

    @property
    def hp(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._hp

    @hp.setter
    def hp(self, hp: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._hp = hp

    @property
    def tp(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._tp

    @tp.setter
    def tp(self, tp: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._tp = tp

    @property
    def min_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._min_damage

    @min_damage.setter
    def min_damage(self, min_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._min_damage = min_damage

    @property
    def max_damage(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._max_damage

    @max_damage.setter
    def max_damage(self, max_damage: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._max_damage = max_damage

    @property
    def accuracy(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._accuracy

    @accuracy.setter
    def accuracy(self, accuracy: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._accuracy = accuracy

    @property
    def evade(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._evade

    @evade.setter
    def evade(self, evade: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._evade = evade

    @property
    def armor(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._armor

    @armor.setter
    def armor(self, armor: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._armor = armor

    @property
    def return_damage(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._return_damage

    @return_damage.setter
    def return_damage(self, return_damage: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._return_damage = return_damage

    @property
    def str(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._str

    @str.setter
    def str(self, str: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._str = str

    @property
    def intl(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._intl

    @intl.setter
    def intl(self, intl: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._intl = intl

    @property
    def wis(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._wis

    @wis.setter
    def wis(self, wis: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._wis = wis

    @property
    def agi(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._agi

    @agi.setter
    def agi(self, agi: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._agi = agi

    @property
    def con(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._con

    @con.setter
    def con(self, con: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._con = con

    @property
    def cha(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._cha

    @cha.setter
    def cha(self, cha: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._cha = cha

    @property
    def light_resistance(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._light_resistance

    @light_resistance.setter
    def light_resistance(self, light_resistance: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._light_resistance = light_resistance

    @property
    def dark_resistance(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._dark_resistance

    @dark_resistance.setter
    def dark_resistance(self, dark_resistance: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._dark_resistance = dark_resistance

    @property
    def earth_resistance(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._earth_resistance

    @earth_resistance.setter
    def earth_resistance(self, earth_resistance: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._earth_resistance = earth_resistance

    @property
    def air_resistance(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._air_resistance

    @air_resistance.setter
    def air_resistance(self, air_resistance: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._air_resistance = air_resistance

    @property
    def water_resistance(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._water_resistance

    @water_resistance.setter
    def water_resistance(self, water_resistance: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._water_resistance = water_resistance

    @property
    def fire_resistance(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._fire_resistance

    @fire_resistance.setter
    def fire_resistance(self, fire_resistance: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._fire_resistance = 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

        Note:
          - Value range is 0-16194276.
        """
        return self._spec1

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

        Note:
          - Value range is 0-16194276.
        """
        self._spec1 = spec1

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

        Note:
          - Value range is 0-252.
        """
        return self._spec2

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

        Note:
          - Value range is 0-252.
        """
        self._spec2 = spec2

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

        Note:
          - Value range is 0-252.
        """
        return self._spec3

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

        Note:
          - Value range is 0-252.
        """
        self._spec3 = spec3

    @property
    def level_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._level_requirement

    @level_requirement.setter
    def level_requirement(self, level_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._level_requirement = level_requirement

    @property
    def class_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._class_requirement

    @class_requirement.setter
    def class_requirement(self, class_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._class_requirement = class_requirement

    @property
    def str_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._str_requirement

    @str_requirement.setter
    def str_requirement(self, str_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._str_requirement = str_requirement

    @property
    def int_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._int_requirement

    @int_requirement.setter
    def int_requirement(self, int_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._int_requirement = int_requirement

    @property
    def wis_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._wis_requirement

    @wis_requirement.setter
    def wis_requirement(self, wis_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._wis_requirement = wis_requirement

    @property
    def agi_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._agi_requirement

    @agi_requirement.setter
    def agi_requirement(self, agi_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._agi_requirement = agi_requirement

    @property
    def con_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._con_requirement

    @con_requirement.setter
    def con_requirement(self, con_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._con_requirement = con_requirement

    @property
    def cha_requirement(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._cha_requirement

    @cha_requirement.setter
    def cha_requirement(self, cha_requirement: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._cha_requirement = cha_requirement

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

    @element.setter
    def element(self, element: Element) -> None:
        self._element = element

    @property
    def element_damage(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._element_damage

    @element_damage.setter
    def element_damage(self, element_damage: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._element_damage = element_damage

    @property
    def weight(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._weight

    @weight.setter
    def weight(self, weight: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._weight = weight

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

    @size.setter
    def size(self, size: ItemSize) -> None:
        self._size = 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.
        """
        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))

    @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.
        """
        data: EifRecord = EifRecord()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._name_length = reader.get_char()
            data._name = reader.get_fixed_string(data._name_length, False)
            data._graphic_id = reader.get_short()
            data._type = ItemType(reader.get_char())
            data._subtype = ItemSubtype(reader.get_char())
            data._special = ItemSpecial(reader.get_char())
            data._hp = reader.get_short()
            data._tp = reader.get_short()
            data._min_damage = reader.get_short()
            data._max_damage = reader.get_short()
            data._accuracy = reader.get_short()
            data._evade = reader.get_short()
            data._armor = reader.get_short()
            data._return_damage = reader.get_char()
            data._str = reader.get_char()
            data._intl = reader.get_char()
            data._wis = reader.get_char()
            data._agi = reader.get_char()
            data._con = reader.get_char()
            data._cha = reader.get_char()
            data._light_resistance = reader.get_char()
            data._dark_resistance = reader.get_char()
            data._earth_resistance = reader.get_char()
            data._air_resistance = reader.get_char()
            data._water_resistance = reader.get_char()
            data._fire_resistance = reader.get_char()
            data._spec1 = reader.get_three()
            data._spec2 = reader.get_char()
            data._spec3 = reader.get_char()
            data._level_requirement = reader.get_short()
            data._class_requirement = reader.get_short()
            data._str_requirement = reader.get_short()
            data._int_requirement = reader.get_short()
            data._wis_requirement = reader.get_short()
            data._agi_requirement = reader.get_short()
            data._con_requirement = reader.get_short()
            data._cha_requirement = reader.get_short()
            data._element = Element(reader.get_char())
            data._element_damage = reader.get_char()
            data._weight = reader.get_char()
            reader.get_char()
            data._size = ItemSize(reader.get_char())
            data._byte_size = reader.position - reader_start_position
            return data
        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 writable

Note
  • Length must be 252 or less.

graphic_id: int property writable

Note
  • Value range is 0-64008.

type: ItemType property writable

subtype: ItemSubtype property writable

special: ItemSpecial property writable

hp: int property writable

Note
  • Value range is 0-64008.

tp: int property writable

Note
  • Value range is 0-64008.

min_damage: int property writable

Note
  • Value range is 0-64008.

max_damage: int property writable

Note
  • Value range is 0-64008.

accuracy: int property writable

Note
  • Value range is 0-64008.

evade: int property writable

Note
  • Value range is 0-64008.

armor: int property writable

Note
  • Value range is 0-64008.

return_damage: int property writable

Note
  • Value range is 0-252.

str: int property writable

Note
  • Value range is 0-252.

intl: int property writable

Note
  • Value range is 0-252.

wis: int property writable

Note
  • Value range is 0-252.

agi: int property writable

Note
  • Value range is 0-252.

con: int property writable

Note
  • Value range is 0-252.

cha: int property writable

Note
  • Value range is 0-252.

light_resistance: int property writable

Note
  • Value range is 0-252.

dark_resistance: int property writable

Note
  • Value range is 0-252.

earth_resistance: int property writable

Note
  • Value range is 0-252.

air_resistance: int property writable

Note
  • Value range is 0-252.

water_resistance: int property writable

Note
  • Value range is 0-252.

fire_resistance: int property writable

Note
  • Value range is 0-252.

spec1: int property writable

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

Note
  • Value range is 0-16194276.

spec2: int property writable

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

Note
  • Value range is 0-252.

spec3: int property writable

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

Note
  • Value range is 0-252.

level_requirement: int property writable

Note
  • Value range is 0-64008.

class_requirement: int property writable

Note
  • Value range is 0-64008.

str_requirement: int property writable

Note
  • Value range is 0-64008.

int_requirement: int property writable

Note
  • Value range is 0-64008.

wis_requirement: int property writable

Note
  • Value range is 0-64008.

agi_requirement: int property writable

Note
  • Value range is 0-64008.

con_requirement: int property writable

Note
  • Value range is 0-64008.

cha_requirement: int property writable

Note
  • Value range is 0-64008.

element: Element property writable

element_damage: int property writable

Note
  • Value range is 0-252.

weight: int property writable

Note
  • Value range is 0-252.

size: ItemSize property writable

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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
@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.
    """
    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))

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
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
@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.
    """
    data: EifRecord = EifRecord()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._name_length = reader.get_char()
        data._name = reader.get_fixed_string(data._name_length, False)
        data._graphic_id = reader.get_short()
        data._type = ItemType(reader.get_char())
        data._subtype = ItemSubtype(reader.get_char())
        data._special = ItemSpecial(reader.get_char())
        data._hp = reader.get_short()
        data._tp = reader.get_short()
        data._min_damage = reader.get_short()
        data._max_damage = reader.get_short()
        data._accuracy = reader.get_short()
        data._evade = reader.get_short()
        data._armor = reader.get_short()
        data._return_damage = reader.get_char()
        data._str = reader.get_char()
        data._intl = reader.get_char()
        data._wis = reader.get_char()
        data._agi = reader.get_char()
        data._con = reader.get_char()
        data._cha = reader.get_char()
        data._light_resistance = reader.get_char()
        data._dark_resistance = reader.get_char()
        data._earth_resistance = reader.get_char()
        data._air_resistance = reader.get_char()
        data._water_resistance = reader.get_char()
        data._fire_resistance = reader.get_char()
        data._spec1 = reader.get_three()
        data._spec2 = reader.get_char()
        data._spec3 = reader.get_char()
        data._level_requirement = reader.get_short()
        data._class_requirement = reader.get_short()
        data._str_requirement = reader.get_short()
        data._int_requirement = reader.get_short()
        data._wis_requirement = reader.get_short()
        data._agi_requirement = reader.get_short()
        data._con_requirement = reader.get_short()
        data._cha_requirement = reader.get_short()
        data._element = Element(reader.get_char())
        data._element_damage = reader.get_char()
        data._weight = reader.get_char()
        reader.get_char()
        data._size = ItemSize(reader.get_char())
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Eif

Endless Item File

Source code in src/eolib/protocol/_generated/pub/eif.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
class Eif:
    """
    Endless Item File
    """
    _byte_size: int = 0
    _rid: list[int] = None # type: ignore [assignment]
    _total_items_count: int = None # type: ignore [assignment]
    _version: int = None # type: ignore [assignment]
    _items: list[EifRecord] = None # type: ignore [assignment]

    @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) -> list[int]:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        return self._rid

    @rid.setter
    def rid(self, rid: list[int]) -> None:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        self._rid = rid

    @property
    def total_items_count(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._total_items_count

    @total_items_count.setter
    def total_items_count(self, total_items_count: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._total_items_count = total_items_count

    @property
    def version(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._version

    @version.setter
    def version(self, version: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._version = version

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

    @items.setter
    def items(self, items: list[EifRecord]) -> None:
        self._items = 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.
        """
        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])

    @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.
        """
        data: Eif = Eif()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            data._rid = []
            for i in range(2):
                data._rid.append(reader.get_short())
            data._total_items_count = reader.get_short()
            data._version = reader.get_char()
            data._items = []
            while reader.remaining > 0:
                data._items.append(EifRecord.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        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: list[int] property writable

Note
  • Length must be 2.
  • Element value range is 0-64008.

total_items_count: int property writable

Note
  • Value range is 0-64008.

version: int property writable

Note
  • Value range is 0-252.

items: list[EifRecord] property writable

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
 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
@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.
    """
    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])

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
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
@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.
    """
    data: Eif = Eif()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        data._rid = []
        for i in range(2):
            data._rid.append(reader.get_short())
        data._total_items_count = reader.get_short()
        data._version = reader.get_char()
        data._items = []
        while reader.remaining > 0:
            data._items.append(EifRecord.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    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
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
class EcfRecord:
    """
    Record of Class data in an Endless Class File
    """
    _byte_size: int = 0
    _name_length: int = None # type: ignore [assignment]
    _name: str = None # type: ignore [assignment]
    _parent_type: int = None # type: ignore [assignment]
    _stat_group: int = None # type: ignore [assignment]
    _str: int = None # type: ignore [assignment]
    _intl: int = None # type: ignore [assignment]
    _wis: int = None # type: ignore [assignment]
    _agi: int = None # type: ignore [assignment]
    _con: int = None # type: ignore [assignment]
    _cha: int = None # type: ignore [assignment]

    @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:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._name

    @name.setter
    def name(self, name: str) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._name = name
        self._name_length = len(self._name)

    @property
    def parent_type(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._parent_type

    @parent_type.setter
    def parent_type(self, parent_type: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._parent_type = parent_type

    @property
    def stat_group(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._stat_group

    @stat_group.setter
    def stat_group(self, stat_group: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._stat_group = stat_group

    @property
    def str(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._str

    @str.setter
    def str(self, str: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._str = str

    @property
    def intl(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._intl

    @intl.setter
    def intl(self, intl: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._intl = intl

    @property
    def wis(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._wis

    @wis.setter
    def wis(self, wis: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._wis = wis

    @property
    def agi(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._agi

    @agi.setter
    def agi(self, agi: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._agi = agi

    @property
    def con(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._con

    @con.setter
    def con(self, con: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._con = con

    @property
    def cha(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._cha

    @cha.setter
    def cha(self, cha: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._cha = 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.
        """
        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)

    @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.
        """
        data: EcfRecord = EcfRecord()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._name_length = reader.get_char()
            data._name = reader.get_fixed_string(data._name_length, False)
            data._parent_type = reader.get_char()
            data._stat_group = reader.get_char()
            data._str = reader.get_short()
            data._intl = reader.get_short()
            data._wis = reader.get_short()
            data._agi = reader.get_short()
            data._con = reader.get_short()
            data._cha = reader.get_short()
            data._byte_size = reader.position - reader_start_position
            return data
        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 writable

Note
  • Length must be 252 or less.

parent_type: int property writable

Note
  • Value range is 0-252.

stat_group: int property writable

Note
  • Value range is 0-252.

str: int property writable

Note
  • Value range is 0-64008.

intl: int property writable

Note
  • Value range is 0-64008.

wis: int property writable

Note
  • Value range is 0-64008.

agi: int property writable

Note
  • Value range is 0-64008.

con: int property writable

Note
  • Value range is 0-64008.

cha: int property writable

Note
  • Value range is 0-64008.

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
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
@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.
    """
    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)

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
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
@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.
    """
    data: EcfRecord = EcfRecord()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._name_length = reader.get_char()
        data._name = reader.get_fixed_string(data._name_length, False)
        data._parent_type = reader.get_char()
        data._stat_group = reader.get_char()
        data._str = reader.get_short()
        data._intl = reader.get_short()
        data._wis = reader.get_short()
        data._agi = reader.get_short()
        data._con = reader.get_short()
        data._cha = reader.get_short()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Ecf

Endless Class File

Source code in src/eolib/protocol/_generated/pub/ecf.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
class Ecf:
    """
    Endless Class File
    """
    _byte_size: int = 0
    _rid: list[int] = None # type: ignore [assignment]
    _total_classes_count: int = None # type: ignore [assignment]
    _version: int = None # type: ignore [assignment]
    _classes: list[EcfRecord] = None # type: ignore [assignment]

    @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) -> list[int]:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        return self._rid

    @rid.setter
    def rid(self, rid: list[int]) -> None:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        self._rid = rid

    @property
    def total_classes_count(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._total_classes_count

    @total_classes_count.setter
    def total_classes_count(self, total_classes_count: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._total_classes_count = total_classes_count

    @property
    def version(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._version

    @version.setter
    def version(self, version: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._version = version

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

    @classes.setter
    def classes(self, classes: list[EcfRecord]) -> None:
        self._classes = 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.
        """
        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])

    @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.
        """
        data: Ecf = Ecf()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            data._rid = []
            for i in range(2):
                data._rid.append(reader.get_short())
            data._total_classes_count = reader.get_short()
            data._version = reader.get_char()
            data._classes = []
            while reader.remaining > 0:
                data._classes.append(EcfRecord.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        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: list[int] property writable

Note
  • Length must be 2.
  • Element value range is 0-64008.

total_classes_count: int property writable

Note
  • Value range is 0-64008.

version: int property writable

Note
  • Value range is 0-252.

classes: list[EcfRecord] property writable

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
 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
@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.
    """
    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])

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
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
@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.
    """
    data: Ecf = Ecf()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        data._rid = []
        for i in range(2):
            data._rid.append(reader.get_short())
        data._total_classes_count = reader.get_short()
        data._version = reader.get_char()
        data._classes = []
        while reader.remaining > 0:
            data._classes.append(EcfRecord.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode