add multiple outputs option

This commit is contained in:
Cheri Dawn 2024-08-26 16:49:11 +03:00
parent 304726302d
commit f9f172b5c5
4 changed files with 27 additions and 9 deletions

View file

@ -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

View file

@ -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."

View file

@ -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):

View file

@ -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"
up = "1"