feat: add elf handler

This commit is contained in:
Naruse
2025-06-17 09:24:55 +08:00
parent 22cbf44bcf
commit a9c362f224
9 changed files with 198 additions and 718 deletions

View File

@@ -5,26 +5,25 @@ namespace KianaBH.Data.Excel;
[ResourceEntity("Elf_AstraMate_Data.json")]
public class ElfAstraMateDataExcel : ExcelResource
{
public uint ElfID { get; set; }
public uint MaxLevel { get; set; }
public uint MaxRarity { get; set; }
public int ElfID { get; set; }
public int MaxLevel { get; set; }
public int MaxRarity { get; set; }
[JsonIgnore] public List<ElfSkillDataExcel> SkillList = [];
public override int GetId()
{
return (int)ElfID;
return ElfID;
}
public override void Loaded()
{
GameData.ElfAstraMateData.Add(GetId(), this);
GameData.ElfAstraMateData.Add(ElfID, this);
}
public override void AfterAllDone()
{
GameData.ElfSkillData.TryGetValue(GetId(), out var Skills);
if (Skills == null || !Skills.ElfIds.Contains(ElfID)) return;
SkillList.Add(Skills);
SkillList.AddRange(GameData.ElfSkillData.Values
.Where(skill => skill.ElfIDList.Contains(ElfID)));
}
}

View File

@@ -3,12 +3,12 @@
[ResourceEntity("ElfSkillData.json")]
public class ElfSkillDataExcel : ExcelResource
{
public uint ElfSkillID { get; set; }
public uint MaxLv { get; set; }
public List<uint> ElfIds { get; set; } = [];
public int ElfSkillID { get; set; }
public int MaxLv { get; set; }
public List<int> ElfIDList { get; set; } = [];
public override int GetId()
{
return (int)ElfSkillID;
return ElfSkillID;
}
public override void Loaded()

View File

@@ -0,0 +1,61 @@
using KianaBH.Data;
using KianaBH.Proto;
using SqlSugar;
namespace KianaBH.Database.Elfs;
[SugarTable("ElfsData")]
public class ElfsData : BaseDatabaseDataHelper
{
[SugarColumn(IsJson = true)] public List<ElfData> Elfs { get; set; } = [];
[SugarColumn(IsJson = true)] public List<ElfFragment> ElfsFragment { get; set; } = [];
}
public class ElfData
{
public int ElfId { get; set; }
public int Level { get; set; }
public int Star { get; set; }
public int Exp { get; set; }
public List<int> EquipTalentIdList { get; set; } = [];
public List<Skill> SkillList { get; set; } = [];
public int CompensateLevel { get; set; }
public int TotalCompensateExp { get; set; }
public long Timestamp { get; set; }
public Elf ToProto()
{
return new Elf
{
ElfId = (uint)ElfId,
Star = (uint)Star,
Level = (uint)Level,
Exp = (uint)Exp,
EquipTalentIdList = { EquipTalentIdList.Select(id => (uint)id) },
CompensateLevel = (uint)CompensateLevel,
TotalCompensateExp = (uint)TotalCompensateExp,
SkillList =
{
SkillList.Select(x => new ElfSkill
{
SkillId = (uint)x.SkillId,
SkillLevel = (uint)x.SkillLevel,
})
}
};
}
}
public class ElfFragment
{
public int ElfId { get; set; }
public int FragmentNum { get; set; }
}
public class Skill
{
public int SkillId { get; set; }
public int SkillLevel { get; set; }
}

View File

@@ -42,6 +42,7 @@ public class WordTextEN
public string Weapon => "Weapon";
public string Banner => "Gacha";
public string Activity => "Activity";
public string Elf => "Elf";
// server info
public string Config => "Config File";
@@ -78,6 +79,7 @@ public class CommandTextEN
public HelpTextEN Help { get; } = new();
public ValkTextEN Valk { get; } = new();
public GiveAllTextEN GiveAll { get; } = new();
public ElfTextEN Elf { get; } = new();
}
#endregion
@@ -211,6 +213,26 @@ public class GiveAllTextEN
public string GiveAllItems => "Granted all {0}";
}
/// <summary>
/// path: Game.Command.Elf
/// </summary>
public class ElfTextEN
{
public string Desc => "Set attributes for owned elfs\n" +
"Note: -1 means all owned elfs\n";
public string Usage =>
"Usage: /elf add [ElfID/-1] l<Level> s<Star>\n\n";
public string ElfNotFound => "Elf does not exist!";
public string ElfAddedAll => "Granted all Elfs to player!";
public string ElfAdded => "Granted Elf {0} to player!";
public string ElfSetLevelAll => "Set all Elfs to level {0}!";
public string ElfSetLevel => "Set Elf {0} to level {1}!";
public string ElfSetStarAll => "Set all Elf's Resonance to {0}!";
public string ElfSetStar => "Set Elf {0}'s Resonance to {1}!";
}
#endregion
#endregion