diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 00000000..924313e4 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,644 @@ +# Archipelago API + +This document tries to explain some internals required to implement a game for +Archipelago's generation and server. Once a seed is generated, a client or mod is +required to send and receive items between the game and server. + +Client implementation is out of scope of this document. Please refer to an +existing game that provides a similar API to yours. +Refer to the following documents as well: + * [network protocol.md](https://github.com/ArchipelagoMW/Archipelago/blob/main/docs/network%20protocol.md) + * [adding games.md](https://github.com/ArchipelagoMW/Archipelago/blob/main/docs/adding%20games.md) + +Archipelago will be abbreviated as "AP" from now on. + + +## Language + +AP worlds are written in python3. +Clients that connect to the server to sync items can be in any language that +allows using WebSockets. + + +## Coding style + +AP follows all the PEPs. When in doubt use an IDE with coding style +linter, for example PyCharm Community Edition. + + +## Docstrings + +Docstrings are strings attached to an object in Python that describe what the +object is supposed to be. Certain docstrings will be picked up and used by AP. +They are assigned by writing a string without any assignment right below a +definition. The string must be a triple-quoted string. +Example: +```python +class MyGameWorld(World): + """This is the description of My Game that will be displayed on the AP + website.""" +``` + + +## Definitions + +### World Class + +A `World` class is the class with all the specifics of a certain game to be +included. It will be instantiated for each player that rolls a seed for that +game. + +### MultiWorld Object + +The `MultiWorld` object references the whole multiworld (all items and locations +for all players) and is accessible through `self.world` inside a `World` object. + +### Player + +The player is just an integer in AP and is accessible through `self.player` +inside a World object. + +### Player Options + +Players provide customized settings for their World in the form of yamls. +Those are accessible through `self.world.[self.player]`. A dict +of valid options has to be provided in `self.options`. Options are automatically +added to the `World` object for easy access. + +### World Options + +Any AP installation can provide settings for a world, for example a ROM file, +accessible through `Utils.get_options()['_options']['