Skip to content

Commit 86ce17a

Browse files
committed
fix: 部分情况下无法正常获取技能最大等级
1 parent fe63c25 commit 86ce17a

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

VModer.Core/Models/Character/SkillInfo.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
/// <summary>
44
/// 存储某一项属性(攻击, 防御等)的每一级别的信息
55
/// </summary>
6-
public sealed class SkillInfo
6+
public sealed class SkillInfo(SkillType skillType)
77
{
8-
public SkillType SkillType { get; }
8+
public SkillType SkillType { get; } = skillType;
99
private readonly List<Skill> _skills = new(3);
1010

11-
public SkillInfo(SkillType skillType)
12-
{
13-
SkillType = skillType;
14-
}
15-
1611
public void Add(Skill skill)
1712
{
1813
_skills.Add(skill);
@@ -25,7 +20,6 @@ public void Add(Skill skill)
2520

2621
public SkillModifier GetModifierDescription(SkillCharacterType type, ushort level)
2722
{
28-
return _skills.Find(skill => skill.Type == type)?.GetModifier(level)
29-
?? new SkillModifier(level, []);
23+
return _skills.Find(skill => skill.Type == type)?.GetModifier(level) ?? new SkillModifier(level, []);
3024
}
3125
}

VModer.Core/Services/GameResource/CharacterSkillService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ public sealed class CharacterSkillService()
2121

2222
public ushort GetMaxSkillValue(SkillType skillType, SkillCharacterType skillCharacterType)
2323
{
24-
return Skills.FirstOrDefault(skill => skill.SkillType == skillType)?.GetMaxValue(skillCharacterType)
25-
?? DefaultSkillMaxValue;
24+
foreach (var skillInfo in Skills.Where(skill => skill.SkillType == skillType))
25+
{
26+
ushort? value = skillInfo.GetMaxValue(skillCharacterType);
27+
if (value.HasValue)
28+
{
29+
return value.Value;
30+
}
31+
}
32+
33+
return DefaultSkillMaxValue;
2634
}
2735

2836
protected override SkillInfo[]? ParseFileToContent(Node rootNode)

0 commit comments

Comments
 (0)