2022-03-30 08:33:56 +00:00
|
|
|
--- @class General : Object
|
2022-03-25 04:28:07 +00:00
|
|
|
General = class("General")
|
|
|
|
|
2022-03-28 14:24:30 +00:00
|
|
|
-- enum Gender
|
|
|
|
General.Male = 0
|
|
|
|
General.Female = 1
|
|
|
|
|
2022-03-25 04:28:07 +00: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 14:24:30 +00:00
|
|
|
self.maxHp = maxHp or hp
|
|
|
|
self.gender = gender or General.Male
|
2022-03-25 04:28:07 +00:00
|
|
|
self.initialHp = initialHp or maxHp
|
|
|
|
|
2022-03-28 14:24:30 +00:00
|
|
|
self.skills = {} -- Skill[]
|
|
|
|
-- skill belongs other general, e.g. "mashu" of pangde
|
|
|
|
self.other_skills = {} -- string[]
|
2022-03-25 04:28:07 +00:00
|
|
|
end
|
|
|
|
|
2022-03-30 08:33:56 +00:00
|
|
|
---@param skill any
|
2022-03-25 04:28:07 +00:00
|
|
|
function General:addSkill(skill)
|
2022-03-28 14:24:30 +00: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 04:28:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return General
|