DeathLoot
This commit is contained in:
@@ -25,6 +25,11 @@ public class DungeonSimulation
|
||||
public ConcurrentDictionary<int, ChestInstance> Chests { get; } = new();
|
||||
public ConcurrentDictionary<int, DroppedItem> DroppedItems { get; } = new();
|
||||
public ConcurrentDictionary<int, PortalInstance> Portals { get; } = new();
|
||||
public ConcurrentDictionary<int, LootChestInstance> LootChests { get; } = new();
|
||||
|
||||
// ID generator for loot chests
|
||||
private int _nextLootChestId = 1;
|
||||
public int GetNextLootChestId() => _nextLootChestId++;
|
||||
|
||||
// Combat tracking
|
||||
private readonly List<DamageEvent> _pendingDamageEvents = new();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace Server.Game.Dungeon;
|
||||
|
||||
/// <summary>
|
||||
/// Runtime instance of a personal loot chest (from death overflow)
|
||||
/// Only visible to the owner player
|
||||
/// </summary>
|
||||
public class LootChestInstance
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public ulong DatabaseId { get; set; } // Reference to DeathChest in DB
|
||||
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Character ID who can see/access this chest
|
||||
/// </summary>
|
||||
public ulong OwnerCharacterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gold stored in this chest
|
||||
/// </summary>
|
||||
public long Gold { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Items in the chest (100 slots max)
|
||||
/// </summary>
|
||||
public List<LootChestItem> Items { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the chest is currently open by the owner
|
||||
/// </summary>
|
||||
public bool IsOpen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Check if chest is empty and can be removed
|
||||
/// </summary>
|
||||
public bool IsEmpty => Items.Count == 0 && Gold == 0;
|
||||
}
|
||||
|
||||
public class LootChestItem
|
||||
{
|
||||
public int SlotIndex { get; set; }
|
||||
public int ItemDefinitionId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
@@ -3,6 +3,23 @@ using Server.Data.Enums;
|
||||
|
||||
namespace Server.Game.Dungeon;
|
||||
|
||||
/// <summary>
|
||||
/// Loot carried by a mob from killing a player
|
||||
/// </summary>
|
||||
public class CarriedLoot
|
||||
{
|
||||
public ulong VictimCharacterId { get; set; }
|
||||
public string VictimName { get; set; } = "";
|
||||
public List<CarriedLootItem> Items { get; set; } = new();
|
||||
public long Gold { get; set; }
|
||||
}
|
||||
|
||||
public class CarriedLootItem
|
||||
{
|
||||
public int ItemDefinitionId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime instance of a mob in a dungeon
|
||||
/// </summary>
|
||||
@@ -34,6 +51,14 @@ public class MobInstance
|
||||
public int SpriteWidth { get; set; } = 32;
|
||||
public int SpriteHeight { get; set; } = 32;
|
||||
public string TintColor { get; set; } = "#ffffff";
|
||||
|
||||
// Carried loot from player kills
|
||||
public List<CarriedLoot> CarriedPlayerLoot { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Check if this mob is carrying loot from player kills
|
||||
/// </summary>
|
||||
public bool HasCarriedLoot => CarriedPlayerLoot.Count > 0;
|
||||
}
|
||||
|
||||
public enum MobState
|
||||
|
||||
+1642
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SystemRevivalServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MobLoot : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "Gold",
|
||||
table: "dungeon_characters",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Gold",
|
||||
table: "dungeon_characters");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,6 +164,9 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Property<long>("Experience")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("Gold")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("Intelligence")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
||||
@@ -49,4 +49,15 @@ public static class DungeonOpCodes
|
||||
// Chat (260-269)
|
||||
public const int CHAT_SEND = 260;
|
||||
public const int CHAT_MESSAGE = 261;
|
||||
|
||||
// Loot Chests (270-279)
|
||||
public const int LOOT_CHEST_OPEN = 270;
|
||||
public const int LOOT_CHEST_STATE = 271;
|
||||
public const int LOOT_CHEST_TAKE_ITEM = 272;
|
||||
public const int LOOT_CHEST_TAKE_ALL = 273;
|
||||
public const int LOOT_CHEST_CLOSE = 274;
|
||||
public const int LOOT_CHEST_SPAWNED = 275;
|
||||
|
||||
// Player Death (280-289)
|
||||
public const int PLAYER_DEATH_LOOT_LOST = 280; // Notifies victim what they lost
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks death chests spawned when loot exceeds player inventory.
|
||||
/// Used for auditing and rule enforcement.
|
||||
/// </summary>
|
||||
[Table("dungeon_death_chests")]
|
||||
public class DeathChest
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The dungeon instance ID where this chest was created
|
||||
/// </summary>
|
||||
public Guid DungeonInstanceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Character who owns this chest (the killer who received the loot)
|
||||
/// </summary>
|
||||
public ulong OwnerCharacterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Character who died and dropped this loot (null if mob death)
|
||||
/// </summary>
|
||||
public ulong? VictimCharacterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mob that died and dropped this loot (null if player death)
|
||||
/// </summary>
|
||||
public int? VictimMobDefinitionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// World position where chest spawned
|
||||
/// </summary>
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total gold in the chest
|
||||
/// </summary>
|
||||
public long GoldAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the chest was created
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// When the chest was fully emptied (null if still has items)
|
||||
/// </summary>
|
||||
public DateTime? EmptiedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether all items have been collected
|
||||
/// </summary>
|
||||
public bool IsEmpty { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Navigation to owner
|
||||
/// </summary>
|
||||
public virtual DungeonCharacter? OwnerCharacter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation to victim (if player)
|
||||
/// </summary>
|
||||
public virtual DungeonCharacter? VictimCharacter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Items stored in this chest
|
||||
/// </summary>
|
||||
public virtual ICollection<DeathChestItem> Items { get; set; } = new List<DeathChestItem>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An item stored in a death chest
|
||||
/// </summary>
|
||||
[Table("dungeon_death_chest_items")]
|
||||
public class DeathChestItem
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong DeathChestId { get; set; }
|
||||
|
||||
public int ItemDefinitionId { get; set; }
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
|
||||
public int SlotIndex { get; set; } // 0-99 for 100 slot chest
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item has been taken
|
||||
/// </summary>
|
||||
public bool IsTaken { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// When the item was taken (for auditing)
|
||||
/// </summary>
|
||||
public DateTime? TakenAt { get; set; }
|
||||
|
||||
// Navigation
|
||||
public virtual DeathChest? DeathChest { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ItemDefinitionId))]
|
||||
public virtual DungeonItemDefinition? ItemDefinition { get; set; }
|
||||
}
|
||||
@@ -47,6 +47,9 @@ public class DungeonCharacter
|
||||
public int CurrentHealth { get; set; } = 50;
|
||||
public int CurrentMana { get; set; } = 20;
|
||||
|
||||
// Currency
|
||||
public long Gold { get; set; } = 0;
|
||||
|
||||
// Equipment slots (ItemId references, null = empty)
|
||||
public ulong? EquippedWeapon { get; set; }
|
||||
public ulong? EquippedOffhand { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user