// Copyright ExByte Studios. Item Interaction Ecosystem.

#pragma once

#include "CoreMinimal.h"
#include "Engine/DataTable.h"
#include "GameplayTagContainer.h"
#include "ItemEnums.h"
#include "ItemContentRows.generated.h"

/** DT_Containers row (section 6): a reusable container template. */
USTRUCT(BlueprintType)
struct ITEMDATABASE_API FContainerDefRow : public FTableRowBase
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	FGameplayTag ContainerTag;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	EInventoryContainerType Type = EInventoryContainerType::SlotList;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	int32 Width = 0;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	int32 Height = 0;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	int32 MaxSlots = 0;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	float MaxWeight = 0.f;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	FGameplayTagContainer AcceptedItemTags;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Container")
	FGameplayTagContainer BlockedItemTags;
};

/** DT_WorldSlots row (section 6/14): documents a world slot's contract. */
USTRUCT(BlueprintType)
struct ITEMDATABASE_API FWorldSlotDefRow : public FTableRowBase
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "World Slot")
	FGameplayTag SlotTag;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "World Slot")
	FGameplayTagContainer AcceptedItemTags;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "World Slot")
	FName AttachSocketName;
};

/** DT_LootTables row (section 6): one weighted drop in a named loot table. */
USTRUCT(BlueprintType)
struct ITEMDATABASE_API FLootEntryRow : public FTableRowBase
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Loot")
	FName TableId;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Loot")
	FName ItemId;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Loot")
	float Weight = 1.f;

	/** 0..1 independent chance that this entry rolls at all. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Loot")
	float Chance = 1.f;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Loot")
	int32 MinQuantity = 1;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Loot")
	int32 MaxQuantity = 1;
};

/** One required ingredient of a recipe. */
USTRUCT(BlueprintType)
struct ITEMDATABASE_API FCraftingIngredient
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	FName ItemId;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	int32 Quantity = 1;
};

/** DT_CraftingRecipes row (section 6). */
USTRUCT(BlueprintType)
struct ITEMDATABASE_API FCraftingRecipeRow : public FTableRowBase
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	FName RecipeId;

	/** Optional station requirement, e.g. Station.Workbench. Empty = craft anywhere. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	FGameplayTag StationTag;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	TArray<FCraftingIngredient> Inputs;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	FName OutputItemId;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	int32 OutputQuantity = 1;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Crafting")
	float CraftTime = 0.f;
};
