Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: APWorld manifest #4516

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Core: APWorld manifest #4516

wants to merge 11 commits into from

Conversation

Berserker66
Copy link
Member

Based on #4331, which I was really hoping to merge before working on this, but that's not how the cookie crumbled.

What is this fixing or adding?

Adds support for a manifest file (archipelago.json) inside an .apworld file. It tells AP the game, minimum core version (optional field), maximum core version (optional field), its own version (used to determine which file to prefer to load only currently)
The file itself is marked as required starting with core 0.7.0, prior, just a warning is printed, with error trace.

How was this tested?

a variety of local functional testing, such as building frozen AP on windows and loading launcher or joinking shapez and setting its minimum version to 0.7.0, by injecting:

{
	"version": 6,
	"compatible_version": 6,
	
	"game": "shapez",
	"minimum_ap_version": "0.7.0",
	"maximum_ap_version": "0.6.0",
	"world_version": "1.0.0"
}

and a bunch of others. However, this is something that can't be tested enough, so I'm putting it out now.

This could use some docs, which I hope someone is willing to contribute. Though, we should first cement if this is the API and behaviour we want.

@github-actions github-actions bot added affects: core Issues/PRs that touch core and may need additional validation. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels Jan 18, 2025
This import was done automatically by PyCharm, so I blame it personally.
@Berserker66 Berserker66 added is: enhancement Issues requesting new features or pull requests implementing new features. meta: help wanted Additional review/assistance is requested for these issues or pull requests. labels Jan 18, 2025
Comment on lines +393 to +396
apworld = APWorldContainer(str(zip_path))
apworld.minimum_ap_version = version
apworld.maximum_ap_version = version
apworld.game = worldtype.game
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should have some way to report world_version for frozen worlds as well to actually handle the beta apworld issues
worlds that want to keep their world version the same as ap's version could report their world_version as current ap + 1 and set their maximum_ap_version to current ap to make it always load over current ap but never overwrite any future release, so a default of ap's version would be fine too
but i imagine there would be some merged world devs that would want to manage their own version numbers as well

Comment on lines +190 to +195
def read_contents(self, opened_zipfile: zipfile.ZipFile) -> Dict[str, Any]:
manifest = super().read_contents(opened_zipfile)
self.player = manifest["player"]
self.server = manifest["server"]
self.player_name = manifest["player_name"]
return manifest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't modifying self and returning something at the same time a bit ambiguous, especially without doc string explaining that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's already how patch files work.

Copy link
Member

@black-sliver black-sliver Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a doc string?

        """
        Reads a manifest from an opened zipfile, updates the APPlayerContainer object and returns the full manifest.
        """

maybe?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's already how patch files work.

This looks wrong to me. In the main branch right now, none of the read_contents return anything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ArchipelagoMW/Archipelago/pull/4331/files#r1921592831
Since this is where it came in, I don't know if it's better to have the discussion there.

compression_level: int = 9
compression_method: int = zipfile.ZIP_DEFLATED
game: Optional[str] = None
"""A zipfile containing at least archipelago.json, which contains a manifest json payload."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like "subclasses extend the contents of the manifest" would be good here imo.



class APPlayerContainer(APContainer):
"""A zipfile containing at least archipelago.json meant for a player"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

", such as a mod" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. is: enhancement Issues requesting new features or pull requests implementing new features. meta: help wanted Additional review/assistance is requested for these issues or pull requests. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants