2022-03-31 13:29:23 +08:00
|
|
|
---@class General : Object
|
|
|
|
---@field package Package
|
|
|
|
---@field name string
|
|
|
|
---@field kingdom string
|
|
|
|
---@field hp number
|
|
|
|
---@field maxHp number
|
|
|
|
---@field gender number
|
|
|
|
---@field skills table
|
|
|
|
---@field other_skills table
|
2022-03-25 12:28:07 +08:00
|
|
|
General = class("General")
|
|
|
|
|
2022-03-28 22:24:30 +08:00
|
|
|
-- enum Gender
|
2022-03-31 13:29:23 +08:00
|
|
|
fk.createEnum(General, {
|
|
|
|
"Male",
|
|
|
|
"Female"
|
|
|
|
})
|
2022-03-28 22:24:30 +08:00
|
|
|
|
2022-03-25 12:28:07 +08:00
|
|
|
function General:initialize(package, name, kingdom, hp, maxHp, gender, initialHp)
|
|
|
|
self.package = package
|
|
|
|
self.name = name
|
|
|
|
self.kingdom = kingdom
|
|
|
|
self.hp = hp
|
2022-03-28 22:24:30 +08:00
|
|
|
self.maxHp = maxHp or hp
|
|
|
|
self.gender = gender or General.Male
|
2022-03-25 12:28:07 +08:00
|
|
|
|
2022-03-28 22:24:30 +08:00
|
|
|
self.skills = {} -- Skill[]
|
|
|
|
-- skill belongs other general, e.g. "mashu" of pangde
|
|
|
|
self.other_skills = {} -- string[]
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
|
|
|
|
2022-03-30 16:33:56 +08:00
|
|
|
---@param skill any
|
2022-03-25 12:28:07 +08:00
|
|
|
function General:addSkill(skill)
|
2022-03-28 22:24:30 +08:00
|
|
|
if (type(skill) == "string") then
|
|
|
|
table.insert(self.other_skills, skill)
|
|
|
|
elseif (skill.class and skill.class:isSubclassOf(Skill)) then
|
|
|
|
table.insert(self.skills, skill)
|
|
|
|
end
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return General
|