From 87bf4af5338fde04db66722b8c0d42b78d089a0f Mon Sep 17 00:00:00 2001 From: Cheri Dawn Date: Thu, 23 May 2024 02:16:13 +0300 Subject: [PATCH] v0.4 initial --- CHANGELOG.md | 16 ++++++++++++ README.md | 6 +++++ docs.toml | 9 ++++--- setage.py | 52 +++++++++++++++++++++++---------------- test-game/manifest.setage | 12 ++++++--- 5 files changed, 67 insertions(+), 28 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5bb5005 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +# v0.4.0 +## Breaking changes +* `title` moved to metadata table. +* `playtested` moved to metadata table. +* `credits` table moved to metadata table. + +## Added features +* `metadata` table: + * `title` of the game + * `description` of the game + * `min_version` required to play the game + +## Fixes +* Fixed wording in some places. +* Fixed examine bug. +* Moved ending title to the bottom. diff --git a/README.md b/README.md index 90c0f44..af90cf2 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,9 @@ see docs.toml ## Example see test-game/manifest.setage + +## Planned Features +* more interactable types: + * `input` provides case insensitive input checking + * `exact input` provides exact input checking + * `item` provides item checking diff --git a/docs.toml b/docs.toml index 9fdc3c3..8a2f13d 100644 --- a/docs.toml +++ b/docs.toml @@ -1,4 +1,9 @@ -[credits] # Optional but highly recommended. +[metadata] # Required. +title = "title of the game" +description = "description of the game" # optional +min_version = "v0.4.0" # optional, highly recommended, minimum version of setage to play this manifest, "v" at the beginning is optional. + +[metadata.credits] # Optional but highly recommended. author = "who made the manifest for the game" contributors = [] # optional list of strings. year = "when it was made" @@ -7,9 +12,7 @@ license = "license for this manifest" [scenario] # Required. -min_version = "v0.3.1" # optional, highly recommended, minimum version of setage to play this manifest, "v" at the beginning is optional. start = "id" # room where the player starts. any valid room id. -title = "title of the game" intro = "intro to the game" prompt = "> " # optional, default shown. playtested = false # optional, default. displays a warning if this is set to false. diff --git a/setage.py b/setage.py index d653451..c42003e 100755 --- a/setage.py +++ b/setage.py @@ -11,11 +11,12 @@ from base64 import b64decode __author__ = "Cheri Dawn" __copyright__ = "Copyright 2024, Cheri Dawn" __license__ = "GPL-3.0-only" -__version__ = "0.3.1" +__version__ = "0.4.0" __maintainer__ = "Cheri Dawn" __status__ = "Prototype" manifest = {} +metadata = {} scenario = {} rooms = {} current_room_id = "" @@ -172,10 +173,13 @@ class SetageShell(Cmd): def complete_examine(self, text, line, bidx, eidx): global current_room_id all_items = manifest["items"] - all_items.update(rooms[current_room_id]["interactables"]) + if "interactables" in rooms[current_room_id]: + all_items.update(rooms[current_room_id]["interactables"]) items = dict(inventory) - items.update(rooms[current_room_id]["items"]) - items.update(rooms[current_room_id]["interactables"]) + if "items" in rooms[current_room_id]: + items.update(rooms[current_room_id]["items"]) + if "interactables" in rooms[current_room_id]: + items.update(rooms[current_room_id]["interactables"]) items = [x for x in items if (not all_items[x]["hidden"])] if not text: return list(items) @@ -423,10 +427,10 @@ class SetageShell(Cmd): def do_credits(self, arg): """Print credits.""" - if "credits" not in manifest: + if "credits" not in metadata: print("No credits :(") return - cred = manifest["credits"] + cred = metadata["credits"] print("Manifest credits:") if "author" in cred and "year" in cred: print(f"\tMade by {cred["author"]} in {cred["year"]}.") @@ -437,7 +441,7 @@ class SetageShell(Cmd): print(f"\tWith contributions by {", ".join(cred["contributors"])}") if "version" in cred: - print(f"\tVersion: {cred["version"]}") + print(f"\tManifest version: {cred["version"]}") if "license" in cred: print(f"\tLicense: {cred["license"]}") @@ -453,24 +457,24 @@ class SetageShell(Cmd): end = endings[ending] if end["trigger"] == "item": if end["target"] in dict(inventory).keys(): - if "title" in end: - print(end["title"]) if "message" not in end: print(f"WARNING: no message for ending '{ending}'") else: print(end["message"]) + if "title" in end: + print(end["title"]) if "exit" not in end: continue if end["exit"]: return True if end["trigger"] == "room": if current_room_id == end["target"]: - if "title" in end: - print(end["title"]) if "message" not in end: print(f"WARNING: no message for ending '{ending}'") else: print(end["message"]) + if "title" in end: + print(end["title"]) if "exit" not in end: continue if end["exit"]: @@ -513,17 +517,21 @@ if __name__ == "__main__": print("FATAL: " "table `scenario` does not exist in manifest.") exit(2) - if "min_version" not in manifest["scenario"]: + if "metadata" not in manifest: + print("FATAL: " + "table `metadata` does not exist in manifest.") + exit(2) + if "min_version" not in manifest["metadata"]: print("WARNING: no minimum SETAGE version specified in manifest.") else: - if VERSION < parse_version(manifest["scenario"]["min_version"]): + if VERSION < parse_version(manifest["metadata"]["min_version"]): print("FATAL: SETAGE version doesn't match required version.") if "rooms" not in manifest: print("FATAL: " "table `rooms` does not exist in manifest.") exit(2) - if "title" not in manifest["scenario"]: + if "title" not in manifest["metadata"]: print("FATAL: " "string `title` does not exist in scenario.") exit(2) @@ -544,10 +552,11 @@ if __name__ == "__main__": print("FATAL: " "`rooms` is not a table in scenario.") exit(2) - if not isinstance(manifest["items"], dict): - print("FATAL: " - "`items` is not a table in scenario.") - exit(2) + if "items" in manifest: + if not isinstance(manifest["items"], dict): + print("FATAL: " + "`items` is not a table in scenario.") + exit(2) if not isinstance(manifest["scenario"]["endings"], dict): print("FATAL: " "`endings` is not a table in scenario.") @@ -568,6 +577,7 @@ if __name__ == "__main__": if "hidden" not in v: v.update({"hidden": False}) + metadata = manifest["metadata"] scenario = manifest["scenario"] rooms = manifest["rooms"] current_room_id = scenario["start"] @@ -577,15 +587,15 @@ if __name__ == "__main__": if "prompt" in scenario: SetageShell.prompt = scenario["prompt"] - if "playtested" not in scenario: + if "playtested" not in metadata: print("WARNING: This manifest has not been playtested.") - elif not scenario["playtested"]: + elif not metadata["playtested"]: print("WARNING: This manifest has not been playtested.") print() print("? for help. Try ls.") print() - print(scenario["title"]) + print(metadata["title"]) print() SetageShell().cmdloop() diff --git a/test-game/manifest.setage b/test-game/manifest.setage index 8b1f72f..1acded8 100644 --- a/test-game/manifest.setage +++ b/test-game/manifest.setage @@ -1,4 +1,10 @@ -[credits] +[metadata] +title = "Dust Bunnies" +description = "A short and dusty game." +min_version = "0.4" +playtested = true + +[metadata.credits] author = "Cheri Dawn" year = "2024" license = "CC0" @@ -7,11 +13,9 @@ version = "2" [scenario] start = "1" -title = "Dust Bunnies" intro = "You wake up in a very dusty and old-looking room.\nYou think you can get out of here if you find something that could help you remember..." prompt = ": " -min_version = "0.3" -playtested = true +min_version = "0.4" [scenario.endings.1] trigger = "item"