2022-03-31 05:29:23 +00:00
|
|
|
---@class General : Object
|
2023-03-26 09:32:45 +00:00
|
|
|
---@field public package Package
|
|
|
|
---@field public name string
|
|
|
|
---@field public trueName string
|
|
|
|
---@field public kingdom string
|
|
|
|
---@field public hp integer
|
|
|
|
---@field public maxHp integer
|
|
|
|
---@field public gender Gender
|
|
|
|
---@field public skills Skill[]
|
|
|
|
---@field public 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
|
2023-03-18 18:21:45 +00:00
|
|
|
local name_splited = name:split("__")
|
|
|
|
self.trueName = name_splited[#name_splited]
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
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)
|
2023-02-15 11:54:35 +00:00
|
|
|
skill.package = self.package
|
2022-04-30 07:27:56 +00:00
|
|
|
end
|
2022-03-25 04:28:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return General
|