55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""Replace only the 63 graded tool sprites in the deployed Wild pack variants."""
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from plugin_supplied_item_art import read_pack
|
|
from plugin_wild_update import write_archive
|
|
|
|
|
|
BASE_SOURCE = "63a771d74aaddddd41f9991b2776ff6d2ac974b9"
|
|
BASE = {
|
|
"arrakis": "5c8c864fc0dd79f5a939dfd30a84779f815b94fbfe4528ae97c007fd7cc42d34",
|
|
"fleet": "aceb73ac41a70eb6df877d6d8d23c8e0e87308b2a994c94bc1df81db9e4b4e77",
|
|
}
|
|
TOOLS = ("sword", "pickaxe", "axe", "shovel", "hoe", "bow", "crossbow", "mace", "trident")
|
|
GRADES = (("very_rare", (9, 10, 11)), ("legendary", (12, 13, 14)), ("mythic", (14,)))
|
|
ASSETS = {
|
|
f"assets/dunerealms/textures/item/equipment/{quality}_mk{mark}_{tool}.png"
|
|
for quality, marks in GRADES for mark in marks for tool in TOOLS
|
|
}
|
|
|
|
|
|
def assemble(variant, baseline, source, pins_file, output):
|
|
if hashlib.sha256(baseline.read_bytes()).hexdigest() != BASE[variant]:
|
|
raise ValueError("Unexpected Wild pack checksum")
|
|
retained = read_pack(baseline)
|
|
pins = json.loads(pins_file.read_bytes())
|
|
updates = {name: (source / name).read_bytes() for name in ASSETS}
|
|
for name, data in updates.items():
|
|
if hashlib.sha256(data).hexdigest() != pins[name] or data == retained[name]:
|
|
raise ValueError(f"Unexpected graded tool texture: {name}")
|
|
expected = retained | updates
|
|
payload = write_archive(expected)
|
|
with output.open("xb") as file:
|
|
file.write(payload)
|
|
if read_pack(output) != expected:
|
|
raise ValueError("Pack entries differ from the approved tool-only transition")
|
|
return {
|
|
"filename": output.name,
|
|
"variant": variant,
|
|
"changed": len(updates),
|
|
"bytes": len(payload),
|
|
"sha1": hashlib.sha1(payload).hexdigest(),
|
|
"sha256": hashlib.sha256(payload).hexdigest(),
|
|
}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("variant", choices=BASE)
|
|
for argument in ("baseline", "source", "pins_file", "output"):
|
|
parser.add_argument(argument, type=Path)
|
|
print(json.dumps(assemble(**vars(parser.parse_args())), indent=2))
|

Staff