diff --git a/README.md b/README.md index 45a75bd..e8084e3 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ see test-game/manifest.setage * [x] `exact input` provides exact input checking * [x] `item check`, `item take` provides item checking * [ ] combining items and other item interactions - * [ ] multiple outputs + * [x] basic + * [x] multiple outputs * [ ] reusable items ? * [ ] lockable + * [ ] "item" = examine an item + * [ ] "room" = enter a room + * [ ] "interactable" = use an interactable diff --git a/docs.toml b/docs.toml index 8c9e3cc..214cef5 100644 --- a/docs.toml +++ b/docs.toml @@ -30,9 +30,15 @@ item.examine = "message when the `item` is examined" # `item` can be any item id item.hidden = false # optional, default. -[recipes.itemid] # Optional +[recipes.recipeid] # Optional ingredients = ["itemid1", "itemid2", ...] # Required +# -- +result_id = "itemid" # Required result_text = "shorttext of the result item" # Required +# OR +result_ids = ["id1", "id2", ...] # Required +result_texts = ["text1", "text2", ...] # Required; short texts of the items +# -- text = "message when items get combined with this recipe" # Optional; default = "> You combined items." diff --git a/setage.py b/setage.py index a135450..3a309c4 100755 --- a/setage.py +++ b/setage.py @@ -489,18 +489,24 @@ class SetageShell(Cmd): recipes = manifest["recipes"] items = [a.strip() for a in arg.split(",")] if len(items) < 2: - print("> Can't combine this amount of items...") + print("> Not enough items to combine...") return for item in items: if item not in inventory: print(f"> {item} not in inventory...") return for recipe in recipes.items(): - if set(items) == set(recipe[1]["ingredients"]): - print(recipe[1]["text"]) + rec = recipe[1] + # FIXME: multiple recipes with same ingredients??? + if set(items) == set(rec["ingredients"]): + print(rec["text"]) for item in items: inventory.pop(item) - inventory[recipe[0]] = recipe[1]["result_text"] + if "result_ids" in rec: + for idx, _id in enumerate(rec["result_ids"]): + inventory[_id] = rec["result_texts"][idx] + else: + inventory[rec["result_id"]] = rec["result_text"] return def do_credits(self, arg): diff --git a/test-game/manifest.setage b/test-game/manifest.setage index ee14cd2..9a9f771 100644 --- a/test-game/manifest.setage +++ b/test-game/manifest.setage @@ -32,12 +32,14 @@ note.examine = "The note reads: there is a [shiny] hidden in one of the rooms of stone.examine = "Ston. Rok." stick.examine = "stiC" weapon.examine = "wpn" +trash.examine = "trasshhhhhhhhhhhhh" [recipes.weapon] -ingredients = ["stone", "stick"] text = "ooja booja" -result_text = "a weapon" +ingredients = ["stone", "stick"] +result_ids = ["weapon", "trash"] +result_texts = ["a weapon", "trsh"] [rooms.1] @@ -106,4 +108,4 @@ examine = "The room has yellowed wallpapers. They stink of old age. There's a fa note = "a torn, yellowed note" [rooms.4.exits] -up = "1" \ No newline at end of file +up = "1"