mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-04-09 09:38:16 -07:00
KH2: Deathlink and ingame item popups (#5206)
--------- Co-authored-by: qwint <qwint.42@gmail.com> Co-authored-by: Delilah <lindsaydiane@gmail.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import os
|
||||
import Utils
|
||||
import zipfile
|
||||
|
||||
from datetime import datetime, UTC
|
||||
|
||||
from .Items import item_dictionary_table
|
||||
from .Locations import all_locations, SoraLevels, exclusion_table
|
||||
from .XPValues import lvlStats, formExp, soraExp
|
||||
@@ -76,7 +78,8 @@ def patch_kh2(self, output_directory):
|
||||
if self.options.LevelDepth == "level_99_sanity":
|
||||
levelsetting.extend(exclusion_table["Level99Sanity"])
|
||||
|
||||
mod_name = f"AP-{self.multiworld.seed_name}-P{self.player}-{self.multiworld.get_file_safe_player_name(self.player)}"
|
||||
curr_timestamp = datetime.strftime(datetime.now(UTC), "%d%b%Y-%H%M%S")
|
||||
mod_name = f"AP-{self.multiworld.seed_name}-P{self.player}-{self.multiworld.get_file_safe_player_name(self.player)}-{curr_timestamp}"
|
||||
all_valid_locations = {location for location, data in all_locations.items()}
|
||||
|
||||
for location in self.multiworld.get_filled_locations(self.player):
|
||||
@@ -384,7 +387,7 @@ def patch_kh2(self, output_directory):
|
||||
{
|
||||
'name': 'msg/sp/he.bar'
|
||||
}
|
||||
],
|
||||
],
|
||||
'method': 'binarc',
|
||||
'source': [
|
||||
{
|
||||
@@ -473,7 +476,9 @@ def patch_kh2(self, output_directory):
|
||||
|
||||
mod_dir = os.path.join(output_directory, mod_name + "_" + Utils.__version__)
|
||||
|
||||
self.mod_yml["title"] = f"Randomizer Seed {mod_name}"
|
||||
self.mod_yml["title"] = f"Archipelago Seed - {self.multiworld.get_file_safe_player_name(self.player)}"
|
||||
self.mod_yml["originalAuthor"] = "JaredWeakStrike"
|
||||
self.mod_yml["description"] = f"Seed {self.multiworld.seed_name} was generated for {self.multiworld.get_file_safe_player_name(self.player)} - Player {self.player} at {curr_timestamp} UTC. Have fun! \nCredit to delilahisdidi for the icons!"
|
||||
|
||||
openkhmod = {
|
||||
"TrsrList.yml": yaml.dump(self.formattedTrsr, line_break="\n"),
|
||||
@@ -487,6 +492,44 @@ def patch_kh2(self, output_directory):
|
||||
"he.yml": yaml.dump(self.cups_text, line_break="\n")
|
||||
}
|
||||
|
||||
## I think I overlooked a really easy way to find the data folder,
|
||||
## but it has to determine if it's a local client generating,
|
||||
## if it's a server generating, if it's a build, or on the complete
|
||||
## offchance that it's a custom world.
|
||||
|
||||
iconbytes = bytes()
|
||||
previewbytes = bytes()
|
||||
# local build/server generating
|
||||
apworldloc = os.path.join("worlds","kh2","data")
|
||||
if os.path.exists(apworldloc):
|
||||
try:
|
||||
with open(os.path.join(apworldloc, "khapicon.png"),'rb') as icon, \
|
||||
open(os.path.join(apworldloc, "preview.png"),'rb') as preview:
|
||||
iconbytes = icon.read()
|
||||
previewbytes = preview.read()
|
||||
openkhmod["icon.png"] = iconbytes
|
||||
openkhmod["preview.png"] = previewbytes
|
||||
except IOError as openerror:
|
||||
logging.warning(openerror)
|
||||
|
||||
# client install generating
|
||||
apworldloc = os.path.join("lib","worlds")
|
||||
if not os.path.isfile(Utils.user_path(apworldloc, 'kh2.apworld')):
|
||||
apworldloc = os.path.join("custom_worlds", "")
|
||||
if os.path.exists(os.path.join(apworldloc,"kh2.apworld")):
|
||||
try:
|
||||
with zipfile.ZipFile(Utils.user_path(os.path.join(
|
||||
apworldloc, 'kh2.apworld')), 'r') as apworld_archive:
|
||||
# zipfile requires the forward slash
|
||||
with apworld_archive.open('kh2/data/khapicon.png', 'r') as icon, \
|
||||
apworld_archive.open('kh2/data/preview.png', 'r') as preview:
|
||||
iconbytes = icon.read()
|
||||
previewbytes = preview.read()
|
||||
openkhmod["icon.png"] = iconbytes
|
||||
openkhmod["preview.png"] = previewbytes
|
||||
except IOError as openerror:
|
||||
logging.warning(openerror)
|
||||
|
||||
mod = KH2Container(openkhmod, mod_dir, output_directory, self.player,
|
||||
self.multiworld.get_file_safe_player_name(self.player))
|
||||
mod.write()
|
||||
|
||||
Reference in New Issue
Block a user