using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Text.Json.Serialization; namespace RynthCore.MonsterEditor; public class MonsterRule : INotifyPropertyChanged { private string _name = "New Monster"; private int _priority = 1; private string _damageType = "Auto"; private int _weaponId; private bool _fester, _broadside, _gravityWell, _imperil, _yield, _vuln; private bool _useArc, _useBolt = true, _useRing, _useStreak, _useBlast; private string _exVuln = "None"; private int _offhandId; private int _preferredAmmoItemId; private string _petDamage = "PAuto"; /// Dashboard-only label; optional (empty shows as "Default" in the game UI). private string _category = string.Empty; /// vTank-style match expression. Empty = for named rules, match on Name substring; for the Default row, it is the global fallback when nothing else matches. private string _matchExpression = string.Empty; public string Name { get => _name; set { _name = value; OnPropertyChanged(); } } public int Priority { get => _priority; set { _priority = value; OnPropertyChanged(); } } public string Category { get => _category; set { _category = value ?? string.Empty; OnPropertyChanged(); } } /// vTank-style match expression. Empty matches on the rule name. public string MatchExpression { get => _matchExpression; set { _matchExpression = value ?? string.Empty; OnPropertyChanged(); } } public string DamageType { get => _damageType; set { _damageType = value; OnPropertyChanged(); } } public int WeaponId { get => _weaponId; set { _weaponId = value; OnPropertyChanged(); } } public bool Fester { get => _fester; set { _fester = value; OnPropertyChanged(); } } public bool Broadside { get => _broadside; set { _broadside = value; OnPropertyChanged(); } } public bool GravityWell { get => _gravityWell; set { _gravityWell = value; OnPropertyChanged(); } } public bool Imperil { get => _imperil; set { _imperil = value; OnPropertyChanged(); } } public bool Yield { get => _yield; set { _yield = value; OnPropertyChanged(); } } public bool Vuln { get => _vuln; set { _vuln = value; OnPropertyChanged(); } } public bool UseArc { get => _useArc; set { _useArc = value; OnPropertyChanged(); } } public bool UseBolt { get => _useBolt; set { _useBolt = value; OnPropertyChanged(); } } public bool UseRing { get => _useRing; set { _useRing = value; OnPropertyChanged(); } } public bool UseStreak { get => _useStreak; set { _useStreak = value; OnPropertyChanged(); } } public bool UseBlast { get => _useBlast; set { _useBlast = value; OnPropertyChanged(); } } public string ExVuln { get => _exVuln; set { _exVuln = value; OnPropertyChanged(); } } public int OffhandId { get => _offhandId; set { _offhandId = value; OnPropertyChanged(); } } /// Optional loose ammo stack id for missile combat while this rule matches (0 = auto). public int PreferredAmmoItemId { get => _preferredAmmoItemId; set { _preferredAmmoItemId = value; OnPropertyChanged(); } } public string PetDamage { get => _petDamage; set { _petDamage = value; OnPropertyChanged(); } } [JsonIgnore] /// True for the special row named "Default" — the catch-all when no other rule matches. public bool IsDefault => string.Equals(_name, "Default", System.StringComparison.OrdinalIgnoreCase); /// Full copy (for import merge). Copies every rule field, UseBlast included. public MonsterRule Clone() { return new MonsterRule { Name = _name, Category = _category, MatchExpression = _matchExpression, Priority = _priority, DamageType = _damageType, WeaponId = _weaponId, Fester = _fester, Broadside = _broadside, GravityWell = _gravityWell, Imperil = _imperil, Yield = _yield, Vuln = _vuln, UseArc = _useArc, UseBolt = _useBolt, UseRing = _useRing, UseStreak = _useStreak, UseBlast = _useBlast, ExVuln = _exVuln, OffhandId = _offhandId, PreferredAmmoItemId = _preferredAmmoItemId, PetDamage = _petDamage, }; } /// Overwrites combat fields (used to merge a VT Default row into the Rynth Default row). public void CopyCombatSettingsFrom(MonsterRule? src) { if (src == null) return; // Keep Name: must stay "Default". Use public setters so the grid updates. Category = src.Category; MatchExpression = src.MatchExpression; Priority = src.Priority; DamageType = src.DamageType; WeaponId = src.WeaponId; Fester = src.Fester; Broadside = src.Broadside; GravityWell = src.GravityWell; Imperil = src.Imperil; Yield = src.Yield; Vuln = src.Vuln; UseArc = src.UseArc; UseBolt = src.UseBolt; UseRing = src.UseRing; UseStreak = src.UseStreak; UseBlast = src.UseBlast; ExVuln = src.ExVuln; OffhandId = src.OffhandId; PreferredAmmoItemId = src.PreferredAmmoItemId; PetDamage = src.PetDamage; } public event PropertyChangedEventHandler? PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string? name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } public class ItemRule { public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Action { get; set; } = "Loot"; public string Element { get; set; } = "Slash"; public bool KeepBuffed { get; set; } = true; } /// Minimal slice of the settings profile — only what the editor needs for dropdowns. public class EditorSettings { public List MonsterRules { get; set; } = new(); public List ItemRules { get; set; } = new(); } /// Used by weapon/offhand ComboBoxes: maps weapon ID → display name. public class WeaponOption { public int Id { get; set; } public string DisplayName { get; set; } = string.Empty; public override string ToString() => DisplayName; }