Crafting Attempt 1

This commit is contained in:
dingo
2025-12-23 08:42:14 -05:00
parent 6f1968943b
commit d813aa2c76
7 changed files with 940 additions and 0 deletions
+183
View File
@@ -0,0 +1,183 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Server.Data.Entities;
/// <summary>
/// A crafting recipe that can produce an item
/// Recipes are discovered through trial-and-error
/// </summary>
[Table("dungeon_crafting_recipes")]
public class DungeonCraftingRecipe
{
[Key]
public int Id { get; set; }
/// <summary>
/// Name of the recipe (e.g., "Iron Sword", "Health Potion")
/// </summary>
[Required]
[MaxLength(64)]
public string Name { get; set; } = "";
/// <summary>
/// Description of the recipe
/// </summary>
[MaxLength(256)]
public string Description { get; set; } = "";
/// <summary>
/// Which crafting skill is used
/// </summary>
public CraftingSkillType SkillType { get; set; }
/// <summary>
/// Minimum crafting level required to craft this recipe
/// </summary>
public int RequiredLevel { get; set; } = 1;
/// <summary>
/// Item definition ID that this recipe produces
/// </summary>
public int OutputItemDefinitionId { get; set; }
/// <summary>
/// How many items are produced per craft
/// </summary>
public int OutputQuantity { get; set; } = 1;
/// <summary>
/// Tier of the recipe (affects XP gain and stat rolls)
/// </summary>
public int Tier { get; set; } = 1;
/// <summary>
/// Base XP awarded for crafting (modified by level difference)
/// </summary>
public int BaseXp { get; set; } = 25;
/// <summary>
/// Whether this is a "base" recipe everyone knows, or must be discovered
/// </summary>
public bool IsBaseRecipe { get; set; } = false;
/// <summary>
/// If true, the output item gets random stat rolls
/// If false, it's a fixed item (like potions)
/// </summary>
public bool HasStatRolls { get; set; } = false;
/// <summary>
/// JSON array of possible stats that can roll on this item
/// e.g., ["BonusStrength", "BonusDexterity", "MinDamage", "MaxDamage"]
/// </summary>
[MaxLength(1024)]
public string? PossibleStatsJson { get; set; }
public bool IsEnabled { get; set; } = true;
// Navigation
public virtual DungeonItemDefinition? OutputItem { get; set; }
public virtual ICollection<DungeonCraftingRecipeIngredient> Ingredients { get; set; } = new List<DungeonCraftingRecipeIngredient>();
// Helper to get possible stats
[NotMapped]
public List<string> PossibleStats
{
get
{
if (string.IsNullOrEmpty(PossibleStatsJson)) return new List<string>();
try { return System.Text.Json.JsonSerializer.Deserialize<List<string>>(PossibleStatsJson) ?? new List<string>(); }
catch { return new List<string>(); }
}
}
}
/// <summary>
/// An ingredient required for a recipe
/// </summary>
[Table("dungeon_crafting_recipe_ingredients")]
public class DungeonCraftingRecipeIngredient
{
[Key]
public int Id { get; set; }
[Required]
public int RecipeId { get; set; }
/// <summary>
/// Item definition ID of the required ingredient
/// </summary>
[Required]
public int ItemDefinitionId { get; set; }
/// <summary>
/// How many of this item are needed
/// </summary>
public int Quantity { get; set; } = 1;
/// <summary>
/// Order for recipe matching (ingredients must match in order for discovery)
/// </summary>
public int SlotOrder { get; set; } = 0;
// Navigation
public virtual DungeonCraftingRecipe? Recipe { get; set; }
public virtual DungeonItemDefinition? ItemDefinition { get; set; }
}
/// <summary>
/// Tracks which recipes a character has discovered
/// </summary>
[Table("dungeon_character_known_recipes")]
public class DungeonCharacterKnownRecipe
{
[Key]
public ulong Id { get; set; }
[Required]
public ulong CharacterId { get; set; }
[Required]
public int RecipeId { get; set; }
/// <summary>
/// When the recipe was discovered
/// </summary>
public DateTime DiscoveredAt { get; set; } = DateTime.UtcNow;
/// <summary>
/// How many times this recipe has been crafted
/// </summary>
public int TimesCrafted { get; set; } = 0;
// Navigation
public virtual DungeonCharacter? Character { get; set; }
public virtual DungeonCraftingRecipe? Recipe { get; set; }
}
/// <summary>
/// A recipe scroll item that can teach a recipe when used
/// </summary>
[Table("dungeon_recipe_scrolls")]
public class DungeonRecipeScroll
{
[Key]
public int Id { get; set; }
/// <summary>
/// The item definition ID of this scroll
/// </summary>
[Required]
public int ItemDefinitionId { get; set; }
/// <summary>
/// The recipe this scroll teaches
/// </summary>
[Required]
public int RecipeId { get; set; }
// Navigation
public virtual DungeonItemDefinition? ItemDefinition { get; set; }
public virtual DungeonCraftingRecipe? Recipe { get; set; }
}