2023-04-09 05:35:35 +00:00
|
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2023-04-12 05:28:01 +00:00
|
|
|
|
--- Skill用来描述一个技能。
|
|
|
|
|
---
|
2022-04-01 12:51:01 +00:00
|
|
|
|
---@class Skill : Object
|
2023-04-12 05:28:01 +00:00
|
|
|
|
---@field public name string @ 技能名
|
|
|
|
|
---@field public trueName string @ 技能真名
|
|
|
|
|
---@field public package Package @ 技能所属的包
|
|
|
|
|
---@field public frequency Frequency @ 技能发动的频繁程度,通常compulsory(锁定技)及limited(限定技)用的多。
|
|
|
|
|
---@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 05:29:23 +00:00
|
|
|
|
local Skill = class("Skill")
|
|
|
|
|
|
2022-04-01 12:51:01 +00:00
|
|
|
|
---@alias Frequency integer
|
2022-03-25 04:28:07 +00:00
|
|
|
|
|
2022-04-01 12:51:01 +00:00
|
|
|
|
Skill.Frequent = 1
|
|
|
|
|
Skill.NotFrequent = 2
|
|
|
|
|
Skill.Compulsory = 3
|
|
|
|
|
Skill.Limited = 4
|
|
|
|
|
Skill.Wake = 5
|
2022-03-25 04:28:07 +00:00
|
|
|
|
|
2023-04-12 05:28:01 +00:00
|
|
|
|
--- 构造函数,不可随意调用。
|
|
|
|
|
---@param name string @ 技能名
|
|
|
|
|
---@param frequency Frequency @ 技能发动的频繁程度,通常compulsory(锁定技)及limited(限定技)用的多。
|
2022-04-01 12:51:01 +00:00
|
|
|
|
function Skill:initialize(name, frequency)
|
2022-04-30 07:27:56 +00:00
|
|
|
|
-- TODO: visible, lord, etc
|
|
|
|
|
self.name = name
|
2023-02-15 11:54:35 +00:00
|
|
|
|
-- skill's package is assigned when calling General:addSkill
|
|
|
|
|
-- if you need skills that not belongs to any general (like 'jixi')
|
2023-04-13 14:01:25 +00:00
|
|
|
|
-- then you should use general function addRelatedSkill to assign them
|
2023-02-15 11:54:35 +00:00
|
|
|
|
self.package = { extensionName = "standard" }
|
2022-04-30 07:27:56 +00:00
|
|
|
|
self.frequency = frequency
|
|
|
|
|
self.visible = true
|
2023-04-15 04:06:24 +00:00
|
|
|
|
self.lordSkill = false
|
2023-01-29 10:11:41 +00:00
|
|
|
|
self.mute = false
|
|
|
|
|
self.anim_type = ""
|
2022-09-14 05:01:10 +00:00
|
|
|
|
self.related_skills = {}
|
2023-01-29 10:11:41 +00:00
|
|
|
|
|
2023-03-13 12:51:12 +00:00
|
|
|
|
local name_splited = name:split("__")
|
|
|
|
|
self.trueName = name_splited[#name_splited]
|
|
|
|
|
|
2023-01-29 10:11:41 +00:00
|
|
|
|
if string.sub(name, 1, 1) == "#" then
|
|
|
|
|
self.visible = false
|
|
|
|
|
end
|
2023-04-15 04:06:24 +00:00
|
|
|
|
if string.sub(name, #name) == "$" then
|
|
|
|
|
self.name = string.sub(name, 1, #name - 1)
|
|
|
|
|
self.lordSkill = true
|
|
|
|
|
end
|
2023-02-15 13:20:40 +00:00
|
|
|
|
|
|
|
|
|
self.attached_equip = nil
|
2022-09-14 05:01:10 +00:00
|
|
|
|
end
|
|
|
|
|
|
2023-04-20 20:29:52 +00:00
|
|
|
|
function Skill:__tostring()
|
|
|
|
|
return "<Skill " .. self.name .. ">"
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-12 05:28:01 +00:00
|
|
|
|
--- 为一个技能增加相关技能。
|
|
|
|
|
---@param skill Skill @ 技能
|
2022-09-14 05:01:10 +00:00
|
|
|
|
function Skill:addRelatedSkill(skill)
|
|
|
|
|
table.insert(self.related_skills, skill)
|
2022-03-25 04:28:07 +00:00
|
|
|
|
end
|
|
|
|
|
|
2023-04-12 05:28:01 +00:00
|
|
|
|
--- 确认本技能是否为装备技能。
|
2023-02-15 13:20:40 +00:00
|
|
|
|
---@return boolean
|
|
|
|
|
function Skill:isEquipmentSkill()
|
|
|
|
|
return self.attached_equip and type(self.attached_equip) == 'string' and self.attached_equip ~= ""
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-23 13:10:07 +00:00
|
|
|
|
--- 判断技能是不是对于某玩家而言失效了。
|
2023-04-12 05:28:01 +00:00
|
|
|
|
---
|
2023-04-23 13:10:07 +00:00
|
|
|
|
--- 它影响的是hasSkill,但也可以单独拿出来判断。
|
2023-04-12 05:28:01 +00:00
|
|
|
|
---@param player Player @ 玩家
|
2023-03-20 12:49:23 +00:00
|
|
|
|
---@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 04:28:07 +00:00
|
|
|
|
return Skill
|