ItemDB+API
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Server.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Database-backed item definition for Void Scavengers
|
||||
/// </summary>
|
||||
public sealed class GameItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
public ItemCategory Category { get; set; }
|
||||
public int CraftCost { get; set; }
|
||||
public string Description { get; set; } = "";
|
||||
public int LootValue { get; set; }
|
||||
public bool Stackable { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
// Weapon stats (JSON or individual columns)
|
||||
public int Damage { get; set; }
|
||||
public float FireRate { get; set; }
|
||||
public float ProjectileSpeed { get; set; }
|
||||
public float Range { get; set; }
|
||||
public int AmmoType { get; set; }
|
||||
public int PelletCount { get; set; } = 1;
|
||||
public float Spread { get; set; }
|
||||
public float ExplosionRadius { get; set; }
|
||||
|
||||
// Tool stats
|
||||
public float HarvestMultiplier { get; set; } = 1f;
|
||||
public float ScanRadius { get; set; }
|
||||
public float ScanCooldown { get; set; }
|
||||
public int ShieldHealth { get; set; }
|
||||
public float ShieldDuration { get; set; }
|
||||
|
||||
// Consumable stats
|
||||
public int HealAmount { get; set; }
|
||||
public float ShieldBoostDuration { get; set; }
|
||||
public float DamageReduction { get; set; }
|
||||
public float SpeedBoostDuration { get; set; }
|
||||
public float SpeedMultiplier { get; set; } = 1f;
|
||||
|
||||
// Armor stats
|
||||
public int HealthBonus { get; set; }
|
||||
public float SpeedPenalty { get; set; }
|
||||
public float DashDistance { get; set; }
|
||||
public float DashCooldown { get; set; }
|
||||
|
||||
// Timestamps
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public enum ItemCategory
|
||||
{
|
||||
Resource = 0,
|
||||
Weapon = 1,
|
||||
Tool = 2,
|
||||
Consumable = 3,
|
||||
Armor = 4
|
||||
}
|
||||
|
||||
public sealed class GameItemConfig : IEntityTypeConfiguration<GameItem>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<GameItem> e)
|
||||
{
|
||||
e.ToTable("game_items");
|
||||
e.HasKey(x => x.Id);
|
||||
// Not auto-generated - we want specific IDs
|
||||
e.Property(x => x.Id).ValueGeneratedNever();
|
||||
|
||||
e.Property(x => x.Name).HasMaxLength(64).IsRequired();
|
||||
e.Property(x => x.Description).HasMaxLength(256);
|
||||
e.Property(x => x.IsEnabled).HasDefaultValue(true);
|
||||
|
||||
e.HasIndex(x => x.Category);
|
||||
e.HasIndex(x => x.IsEnabled);
|
||||
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user