SoE: update to v042 and balancing changes (#1125)

* SoE: rebalancing and cleanup

* ModuleUpdate: make url detection more generic

* SoE: change item rules to depend on target player difficulty

* SoE: Update to pyevermizer 0.41.0

* adds footknight
* adds location difficulty

* SoE: minor optimization in item rule

if .. in is faster with sets

* SoE: drop support of patch format v3

* SoE: fix some typing and warnings

* SoE: cleanup imports
This commit is contained in:
black-sliver
2022-10-21 23:26:40 +02:00
committed by GitHub
parent 40c3ef35c7
commit 04b6c31076
6 changed files with 157 additions and 86 deletions

View File

@@ -1,9 +1,8 @@
import bsdiff4
import yaml
import os
from typing import Optional
import Utils
from worlds.Files import APDeltaPatch
import os
USHASH = '6e9c94511d04fac6e0a1e582c170be3a'
@@ -24,6 +23,8 @@ def get_base_rom_path(file_name: Optional[str] = None) -> str:
options = Utils.get_options()
if not file_name:
file_name = options["soe_options"]["rom_file"]
if not file_name:
raise ValueError("Missing soe_options -> rom_file from host.yaml")
if not os.path.exists(file_name):
file_name = Utils.user_path(file_name)
return file_name
@@ -37,30 +38,6 @@ def read_rom(stream, strip_header=True) -> bytes:
return data
def generate_yaml(patch: bytes, metadata: Optional[dict] = None) -> bytes:
"""Generate old (<4) apbp format yaml"""
patch = yaml.dump({"meta": metadata,
"patch": patch,
"game": "Secret of Evermore",
# minimum version of patch system expected for patching to be successful
"compatible_version": 1,
"version": 2,
"base_checksum": USHASH})
return patch.encode(encoding="utf-8-sig")
def generate_patch(vanilla_file, randomized_file, metadata: Optional[dict] = None) -> bytes:
"""Generate old (<4) apbp format patch data. Run through lzma to get a complete apbp file."""
with open(vanilla_file, "rb") as f:
vanilla = read_rom(f)
with open(randomized_file, "rb") as f:
randomized = read_rom(f)
if metadata is None:
metadata = {}
patch = bsdiff4.diff(vanilla, randomized)
return generate_yaml(patch, metadata)
if __name__ == '__main__':
import sys
print('Please use ../../Patch.py', file=sys.stderr)