diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua
index 6c8d5f8e..a0ab51f3 100644
--- a/lua/client/client_util.lua
+++ b/lua/client/client_util.lua
@@ -28,7 +28,8 @@ function GetGeneralDetail(name)
kingdom = general.kingdom,
hp = general.hp,
maxHp = general.maxHp,
- skill = {}
+ skill = {},
+ related_skill = {}
}
for _, s in ipairs(general.skills) do
table.insert(ret.skill, {
@@ -42,6 +43,18 @@ function GetGeneralDetail(name)
description = Fk:getDescription(s)
})
end
+ for _, s in ipairs(general.related_skills) do
+ table.insert(ret.related_skill, {
+ name = s.name,
+ description = Fk:getDescription(s.name)
+ })
+ end
+ for _, s in ipairs(general.related_other_skills) do
+ table.insert(ret.related_skill, {
+ name = s,
+ description = Fk:getDescription(s)
+ })
+ end
return json.encode(ret)
end
diff --git a/lua/core/general.lua b/lua/core/general.lua
index ae98f342..5ca667b3 100644
--- a/lua/core/general.lua
+++ b/lua/core/general.lua
@@ -17,12 +17,16 @@
---@field public gender Gender @ 武将性别
---@field public skills Skill[] @ 武将技能
---@field public other_skills string[] @ 武将身上属于其他武将的技能,通过字符串调用
+---@field public related_skills Skill[] @ 武将相关的不属于其他武将的技能,例如邓艾的急袭
+---@field public related_other_skills string [] @ 武将相关的属于其他武将的技能,例如孙策的英姿
General = class("General")
---@alias Gender integer
General.Male = 1
General.Female = 2
+General.Bigender = 3
+General.Agender = 4
--- 构造函数,不可随意调用。
---@param package Package @ 武将所属包
@@ -45,6 +49,8 @@ function General:initialize(package, name, kingdom, hp, maxHp, gender)
self.skills = {} -- skills first added to this general
self.other_skills = {} -- skill belongs other general, e.g. "mashu" of pangde
+ self.related_skills = {} -- skills related to this general, but not first added to it, e.g. "jixi" of dengai
+ self.related_other_skills = {} -- skills related to this general and belong to other generals, e.g. "yingzi" of sunce
package:addGeneral(self)
end
@@ -60,4 +66,16 @@ function General:addSkill(skill)
end
end
+--- 为武将增加相关技能,需要注意增加其他武将技能时的处理方式。
+---@param skill Skill @ (单个)武将技能
+function General:addRelatedSkill(skill)
+ if (type(skill) == "string") then
+ table.insert(self.related_other_skills, skill)
+ elseif (skill.class and skill.class:isSubclassOf(Skill)) then
+ table.insert(self.related_skills, skill)
+ Fk:addSkill(skill)
+ skill.package = self.package
+ end
+end
+
return General
diff --git a/lua/core/skill.lua b/lua/core/skill.lua
index a50de3b5..22d68910 100644
--- a/lua/core/skill.lua
+++ b/lua/core/skill.lua
@@ -30,7 +30,7 @@ function Skill:initialize(name, frequency)
self.name = name
-- skill's package is assigned when calling General:addSkill
-- if you need skills that not belongs to any general (like 'jixi')
- -- then you should assign skill.package explicitly
+ -- then you should use general function addRelatedSkill to assign them
self.package = { extensionName = "standard" }
self.frequency = frequency
self.visible = true
diff --git a/qml/Pages/GeneralsOverview.qml b/qml/Pages/GeneralsOverview.qml
index 4d37b4e7..bfad994b 100644
--- a/qml/Pages/GeneralsOverview.qml
+++ b/qml/Pages/GeneralsOverview.qml
@@ -87,6 +87,9 @@ Item {
data.skill.forEach(t => {
this.append("" + Backend.translate(t.name) + ": " + t.description)
});
+ data.related_skill.forEach(t => {
+ this.append("" + Backend.translate(t.name) + ": " + t.description + "")
+ });
}
}
}