2022-03-31 13:29:23 +08:00
|
|
|
---@class General : Object
|
|
|
|
---@field package Package
|
|
|
|
---@field name string
|
|
|
|
---@field kingdom string
|
2022-04-01 20:51:01 +08:00
|
|
|
---@field hp integer
|
|
|
|
---@field maxHp integer
|
|
|
|
---@field gender Gender
|
|
|
|
---@field skills Skill[]
|
|
|
|
---@field other_skills string[]
|
2022-03-25 12:28:07 +08:00
|
|
|
General = class("General")
|
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
---@alias Gender integer
|
2022-03-28 22:24:30 +08:00
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
General.Male = 1
|
|
|
|
General.Female = 2
|
|
|
|
|
|
|
|
function General:initialize(package, name, kingdom, hp, maxHp, gender)
|
2022-03-25 12:28:07 +08:00
|
|
|
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-04-01 20:51:01 +08:00
|
|
|
self.skills = {} -- skills first added to this general
|
|
|
|
self.other_skills = {} -- skill belongs other general, e.g. "mashu" of pangde
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
---@param skill Skill
|
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
|