2022-04-01 20:51:01 +08:00
|
|
|
---@class Skill : Object
|
2023-03-26 17:32:45 +08:00
|
|
|
---@field public name string
|
|
|
|
---@field public trueName string
|
|
|
|
---@field public package Package
|
|
|
|
---@field public frequency Frequency
|
|
|
|
---@field public visible boolean
|
|
|
|
---@field public mute boolean
|
|
|
|
---@field public anim_type string
|
|
|
|
---@field public related_skills Skill[]
|
|
|
|
---@field public attached_equip string
|
2022-03-31 13:29:23 +08:00
|
|
|
local Skill = class("Skill")
|
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
---@alias Frequency integer
|
2022-03-25 12:28:07 +08:00
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
Skill.Frequent = 1
|
|
|
|
Skill.NotFrequent = 2
|
|
|
|
Skill.Compulsory = 3
|
|
|
|
Skill.Limited = 4
|
|
|
|
Skill.Wake = 5
|
2022-03-25 12:28:07 +08:00
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
function Skill:initialize(name, frequency)
|
2022-04-30 15:27:56 +08:00
|
|
|
-- TODO: visible, lord, etc
|
|
|
|
self.name = name
|
2023-02-15 19:54:35 +08:00
|
|
|
-- skill's package is assigned when calling General:addSkill
|
|
|
|
-- if you need skills that not belongs to any general (like 'jixi')
|
|
|
|
-- then you should assign skill.package explicitly
|
|
|
|
self.package = { extensionName = "standard" }
|
2022-04-30 15:27:56 +08:00
|
|
|
self.frequency = frequency
|
|
|
|
self.visible = true
|
2023-01-29 18:11:41 +08:00
|
|
|
self.mute = false
|
|
|
|
self.anim_type = ""
|
2022-09-14 13:01:10 +08:00
|
|
|
self.related_skills = {}
|
2023-01-29 18:11:41 +08:00
|
|
|
|
2023-03-13 20:51:12 +08:00
|
|
|
local name_splited = name:split("__")
|
|
|
|
self.trueName = name_splited[#name_splited]
|
|
|
|
|
2023-01-29 18:11:41 +08:00
|
|
|
if string.sub(name, 1, 1) == "#" then
|
|
|
|
self.visible = false
|
|
|
|
end
|
2023-02-15 21:20:40 +08:00
|
|
|
|
|
|
|
self.attached_equip = nil
|
2022-09-14 13:01:10 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
---@param skill Skill
|
|
|
|
function Skill:addRelatedSkill(skill)
|
|
|
|
table.insert(self.related_skills, skill)
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
|
|
|
|
2023-02-15 21:20:40 +08:00
|
|
|
---@return boolean
|
|
|
|
function Skill:isEquipmentSkill()
|
|
|
|
return self.attached_equip and type(self.attached_equip) == 'string' and self.attached_equip ~= ""
|
|
|
|
end
|
|
|
|
|
2023-03-20 20:49:23 +08:00
|
|
|
---@param player Player
|
|
|
|
---@return boolean
|
|
|
|
function Skill:isEffectable(player)
|
|
|
|
local nullifySkills = Fk:currentRoom().status_skills[InvaliditySkill] or {}
|
|
|
|
for _, nullifySkill in ipairs(nullifySkills) do
|
|
|
|
if self.name ~= nullifySkill.name and nullifySkill:getInvalidity(player, self) then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2022-03-25 12:28:07 +08:00
|
|
|
return Skill
|