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