This commit is contained in:
2025-05-20 21:34:52 -05:00
parent 7b92b11696
commit 1bce56231c
11 changed files with 107 additions and 40 deletions

View File

@@ -1,14 +1,22 @@
class_name Item
enum Type {
POTION,
ONION
# Items
POTION = 1,
# Ingredients
ONION = 2,
SWEET_POTATO = 3,
# Recipe outputs
ASH_BAKED_SWEET_POTATO = 4,
};
enum Category {
MEDICINE,
KEY_ITEM,
INGREDIENT
INGREDIENT,
FOOD
};
static func isStackable(itemType:Type) -> bool:
@@ -17,7 +25,7 @@ static func isStackable(itemType:Type) -> bool:
_:
return true
static func getName(itemType:Type, count:int = 1) -> String:
static func getItemName(itemType:Type, count:int = 1) -> String:
match itemType:
Type.POTION:
if count != 1:
@@ -29,35 +37,52 @@ static func getName(itemType:Type, count:int = 1) -> String:
return "Onions"
return "Onion"
Type.SWEET_POTATO:
if count != 1:
return "Sweet Potatoes"
return "Sweet Potato"
Type.ASH_BAKED_SWEET_POTATO:
if count != 1:
return "Ash-Baked Sweet Potatoes"
return "Ash-Baked Sweet Potato"
_:
assert(false, "Invalid item type")
return ""
# func getName() -> String:
# push_error("getName() must be overridden in derived classes");
# return "";
static func getItemDescription(itemType:Type) -> String:
match itemType:
Type.POTION:
return "A potent healing drink, infused with magical properties. Restores health and stamina."
# func isStackable() -> bool:
# return true;
Type.ONION:
return "A common vegetable, known for its strong flavor and aroma. Can be used in cooking."
# func isDroppable() -> bool:
# return true;
Type.SWEET_POTATO:
return "A nutritious root vegetable, sweet and starchy. Can be used in cooking."
# func isSellable() -> bool:
# return true;
Type.ASH_BAKED_SWEET_POTATO:
return "Tender, warm, and sweet meal, made by baking a sweet potato in campfire embers. Comforting, simple, and gently filling."
# func getSellPrice() -> int:
# return 0;
_:
assert(false, "Invalid item type")
return ""
# func getBuyPrice() -> int:
# return 0;
static func getItemCategory(itemType:Type) -> Category:
match itemType:
Type.POTION:
return Category.MEDICINE
# func isConsumable() -> bool:
# return false;
Type.ONION:
return Category.INGREDIENT
# func consume() -> void:
# pass
# func getCategory() -> ItemCategory:
# push_error("getCategory() must be overriden in derived class");
# return ItemCategory.MEDICINE;
Type.SWEET_POTATO:
return Category.INGREDIENT
Type.ASH_BAKED_SWEET_POTATO:
return Category.FOOD
_:
assert(false, "Invalid item type")
return Category.KEY_ITEM