2023-04-09 13:35:35 +08:00
|
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2023-04-12 13:28:01 +08:00
|
|
|
|
--- Skill用来描述一个技能。
|
|
|
|
|
---
|
2022-04-01 20:51:01 +08:00
|
|
|
|
---@class Skill : Object
|
2023-04-12 13:28:01 +08: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 @ 属于什么装备的技能?
|
2023-06-03 23:59:04 +08:00
|
|
|
|
---@field public switchSkillName 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
|
2023-05-28 18:45:54 +08:00
|
|
|
|
Skill.Quest = 6
|
2022-03-25 12:28:07 +08:00
|
|
|
|
|
2023-04-12 13:28:01 +08:00
|
|
|
|
--- 构造函数,不可随意调用。
|
|
|
|
|
---@param name string @ 技能名
|
|
|
|
|
---@param frequency Frequency @ 技能发动的频繁程度,通常compulsory(锁定技)及limited(限定技)用的多。
|
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')
|
2023-04-13 22:01:25 +08:00
|
|
|
|
-- then you should use general function addRelatedSkill to assign them
|
2023-02-15 19:54:35 +08:00
|
|
|
|
self.package = { extensionName = "standard" }
|
2022-04-30 15:27:56 +08:00
|
|
|
|
self.frequency = frequency
|
|
|
|
|
self.visible = true
|
2023-04-15 12:06:24 +08:00
|
|
|
|
self.lordSkill = false
|
2023-06-11 12:45:12 +08:00
|
|
|
|
self.cardSkill = false
|
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-04-30 18:55:59 +08:00
|
|
|
|
self.attachedKingdom = {}
|
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-04-15 12:06:24 +08:00
|
|
|
|
if string.sub(name, #name) == "$" then
|
|
|
|
|
self.name = string.sub(name, 1, #name - 1)
|
|
|
|
|
self.lordSkill = true
|
|
|
|
|
end
|
2023-02-15 21:20:40 +08:00
|
|
|
|
|
|
|
|
|
self.attached_equip = nil
|
2022-09-14 13:01:10 +08:00
|
|
|
|
end
|
|
|
|
|
|
2023-06-16 10:56:33 +08:00
|
|
|
|
function Skill:__index(k)
|
|
|
|
|
if k == "cost_data" then
|
|
|
|
|
return Fk:currentRoom().skill_costs[self.name]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Skill:__newindex(k, v)
|
|
|
|
|
if k == "cost_data" then
|
|
|
|
|
Fk:currentRoom().skill_costs[self.name] = v
|
|
|
|
|
else
|
|
|
|
|
rawset(self, k, v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-21 04:29:52 +08:00
|
|
|
|
function Skill:__tostring()
|
|
|
|
|
return "<Skill " .. self.name .. ">"
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-12 13:28:01 +08:00
|
|
|
|
--- 为一个技能增加相关技能。
|
|
|
|
|
---@param skill Skill @ 技能
|
2022-09-14 13:01:10 +08:00
|
|
|
|
function Skill:addRelatedSkill(skill)
|
|
|
|
|
table.insert(self.related_skills, skill)
|
2022-03-25 12:28:07 +08:00
|
|
|
|
end
|
|
|
|
|
|
2023-04-12 13:28:01 +08:00
|
|
|
|
--- 确认本技能是否为装备技能。
|
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-04-23 21:10:07 +08:00
|
|
|
|
--- 判断技能是不是对于某玩家而言失效了。
|
2023-04-12 13:28:01 +08:00
|
|
|
|
---
|
2023-04-23 21:10:07 +08:00
|
|
|
|
--- 它影响的是hasSkill,但也可以单独拿出来判断。
|
2023-04-12 13:28:01 +08:00
|
|
|
|
---@param player Player @ 玩家
|
2023-03-20 20:49:23 +08:00
|
|
|
|
---@return boolean
|
|
|
|
|
function Skill:isEffectable(player)
|
2023-06-11 12:45:12 +08:00
|
|
|
|
if self.cardSkill then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2023-06-11 16:22:11 +08:00
|
|
|
|
local nullifySkills = Fk:currentRoom().status_skills[InvaliditySkill] or Util.DummyTable
|
2023-03-20 20:49:23 +08:00
|
|
|
|
for _, nullifySkill in ipairs(nullifySkills) do
|
|
|
|
|
if self.name ~= nullifySkill.name and nullifySkill:getInvalidity(player, self) then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2023-06-03 23:59:04 +08:00
|
|
|
|
--- 为技能增加所属势力,需要在隶属特定势力时才能使用此技能。
|
|
|
|
|
--- 案例:手杀文鸯
|
2023-04-30 18:55:59 +08:00
|
|
|
|
function Skill:addAttachedKingdom(kingdom)
|
|
|
|
|
table.insertIfNeed(self.attachedKingdom, kingdom)
|
|
|
|
|
end
|
|
|
|
|
|
2023-06-03 23:59:04 +08:00
|
|
|
|
--- 判断某个技能是否为转换技
|
2023-05-13 14:20:34 +08:00
|
|
|
|
function Skill:isSwitchSkill()
|
|
|
|
|
return self.switchSkillName and type(self.switchSkillName) == 'string' and self.switchSkillName ~= ""
|
|
|
|
|
end
|
|
|
|
|
|
2022-03-25 12:28:07 +08:00
|
|
|
|
return Skill
|