From 0bac99434f6dd79fc9f457724379ab71036331c5 Mon Sep 17 00:00:00 2001 From: Cheri Dawn Date: Wed, 22 May 2024 21:25:22 +0300 Subject: [PATCH] add version checking, add gitignore --- .gitignore | 1 + setage.py | 22 +++++++++++++++++++++- test-game/manifest.setage | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a348e50 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/__pycache__/ diff --git a/setage.py b/setage.py index 74cd9c1..d653451 100755 --- a/setage.py +++ b/setage.py @@ -11,7 +11,7 @@ from base64 import b64decode __author__ = "Cheri Dawn" __copyright__ = "Copyright 2024, Cheri Dawn" __license__ = "GPL-3.0-only" -__version__ = "0.3.0" +__version__ = "0.3.1" __maintainer__ = "Cheri Dawn" __status__ = "Prototype" @@ -22,6 +22,21 @@ current_room_id = "" inventory = [] +def parse_version(ver): + if len(ver) < 1: + raise ValueError("empty version string") + if ver[0] == "v": + ver = ver[1:] + try: + ver = [int(x) for x in ver.split(".")] + except ValueError: + raise ValueError("non integer version") + return tuple(ver) + + +VERSION = parse_version(__version__) + + def print_items(cur_room): if "items" not in cur_room: return @@ -498,6 +513,11 @@ if __name__ == "__main__": print("FATAL: " "table `scenario` does not exist in manifest.") exit(2) + if "min_version" not in manifest["scenario"]: + print("WARNING: no minimum SETAGE version specified in manifest.") + else: + if VERSION < parse_version(manifest["scenario"]["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.") diff --git a/test-game/manifest.setage b/test-game/manifest.setage index 0d87d01..8b1f72f 100644 --- a/test-game/manifest.setage +++ b/test-game/manifest.setage @@ -2,6 +2,7 @@ author = "Cheri Dawn" year = "2024" license = "CC0" +version = "2" [scenario] @@ -9,6 +10,8 @@ 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 [scenario.endings.1] trigger = "item"