mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 03:32:34 +08:00
Enhancement (#117)
添加武将相关技能 添加武将中性和无性 Signed-off-by: Mechanel <nyutanislavsky@qq.com>
This commit is contained in:
parent
9ae119028c
commit
13b77e4c36
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -87,6 +87,9 @@ Item {
|
|||
data.skill.forEach(t => {
|
||||
this.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
|
||||
});
|
||||
data.related_skill.forEach(t => {
|
||||
this.append("<font color=\"purple\"><b>" + Backend.translate(t.name) + "</b>: " + t.description + "</font>")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user