FreeKill/lua/core/general.lua
YoumuKon 21e4c65204
终结标记与界bugfix (#307)
-
正式移除了作为临时手段的-tmp标记,现在can_use和target_filter支持读取extra_data(card_filter暂时搁置)
-
规范了askForUseCard中card_name和pattern的关系,现在的格式将以pattern为主,若无pattern才会将card_name视为pattern
- 将withinDistanceLimit迁移至ActiveSkill内
- 添加了令卡牌无距离/次数限制的标记判断
- 添加放大了⑨倍的冰伤音效
- 优化了同将判断的逻辑,使其能够准确读取trueName
- 身份场主公选将后其他角色能看见主公技能(只是看见,无实际功能)
- 开局添加不存在的技能时会放出警报
- 修复了findParent在当前事件无parent时报错的bug
- 修复了人工洗牌后不刷新摸牌堆的bug
- 修复了getPile返回牌堆实例的bug
- 修复了getSkillNameList无法过滤主公技的bug
- 修复了死亡后武将牌没有圆角效果的bug
2024-01-25 03:13:57 +08:00

123 lines
4.4 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- SPDX-License-Identifier: GPL-3.0-or-later
--- General用来描述一个武将。
---
--- 所谓武将,就是所属包、武将基础信息的集合。
---
--- 也许···类似于身份证?
---
---@class General : Object
---@field public package Package @ 武将所属包
---@field public name string @ 武将名字
---@field public trueName string @ 武将真名,也许可以分辨标界?
---@field public kingdom string @ 武将所属势力
---@field public subkingdom string @ 武将副势力
---@field public hp integer @ 武将初始体力
---@field public maxHp integer @ 武将初始最大体力
---@field public mainMaxHpAdjustedValue integer @ 主将体力上限调整
---@field public deputyMaxHpAdjustedValue integer @ 副将体力上限调整
---@field public shield integer @ 初始护甲
---@field public gender Gender @ 武将性别
---@field public skills Skill[] @ 武将技能
---@field public other_skills string[] @ 武将身上属于其他武将的技能,通过字符串调用
---@field public related_skills Skill[] @ 武将相关的不属于其他武将的技能,例如邓艾的急袭
---@field public related_other_skills string [] @ 武将相关的属于其他武将的技能,例如孙策的英姿
---@field public companions string [] @ 有珠联璧合关系的武将
---@field public hidden boolean @ 不在选将框里出现,可以点将,可以在武将一览里查询到
---@field public total_hidden boolean @ 完全隐藏
General = class("General")
---@alias Gender integer
General.Male = 1
General.Female = 2
General.Bigender = 3
General.Agender = 4
--- 构造函数,不可随意调用。
---@param package Package @ 武将所属包
---@param name string @ 武将名字
---@param kingdom string @ 武将所属势力
---@param hp integer @ 武将初始体力
---@param maxHp integer @ 武将初始最大体力
---@param gender Gender @ 武将性别
function General:initialize(package, name, kingdom, hp, maxHp, gender)
self.package = package
self.name = name
local name_splited = name:split("__")
self.trueName = name_splited[#name_splited]
self.kingdom = kingdom
self.hp = hp
self.maxHp = maxHp or hp
self.gender = gender or General.Male
self.mainMaxHpAdjustedValue = 0
self.deputyMaxHpAdjustedValue = 0
self.shield = 0
self.subkingdom = nil
self.skills = {} -- skills first added to this general
self.other_skills = {} -- skill belongs other general, e.g. "mashu" of pangde
self.related_skills = {} -- skills related to this general, but not first added to it, e.g. "jixi" of dengai
self.related_other_skills = {} -- skills related to this general and belong to other generals, e.g. "yingzi" of sunce
self.companions = {}
package:addGeneral(self)
end
function General:__tostring()
return string.format("<General %s>", self.name)
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)
skill.package = self.package
end
end
--- 为武将增加相关技能,需要注意增加其他武将技能时的处理方式。
---@param skill Skill @ (单个)武将技能
function General:addRelatedSkill(skill)
if (type(skill) == "string") then
table.insert(self.related_other_skills, skill)
elseif (skill.class and skill.class:isSubclassOf(Skill)) then
table.insert(self.related_skills, skill)
Fk:addSkill(skill)
skill.package = self.package
end
end
--- 获取武将所有技能。
---@param include_lord bool
function General:getSkillNameList(include_lord)
local ret = {}
local other_skills = table.map(self.other_skills, Util.Name2SkillMapper)
local skills = table.connect(self.skills, other_skills)
for _, skill in ipairs(skills) do
if include_lord or not skill.lordSkill then
table.insert(ret, skill.name)
end
end
-- table.insertTable(ret, self.other_skills)
return ret
end
--- 为武将增加珠联璧合关系武将1个或多个只需写trueName。
---@param name string[] @ 武将真名(表)
function General:addCompanions(name)
if type(name) == "table" then
table.insertTable(self.companions, name)
elseif type(name) == "string" then
table.insert(self.companions, name)
end
end
return General