Settings: add requires

This commit is contained in:
Fabian Dill 2021-06-18 22:15:54 +02:00
parent a5bf3a8407
commit a08d7bb1b2
8 changed files with 32 additions and 14 deletions

View File

@ -76,7 +76,7 @@ class FactorioContext(CommonContext):
await super(FactorioContext, self).server_auth(password_requested)
await self.send_msgs([{"cmd": 'Connect',
'password': self.password, 'name': self.auth, 'version': Utils._version_tuple,
'password': self.password, 'name': self.auth, 'version': Utils.version_tuple,
'tags': ['AP'],
'uuid': Utils.get_unique_identifier(), 'game': "Factorio"
}])

View File

@ -97,7 +97,7 @@ class Context(CommonContext):
self.auth = self.rom
auth = base64.b64encode(self.rom).decode()
await self.send_msgs([{"cmd": 'Connect',
'password': self.password, 'name': auth, 'version': Utils._version_tuple,
'password': self.password, 'name': auth, 'version': Utils.version_tuple,
'tags': get_tags(self),
'uuid': Utils.get_unique_identifier(), 'game': "A Link to the Past"
}])

View File

@ -20,7 +20,7 @@ from worlds.alttp.Dungeons import create_dungeons, fill_dungeons, fill_dungeons_
from Fill import distribute_items_restrictive, flood_items, balance_multiworld_progression, distribute_planned
from worlds.alttp.Shops import create_shops, ShopSlotFill, SHOP_ID_START, total_shop_slots, FillDisabledShopSlots
from worlds.alttp.ItemPool import generate_itempool, difficulties, fill_prizes
from Utils import output_path, parse_player_names, get_options, __version__, _version_tuple
from Utils import output_path, parse_player_names, get_options, __version__, version_tuple
from worlds.hk import gen_hollow
from worlds.hk import create_regions as hk_create_regions
from worlds.minecraft import gen_minecraft, fill_minecraft_slot_data, generate_mc_data
@ -557,7 +557,7 @@ def main(args, seed=None):
"er_hint_data": er_hint_data,
"precollected_items": precollected_items,
"precollected_hints": precollected_hints,
"version": tuple(_version_tuple),
"version": tuple(version_tuple),
"tags": ["AP"],
"minimum_versions": minimum_versions,
"seed_name": world.seed_name

View File

@ -30,7 +30,7 @@ from worlds import network_data_package, lookup_any_item_id_to_name, lookup_any_
lookup_any_location_id_to_name, lookup_any_location_name_to_id
import Utils
from Utils import get_item_name_from_id, get_location_name_from_id, \
_version_tuple, restricted_loads, Version
version_tuple, restricted_loads, Version
from NetUtils import Node, Endpoint, ClientStatus, NetworkItem, decode, NetworkPlayer
colorama.init()
@ -136,9 +136,9 @@ class Context(Node):
def _load(self, decoded_obj: dict, use_embedded_server_options: bool):
mdata_ver = decoded_obj["minimum_versions"]["server"]
if mdata_ver > Utils._version_tuple:
if mdata_ver > Utils.version_tuple:
raise RuntimeError(f"Supplied Multidata (.archipelago) requires a server of at least version {mdata_ver},"
f"however this server is of version {Utils._version_tuple}")
f"however this server is of version {Utils.version_tuple}")
clients_ver = decoded_obj["minimum_versions"].get("clients", {})
self.minimum_client_versions = {}
for player, version in clients_ver.items():
@ -379,7 +379,7 @@ async def on_client_connected(ctx: Context, client: Client):
# tags are for additional features in the communication.
# Name them by feature or fork, as you feel is appropriate.
'tags': ctx.tags,
'version': Utils._version_tuple,
'version': Utils.version_tuple,
'forfeit_mode': ctx.forfeit_mode,
'remaining_mode': ctx.remaining_mode,
'hint_cost': ctx.hint_cost,
@ -1011,7 +1011,7 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
errors.add('IncompatibleVersion')
# only exact version match allowed
if ctx.compatibility == 0 and args['version'] != _version_tuple:
if ctx.compatibility == 0 and args['version'] != version_tuple:
errors.add('IncompatibleVersion')
if errors:
logging.info(f"A client connection was refused due to: {errors}")

View File

@ -13,7 +13,7 @@ from worlds.generic import PlandoItem, PlandoConnection
ModuleUpdate.update()
from Utils import parse_yaml
from Utils import parse_yaml, version_tuple, __version__, tuplize_version
from worlds.alttp.EntranceRandomizer import parse_arguments
from Main import main as ERmain
from Main import get_seed, seeddigits
@ -453,6 +453,22 @@ def get_plando_bosses(boss_shuffle: str, plando_options: typing.Set[str]) -> str
def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("bosses",))):
requirements = weights.get("requires", {})
if requirements:
version = requirements.get("version", __version__)
if tuplize_version(version) > version_tuple:
raise Exception(f"Settings reports required version of generator is at least {version}, "
f"however generator is of version {__version__}")
required_plando_options = requirements.get("plando", "")
required_plando_options = set(option.strip() for option in required_plando_options.split(","))
required_plando_options -= plando_options
if required_plando_options:
if len(required_plando_options) == 1:
raise Exception(f"Settings reports required plando module {', '.join(required_plando_options)}, "
f"which is not enabled.")
else:
raise Exception(f"Settings reports required plando modules {', '.join(required_plando_options)}, "
f"which are not enabled.")
if "pre_rolled" in weights:
pre_rolled = weights["pre_rolled"]

View File

@ -12,8 +12,8 @@ class Version(typing.NamedTuple):
minor: int
build: int
__version__ = "0.1.2"
_version_tuple = tuplize_version(__version__)
__version__ = "0.1.3"
version_tuple = tuplize_version(__version__)
import builtins
import os

View File

@ -27,6 +27,8 @@ game:
A Link to the Past: 1
Factorio: 1
Minecraft: 1
requires:
version: 0.1.3 # Version of Archipelago required for this yaml to work as expected.
# Shared Options supported by all games:
accessibility:
items: 0 # Guarantees you will be able to acquire all items, but you may not be able to access all locations

View File

@ -48,10 +48,10 @@ def manifest_creation(folder):
path = os.path.join(dirpath, filename)
hashes[os.path.relpath(path, start=folder)] = pool.submit(_threaded_hash, path)
import json
from Utils import _version_tuple
from Utils import version_tuple
manifest = {"buildtime": buildtime.isoformat(sep=" ", timespec="seconds"),
"hashes": {path: hash.result() for path, hash in hashes.items()},
"version": _version_tuple}
"version": version_tuple}
json.dump(manifest, open(manifestpath, "wt"), indent=4)
print("Created Manifest")