mirror of
https://github.com/Steffo99/lihzahrd.git
synced 2024-11-21 23:54:23 +00:00
Improve bestiary handling
This commit is contained in:
parent
d115938a11
commit
193ed2ec78
4 changed files with 748 additions and 764 deletions
|
@ -1,24 +1,19 @@
|
|||
import typing
|
||||
from typing import Dict, List
|
||||
from ..enums import EntityType
|
||||
|
||||
|
||||
class Bestiary:
|
||||
"""A bestiary entry."""
|
||||
|
||||
__slots__ = "npc_chats_count", "npc_chats_data", "npc_kill_count", "npc_kill_data", "npc_sighting_count", "npc_sighting_data"
|
||||
__slots__ = "chats", "kills", "sightings"
|
||||
|
||||
def __init__(self,
|
||||
npc_chats_count: int,
|
||||
npc_chats_data: typing.Dict[str, int],
|
||||
npc_kill_count: int,
|
||||
npc_kill_data: typing.List[str],
|
||||
npc_sighting_count: int,
|
||||
npc_sighting_data: typing.List[str], ):
|
||||
self.npc_chats_count: int = npc_chats_count
|
||||
self.npc_chats_data: typing.Dict[str, int] = npc_chats_data
|
||||
self.npc_kill_count: int = npc_kill_count
|
||||
self.npc_kill_data: typing.List[str] = npc_kill_data
|
||||
self.npc_sighting_count: int = npc_sighting_count
|
||||
self.npc_sighting_data: typing.List[str] = npc_sighting_data
|
||||
chats: List[EntityType],
|
||||
kills: Dict[EntityType, int],
|
||||
sightings: List[EntityType]):
|
||||
self.chats: List[EntityType] = chats
|
||||
self.kills: Dict[EntityType, int] = kills
|
||||
self.sightings: List[EntityType] = sightings
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Bestiary entry: chats={self.npc_chats_count}: {self.npc_chats_data}, kills={self.npc_kill_count}: {self.npc_kill_data}, sightings={self.npc_sighting_count}: {self.npc_sighting_data}>"
|
||||
return f"<Bestiary with {len(self.chats) + len(self.kills.keys()) + len(self.sightings)} entries>"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5098,7 +5098,5 @@ class ItemType(enum.IntEnum):
|
|||
CARTON_OF_MILK = 5041
|
||||
COFFEE = 5042
|
||||
|
||||
COUNT = 5043
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.__class__.__name__}.{self.name}"
|
||||
|
|
|
@ -856,22 +856,16 @@ class World:
|
|||
|
||||
unknown_town_manager_data = f.read_until(pointers.bestiary)
|
||||
|
||||
bestiary_kill_count = f.int4()
|
||||
bestiary_kill_data = {}
|
||||
for _ in range(bestiary_kill_count):
|
||||
beast = f.string()
|
||||
beast_count = f.int4()
|
||||
bestiary_kill_data[beast] = beast_count
|
||||
bestiary_sighting_count = f.int4()
|
||||
bestiary_sighting_data = [f.string() for _ in range(bestiary_sighting_count)]
|
||||
bestiary_chat_count = f.int4()
|
||||
bestiary_chat_data = [f.string() for _ in range(bestiary_chat_count)]
|
||||
bestiary = Bestiary(bestiary_chat_count,
|
||||
bestiary_chat_data,
|
||||
bestiary_kill_count,
|
||||
bestiary_kill_data,
|
||||
bestiary_sighting_count,
|
||||
bestiary_sighting_data)
|
||||
bestiary_kills = {}
|
||||
for _ in range(f.int4()):
|
||||
entity = EntityType[f.string()]
|
||||
kills = f.int4()
|
||||
bestiary_kills[entity] = kills
|
||||
|
||||
bestiary_sightings = [EntityType[f.string()] for _ in range(f.int4())]
|
||||
bestiary_chats = [EntityType[f.string()] for _ in range(f.int4())]
|
||||
|
||||
bestiary = Bestiary(chats=bestiary_chats, kills=bestiary_kills, sightings=bestiary_sightings)
|
||||
|
||||
unknown_bestiary_data = f.read_until(pointers.journey_powers)
|
||||
|
||||
|
|
Loading…
Reference in a new issue