From 6f8b9b75b36d13a0794f569352ab94c1765599a9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 9 Aug 2019 15:16:57 +0200 Subject: [PATCH] Start work on tile data --- lihzahrd/__init__.py | 3 +- lihzahrd/header/__init__.py | 2 - lihzahrd/savedata/__init__.py | 0 lihzahrd/{header => savedata}/filereader.py | 2 +- lihzahrd/{header => savedata}/rect.py | 0 lihzahrd/tiles/__init__.py | 6 + lihzahrd/tiles/liquid.py | 18 + lihzahrd/tiles/rleencoding.py | 11 + lihzahrd/tiles/shape.py | 14 + lihzahrd/tiles/tile.py | 18 + lihzahrd/tiles/wires.py | 12 + lihzahrd/world.py | 344 +++++++++++--------- test.py | 3 + 13 files changed, 278 insertions(+), 155 deletions(-) create mode 100644 lihzahrd/savedata/__init__.py rename lihzahrd/{header => savedata}/filereader.py (96%) rename lihzahrd/{header => savedata}/rect.py (100%) create mode 100644 lihzahrd/tiles/__init__.py create mode 100644 lihzahrd/tiles/liquid.py create mode 100644 lihzahrd/tiles/rleencoding.py create mode 100644 lihzahrd/tiles/shape.py create mode 100644 lihzahrd/tiles/tile.py create mode 100644 lihzahrd/tiles/wires.py create mode 100644 test.py diff --git a/lihzahrd/__init__.py b/lihzahrd/__init__.py index 04f6b11..aad0c7d 100644 --- a/lihzahrd/__init__.py +++ b/lihzahrd/__init__.py @@ -1,4 +1,3 @@ -from . import header from .world import World -__all__ = ["header", "World"] +__all__ = ["World"] diff --git a/lihzahrd/header/__init__.py b/lihzahrd/header/__init__.py index f375896..d1a5ce8 100644 --- a/lihzahrd/header/__init__.py +++ b/lihzahrd/header/__init__.py @@ -6,7 +6,6 @@ from .bossesdefeated import BossesDefeated from .clouds import Clouds from .coordinates import Coordinates from .events import Events -from .filereader import FileReader from .fourpartsplit import FourPartSplit from .generatorinfo import GeneratorInfo from .hardmodeore import HardmodeTier1Ore, HardmodeTier2Ore, HardmodeTier3Ore @@ -19,7 +18,6 @@ from .oldonesarmytiers import OldOnesArmyTiers from .party import Party from .pillarsinfo import PillarsInfo from .rain import Rain -from .rect import Rect from .sandstorm import Sandstorm from .savednpcs import SavedNPCs from .shadoworbs import ShadowOrbs diff --git a/lihzahrd/savedata/__init__.py b/lihzahrd/savedata/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lihzahrd/header/filereader.py b/lihzahrd/savedata/filereader.py similarity index 96% rename from lihzahrd/header/filereader.py rename to lihzahrd/savedata/filereader.py index c6790f9..b5bdcca 100644 --- a/lihzahrd/header/filereader.py +++ b/lihzahrd/savedata/filereader.py @@ -42,7 +42,7 @@ class FileReader: def double(self) -> float: return struct.unpack("d", self.file.read(8))[0] - def bit(self) -> typing.Tuple[bool, bool, bool, bool, bool, bool, bool, bool]: + def bits(self) -> typing.Tuple[bool, bool, bool, bool, bool, bool, bool, bool]: data = struct.unpack("B", self.file.read(1))[0] return (bool(data & 0b1000_0000), bool(data & 0b0100_0000), diff --git a/lihzahrd/header/rect.py b/lihzahrd/savedata/rect.py similarity index 100% rename from lihzahrd/header/rect.py rename to lihzahrd/savedata/rect.py diff --git a/lihzahrd/tiles/__init__.py b/lihzahrd/tiles/__init__.py new file mode 100644 index 0000000..93d5bb1 --- /dev/null +++ b/lihzahrd/tiles/__init__.py @@ -0,0 +1,6 @@ +from .liquid import Liquid +from .rleencoding import RLEEncoding +from .shape import Shape +from .wires import Wires + +__all__ = ["Liquid", "RLEEncoding", "Shape", "Wires"] diff --git a/lihzahrd/tiles/liquid.py b/lihzahrd/tiles/liquid.py new file mode 100644 index 0000000..fb7da48 --- /dev/null +++ b/lihzahrd/tiles/liquid.py @@ -0,0 +1,18 @@ +import enum + + +class Liquid(enum.IntEnum): + NO_LIQUID = 0 + WATER = 1 + LAVA = 2 + HONEY = 3 + + @classmethod + def from_flags(cls, flags1): + if flags1[3] and flags1[4]: + return cls.HONEY + if flags1[4]: + return cls.LAVA + if flags1[3]: + return cls.WATER + return cls.NO_LIQUID diff --git a/lihzahrd/tiles/rleencoding.py b/lihzahrd/tiles/rleencoding.py new file mode 100644 index 0000000..611241d --- /dev/null +++ b/lihzahrd/tiles/rleencoding.py @@ -0,0 +1,11 @@ +import enum + + +class RLEEncoding(enum.IntEnum): + NO_COMPRESSION = 0 + SINGLE_BYTE = 1 + DOUBLE_BYTE = 2 + + @classmethod + def from_flags(cls, flags1): + return cls(flags1[7] * 2 + flags1[6]) diff --git a/lihzahrd/tiles/shape.py b/lihzahrd/tiles/shape.py new file mode 100644 index 0000000..11e280f --- /dev/null +++ b/lihzahrd/tiles/shape.py @@ -0,0 +1,14 @@ +import enum + + +class Shape(enum.IntEnum): + NORMAL = 0 + HALF_TILE = 1 + TOP_RIGHT_SLOPE = 2 + TOP_LEFT_SLOPE = 3 + BOTTOM_RIGHT_SLOPE = 4 + BOTTOM_LEFT_SLOPE = 5 + + @classmethod + def from_flags(cls, flags2): + return cls(flags2[6] * 4 + flags2[5] * 2 + flags2[4]) diff --git a/lihzahrd/tiles/tile.py b/lihzahrd/tiles/tile.py new file mode 100644 index 0000000..c18585e --- /dev/null +++ b/lihzahrd/tiles/tile.py @@ -0,0 +1,18 @@ +import enum + + +class Liquid(enum.IntEnum): + NO_LIQUID = 0 + WATER = 1 + LAVA = 2 + HONEY = 3 + + @classmethod + def from_flags(cls, flags13, flags14): + if flags13 and flags14: + return cls.HONEY + if flags14: + return cls.LAVA + if flags13: + return cls.WATER + return cls.NO_LIQUID diff --git a/lihzahrd/tiles/wires.py b/lihzahrd/tiles/wires.py new file mode 100644 index 0000000..ce12924 --- /dev/null +++ b/lihzahrd/tiles/wires.py @@ -0,0 +1,12 @@ +class Wires: + def __init__(self, + red: bool = False, + green: bool = False, + blue: bool = False, + yellow: bool = False, + actuator: bool = False): + self.red: bool = red + self.green: bool = green + self.blue: bool = blue + self.yellow: bool = yellow + self.actuator: bool = actuator diff --git a/lihzahrd/world.py b/lihzahrd/world.py index 713b719..1ea6fe0 100644 --- a/lihzahrd/world.py +++ b/lihzahrd/world.py @@ -1,42 +1,45 @@ import uuid import math -from . import header as h +from .header import * +from .savedata import filereader +from .tiles import * class World: """The Python representation of a Terraria world.""" + def __init__(self, - version: h.Version, + version: Version, savefile_type: int, revision: int, is_favorite: bool, name: str, - generator: h.GeneratorInfo, + generator: GeneratorInfo, uuid_: uuid.UUID, id_: int, - bounds: h.Rect, - size: h.Coordinates, + bounds: Rect, + size: Coordinates, is_expert: bool, created_on, - styles: h.Styles, - backgrounds: h.Backgrounds, - spawn_point: h.Coordinates, + styles: Styles, + backgrounds: Backgrounds, + spawn_point: Coordinates, underground_level: float, cavern_level: float, - time: h.Time, - events: h.Events, - dungeon_point: h.Coordinates, - world_evil: h.WorldEvilType, - saved_npcs: h.SavedNPCs, - altars_smashed: h.AltarsSmashed, + time: Time, + events: Events, + dungeon_point: Coordinates, + world_evil: WorldEvilType, + saved_npcs: SavedNPCs, + altars_smashed: AltarsSmashed, is_hardmode: bool, - shadow_orbs: h.ShadowOrbs, - bosses_defeated: h.BossesDefeated, - anglers_quest: h.AnglerQuest, - clouds: h.Clouds, + shadow_orbs: ShadowOrbs, + bosses_defeated: BossesDefeated, + anglers_quest: AnglerQuest, + clouds: Clouds, cultist_delay: int): - self.version: h.Version = version + self.version: Version = version """The game version when this savefile was last saved.""" self.savefile_type = savefile_type @@ -51,7 +54,7 @@ class World: self.name: str = name """The name the world was given at creation. Doesn't always match the filename.""" - self.generator: h.GeneratorInfo = generator + self.generator: GeneratorInfo = generator """Information about the generation of this world.""" self.uuid: uuid.UUID = uuid_ @@ -60,10 +63,10 @@ class World: self.id: int = id_ """The world id. Used to name the minimap file.""" - self.bounds: h.rect.Rect = bounds + self.bounds: Rect = bounds """The world size in pixels.""" - self.size: h.Coordinates = size + self.size: Coordinates = size """The world size in tiles.""" self.is_expert: bool = is_expert @@ -72,13 +75,13 @@ class World: self.created_on = created_on """The date and time this world was created in.""" - self.styles: h.Styles = styles + self.styles: Styles = styles """The styles of various world elements.""" - self.backgrounds: h.Backgrounds = backgrounds + self.backgrounds: Backgrounds = backgrounds """The backgrounds of the various biomes.""" - self.spawn_point: h.Coordinates = spawn_point + self.spawn_point: Coordinates = spawn_point """The coordinates of the spawn point.""" self.underground_level: float = underground_level @@ -87,61 +90,100 @@ class World: self.cavern_level: float = cavern_level """The depth at which the cavern biome starts.""" - self.time: h.Time = time + self.time: Time = time """Game time related information.""" - self.events: h.Events = events + self.events: Events = events """Currently ongoing world events.""" - self.dungeon_point: h.Coordinates = dungeon_point + self.dungeon_point: Coordinates = dungeon_point """The Old Man spawn point.""" - self.world_evil: h.WorldEvilType = world_evil + self.world_evil: WorldEvilType = world_evil """Whether the world has Corruption or Crimson.""" - self.saved_npcs: h.SavedNPCs = saved_npcs + self.saved_npcs: SavedNPCs = saved_npcs """The NPCs that were rescued by the player.""" - self.altars_smashed: h.AltarsSmashed = altars_smashed + self.altars_smashed: AltarsSmashed = altars_smashed """Information related to the destruction of Demon Altars with a Pwnhammer.""" self.is_hardmode: bool = is_hardmode """Whether or not the world is in hardmode.""" - self.shadow_orbs: h.ShadowOrbs = shadow_orbs + self.shadow_orbs: ShadowOrbs = shadow_orbs """Information related to the Shadow Orbs or Crimson Hearts in the world.""" - self.bosses_defeated: h.BossesDefeated = bosses_defeated + self.bosses_defeated: BossesDefeated = bosses_defeated """Which bosses have been defeated in the world.""" - self.anglers_quest: h.AnglerQuest = anglers_quest + self.anglers_quest: AnglerQuest = anglers_quest """Information about today's Angler's Quest.""" - self.clouds: h.Clouds = clouds + self.clouds: Clouds = clouds self.cultist_delay: int = cultist_delay def __repr__(self): return f'' @property - def crimson_hearts(self) -> h.shadoworbs.ShadowOrbs: + def crimson_hearts(self) -> ShadowOrbs: return self.shadow_orbs @crimson_hearts.setter def crimson_hearts(self, value): self.shadow_orbs = value + @staticmethod + def _read_tiles(fr: FileReader, tileframeimportant): + flags1 = fr.bits() + has_tile = flags1[1] + has_wall = flags1[2] + liquid = Liquid.from_flags(flags1) + extended_block_id = flags1[5] + rle_compression = RLEEncoding.from_flags(flags1) + if flags1[0]: + flags2 = fr.bits() + shape = Shape.from_flags(flags2) + if flags2[0]: + flags3 = fr.bits() + is_active = not flags3[2] + wires = Wires(red=flags2[1], green=flags2[2], blue=flags2[3], yellow=flags3[5], actuator=flags3[1]) + is_tile_painted = flags3[3] + is_wall_painted = flags3[4] + else: + is_active = True + wires = Wires(red=flags2[1], green=flags2[2], blue=flags2[3]) + is_tile_painted = False + is_wall_painted = False + else: + shape = Shape.NORMAL + is_active = True + wires = Wires() + is_tile_painted = False + is_wall_painted = False + if has_tile: + if extended_block_id: + block_id = fr.uint2() + else: + block_id = fr.uint1() + else: + block_id = None + if tileframeimportant: + ... + breakpoint() + @classmethod def create_from_file(cls, file): """Create a World object from a .wld file.""" # This code is a mess. - f = h.filereader.FileReader(file) + f = filereader.FileReader(file) - version = h.version.Version(f.int4()) + version = Version(f.int4()) relogic = f.string(7) savefile_type = f.uint1() - if version != h.version.Version("1.3.5.3") or relogic != "relogic" or savefile_type != 2: + if version != Version("1.3.5.3") or relogic != "relogic" or savefile_type != 2: raise NotImplementedError("This parser can only read Terraria 1.3.5.3 save files.") revision = f.uint4() @@ -150,51 +192,51 @@ class World: # Pointers and tileframeimportant _ = [f.int4() for _ in range(f.int2())] tileframeimportant_size = math.ceil(f.int2() / 8) - _ = [] + tileframeimportant = [] for _ in range(tileframeimportant_size): - current_bit = f.bit() - _ = [*_, *current_bit] + current_bit = f.bits() + tileframeimportant = [*tileframeimportant, *current_bit] name = f.string() - generator = h.GeneratorInfo(f.string(), f.int4()) + generator = GeneratorInfo(f.string(), f.int4()) uuid_ = f.uuid() id_ = f.int8() bounds = f.rect() - world_size = h.Coordinates(y=f.int4(), x=f.int4()) + world_size = Coordinates(y=f.int4(), x=f.int4()) is_expert = f.bool() created_on = f.datetime() - world_styles = h.Styles(moon=h.moonstyle.MoonStyle(f.uint1()), - trees=h.fourpartsplit.FourPartSplit(separators=[f.int4(), f.int4(), f.int4()], - properties=[f.int4(), - f.int4(), - f.int4(), - f.int4()]), - moss=h.fourpartsplit.FourPartSplit(separators=[f.int4(), f.int4(), f.int4()], - properties=[f.int4(), - f.int4(), - f.int4(), - f.int4()])) + world_styles = Styles(moon=MoonStyle(f.uint1()), + trees=FourPartSplit(separators=[f.int4(), f.int4(), f.int4()], + properties=[f.int4(), + f.int4(), + f.int4(), + f.int4()]), + moss=FourPartSplit(separators=[f.int4(), f.int4(), f.int4()], + properties=[f.int4(), + f.int4(), + f.int4(), + f.int4()])) bg_underground_snow = f.int4() bg_underground_jungle = f.int4() bg_hell = f.int4() - spawn_point = h.Coordinates(f.int4(), f.int4()) + spawn_point = Coordinates(f.int4(), f.int4()) underground_level = f.double() cavern_level = f.double() current_time = f.double() is_daytime = f.bool() - moon_phase = h.MoonPhase(f.uint4()) + moon_phase = MoonPhase(f.uint4()) blood_moon = f.bool() eclipse = f.bool() - dungeon_point = h.Coordinates(f.int4(), f.int4()) - world_evil = h.WorldEvilType(f.bool()) + dungeon_point = Coordinates(f.int4(), f.int4()) + world_evil = WorldEvilType(f.bool()) defeated_eye_of_cthulhu = f.bool() # Possibly. I'm not sure. defeated_eater_of_worlds = f.bool() # Possibly. I'm not sure. @@ -217,9 +259,9 @@ class World: defeated_frost_moon = f.bool() defeated_pirates = f.bool() - shadow_orbs = h.ShadowOrbs(smashed_at_least_once=f.bool(), - spawn_meteorite=f.bool(), - evil_boss_counter=f.int4()) + shadow_orbs = ShadowOrbs(smashed_at_least_once=f.bool(), + spawn_meteorite=f.bool(), + evil_boss_counter=f.int4()) smashed_altars_count = f.int4() @@ -227,22 +269,22 @@ class World: invasion_delay = f.int4() invasion_size = f.int4() - invasion_type = h.InvasionType(f.int4()) + invasion_type = InvasionType(f.int4()) invasion_position = f.double() time_left_slime_rain = f.double() sundial_cooldown = f.uint1() - rain = h.Rain(is_active=f.bool(), time_left=f.int4(), max_rain=f.single()) + rain = Rain(is_active=f.bool(), time_left=f.int4(), max_rain=f.single()) - hardmode_ore_1 = h.HardmodeTier1Ore(f.int4()) - hardmode_ore_2 = h.HardmodeTier2Ore(f.int4()) - hardmode_ore_3 = h.HardmodeTier3Ore(f.int4()) - altars_smashed = h.AltarsSmashed(count=smashed_altars_count, - ore_tier1=hardmode_ore_1, - ore_tier2=hardmode_ore_2, - ore_tier3=hardmode_ore_3) + hardmode_ore_1 = HardmodeTier1Ore(f.int4()) + hardmode_ore_2 = HardmodeTier2Ore(f.int4()) + hardmode_ore_3 = HardmodeTier3Ore(f.int4()) + altars_smashed = AltarsSmashed(count=smashed_altars_count, + ore_tier1=hardmode_ore_1, + ore_tier2=hardmode_ore_2, + ore_tier3=hardmode_ore_3) bg_forest = f.int1() bg_corruption = f.int1() @@ -253,19 +295,19 @@ class World: bg_desert = f.int1() bg_ocean = f.int1() - backgrounds = h.Backgrounds(bg_underground_snow=bg_underground_snow, - bg_underground_jungle=bg_underground_jungle, - bg_hell=bg_hell, - bg_forest=bg_forest, - bg_corruption=bg_corruption, - bg_jungle=bg_jungle, - bg_snow=bg_snow, - bg_hallow=bg_hallow, - bg_crimson=bg_crimson, - bg_desert=bg_desert, - bg_ocean=bg_ocean) + backgrounds = Backgrounds(bg_underground_snow=bg_underground_snow, + bg_underground_jungle=bg_underground_jungle, + bg_hell=bg_hell, + bg_forest=bg_forest, + bg_corruption=bg_corruption, + bg_jungle=bg_jungle, + bg_snow=bg_snow, + bg_hallow=bg_hallow, + bg_crimson=bg_crimson, + bg_desert=bg_desert, + bg_ocean=bg_ocean) - clouds = h.Clouds(bg_cloud=f.int4(), cloud_number=f.int2(), wind_speed=f.single()) + clouds = Clouds(bg_cloud=f.int4(), cloud_number=f.int2(), wind_speed=f.single()) angler_today_quest_completed_by_count = f.uint1() angler_today_quest_completed_by = [] @@ -274,19 +316,19 @@ class World: saved_angler = f.bool() - angler_today_quest_target = h.AnglerQuestFish(f.int4()) - anglers_quest = h.AnglerQuest(current_goal=angler_today_quest_target, - completed_by=angler_today_quest_completed_by) + angler_today_quest_target = AnglerQuestFish(f.int4()) + anglers_quest = AnglerQuest(current_goal=angler_today_quest_target, + completed_by=angler_today_quest_completed_by) saved_stylist = f.bool() saved_tax_collector = f.bool() invasion_size_start = f.int4() # ??? - invasion = h.Invasion(delay=invasion_delay, - size=invasion_size, - type_=invasion_type, - position=invasion_position, - size_start=invasion_size_start) + invasion = Invasion(delay=invasion_delay, + size=invasion_size, + type_=invasion_type, + position=invasion_position, + size_start=invasion_size_start) cultist_delay = f.int4() # ??? mob_types_count = f.int2() @@ -295,11 +337,11 @@ class World: mob_kills[mob_id] = f.int4() fast_forward_time = f.bool() - time = h.Time(current=current_time, - is_daytime=is_daytime, - moon_phase=moon_phase, - sundial_cooldown=sundial_cooldown, - fast_forward_time=fast_forward_time) + time = Time(current=current_time, + is_daytime=is_daytime, + moon_phase=moon_phase, + sundial_cooldown=sundial_cooldown, + fast_forward_time=fast_forward_time) defeated_duke_fishron = f.bool() defeated_moon_lord = f.bool() @@ -308,13 +350,13 @@ class World: defeated_ice_queen = f.bool() defeated_santa_nk1 = f.bool() defeated_everscream = f.bool() - defeated_pillars = h.PillarsInfo(solar=f.bool(), vortex=f.bool(), nebula=f.bool(), stardust=f.bool()) + defeated_pillars = PillarsInfo(solar=f.bool(), vortex=f.bool(), nebula=f.bool(), stardust=f.bool()) - lunar_events = h.LunarEvents(pillars_present=h.PillarsInfo(solar=f.bool(), - vortex=f.bool(), - nebula=f.bool(), - stardust=f.bool()), - are_active=f.bool()) + lunar_events = LunarEvents(pillars_present=PillarsInfo(solar=f.bool(), + vortex=f.bool(), + nebula=f.bool(), + stardust=f.bool()), + are_active=f.bool()) party_center_active = f.bool() party_natural_active = f.bool() @@ -323,61 +365,63 @@ class World: partying_npcs = [] for _ in range(partying_npcs_count): partying_npcs.append(f.int4()) - party = h.Party(thrown_by_party_center=party_center_active, - thrown_by_npcs=party_natural_active, - cooldown=party_cooldown, - partying_npcs=partying_npcs) + party = Party(thrown_by_party_center=party_center_active, + thrown_by_npcs=party_natural_active, + cooldown=party_cooldown, + partying_npcs=partying_npcs) - sandstorm = h.Sandstorm(is_active=f.bool(), - time_left=f.int4(), - severity=f.single(), - intended_severity=f.single()) + sandstorm = Sandstorm(is_active=f.bool(), + time_left=f.int4(), + severity=f.single(), + intended_severity=f.single()) - events = h.Events(blood_moon=blood_moon, - solar_eclipse=eclipse, - invasion=invasion, - slime_rain=time_left_slime_rain, - rain=rain, - party=party, - sandstorm=sandstorm, - lunar_events=lunar_events) + events = Events(blood_moon=blood_moon, + solar_eclipse=eclipse, + invasion=invasion, + slime_rain=time_left_slime_rain, + rain=rain, + party=party, + sandstorm=sandstorm, + lunar_events=lunar_events) saved_bartender = f.bool() - saved_npcs = h.SavedNPCs(goblin_tinkerer=saved_goblin_tinkerer, - wizard=saved_wizard, - mechanic=saved_mechanic, - angler=saved_angler, - stylist=saved_stylist, - tax_collector=saved_tax_collector, - bartender=saved_bartender) + saved_npcs = SavedNPCs(goblin_tinkerer=saved_goblin_tinkerer, + wizard=saved_wizard, + mechanic=saved_mechanic, + angler=saved_angler, + stylist=saved_stylist, + tax_collector=saved_tax_collector, + bartender=saved_bartender) - old_ones_army = h.OldOnesArmyTiers(f.bool(), f.bool(), f.bool()) + old_ones_army = OldOnesArmyTiers(f.bool(), f.bool(), f.bool()) - bosses_defeated = h.BossesDefeated(eye_of_cthulhu=defeated_eye_of_cthulhu, - eater_of_worlds=defeated_eater_of_worlds, - skeletron=defeated_skeletron, - queen_bee=defeated_queen_bee, - the_twins=defeated_the_twins, - the_destroyer=defeated_the_destroyer, - skeletron_prime=defeated_skeletron_prime, - any_mechnical_boss=defeated_any_mechnical_boss, - plantera=defeated_plantera, - golem=defeated_golem, - king_slime=defeated_king_slime, - goblin_army=defeated_goblin_army, - clown=defeated_clown, - frost_moon=defeated_frost_moon, - pirates=defeated_pirates, - duke_fishron=defeated_duke_fishron, - moon_lord=defeated_moon_lord, - pumpking=defeated_pumpking, - mourning_wood=defeated_mourning_wood, - ice_queen=defeated_ice_queen, - santa_nk1=defeated_santa_nk1, - everscream=defeated_everscream, - lunar_pillars=defeated_pillars, - old_ones_army=old_ones_army) + bosses_defeated = BossesDefeated(eye_of_cthulhu=defeated_eye_of_cthulhu, + eater_of_worlds=defeated_eater_of_worlds, + skeletron=defeated_skeletron, + queen_bee=defeated_queen_bee, + the_twins=defeated_the_twins, + the_destroyer=defeated_the_destroyer, + skeletron_prime=defeated_skeletron_prime, + any_mechnical_boss=defeated_any_mechnical_boss, + plantera=defeated_plantera, + golem=defeated_golem, + king_slime=defeated_king_slime, + goblin_army=defeated_goblin_army, + clown=defeated_clown, + frost_moon=defeated_frost_moon, + pirates=defeated_pirates, + duke_fishron=defeated_duke_fishron, + moon_lord=defeated_moon_lord, + pumpking=defeated_pumpking, + mourning_wood=defeated_mourning_wood, + ice_queen=defeated_ice_queen, + santa_nk1=defeated_santa_nk1, + everscream=defeated_everscream, + lunar_pillars=defeated_pillars, + old_ones_army=old_ones_army) # Tile data starts here + first_tile = cls._read_tiles(f) + world = World(version=version, savefile_type=savefile_type, revision=revision, is_favorite=is_favorite, name=name, generator=generator, uuid_=uuid_, id_=id_, bounds=bounds, size=world_size, is_expert=is_expert, created_on=created_on, styles=world_styles, backgrounds=backgrounds, diff --git a/test.py b/test.py new file mode 100644 index 0000000..4d0de0d --- /dev/null +++ b/test.py @@ -0,0 +1,3 @@ +import lihzahrd + +lihzahrd.World.create_from_file(open("Small_Example.wld", "rb"))