add version checking, add gitignore
This commit is contained in:
parent
87a8200d5d
commit
0bac99434f
3 changed files with 25 additions and 1 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/__pycache__/
|
22
setage.py
22
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.")
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue