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,8 +1,30 @@
@tool
class_name Recipe extends Node
@export var recipeName:String = ""
@export var ingredients:Array[RecipeIngredient] = []
@export var ingredients:Array[ItemResource] = []
@export var outputs:Array[ItemResource] = []
func test():
print("test")
var learned:bool = false
var timesMade:int = 0
func hasIngredients(inventory:Inventory = null) -> bool:
if inventory == null:
inventory = ITEM.PLAYER_INVENTORY
for ingredient in ingredients:
if !inventory.hasItem(ingredient.type, ingredient.quantity):
return false
return true
func make(inventory:Inventory = null) -> void:
if inventory == null:
inventory = ITEM.PLAYER_INVENTORY
for ingredient in ingredients:
inventory.removeItem(ingredient.type, ingredient.quantity)
for output in outputs:
inventory.addItem(output.type, output.quantity)
timesMade += 1

View File

@@ -1,4 +0,0 @@
class_name RecipeIngredient extends Resource
@export var thing:int = 0
@export var count:int = 1

View File

@@ -18,9 +18,9 @@ func start() -> void:
var text:String = "";
match getType:
GetType.FOUND:
text = "Found " + str(quantity) + " " + Item.getName(itemType, quantity) + ".";
text = "Found " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
GetType.GIVEN:
text = "Received " + str(quantity) + " " + Item.getName(itemType, quantity) + ".";
text = "Received " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
_:
pass
VN.getTextbox().setText(text);

View File

@@ -1,5 +1,8 @@
class_name EventStartQuest extends "res://scripts/Event/Quest/EventShowQuest.gd"
@export_category("Event Start Quest")
var nothing:bool = false
func start():
assert(QUEST.quests.has(quest), "Quest not found.")
QUEST.quests[quest].start()

View File

@@ -7,7 +7,7 @@ enum ItemSortType {
class ItemStackNameComparator:
static func _sort(a, b):
return a.item.getName().to_lower() < b.item.getName().to_lower()
return Item.getItemName(a).to_lower() < Item.getItemName(b).to_lower()
class ItemStackTypeComparator:
static func _sort(a, b):

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

View File

@@ -0,0 +1,4 @@
class_name ItemResource extends Resource
@export var itemType:Item.Type = Item.Type.ONION;
@export var count:int = 1;

View File

@@ -0,0 +1 @@
uid://c26aptwsjs044

View File

@@ -1,5 +1,5 @@
class_name ItemLine extends HBoxContainer
func setStack(stack:ItemStack) -> void:
$ItemName.text = Item.getName(stack.type, 1)
$ItemName.text = Item.getItemName(stack.type, 1)
$ItemQuantity.text = str(stack.quantity)