File size: 3,057 Bytes
fbfe791
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
namespace SilkroadBot.Domain.Models;

/// <summary>
/// Represents a 2D position in the Silkroad world.
/// </summary>
public record struct WorldPosition(short RegionId, float X, float Y, float Z)
{
    public double DistanceTo(WorldPosition other)
    {
        if (RegionId != other.RegionId) return double.MaxValue;
        var dx = X - other.X;
        var dy = Y - other.Y;
        var dz = Z - other.Z;
        return Math.Sqrt(dx * dx + dy * dy + dz * dz);
    }

    public override string ToString() => $"[{RegionId}] ({X:F1}, {Y:F1}, {Z:F1})";
}

/// <summary>
/// Represents a game character (player, NPC, or monster).
/// </summary>
public class GameEntity
{
    public uint UniqueId { get; set; }
    public uint ModelId { get; set; }
    public string Name { get; set; } = string.Empty;
    public WorldPosition Position { get; set; }
    public int Level { get; set; }
    public bool IsAlive { get; set; } = true;
    public EntityType Type { get; set; }
}

public enum EntityType
{
    Player,
    NPC,
    Monster,
    Pet,
    Item,
    Structure
}

/// <summary>
/// Represents the player's character state.
/// </summary>
public class CharacterState
{
    public string Name { get; set; } = string.Empty;
    public int Level { get; set; }
    public long Experience { get; set; }
    public long MaxExperience { get; set; }
    public int HP { get; set; }
    public int MaxHP { get; set; }
    public int MP { get; set; }
    public int MaxMP { get; set; }
    public WorldPosition Position { get; set; }
    public uint Gold { get; set; }
    public int SkillPoints { get; set; }
    public int StatPoints { get; set; }
    public byte Speed { get; set; }
    public bool IsInCombat { get; set; }
    public bool IsDead => HP <= 0;
    
    public double HPPercentage => MaxHP > 0 ? (double)HP / MaxHP * 100 : 0;
    public double MPPercentage => MaxMP > 0 ? (double)MP / MaxMP * 100 : 0;
}

/// <summary>
/// Represents an item in the inventory.
/// </summary>
public class InventoryItem
{
    public byte Slot { get; set; }
    public uint ItemId { get; set; }
    public string Name { get; set; } = string.Empty;
    public ushort Quantity { get; set; }
    public byte Enhancement { get; set; }
    public Enums.InventorySlot SlotType { get; set; }
}

/// <summary>
/// Represents a skill.
/// </summary>
public class Skill
{
    public uint SkillId { get; set; }
    public string Name { get; set; } = string.Empty;
    public byte Level { get; set; }
    public bool IsPassive { get; set; }
    public int CooldownMs { get; set; }
    public DateTime LastUsed { get; set; } = DateTime.MinValue;
    
    public bool IsOnCooldown => (DateTime.UtcNow - LastUsed).TotalMilliseconds < CooldownMs;
}

/// <summary>
/// Represents a party member.
/// </summary>
public class PartyMember
{
    public uint UniqueId { get; set; }
    public string Name { get; set; } = string.Empty;
    public int Level { get; set; }
    public int HP { get; set; }
    public int MaxHP { get; set; }
    public WorldPosition Position { get; set; }
}