From 4fcce665053e6f0a3c2c1d4a753dee6ee9688394 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 31 Aug 2021 17:28:46 -0400 Subject: [PATCH] Move game names and descriptions into AutoWorld, fix option value names on player-settings pages --- WebHostLib/__init__.py | 50 ++++----------------------- WebHostLib/options.py | 2 +- WebHostLib/templates/games/games.html | 6 ++-- worlds/alttp/__init__.py | 12 +++++-- worlds/factorio/__init__.py | 5 +++ worlds/minecraft/__init__.py | 16 ++++++--- worlds/subnautica/__init__.py | 7 +++- 7 files changed, 41 insertions(+), 57 deletions(-) diff --git a/WebHostLib/__init__.py b/WebHostLib/__init__.py index 59091f6a..eb8b4724 100644 --- a/WebHostLib/__init__.py +++ b/WebHostLib/__init__.py @@ -8,6 +8,7 @@ from pony.flask import Pony from flask import Flask, request, redirect, url_for, render_template, Response, session, abort, send_from_directory from flask_caching import Cache from flask_compress import Compress +from worlds.AutoWorld import AutoWorldRegister from .models import * @@ -81,49 +82,6 @@ def page_not_found(err): return render_template('404.html'), 404 -games_list = { - "A Link to the Past": ("The Legend of Zelda: A Link to the Past", - """ - The Legend of Zelda: A Link to the Past is an action/adventure game. Take on the role of - Link, a boy who is destined to save the land of Hyrule. Delve through three palaces and nine - dungeons on your quest to rescue the descendents of the seven wise men and defeat the evil - Ganon!"""), - "Factorio": ("Factorio", - """ - Factorio is a game about automation. You play as an engineer who has crash landed on the planet - Nauvis, an inhospitable world filled with dangerous creatures called biters. Build a factory, - research new technologies, and become more efficient in your quest to build a rocket and return home. - """), - "Minecraft": ("Minecraft", - """ - Minecraft is a game about creativity. In a world made entirely of cubes, you explore, discover, mine, - craft, and try not to explode. Delve deep into the earth and discover abandoned mines, ancient - structures, and materials to create a portal to another world. Defeat the Ender Dragon, and claim - victory!"""), - "Subnautica": ("Subnautica", - """ - Subnautica is an undersea exploration game. Stranded on an alien world, you become infected by - an unknown bacteria. The planet's automatic quarantine will shoot you down if you try to leave. - You must find a cure for yourself, build an escape rocket, and leave the planet. - """), - "Ocarina of Time": ("The Legend of Zelda: Ocarina of Time", - """ - The Legend of Zelda: Ocarina of Time was the first three dimensional Zelda game. Journey as - Link as he quests to fulfil his destiny. Journey across Hyrule and defeat the evil masters of - corrupted temples or seek out the pieces of the Triforce. Defeat the evil Ganondorf to become - the Hero of Time and save Hyrule! - """), - "Super Metroid": ("Super Metroid", - """ - Samus is back in her first 16 bit adventure! Space pirates have attacked Ceres station and stolen - the last living Metroid. Go to planet Zebes and search out the abilities you will need to power - up your suit and defeat the villainous leader of the space pirates, Mother Brain. - """), - # "Ori and the Blind Forest": ("Ori and the Blind Forest", "Coming Soon™"), - # "Hollow Knight": ("Hollow Knight", "Coming Soon™"), -} - - # Player settings pages @app.route('/games//player-settings') def player_settings(game): @@ -145,7 +103,11 @@ def game_page(game): # List of supported games @app.route('/games') def games(): - return render_template("games/games.html", games_list=games_list) + worlds = {} + for game, world in AutoWorldRegister.world_types.items(): + if not world.hidden: + worlds[game] = world.__doc__ if world.__doc__ else "No description provided." + return render_template("games/games.html", worlds=worlds) @app.route('/tutorial///') diff --git a/WebHostLib/options.py b/WebHostLib/options.py index fa0b1db6..6a052fa2 100644 --- a/WebHostLib/options.py +++ b/WebHostLib/options.py @@ -48,7 +48,7 @@ def create(): for sub_option_name, sub_option_id in option.options.items(): this_option["options"].append({ - "name": sub_option_name, + "name": option.get_option_name(sub_option_id), "value": sub_option_name, }) diff --git a/WebHostLib/templates/games/games.html b/WebHostLib/templates/games/games.html index 9b5bec8d..3aa1eb49 100644 --- a/WebHostLib/templates/games/games.html +++ b/WebHostLib/templates/games/games.html @@ -9,9 +9,9 @@ {% include 'header/grassHeader.html' %}

Currently Supported Games

- {% for game, (display_name, description) in games_list.items() %} -

{{ display_name}}

-

{{ description}}

+ {% for game, description in worlds.items() %} +

{{ game }}

+

{{ description }}

{% endfor %}
{% endblock %} diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 10006daf..5ef5d332 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -24,6 +24,12 @@ lttp_logger = logging.getLogger("A Link to the Past") class ALTTPWorld(World): + """ + The Legend of Zelda: A Link to the Past is an action/adventure game. Take on the role of + Link, a boy who is destined to save the land of Hyrule. Delve through three palaces and nine + dungeons on your quest to rescue the descendents of the seven wise men and defeat the evil + Ganon! + """ game: str = "A Link to the Past" options = alttp_options topology_present = True @@ -192,8 +198,8 @@ class ALTTPWorld(World): elif 'Bow' in item_name: if state.has('Silver Bow', item.player): return - elif state.has('Bow', item.player) and (self.world.difficulty_requirements[item.player].progressive_bow_limit >= 2 - or self.world.logic[item.player] == 'noglitches' + elif state.has('Bow', item.player) and (self.world.difficulty_requirements[item.player].progressive_bow_limit >= 2 + or self.world.logic[item.player] == 'noglitches' or self.world.swordless[item.player]): # modes where silver bow is always required for ganon return 'Silver Bow' elif self.world.difficulty_requirements[item.player].progressive_bow_limit >= 1: @@ -401,4 +407,4 @@ class ALttPLogic(LogicMixin): return True if self.world.smallkey_shuffle[player] == smallkey_shuffle.option_universal: return self.can_buy_unlimited('Small Key (Universal)', player) - return self.prog_items[item, player] >= count \ No newline at end of file + return self.prog_items[item, player] >= count diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index 6c4bce45..6028ae61 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -24,6 +24,11 @@ all_items["Evolution Trap"] = factorio_base_id - 2 class Factorio(World): + """ + Factorio is a game about automation. You play as an engineer who has crash landed on the planet + Nauvis, an inhospitable world filled with dangerous creatures called biters. Build a factory, + research new technologies, and become more efficient in your quest to build a rocket and return home. + """ game: str = "Factorio" static_nodes = {"automation", "logistics", "rocket-silo"} custom_recipes = {} diff --git a/worlds/minecraft/__init__.py b/worlds/minecraft/__init__.py index 78ab60b9..fd972740 100644 --- a/worlds/minecraft/__init__.py +++ b/worlds/minecraft/__init__.py @@ -16,6 +16,12 @@ from ..AutoWorld import World client_version = 6 class MinecraftWorld(World): + """ + Minecraft is a game about creativity. In a world made entirely of cubes, you explore, discover, mine, + craft, and try not to explode. Delve deep into the earth and discover abandoned mines, ancient + structures, and materials to create a portal to another world. Defeat the Ender Dragon, and claim + victory! + """ game: str = "Minecraft" options = minecraft_options topology_present = True @@ -47,7 +53,7 @@ class MinecraftWorld(World): itempool = [] junk_pool = junk_weights.copy() # Add all required progression items - for (name, num) in required_items.items(): + for (name, num) in required_items.items(): itempool += [name] * num # Add structure compasses if desired if self.world.structure_compasses[self.player]: @@ -85,9 +91,9 @@ class MinecraftWorld(World): def MCRegion(region_name: str, exits=[]): ret = Region(region_name, None, region_name, self.player, self.world) ret.locations = [MinecraftAdvancement(self.player, loc_name, loc_data.id, ret) - for loc_name, loc_data in advancement_table.items() + for loc_name, loc_data in advancement_table.items() if loc_data.region == region_name] - for exit in exits: + for exit in exits: ret.exits.append(Entrance(self.player, exit, ret)) return ret @@ -100,7 +106,7 @@ class MinecraftWorld(World): with open(os.path.join(output_directory, filename), 'wb') as f: f.write(b64encode(bytes(json.dumps(data), 'utf-8'))) - def fill_slot_data(self): + def fill_slot_data(self): slot_data = self._get_mc_data() for option_name in minecraft_options: option = getattr(self.world, option_name)[self.player] @@ -115,7 +121,7 @@ class MinecraftWorld(World): item.never_exclude = True return item -def mc_update_output(raw_data, server, port): +def mc_update_output(raw_data, server, port): data = json.loads(b64decode(raw_data)) data['server'] = server data['port'] = port diff --git a/worlds/subnautica/__init__.py b/worlds/subnautica/__init__.py index 527cf8ee..50376a37 100644 --- a/worlds/subnautica/__init__.py +++ b/worlds/subnautica/__init__.py @@ -15,6 +15,11 @@ from ..AutoWorld import World class SubnauticaWorld(World): + """ + Subnautica is an undersea exploration game. Stranded on an alien world, you become infected by + an unknown bacteria. The planet's automatic quarantine will shoot you down if you try to leave. + You must find a cure for yourself, build an escape rocket, and leave the planet. + """ game: str = "Subnautica" item_name_to_id = items_lookup_name_to_id @@ -53,7 +58,7 @@ class SubnauticaWorld(World): pass - def fill_slot_data(self): + def fill_slot_data(self): slot_data = {} return slot_data