Skip to content

Commit

Permalink
Fix schema
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquegemignani committed Jan 30, 2023
1 parent 99c04cb commit 0f7ef48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
12 changes: 9 additions & 3 deletions open_dread_rando/dread_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing
from pathlib import Path

from construct import ListContainer
from mercury_engine_data_structures.file_tree_editor import OutputFormat

from open_dread_rando import elevator, lua_util, game_patches
Expand All @@ -21,7 +22,6 @@
from open_dread_rando.text_patches import apply_text_patches, patch_credits, patch_hints, patch_text
from open_dread_rando.tilegroup_patcher import patch_tilegroup
from open_dread_rando.validator_with_default import DefaultValidatingDraft7Validator
from construct import ListContainer

T = typing.TypeVar("T")

Expand Down Expand Up @@ -114,6 +114,7 @@ def patch_doors(editor: PatcherEditor, doors_config: list[dict], show_shields: b
for door in doors_config:
door_editor.patch_door(door["actor"], door["door_type"])


def patch_spawn_points(editor: PatcherEditor, spawn_config: list[dict]):
# create custom spawn point
_EXAMPLE_SP = {"scenario": "s010_cave", "layer": "default", "actor": "StartPoint0"}
Expand All @@ -122,7 +123,8 @@ def patch_spawn_points(editor: PatcherEditor, spawn_config: list[dict]):
scenario_name = new_spawn["new_actor"]["scenario"]
new_actor_name = new_spawn["new_actor"]["actor"]
collision_camera_name = new_spawn["collision_camera_name"]
new_spawn_pos = ListContainer((new_spawn["location"]["x"], new_spawn["location"]["y"], new_spawn["location"]["z"]))
new_spawn_pos = ListContainer(
(new_spawn["location"]["x"], new_spawn["location"]["y"], new_spawn["location"]["z"]))

scenario = editor.get_scenario(scenario_name)

Expand All @@ -149,10 +151,14 @@ def add_custom_files(editor: PatcherEditor):
editor.add_new_asset(full_path.as_posix(), child.read_bytes(), ["packs/system/system.pkg"])


def validate(configuration: dict):
DefaultValidatingDraft7Validator(_read_schema()).validate(configuration)


def patch_extracted(input_path: Path, output_path: Path, configuration: dict):
LOG.info("Will patch files from %s", input_path)

DefaultValidatingDraft7Validator(_read_schema()).validate(configuration)
validate(configuration)

editor = PatcherEditor(input_path)
lua_scripts = LuaEditor()
Expand Down
2 changes: 1 addition & 1 deletion open_dread_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
},
"show_shields_on_minimap": {
"type": "boolean",
"default": "false"
"default": false
},
"door_patches": {
"type": "array",
Expand Down
13 changes: 13 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import json
from pathlib import Path

from open_dread_rando import dread_patcher


def test_starter_preset():
test_files: Path = Path(__file__).parent.joinpath("test_files")

with test_files.joinpath("starter_preset_patcher.json").open() as f:
configuration = json.load(f)

dread_patcher.validate(configuration)

0 comments on commit 0f7ef48

Please sign in to comment.