Big cleanup
This commit is contained in:
@@ -11,11 +11,7 @@ public sealed class GameDbContext : DbContext
|
||||
|
||||
public DbSet<Account> Accounts => Set<Account>();
|
||||
public DbSet<Session> Sessions => Set<Session>();
|
||||
public DbSet<Old_Character> Characters => Set<Old_Character>();
|
||||
public DbSet<Zone> Zones => Set<Zone>();
|
||||
public DbSet<ItemTemplate> ItemTemplates => Set<ItemTemplate>();
|
||||
public DbSet<InventoryItem> Inventory => Set<InventoryItem>();
|
||||
public DbSet<EquipmentSlot> Equipment => Set<EquipmentSlot>();
|
||||
public DbSet<DungeonCharacter> DungeonCharacters => Set<DungeonCharacter>();
|
||||
public DbSet<DungeonCharacterItem> DungeonCharacterItems => Set<DungeonCharacterItem>();
|
||||
public DbSet<DungeonStashItem> DungeonStashItems => Set<DungeonStashItem>();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DataServer.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace DataServer.Data;
|
||||
@@ -20,7 +21,7 @@ public sealed class Account
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
public ICollection<Session> Sessions { get; set; } = new List<Session>();
|
||||
public ICollection<Old_Character> Characters { get; set; } = new List<Old_Character>();
|
||||
public ICollection<DungeonCharacter> Characters { get; set; } = new List<DungeonCharacter>();
|
||||
|
||||
// Helper methods
|
||||
public bool IsAdmin => Role == AccountRole.Admin || Role == AccountRole.SuperAdmin;
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DataServer.Data;
|
||||
namespace DataServer.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Derived stats calculator - used at runtime
|
||||
/// </summary>
|
||||
public static class CharacterStats
|
||||
{
|
||||
public static int GetMaxHealth(Character c) => 50 + (c.Endurance * 10);
|
||||
public static int GetMaxMana(Character c) => 20 + (c.Wisdom * 8);
|
||||
public static int GetMaxStamina(Character c) => 50 + (c.Endurance * 5);
|
||||
public static float GetXpBonus(Character c) => 1.0f + (c.Wisdom * 0.02f);
|
||||
public static float GetMoveSpeed(Character c) => 100f + (c.Dexterity * 2f);
|
||||
public static float GetAttackSpeed(Character c) => 1.0f + (c.Dexterity * 0.02f);
|
||||
public static float GetRegenRate(Character c) => 1.0f + (c.Endurance * 0.1f);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate combat stats including equipment bonuses
|
||||
/// </summary>
|
||||
public static CharacterCombatStats GetCombatStats(Character c, List<ItemDefinition>? equippedItems = null)
|
||||
{
|
||||
var stats = new CharacterCombatStats
|
||||
{
|
||||
Strength = c.Strength,
|
||||
Intelligence = c.Intelligence,
|
||||
Wisdom = c.Wisdom,
|
||||
Endurance = c.Endurance,
|
||||
Dexterity = c.Dexterity
|
||||
};
|
||||
|
||||
if (equippedItems != null)
|
||||
{
|
||||
foreach (var item in equippedItems)
|
||||
{
|
||||
stats.Strength += item.BonusStrength;
|
||||
stats.Intelligence += item.BonusIntelligence;
|
||||
stats.Wisdom += item.BonusWisdom;
|
||||
stats.Endurance += item.BonusEndurance;
|
||||
stats.Dexterity += item.BonusDexterity;
|
||||
stats.BonusHealth += item.BonusHealth;
|
||||
stats.BonusMana += item.BonusMana;
|
||||
stats.Armor += item.Armor;
|
||||
stats.MagicResist += item.MagicResist;
|
||||
}
|
||||
}
|
||||
|
||||
stats.MaxHealth = 50 + (stats.Endurance * 10) + stats.BonusHealth;
|
||||
stats.MaxMana = 20 + (stats.Wisdom * 8) + stats.BonusMana;
|
||||
stats.MaxStamina = 50 + (stats.Endurance * 5);
|
||||
stats.MoveSpeed = 100f + (stats.Dexterity * 2f);
|
||||
stats.AttackSpeed = 1.0f + (stats.Dexterity * 0.02f);
|
||||
stats.RegenRate = 1.0f + (stats.Endurance * 0.1f);
|
||||
stats.PhysicalDamageMultiplier = 1.0f + (stats.Strength * 0.05f);
|
||||
stats.SpellDamageMultiplier = 1.0f + (stats.Intelligence * 0.05f);
|
||||
stats.XpBonus = 1.0f + (stats.Wisdom * 0.02f);
|
||||
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
||||
public class CharacterCombatStats
|
||||
{
|
||||
public int Strength { get; set; }
|
||||
public int Intelligence { get; set; }
|
||||
public int Wisdom { get; set; }
|
||||
public int Endurance { get; set; }
|
||||
public int Dexterity { get; set; }
|
||||
public int MaxHealth { get; set; }
|
||||
public int MaxMana { get; set; }
|
||||
public int MaxStamina { get; set; }
|
||||
public int BonusHealth { get; set; }
|
||||
public int BonusMana { get; set; }
|
||||
public int Armor { get; set; }
|
||||
public int MagicResist { get; set; }
|
||||
public float MoveSpeed { get; set; }
|
||||
public float AttackSpeed { get; set; }
|
||||
public float RegenRate { get; set; }
|
||||
public float PhysicalDamageMultiplier { get; set; }
|
||||
public float SpellDamageMultiplier { get; set; }
|
||||
public float XpBonus { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Persistent player character with stats and equipment
|
||||
/// </summary>
|
||||
[Table("characters")]
|
||||
public class Character
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public ulong AccountId { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(32)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime LastPlayedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Progression
|
||||
public int Level { get; set; } = 1;
|
||||
public long Experience { get; set; } = 0;
|
||||
public int UnspentStatPoints { get; set; } = 5; // Start with 5 points
|
||||
|
||||
// Core Stats (5 points per level to distribute)
|
||||
public int Strength { get; set; } = 1; // Physical damage, heavy equipment
|
||||
public int Intelligence { get; set; } = 1; // Spell damage, magical equipment
|
||||
public int Wisdom { get; set; } = 1; // Max mana, XP bonus, spell learning
|
||||
public int Endurance { get; set; } = 1; // Max HP, max stamina, regen rate
|
||||
public int Dexterity { get; set; } = 1; // Move speed, attack speed, light equipment
|
||||
|
||||
// Derived stats (calculated from base stats)
|
||||
[NotMapped] public int MaxHealth => 50 + (Endurance * 10);
|
||||
[NotMapped] public int MaxMana => 20 + (Wisdom * 8);
|
||||
[NotMapped] public int MaxStamina => 50 + (Endurance * 5);
|
||||
[NotMapped] public float XpBonus => 1.0f + (Wisdom * 0.02f); // 2% per WIS
|
||||
[NotMapped] public float MoveSpeed => 100f + (Dexterity * 2f);
|
||||
[NotMapped] public float AttackSpeed => 1.0f + (Dexterity * 0.02f);
|
||||
[NotMapped] public float RegenRate => 1.0f + (Endurance * 0.1f); // HP/Mana/Stamina regen multiplier
|
||||
|
||||
// Current state (saved on logout/death)
|
||||
public int CurrentHealth { get; set; } = 50;
|
||||
public int CurrentMana { get; set; } = 20;
|
||||
|
||||
// Equipment slots (ItemId references, null = empty)
|
||||
public ulong? EquippedWeapon { get; set; }
|
||||
public ulong? EquippedOffhand { get; set; }
|
||||
public ulong? EquippedHead { get; set; }
|
||||
public ulong? EquippedChest { get; set; }
|
||||
public ulong? EquippedLegs { get; set; }
|
||||
public ulong? EquippedBoots { get; set; }
|
||||
public ulong? EquippedGloves { get; set; }
|
||||
public ulong? EquippedAccessory { get; set; }
|
||||
|
||||
// Lifetime stats
|
||||
public int TotalKills { get; set; }
|
||||
public int TotalDeaths { get; set; }
|
||||
public int PlayersKilled { get; set; }
|
||||
public int DungeonsCompleted { get; set; }
|
||||
public int BossesKilled { get; set; }
|
||||
|
||||
// Soft delete
|
||||
public bool IsDeleted { get; set; } = false;
|
||||
|
||||
// Navigation
|
||||
public virtual Account? Account { get; set; }
|
||||
public virtual ICollection<CharacterItem> Inventory { get; set; } = new List<CharacterItem>();
|
||||
public virtual ICollection<StashItem> Stash { get; set; } = new List<StashItem>();
|
||||
public virtual ICollection<LearnedSpell> LearnedSpells { get; set; } = new List<LearnedSpell>();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DungeonVisit
|
||||
|
||||
// Navigation
|
||||
public virtual DungeonInstance? Dungeon { get; set; }
|
||||
public virtual Character? Character { get; set; }
|
||||
//public virtual Character? Character { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class LootTableEntry
|
||||
|
||||
// Navigation
|
||||
public virtual LootTable? LootTable { get; set; }
|
||||
public virtual ItemDefinition? ItemDefinition { get; set; }
|
||||
//public virtual ItemDefinition? ItemDefinition { get; set; }
|
||||
}
|
||||
|
||||
// Enums
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace DataServer.Data;
|
||||
|
||||
public sealed class EquipmentSlot
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public ulong CharacterId { get; set; }
|
||||
public byte SlotCode { get; set; } // 1=head,2=chest,...
|
||||
public ulong ItemTemplateId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
public Old_Character? Old_Character { get; set; }
|
||||
public ItemTemplate? ItemTemplate { get; set; }
|
||||
}
|
||||
|
||||
public sealed class EquipmentSlotConfig : IEntityTypeConfiguration<EquipmentSlot>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<EquipmentSlot> e)
|
||||
{
|
||||
e.ToTable("equipment");
|
||||
e.HasKey(x => x.Id);
|
||||
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||
e.HasIndex(x => new { x.CharacterId, x.SlotCode }).IsUnique();
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
|
||||
e.HasOne(x => x.Old_Character).WithMany().HasForeignKey(x => x.CharacterId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(x => x.ItemTemplate).WithMany().HasForeignKey(x => x.ItemTemplateId).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace DataServer.Data;
|
||||
|
||||
public sealed class InventoryItem
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public ulong CharacterId { get; set; }
|
||||
public uint SlotIndex { get; set; }
|
||||
public ulong ItemTemplateId { get; set; }
|
||||
public uint Quantity { get; set; } = 1;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
public Old_Character? Old_Character { get; set; }
|
||||
public ItemTemplate? ItemTemplate { get; set; }
|
||||
}
|
||||
|
||||
public sealed class InventoryItemConfig : IEntityTypeConfiguration<InventoryItem>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<InventoryItem> e)
|
||||
{
|
||||
e.ToTable("inventories");
|
||||
e.HasKey(x => x.Id);
|
||||
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||
e.HasIndex(x => new { x.CharacterId, x.SlotIndex }).IsUnique();
|
||||
e.HasIndex(x => x.CharacterId);
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
|
||||
e.HasOne(x => x.Old_Character).WithMany().HasForeignKey(x => x.CharacterId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(x => x.ItemTemplate).WithMany().HasForeignKey(x => x.ItemTemplateId).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace DataServer.Data;
|
||||
|
||||
public sealed class ItemTemplate
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
public byte ItemType { get; set; } = 1;
|
||||
public byte Rarity { get; set; } = 1;
|
||||
public uint MaxStack { get; set; } = 1;
|
||||
public uint Weight { get; set; } = 0;
|
||||
public string? StatsJson { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ItemTemplateConfig : IEntityTypeConfiguration<ItemTemplate>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ItemTemplate> e)
|
||||
{
|
||||
e.ToTable("item_templates");
|
||||
e.HasKey(x => x.Id);
|
||||
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||
e.Property(x => x.Name).HasMaxLength(64).IsRequired();
|
||||
e.HasIndex(x => x.Name).IsUnique();
|
||||
e.Property(x => x.StatsJson).HasColumnType("json");
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DataServer.Data.Enums;
|
||||
|
||||
namespace DataServer.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Item template/definition - what an item IS
|
||||
/// </summary>
|
||||
[Table("item_definitions")]
|
||||
public class ItemDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public ItemType Type { get; set; }
|
||||
public ItemRarity Rarity { get; set; } = ItemRarity.Common;
|
||||
public EquipmentSlot? EquipSlot { get; set; } // Null if not equippable
|
||||
|
||||
// Stat requirements to equip/use
|
||||
public int RequiredStrength { get; set; } = 0;
|
||||
public int RequiredIntelligence { get; set; } = 0;
|
||||
public int RequiredWisdom { get; set; } = 0;
|
||||
public int RequiredDexterity { get; set; } = 0;
|
||||
public int RequiredLevel { get; set; } = 1;
|
||||
|
||||
// Stat bonuses when equipped
|
||||
public int BonusStrength { get; set; } = 0;
|
||||
public int BonusIntelligence { get; set; } = 0;
|
||||
public int BonusWisdom { get; set; } = 0;
|
||||
public int BonusEndurance { get; set; } = 0;
|
||||
public int BonusDexterity { get; set; } = 0;
|
||||
public int BonusHealth { get; set; } = 0;
|
||||
public int BonusMana { get; set; } = 0;
|
||||
|
||||
// Weapon stats
|
||||
public int MinDamage { get; set; } = 0;
|
||||
public int MaxDamage { get; set; } = 0;
|
||||
public float AttackRange { get; set; } = 0; // 0 = melee
|
||||
public DamageType DamageType { get; set; } = DamageType.Physical;
|
||||
|
||||
// Armor stats
|
||||
public int Armor { get; set; } = 0;
|
||||
public int MagicResist { get; set; } = 0;
|
||||
|
||||
// Consumable effects
|
||||
public int HealAmount { get; set; } = 0;
|
||||
public int ManaRestore { get; set; } = 0;
|
||||
public int StaminaRestore { get; set; } = 0;
|
||||
|
||||
// Special
|
||||
public bool IsTeleportScroll { get; set; } = false;
|
||||
public int? TeachesSpellId { get; set; } // For spell tomes
|
||||
|
||||
// Stacking
|
||||
public bool Stackable { get; set; } = false;
|
||||
public int MaxStack { get; set; } = 1;
|
||||
|
||||
// Visuals
|
||||
public int SpriteId { get; set; } = 0;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Actual item instance owned by a character (inventory or equipped)
|
||||
/// </summary>
|
||||
[Table("character_items")]
|
||||
public class CharacterItem
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong CharacterId { get; set; }
|
||||
public int ItemDefinitionId { get; set; }
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
public int SlotIndex { get; set; } // Inventory position (0-29 for example)
|
||||
|
||||
public DateTime AcquiredAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation
|
||||
public virtual Character? Character { get; set; }
|
||||
public virtual ItemDefinition? Definition { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Items stored in character's stash (safe storage in hub)
|
||||
/// </summary>
|
||||
[Table("stash_items")]
|
||||
public class StashItem
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong CharacterId { get; set; }
|
||||
public int ItemDefinitionId { get; set; }
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
public int SlotIndex { get; set; }
|
||||
|
||||
public DateTime StoredAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation
|
||||
public virtual Character? Character { get; set; }
|
||||
public virtual ItemDefinition? Definition { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spell definition - learnable abilities
|
||||
/// </summary>
|
||||
[Table("spell_definitions")]
|
||||
public class SpellDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public SpellType Type { get; set; }
|
||||
|
||||
// Requirements
|
||||
public int RequiredWisdom { get; set; } = 1;
|
||||
public int RequiredIntelligence { get; set; } = 0;
|
||||
public int RequiredLevel { get; set; } = 1;
|
||||
|
||||
// Costs
|
||||
public int ManaCost { get; set; } = 10;
|
||||
public float Cooldown { get; set; } = 1.0f; // Seconds
|
||||
|
||||
// Effects
|
||||
public int BaseDamage { get; set; } = 0; // Scales with INT
|
||||
public int BaseHealing { get; set; } = 0; // Scales with WIS
|
||||
public float Range { get; set; } = 100f;
|
||||
public float AreaOfEffect { get; set; } = 0; // 0 = single target
|
||||
|
||||
// Special
|
||||
public bool IsTeleport { get; set; } = false;
|
||||
public bool IsShield { get; set; } = false;
|
||||
public int ShieldAmount { get; set; } = 0;
|
||||
|
||||
// Visuals
|
||||
public int SpriteId { get; set; } = 0;
|
||||
public string EffectColor { get; set; } = "#ffffff";
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spells a character has learned
|
||||
/// </summary>
|
||||
[Table("learned_spells")]
|
||||
public class LearnedSpell
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong CharacterId { get; set; }
|
||||
public int SpellDefinitionId { get; set; }
|
||||
|
||||
public DateTime LearnedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Could add spell levels/upgrades later
|
||||
public int SpellLevel { get; set; } = 1;
|
||||
|
||||
// Navigation
|
||||
public virtual Character? Character { get; set; }
|
||||
public virtual SpellDefinition? Definition { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace DataServer.Data;
|
||||
|
||||
public sealed class Old_Character
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public ulong AccountId { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public uint Level { get; set; } = 1;
|
||||
public ulong Xp { get; set; } = 0;
|
||||
|
||||
public uint StatStrength { get; set; } = 1;
|
||||
public uint StatDexterity { get; set; } = 1;
|
||||
public uint StatWisdom { get; set; } = 1;
|
||||
public uint StatIntelligence { get; set; } = 1;
|
||||
public uint StatEndurance { get; set; } = 1;
|
||||
|
||||
public uint HpCurrent { get; set; } = 10;
|
||||
public uint HpMax { get; set; } = 10;
|
||||
public uint MpCurrent { get; set; } = 0;
|
||||
public uint MpMax { get; set; } = 0;
|
||||
public uint StaminaCurrent { get; set; } = 0;
|
||||
public uint StaminaMax { get; set; } = 0;
|
||||
|
||||
public ulong ZoneId { get; set; }
|
||||
public double PosX { get; set; }
|
||||
public double PosY { get; set; }
|
||||
public double PosZ { get; set; }
|
||||
public float FacingDeg { get; set; }
|
||||
|
||||
// store as JSON in MySQL 8
|
||||
public string? AppearanceJson { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
public Account? Account { get; set; }
|
||||
public Zone? Zone { get; set; }
|
||||
}
|
||||
|
||||
public sealed class CharacterConfig : IEntityTypeConfiguration<Old_Character>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Old_Character> e)
|
||||
{
|
||||
e.ToTable("characters");
|
||||
e.HasKey(x => x.Id);
|
||||
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||
e.Property(x => x.Name).HasMaxLength(32).IsRequired();
|
||||
|
||||
e.HasIndex(x => x.AccountId).IsUnique(); // 1 character per account (change later if needed)
|
||||
e.HasIndex(x => x.ZoneId);
|
||||
|
||||
e.Property(x => x.AppearanceJson).HasColumnType("json");
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
|
||||
e.HasOne(x => x.Account).WithMany(a => a.Characters).HasForeignKey(x => x.AccountId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(x => x.Zone).WithMany().HasForeignKey(x => x.ZoneId).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user