add basic combine
This commit is contained in:
parent
425b266dcf
commit
304726302d
4 changed files with 39 additions and 1 deletions
|
@ -17,4 +17,6 @@ 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
|
||||
* [ ] reusable items ?
|
||||
* [ ] lockable
|
||||
|
|
|
@ -30,6 +30,12 @@ item.examine = "message when the `item` is examined" # `item` can be any item id
|
|||
item.hidden = false # optional, default.
|
||||
|
||||
|
||||
[recipes.itemid] # Optional
|
||||
ingredients = ["itemid1", "itemid2", ...] # Required
|
||||
result_text = "shorttext of the result item" # Required
|
||||
text = "message when items get combined with this recipe" # Optional; default = "> You combined items."
|
||||
|
||||
|
||||
[rooms.id] # Required, id can be any other room id.
|
||||
description = "description of the room as it appears in the listing of exits from other rooms"
|
||||
examine = "description of the room when you examine it"
|
||||
|
|
19
setage.py
19
setage.py
|
@ -484,6 +484,25 @@ class SetageShell(Cmd):
|
|||
"""Check your inventory."""
|
||||
self.do_inventory(arg)
|
||||
|
||||
def do_combine(self, arg):
|
||||
"""Combine items: combine item1,item2"""
|
||||
recipes = manifest["recipes"]
|
||||
items = [a.strip() for a in arg.split(",")]
|
||||
if len(items) < 2:
|
||||
print("> Can't combine this amount of items...")
|
||||
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"])
|
||||
for item in items:
|
||||
inventory.pop(item)
|
||||
inventory[recipe[0]] = recipe[1]["result_text"]
|
||||
return
|
||||
|
||||
def do_credits(self, arg):
|
||||
"""Print credits."""
|
||||
if "credits" not in metadata:
|
||||
|
|
|
@ -29,6 +29,15 @@ detergent.examine = "A bottle of detergent. Half-filled. Stinks."
|
|||
shiny.examine = "A heart-shaped shiny locket with a picture of a horse inside."
|
||||
shiny.hidden = true
|
||||
note.examine = "The note reads: there is a [shiny] hidden in one of the rooms of this house."
|
||||
stone.examine = "Ston. Rok."
|
||||
stick.examine = "stiC"
|
||||
weapon.examine = "wpn"
|
||||
|
||||
|
||||
[recipes.weapon]
|
||||
ingredients = ["stone", "stick"]
|
||||
text = "ooja booja"
|
||||
result_text = "a weapon"
|
||||
|
||||
|
||||
[rooms.1]
|
||||
|
@ -37,6 +46,8 @@ go = "You walk into a room full of trash, garbage and other junk."
|
|||
examine = "This room doesn't have much to it, just a lot of dust, old wood trash and a couple torn paintings. This room stinks!"
|
||||
|
||||
[rooms.1.items]
|
||||
stone = "Ston. RoK."
|
||||
stick = "stiC"
|
||||
|
||||
[rooms.1.interactables.lever]
|
||||
name = "a rustic lever"
|
||||
|
|
Loading…
Reference in a new issue