FreeKill/lua/core/general.lua
Notify-ctrl 4e25c032e6
Skill (#9)
* TriggerSkill

* update type comment

* events of phases

* lua annotation

* change style of enums

* clear lua stack

* multi lua_State at server side

* disable addPlayer when room is full or started

* logic:trigger

Co-authored-by: Notify-ctrl <notify-ctrl@qq.com>
2022-04-01 20:51:01 +08:00

39 lines
980 B
Lua

---@class General : Object
---@field package Package
---@field name string
---@field kingdom string
---@field hp integer
---@field maxHp integer
---@field gender Gender
---@field skills Skill[]
---@field other_skills string[]
General = class("General")
---@alias Gender integer
General.Male = 1
General.Female = 2
function General:initialize(package, name, kingdom, hp, maxHp, gender)
self.package = package
self.name = name
self.kingdom = kingdom
self.hp = hp
self.maxHp = maxHp or hp
self.gender = gender or General.Male
self.skills = {} -- skills first added to this general
self.other_skills = {} -- skill belongs other general, e.g. "mashu" of pangde
end
---@param skill Skill
function General:addSkill(skill)
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
end
return General