在注释中大量改为使用问号

This commit is contained in:
notify 2023-12-03 19:35:14 +08:00
parent eba115a4fa
commit 8afe5122d7
20 changed files with 388 additions and 387 deletions

View File

@ -21,10 +21,10 @@
---@field private _skillName string ---@field private _skillName string
---@field public skillNames string[] @ 虚拟牌的技能名们(一张虚拟牌可能有多个技能名,如芳魂、龙胆、朱雀羽扇) ---@field public skillNames string[] @ 虚拟牌的技能名们(一张虚拟牌可能有多个技能名,如芳魂、龙胆、朱雀羽扇)
---@field public skill Skill @ 技能(用于实现卡牌效果) ---@field public skill Skill @ 技能(用于实现卡牌效果)
---@field public special_skills string[] | nil @ 衍生技能,如重铸 ---@field public special_skills? string[] @ 衍生技能,如重铸
---@field public is_damage_card boolean @ 是否为会造成伤害的牌 ---@field public is_damage_card boolean @ 是否为会造成伤害的牌
---@field public multiple_targets boolean @ 是否为指定多个目标的牌 ---@field public multiple_targets boolean @ 是否为指定多个目标的牌
---@field public is_derived bool @ 判断是否为衍生牌 ---@field public is_derived? boolean @ 判断是否为衍生牌
local Card = class("Card") local Card = class("Card")
---@alias Suit integer ---@alias Suit integer
@ -136,8 +136,8 @@ end
--- 克隆特定卡牌并赋予花色与点数。 --- 克隆特定卡牌并赋予花色与点数。
--- ---
--- 会将skill/special_skills/equip_skill继承到克隆牌中。 --- 会将skill/special_skills/equip_skill继承到克隆牌中。
---@param suit Suit|nil @ 克隆后的牌的花色 ---@param suit? Suit @ 克隆后的牌的花色
---@param number integer|nil @ 克隆后的牌的点数 ---@param number? integer @ 克隆后的牌的点数
---@return Card @ 产品 ---@return Card @ 产品
function Card:clone(suit, number) function Card:clone(suit, number)
local newCard = self.class:new(self.name, suit, number) local newCard = self.class:new(self.name, suit, number)
@ -157,7 +157,7 @@ end
--- 获取卡牌的ID。 --- 获取卡牌的ID。
--- ---
--- 如果牌是虚拟牌则返回其第一张子卡的id没有子卡就返回nil --- 如果牌是虚拟牌则返回其第一张子卡的id没有子卡就返回nil
---@return integer | nil ---@return integer?
function Card:getEffectiveId() function Card:getEffectiveId()
if self:isVirtual() then if self:isVirtual() then
return #self.subcards > 0 and self.subcards[1] or nil return #self.subcards > 0 and self.subcards[1] or nil
@ -236,7 +236,7 @@ function Card:matchPattern(pattern)
end end
--- 获取卡牌花色并返回花色文字描述(如 黑桃、红桃、梅花、方块)或者符号(如♠♥♣♦,带颜色)。 --- 获取卡牌花色并返回花色文字描述(如 黑桃、红桃、梅花、方块)或者符号(如♠♥♣♦,带颜色)。
---@param symbol bool @ 是否以符号形式显示 ---@param symbol? boolean @ 是否以符号形式显示
---@return string @ 描述花色的字符串 ---@return string @ 描述花色的字符串
function Card:getSuitString(symbol) function Card:getSuitString(symbol)
local suit = self.suit local suit = self.suit
@ -428,7 +428,7 @@ end
--- 比较两张卡牌的花色是否相同 --- 比较两张卡牌的花色是否相同
---@param anotherCard Card @ 另一张卡牌 ---@param anotherCard Card @ 另一张卡牌
---@param diff bool @ 比较二者相同还是不同 ---@param diff? boolean @ 比较二者相同还是不同
---@return boolean 返回比较结果 ---@return boolean 返回比较结果
function Card:compareSuitWith(anotherCard, diff) function Card:compareSuitWith(anotherCard, diff)
if self ~= anotherCard and table.contains({ self.suit, anotherCard.suit }, Card.NoSuit) then if self ~= anotherCard and table.contains({ self.suit, anotherCard.suit }, Card.NoSuit) then

View File

@ -167,7 +167,7 @@ end
--- 向翻译表中加载新的翻译表。 --- 向翻译表中加载新的翻译表。
---@param t table @ 要加载的翻译表,这是一个 原文 --> 译文 的键值对表 ---@param t table @ 要加载的翻译表,这是一个 原文 --> 译文 的键值对表
---@param lang string|nil @ 目标语言默认为zh_CN ---@param lang? string @ 目标语言默认为zh_CN
function Engine:loadTranslationTable(t, lang) function Engine:loadTranslationTable(t, lang)
assert(type(t) == "table") assert(type(t) == "table")
lang = lang or "zh_CN" lang = lang or "zh_CN"
@ -179,8 +179,9 @@ end
--- 翻译一段文本。其实就是从翻译表中去找 --- 翻译一段文本。其实就是从翻译表中去找
---@param src string @ 要翻译的文本 ---@param src string @ 要翻译的文本
function Engine:translate(src) ---@param lang? string @ 要使用的语言默认读取config
local lang = Config.language or "zh_CN" function Engine:translate(src, lang)
lang = lang or (Config.language or "zh_CN")
if not self.translations[lang] then lang = "zh_CN" end if not self.translations[lang] then lang = "zh_CN" end
local ret = self.translations[lang][src] local ret = self.translations[lang][src]
return ret or src return ret or src
@ -306,8 +307,8 @@ end
--- ---
--- 返回的牌是一张虚拟牌。 --- 返回的牌是一张虚拟牌。
---@param name string @ 牌名 ---@param name string @ 牌名
---@param suit Suit|nil @ 花色 ---@param suit? Suit @ 花色
---@param number integer|nil @ 点数 ---@param number? integer @ 点数
---@return Card ---@return Card
function Engine:cloneCard(name, suit, number) function Engine:cloneCard(name, suit, number)
local cd = self.all_card_types[name] local cd = self.all_card_types[name]
@ -355,9 +356,9 @@ end
--- ---
--- 如果符合条件的武将不够,那么就不能保证能选出那么多武将。 --- 如果符合条件的武将不够,那么就不能保证能选出那么多武将。
---@param num integer @ 要选出的武将数量 ---@param num integer @ 要选出的武将数量
---@param generalPool General[] | nil @ 选择的范围,默认是已经启用的所有武将 ---@param generalPool? General[] @ 选择的范围,默认是已经启用的所有武将
---@param except string[] | nil @ 特别要排除掉的武将名列表,默认是空表 ---@param except? string[] @ 特别要排除掉的武将名列表,默认是空表
---@param filter nil | fun(g: General): boolean @ 可选参数若这个函数返回true的话这个武将被排除在外 ---@param filter? fun(g: General): boolean? @ 可选参数若这个函数返回true的话这个武将被排除在外
---@return General[] @ 随机选出的武将列表 ---@return General[] @ 随机选出的武将列表
function Engine:getGeneralsRandomly(num, generalPool, except, filter) function Engine:getGeneralsRandomly(num, generalPool, except, filter)
if filter then if filter then
@ -390,7 +391,7 @@ function Engine:getGeneralsRandomly(num, generalPool, except, filter)
end end
--- 获取已经启用的所有武将的列表。 --- 获取已经启用的所有武将的列表。
---@param except General[] | nil @ 特别指明要排除在外的武将 ---@param except? General[] @ 特别指明要排除在外的武将
---@return General[] @ 所有武将的列表 ---@return General[] @ 所有武将的列表
function Engine:getAllGenerals(except) function Engine:getAllGenerals(except)
local result = {} local result = {}
@ -406,7 +407,7 @@ function Engine:getAllGenerals(except)
end end
--- 获取当前已经启用的所有卡牌。 --- 获取当前已经启用的所有卡牌。
---@param except integer[] | nil @ 特别指定要排除在外的id列表 ---@param except? integer[] @ 特别指定要排除在外的id列表
---@return integer[] @ 所有卡牌id的列表 ---@return integer[] @ 所有卡牌id的列表
function Engine:getAllCardIds(except) function Engine:getAllCardIds(except)
local result = {} local result = {}
@ -423,7 +424,7 @@ end
--- 根据id返回相应的卡牌。 --- 根据id返回相应的卡牌。
---@param id integer @ 牌的id ---@param id integer @ 牌的id
---@param ignoreFilter bool @ 是否要无视掉锁定视为技,直接获得真牌 ---@param ignoreFilter? boolean @ 是否要无视掉锁定视为技,直接获得真牌
---@return Card @ 这个id对应的卡牌 ---@return Card @ 这个id对应的卡牌
function Engine:getCardById(id, ignoreFilter) function Engine:getCardById(id, ignoreFilter)
if id == nil then return nil end if id == nil then return nil end

View File

@ -8,10 +8,10 @@
---@field public name string @ 游戏模式名 ---@field public name string @ 游戏模式名
---@field public minPlayer integer @ 最小玩家数 ---@field public minPlayer integer @ 最小玩家数
---@field public maxPlayer integer @ 最大玩家数 ---@field public maxPlayer integer @ 最大玩家数
---@field public rule nil|TriggerSkill @ 规则(通过技能完成,通常用来为特定角色及特定时机提供触发事件) ---@field public rule? TriggerSkill @ 规则(通过技能完成,通常用来为特定角色及特定时机提供触发事件)
---@field public logic nil|fun() @ 逻辑通过function完成通常用来初始化、分配身份及座次 ---@field public logic? fun(): GameLogic @ 逻辑通过function完成通常用来初始化、分配身份及座次
---@field public whitelist string[]|nil @ 白名单 ---@field public whitelist? string[] @ 白名单
---@field public blacklist string[]|nil @ 黑名单 ---@field public blacklist? string[] @ 黑名单
local GameMode = class("GameMode") local GameMode = class("GameMode")
--- 构造函数,不可随意调用。 --- 构造函数,不可随意调用。

View File

@ -13,8 +13,8 @@
---@field public related_skills table<string, string> @ 对于额外技能而言的关联技能 ---@field public related_skills table<string, string> @ 对于额外技能而言的关联技能
---@field public cards Card[] @ 拓展包包含的卡牌 ---@field public cards Card[] @ 拓展包包含的卡牌
---@field public game_modes GameMode[] @ 拓展包包含的游戏模式 ---@field public game_modes GameMode[] @ 拓展包包含的游戏模式
---@field public game_modes_whitelist string[]|nil @ 拓展包关于游戏模式的白名单 ---@field public game_modes_whitelist? string[] @ 拓展包关于游戏模式的白名单
---@field public game_modes_blacklist string[]|nil @ 拓展包关于游戏模式的黑名单 ---@field public game_modes_blacklist? string[] @ 拓展包关于游戏模式的黑名单
local Package = class("Package") local Package = class("Package")
---@alias PackageType integer ---@alias PackageType integer
@ -25,7 +25,7 @@ Package.SpecialPack = 3
--- 拓展包的构造函数。 --- 拓展包的构造函数。
---@param name string @ 包的名字 ---@param name string @ 包的名字
---@param _type integer|nil @ 包的类型,默认为武将包 ---@param _type? integer @ 包的类型,默认为武将包
function Package:initialize(name, _type) function Package:initialize(name, _type)
assert(type(name) == "string") assert(type(name) == "string")
assert(type(_type) == "nil" or type(_type) == "number") assert(type(_type) == "nil" or type(_type) == "number")

View File

@ -121,8 +121,8 @@ end
--- 设置角色、体力、技能。 --- 设置角色、体力、技能。
---@param general General @ 角色类型 ---@param general General @ 角色类型
---@param setHp bool @ 是否设置体力 ---@param setHp? boolean @ 是否设置体力
---@param addSkills bool @ 是否增加技能 ---@param addSkills? boolean @ 是否增加技能
function Player:setGeneral(general, setHp, addSkills) function Player:setGeneral(general, setHp, addSkills)
self.general = general.name self.general = general.name
if setHp then if setHp then
@ -202,7 +202,7 @@ end
--- 为角色设置Mark至指定数量。 --- 为角色设置Mark至指定数量。
---@param mark string @ 标记 ---@param mark string @ 标记
---@param count integer|nil @ 为标记删除的数量 ---@param count? integer @ 为标记删除的数量
function Player:setMark(mark, count) function Player:setMark(mark, count)
if count == 0 then count = nil end if count == 0 then count = nil end
if self.mark[mark] ~= count then if self.mark[mark] ~= count then
@ -237,7 +237,7 @@ end
--- 将指定数量的牌加入玩家的对应区域。 --- 将指定数量的牌加入玩家的对应区域。
---@param playerArea PlayerCardArea @ 玩家牌所在的区域 ---@param playerArea PlayerCardArea @ 玩家牌所在的区域
---@param cardIds integer[] @ 牌的ID返回唯一牌 ---@param cardIds integer[] @ 牌的ID返回唯一牌
---@param specialName string|nil @ 私人牌堆名 ---@param specialName? string @ 私人牌堆名
function Player:addCards(playerArea, cardIds, specialName) function Player:addCards(playerArea, cardIds, specialName)
assert(table.contains({ Player.Hand, Player.Equip, Player.Judge, Player.Special }, playerArea)) assert(table.contains({ Player.Hand, Player.Equip, Player.Judge, Player.Special }, playerArea))
assert(playerArea ~= Player.Special or type(specialName) == "string") assert(playerArea ~= Player.Special or type(specialName) == "string")
@ -253,7 +253,7 @@ end
--- 将指定数量的牌移除出玩家的对应区域。 --- 将指定数量的牌移除出玩家的对应区域。
---@param playerArea PlayerCardArea @ 玩家牌所在的区域 ---@param playerArea PlayerCardArea @ 玩家牌所在的区域
---@param cardIds integer[] @ 牌的ID返回唯一牌 ---@param cardIds integer[] @ 牌的ID返回唯一牌
---@param specialName string|nil @ 私人牌堆名 ---@param specialName? string @ 私人牌堆名
function Player:removeCards(playerArea, cardIds, specialName) function Player:removeCards(playerArea, cardIds, specialName)
assert(table.contains({ Player.Hand, Player.Equip, Player.Judge, Player.Special }, playerArea)) assert(table.contains({ Player.Hand, Player.Equip, Player.Judge, Player.Special }, playerArea))
assert(playerArea ~= Player.Special or type(specialName) == "string") assert(playerArea ~= Player.Special or type(specialName) == "string")
@ -323,8 +323,8 @@ function Player:hasDelayedTrick(card_name)
end end
--- 获取玩家特定区域所有牌的ID。 --- 获取玩家特定区域所有牌的ID。
---@param playerAreas PlayerCardArea|PlayerCardArea[]|string|nil @ 玩家牌所在的区域 ---@param playerAreas? PlayerCardArea|PlayerCardArea[]|string @ 玩家牌所在的区域
---@param specialName string|nil @私人牌堆名 ---@param specialName? string @私人牌堆名
---@return integer[] @ 返回对应区域的所有牌对应的ID ---@return integer[] @ 返回对应区域的所有牌对应的ID
function Player:getCardIds(playerAreas, specialName) function Player:getCardIds(playerAreas, specialName)
local rightAreas = { Player.Hand, Player.Equip, Player.Judge } local rightAreas = { Player.Hand, Player.Equip, Player.Judge }
@ -370,7 +370,7 @@ end
--- 通过ID检索获取玩家是否存在对应私人牌堆。 --- 通过ID检索获取玩家是否存在对应私人牌堆。
---@param id integer @ 私人牌堆ID ---@param id integer @ 私人牌堆ID
---@return string|null ---@return string?
function Player:getPileNameOfId(id) function Player:getPileNameOfId(id)
for k, v in pairs(self.special_cards) do for k, v in pairs(self.special_cards) do
if table.contains(v, id) then return k end if table.contains(v, id) then return k end
@ -379,7 +379,7 @@ end
--- 返回所有“如手牌般使用或打出”的牌。 --- 返回所有“如手牌般使用或打出”的牌。
--- 或者说,返回所有名字以“&”结尾的pile的牌。 --- 或者说,返回所有名字以“&”结尾的pile的牌。
---@param include_hand bool @ 是否包含真正的手牌 ---@param include_hand? boolean @ 是否包含真正的手牌
---@return integer[] ---@return integer[]
function Player:getHandlyIds(include_hand) function Player:getHandlyIds(include_hand)
include_hand = include_hand or include_hand == nil include_hand = include_hand or include_hand == nil
@ -403,7 +403,7 @@ end
--- 检索玩家装备区是否存在对应类型的装备。 --- 检索玩家装备区是否存在对应类型的装备。
---@param cardSubtype CardSubtype @ 卡牌子类 ---@param cardSubtype CardSubtype @ 卡牌子类
---@return integer|null @ 返回卡牌ID或nil ---@return integer? @ 返回卡牌ID或nil
function Player:getEquipment(cardSubtype) function Player:getEquipment(cardSubtype)
for _, cardId in ipairs(self.player_cards[Player.Equip]) do for _, cardId in ipairs(self.player_cards[Player.Equip]) do
if Fk:getCardById(cardId).sub_type == cardSubtype then if Fk:getCardById(cardId).sub_type == cardSubtype then
@ -491,8 +491,8 @@ end
--- ---
--- 通过 二者位次+距离技能之和 与 两者间固定距离 进行对比,更大的为实际距离。 --- 通过 二者位次+距离技能之和 与 两者间固定距离 进行对比,更大的为实际距离。
---@param other Player @ 其他玩家 ---@param other Player @ 其他玩家
---@param mode string|nil @ 计算模式(left/right/both) ---@param mode? string @ 计算模式(left/right/both)
---@param ignore_dead bool @ 是否忽略尸体 ---@param ignore_dead? boolean @ 是否忽略尸体
function Player:distanceTo(other, mode, ignore_dead) function Player:distanceTo(other, mode, ignore_dead)
assert(other:isInstanceOf(Player)) assert(other:isInstanceOf(Player))
mode = mode or "both" mode = mode or "both"
@ -546,7 +546,7 @@ end
--- 获取其他玩家是否在玩家的攻击距离内。 --- 获取其他玩家是否在玩家的攻击距离内。
---@param other Player @ 其他玩家 ---@param other Player @ 其他玩家
---@param fixLimit number|null @ 卡牌距离限制增加专用 ---@param fixLimit? integer @ 卡牌距离限制增加专用
function Player:inMyAttackRange(other, fixLimit) function Player:inMyAttackRange(other, fixLimit)
assert(other:isInstanceOf(Player)) assert(other:isInstanceOf(Player))
if self == other or (other and (other.dead or other:isRemoved())) or self:isRemoved() then if self == other or (other and (other.dead or other:isRemoved())) or self:isRemoved() then
@ -567,8 +567,8 @@ function Player:inMyAttackRange(other, fixLimit)
end end
--- 获取下家。 --- 获取下家。
---@param ignoreRemoved bool @ 忽略被移除 ---@param ignoreRemoved? boolean @ 忽略被移除
---@param num interger|nil @ 第几个默认1 ---@param num? integer @ 第几个默认1
---@return ServerPlayer ---@return ServerPlayer
function Player:getNextAlive(ignoreRemoved, num) function Player:getNextAlive(ignoreRemoved, num)
if #Fk:currentRoom().alive_players == 0 then if #Fk:currentRoom().alive_players == 0 then
@ -591,8 +591,8 @@ function Player:getNextAlive(ignoreRemoved, num)
end end
--- 获取上家。 --- 获取上家。
---@param ignoreRemoved bool @ 忽略被移除 ---@param ignoreRemoved boolean @ 忽略被移除
---@param num interger|nil @ 第几个默认1 ---@param num? integer @ 第几个默认1
---@return ServerPlayer ---@return ServerPlayer
function Player:getLastAlive(ignoreRemoved, num) function Player:getLastAlive(ignoreRemoved, num)
num = num or 1 num = num or 1
@ -602,7 +602,7 @@ end
--- 增加玩家使用特定牌的历史次数。 --- 增加玩家使用特定牌的历史次数。
---@param cardName string @ 牌名 ---@param cardName string @ 牌名
---@param num integer|nil @ 次数 ---@param num? integer @ 次数
function Player:addCardUseHistory(cardName, num) function Player:addCardUseHistory(cardName, num)
num = num or 1 num = num or 1
assert(type(num) == "number" and num ~= 0) assert(type(num) == "number" and num ~= 0)
@ -617,7 +617,7 @@ end
--- 设定玩家使用特定牌的历史次数。 --- 设定玩家使用特定牌的历史次数。
---@param cardName string @ 牌名 ---@param cardName string @ 牌名
---@param num integer @ 次数 ---@param num integer @ 次数
---@param scope integer|nil @ 查询历史范围 ---@param scope? integer @ 历史范围 全为nil意为清空
function Player:setCardUseHistory(cardName, num, scope) function Player:setCardUseHistory(cardName, num, scope)
if cardName == "" and num == nil and scope == nil then if cardName == "" and num == nil and scope == nil then
self.cardUsedHistory = {} self.cardUsedHistory = {}
@ -639,7 +639,7 @@ end
--- 增加玩家使用特定技能的历史次数。 --- 增加玩家使用特定技能的历史次数。
---@param skill_name string @ 技能名 ---@param skill_name string @ 技能名
---@param num integer|nil @ 次数 ---@param num? integer @ 次数 默认1
function Player:addSkillUseHistory(skill_name, num) function Player:addSkillUseHistory(skill_name, num)
num = num or 1 num = num or 1
assert(type(num) == "number" and num ~= 0) assert(type(num) == "number" and num ~= 0)
@ -653,8 +653,8 @@ end
--- 设定玩家使用特定技能的历史次数。 --- 设定玩家使用特定技能的历史次数。
---@param skill_name string @ 技能名 ---@param skill_name string @ 技能名
---@param num integer|nil @ 次数 ---@param num? integer @ 次数 默认0
---@param scope integer|nil @ 查询历史范围 ---@param scope? integer @ 查询历史范围
function Player:setSkillUseHistory(skill_name, num, scope) function Player:setSkillUseHistory(skill_name, num, scope)
if skill_name == "" and num == nil and scope == nil then if skill_name == "" and num == nil and scope == nil then
self.skillUsedHistory = {} self.skillUsedHistory = {}
@ -675,7 +675,7 @@ end
--- 获取玩家使用特定牌的历史次数。 --- 获取玩家使用特定牌的历史次数。
---@param cardName string @ 牌名 ---@param cardName string @ 牌名
---@param scope integer|nil @ 查询历史范围 ---@param scope? integer @ 查询历史范围默认Turn
function Player:usedCardTimes(cardName, scope) function Player:usedCardTimes(cardName, scope)
if not self.cardUsedHistory[cardName] then if not self.cardUsedHistory[cardName] then
return 0 return 0
@ -686,7 +686,7 @@ end
--- 获取玩家使用特定技能的历史次数。 --- 获取玩家使用特定技能的历史次数。
---@param skill_name string @ 技能名 ---@param skill_name string @ 技能名
---@param scope integer|nil @ 查询历史范围 ---@param scope? integer @ 查询历史范围默认Turn
function Player:usedSkillTimes(skill_name, scope) function Player:usedSkillTimes(skill_name, scope)
if not self.skillUsedHistory[skill_name] then if not self.skillUsedHistory[skill_name] then
return 0 return 0
@ -732,8 +732,8 @@ end
--- 检索玩家是否有对应技能。 --- 检索玩家是否有对应技能。
---@param skill string | Skill @ 技能名 ---@param skill string | Skill @ 技能名
---@param ignoreNullified bool @ 忽略技能是否被无效 ---@param ignoreNullified? boolean @ 忽略技能是否被无效
---@param ignoreAlive bool @ 忽略角色在场与否 ---@param ignoreAlive? boolean @ 忽略角色在场与否
function Player:hasSkill(skill, ignoreNullified, ignoreAlive) function Player:hasSkill(skill, ignoreNullified, ignoreAlive)
if not ignoreAlive and self.dead then if not ignoreAlive and self.dead then
return false return false
@ -767,7 +767,7 @@ end
--- 为玩家增加对应技能。 --- 为玩家增加对应技能。
---@param skill string | Skill @ 技能名 ---@param skill string | Skill @ 技能名
---@param source_skill string | Skill | nil @ 本有技能(和衍生技能相对) ---@param source_skill? string | Skill @ 本有技能(和衍生技能相对)
---@return Skill[] @ got skills that Player didn't have at start ---@return Skill[] @ got skills that Player didn't have at start
function Player:addSkill(skill, source_skill) function Player:addSkill(skill, source_skill)
skill = getActualSkill(skill) skill = getActualSkill(skill)
@ -813,7 +813,7 @@ end
--- 为玩家删除对应技能。 --- 为玩家删除对应技能。
---@param skill string | Skill @ 技能名 ---@param skill string | Skill @ 技能名
---@param source_skill string | Skill | nil @ 本有技能(和衍生技能相对) ---@param source_skill? string | Skill @ 本有技能(和衍生技能相对)
---@return Skill[] @ lost skills that the Player doesn't have anymore ---@return Skill[] @ lost skills that the Player doesn't have anymore
function Player:loseSkill(skill, source_skill) function Player:loseSkill(skill, source_skill)
skill = getActualSkill(skill) skill = getActualSkill(skill)
@ -944,8 +944,8 @@ fk.SwitchYin = 1
--- 获取转换技状态 --- 获取转换技状态
---@param skillName string @ 技能名 ---@param skillName string @ 技能名
---@param afterUse bool @ 是否提前计算转换后状态 ---@param afterUse? boolean @ 是否提前计算转换后状态
---@param inWord bool @ 是否返回文字 ---@param inWord? boolean @ 是否返回文字
---@return number|string @ 转换技状态 ---@return number|string @ 转换技状态
function Player:getSwitchSkillState(skillName, afterUse, inWord) function Player:getSwitchSkillState(skillName, afterUse, inWord)
if afterUse then if afterUse then

View File

@ -53,9 +53,9 @@ end
--- Determine whether a target can be selected by this skill(in modifying targets) --- Determine whether a target can be selected by this skill(in modifying targets)
--- only used in skill of players --- only used in skill of players
---@param to_select integer @ id of the target ---@param to_select integer @ id of the target
---@param selected nil|integer[] @ ids of selected targets ---@param selected? integer[] @ ids of selected targets
---@param user nil|integer @ id of the userdata ---@param user? integer @ id of the userdata
---@param card nil|Card @ helper ---@param card? Card @ helper
---@param distance_limited boolean @ is limited by distance ---@param distance_limited boolean @ is limited by distance
function ActiveSkill:modTargetFilter(to_select, selected, user, card, distance_limited) function ActiveSkill:modTargetFilter(to_select, selected, user, card, distance_limited)
return false return false

View File

@ -3,7 +3,7 @@
---@class MaxCardsSkill : StatusSkill ---@class MaxCardsSkill : StatusSkill
local MaxCardsSkill = StatusSkill:subclass("MaxCardsSkill") local MaxCardsSkill = StatusSkill:subclass("MaxCardsSkill")
---@return integer|nil ---@return integer?
function MaxCardsSkill:getFixed(player) function MaxCardsSkill:getFixed(player)
return nil return nil
end end

View File

@ -101,7 +101,7 @@ end
---@param target ServerPlayer @ Player who triggered this event ---@param target ServerPlayer @ Player who triggered this event
---@param player ServerPlayer @ Player who is operating ---@param player ServerPlayer @ Player who is operating
---@param data any @ useful data of the event ---@param data any @ useful data of the event
---@return bool ---@return boolean?
function TriggerSkill:use(event, target, player, data) end function TriggerSkill:use(event, target, player, data) end
function TriggerSkill:canWake(event, target, player, data) function TriggerSkill:canWake(event, target, player, data)

View File

@ -18,7 +18,7 @@ function ViewAsSkill:cardFilter(to_select, selected)
end end
---@param cards integer[] @ ids of cards ---@param cards integer[] @ ids of cards
---@return Card|nil ---@return Card?
function ViewAsSkill:viewAs(cards) function ViewAsSkill:viewAs(cards)
return nil return nil
end end

View File

@ -360,7 +360,7 @@ end
---@generic T ---@generic T
---@param self T[] ---@param self T[]
---@param n integer|nil ---@param n? integer
---@return T|T[] ---@return T|T[]
function table:random(n) function table:random(n)
local n0 = n local n0 = n

View File

@ -75,26 +75,26 @@ local function readStatusSpecToSkill(skill, spec)
end end
---@class UsableSkillSpec: UsableSkill ---@class UsableSkillSpec: UsableSkill
---@field public max_phase_use_time nil|integer ---@field public max_phase_use_time? integer
---@field public max_turn_use_time nil|integer ---@field public max_turn_use_time? integer
---@field public max_round_use_time nil|integer ---@field public max_round_use_time? integer
---@field public max_game_use_time nil|integer ---@field public max_game_use_time? integer
---@class StatusSkillSpec: StatusSkill ---@class StatusSkillSpec: StatusSkill
---@alias TrigFunc fun(self: TriggerSkill, event: Event, target: ServerPlayer, player: ServerPlayer, data: any):bool ---@alias TrigFunc fun(self: TriggerSkill, event: Event, target: ServerPlayer, player: ServerPlayer, data: any): boolean?
---@class TriggerSkillSpec: UsableSkillSpec ---@class TriggerSkillSpec: UsableSkillSpec
---@field public global bool ---@field public global? boolean
---@field public events nil|Event | Event[] ---@field public events? Event | Event[]
---@field public refresh_events nil|Event | Event[] ---@field public refresh_events? Event | Event[]
---@field public priority nil|number | table<Event, number> ---@field public priority? number | table<Event, number>
---@field public on_trigger nil|TrigFunc ---@field public on_trigger? TrigFunc
---@field public can_trigger nil|TrigFunc ---@field public can_trigger? TrigFunc
---@field public on_cost nil|TrigFunc ---@field public on_cost? TrigFunc
---@field public on_use nil|TrigFunc ---@field public on_use? TrigFunc
---@field public on_refresh nil|TrigFunc ---@field public on_refresh? TrigFunc
---@field public can_refresh nil|TrigFunc ---@field public can_refresh? TrigFunc
---@field public can_wake nil|TrigFunc ---@field public can_wake? TrigFunc
---@param spec TriggerSkillSpec ---@param spec TriggerSkillSpec
---@return TriggerSkill ---@return TriggerSkill
@ -170,16 +170,16 @@ function fk.CreateTriggerSkill(spec)
end end
---@class ActiveSkillSpec: UsableSkillSpec ---@class ActiveSkillSpec: UsableSkillSpec
---@field public can_use nil|fun(self: ActiveSkill, player: Player, card: Card): bool ---@field public can_use? fun(self: ActiveSkill, player: Player, card: Card): boolean?
---@field public card_filter nil|fun(self: ActiveSkill, to_select: integer, selected: integer[], selected_targets: integer[]): bool ---@field public card_filter? fun(self: ActiveSkill, to_select: integer, selected: integer[], selected_targets: integer[]): boolean?
---@field public target_filter nil|fun(self: ActiveSkill, to_select: integer, selected: integer[], selected_cards: integer[], card: Card): bool ---@field public target_filter? fun(self: ActiveSkill, to_select: integer, selected: integer[], selected_cards: integer[], card: Card): boolean?
---@field public feasible nil|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): bool ---@field public feasible? fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): boolean?
---@field public on_use nil|fun(self: ActiveSkill, room: Room, cardUseEvent: CardUseStruct): bool ---@field public on_use? fun(self: ActiveSkill, room: Room, cardUseEvent: CardUseStruct): boolean?
---@field public about_to_effect nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool ---@field public about_to_effect? fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean?
---@field public on_effect nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool ---@field public on_effect? fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean?
---@field public on_nullified nil|fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): bool ---@field public on_nullified? fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean?
---@field public mod_target_filter nil|fun(self: ActiveSkill, to_select: integer, selected: integer[], user: integer, card: Card, distance_limited: boolean): bool ---@field public mod_target_filter? fun(self: ActiveSkill, to_select: integer, selected: integer[], user: integer, card: Card, distance_limited: boolean): boolean?
---@field public prompt nil|string|fun(self: ActiveSkill, selected_cards: integer[], selected_targets: integer[]): string ---@field public prompt? string|fun(self: ActiveSkill, selected_cards: integer[], selected_targets: integer[]): string
---@field public interaction any ---@field public interaction any
---@param spec ActiveSkillSpec ---@param spec ActiveSkillSpec
@ -222,13 +222,13 @@ function fk.CreateActiveSkill(spec)
end end
---@class ViewAsSkillSpec: UsableSkillSpec ---@class ViewAsSkillSpec: UsableSkillSpec
---@field public card_filter nil|fun(self: ViewAsSkill, to_select: integer, selected: integer[]): bool ---@field public card_filter? fun(self: ViewAsSkill, to_select: integer, selected: integer[]): boolean?
---@field public view_as fun(self: ViewAsSkill, cards: integer[]): Card|nil ---@field public view_as fun(self: ViewAsSkill, cards: integer[]): Card?
---@field public pattern nil|string ---@field public pattern? string
---@field public enabled_at_play nil|fun(self: ViewAsSkill, player: Player): bool ---@field public enabled_at_play? fun(self: ViewAsSkill, player: Player): boolean?
---@field public enabled_at_response nil|fun(self: ViewAsSkill, player: Player, response: boolean): bool ---@field public enabled_at_response? fun(self: ViewAsSkill, player: Player, response: boolean): boolean?
---@field public before_use nil|fun(self: ViewAsSkill, player: ServerPlayer, use: CardUseStruct) ---@field public before_use? fun(self: ViewAsSkill, player: ServerPlayer, use: CardUseStruct)
---@field public prompt nil|string|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): string ---@field public prompt? string|fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): string
---@param spec ViewAsSkillSpec ---@param spec ViewAsSkillSpec
---@return ViewAsSkill ---@return ViewAsSkill
@ -278,8 +278,8 @@ function fk.CreateViewAsSkill(spec)
end end
---@class DistanceSpec: StatusSkillSpec ---@class DistanceSpec: StatusSkillSpec
---@field public correct_func nil|fun(self: DistanceSkill, from: Player, to: Player): integer|nil ---@field public correct_func? fun(self: DistanceSkill, from: Player, to: Player): integer?
---@field public fixed_func nil|fun(self: DistanceSkill, from: Player, to: Player): integer|nil ---@field public fixed_func? fun(self: DistanceSkill, from: Player, to: Player): integer?
---@param spec DistanceSpec ---@param spec DistanceSpec
---@return DistanceSkill ---@return DistanceSkill
@ -296,10 +296,10 @@ function fk.CreateDistanceSkill(spec)
end end
---@class ProhibitSpec: StatusSkillSpec ---@class ProhibitSpec: StatusSkillSpec
---@field public is_prohibited nil|fun(self: ProhibitSkill, from: Player, to: Player, card: Card): bool ---@field public is_prohibited? fun(self: ProhibitSkill, from: Player, to: Player, card: Card): boolean?
---@field public prohibit_use nil|fun(self: ProhibitSkill, player: Player, card: Card): bool ---@field public prohibit_use? fun(self: ProhibitSkill, player: Player, card: Card): boolean?
---@field public prohibit_response nil|fun(self: ProhibitSkill, player: Player, card: Card): bool ---@field public prohibit_response? fun(self: ProhibitSkill, player: Player, card: Card): boolean?
---@field public prohibit_discard nil|fun(self: ProhibitSkill, player: Player, card: Card): bool ---@field public prohibit_discard? fun(self: ProhibitSkill, player: Player, card: Card): boolean?
---@param spec ProhibitSpec ---@param spec ProhibitSpec
---@return ProhibitSkill ---@return ProhibitSkill
@ -317,8 +317,8 @@ function fk.CreateProhibitSkill(spec)
end end
---@class AttackRangeSpec: StatusSkillSpec ---@class AttackRangeSpec: StatusSkillSpec
---@field public correct_func nil|fun(self: AttackRangeSkill, from: Player, to: Player): number|nil ---@field public correct_func? fun(self: AttackRangeSkill, from: Player, to: Player): number?
---@field public within_func nil|fun(self: AttackRangeSkill, from: Player, to: Player): bool ---@field public within_func? fun(self: AttackRangeSkill, from: Player, to: Player): boolean?
---@param spec AttackRangeSpec ---@param spec AttackRangeSpec
---@return AttackRangeSkill ---@return AttackRangeSkill
@ -339,9 +339,9 @@ function fk.CreateAttackRangeSkill(spec)
end end
---@class MaxCardsSpec: StatusSkillSpec ---@class MaxCardsSpec: StatusSkillSpec
---@field public correct_func nil|fun(self: MaxCardsSkill, player: Player): number|nil ---@field public correct_func? fun(self: MaxCardsSkill, player: Player): number?
---@field public fixed_func nil|fun(self: MaxCardsSkill, player: Player): number|nil ---@field public fixed_func? fun(self: MaxCardsSkill, player: Player): number?
---@field public exclude_from nil|fun(self: MaxCardsSkill, player: Player, card: Card): bool ---@field public exclude_from? fun(self: MaxCardsSkill, player: Player, card: Card): boolean?
---@param spec MaxCardsSpec ---@param spec MaxCardsSpec
---@return MaxCardsSkill ---@return MaxCardsSkill
@ -363,11 +363,11 @@ function fk.CreateMaxCardsSkill(spec)
end end
---@class TargetModSpec: StatusSkillSpec ---@class TargetModSpec: StatusSkillSpec
---@field public bypass_times nil|fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player): bool ---@field public bypass_times? fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player): boolean?
---@field public residue_func nil|fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player): number|nil ---@field public residue_func? fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player): number?
---@field public bypass_distances nil|fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card, to: Player): bool ---@field public bypass_distances? fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card, to: Player): boolean?
---@field public distance_limit_func nil|fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card, to: Player): number|nil ---@field public distance_limit_func? fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card, to: Player): number?
---@field public extra_target_func nil|fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card): number|nil ---@field public extra_target_func? fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card): number?
---@param spec TargetModSpec ---@param spec TargetModSpec
---@return TargetModSkill ---@return TargetModSkill
@ -396,8 +396,8 @@ function fk.CreateTargetModSkill(spec)
end end
---@class FilterSpec: StatusSkillSpec ---@class FilterSpec: StatusSkillSpec
---@field public card_filter nil|fun(self: FilterSkill, card: Card, player: Player): bool ---@field public card_filter? fun(self: FilterSkill, card: Card, player: Player): boolean?
---@field public view_as nil|fun(self: FilterSkill, card: Card, player: Player): Card|nil ---@field public view_as? fun(self: FilterSkill, card: Card, player: Player): Card?
---@param spec FilterSpec ---@param spec FilterSpec
---@return FilterSkill ---@return FilterSkill
@ -413,7 +413,7 @@ function fk.CreateFilterSkill(spec)
end end
---@class InvaliditySpec: StatusSkillSpec ---@class InvaliditySpec: StatusSkillSpec
---@field public invalidity_func nil|fun(self: InvaliditySkill, from: Player, skill: Skill): bool ---@field public invalidity_func? fun(self: InvaliditySkill, from: Player, skill: Skill): boolean?
---@param spec InvaliditySpec ---@param spec InvaliditySpec
---@return InvaliditySkill ---@return InvaliditySkill
@ -428,11 +428,11 @@ function fk.CreateInvaliditySkill(spec)
end end
---@class CardSpec: Card ---@class CardSpec: Card
---@field public skill nil|Skill ---@field public skill? Skill
---@field public equip_skill nil|Skill ---@field public equip_skill? Skill
---@field public special_skills string[] | nil ---@field public special_skills? string[]
---@field public is_damage_card bool ---@field public is_damage_card? boolean
---@field public multiple_targets bool ---@field public multiple_targets? boolean
local defaultCardSkill = fk.CreateActiveSkill{ local defaultCardSkill = fk.CreateActiveSkill{
name = "default_card_skill", name = "default_card_skill",
@ -593,8 +593,8 @@ end
---@class PoxiSpec ---@class PoxiSpec
---@field name string ---@field name string
---@field card_filter fun(to_select: int, selected: int[], data: any, extra_data: any): bool ---@field card_filter fun(to_select: int, selected: int[], data: any, extra_data: any): boolean?
---@field feasible fun(selected: int[], data: any, extra_data: any): bool ---@field feasible fun(selected: int[], data: any, extra_data: any): boolean?
---@field post_select nil | fun(selected: int[], data: any, extra_data: any): int[] ---@field post_select? fun(selected: int[], data: any, extra_data: any): int[]
---@field default_choice nil | fun(data: any, extra_data: any): int[] ---@field default_choice? fun(data: any, extra_data: any): int[]
---@field prompt nil | string | fun(data: any, extra_data: any): string ---@field prompt? string | fun(data: any, extra_data: any): string

View File

@ -13,7 +13,7 @@ function SPlayerList:append(e)end
function SPlayerList:contains(e)end function SPlayerList:contains(e)end
---@param index integer ---@param index integer
---@return fk.ServerPlayer | nil ---@return fk.ServerPlayer
function SPlayerList:at(index)end function SPlayerList:at(index)end
function SPlayerList:first()end function SPlayerList:first()end

View File

@ -5,7 +5,7 @@ local RandomAI = AI:subclass("RandomAI")
---@param self RandomAI ---@param self RandomAI
---@param skill ActiveSkill ---@param skill ActiveSkill
---@param card Card | nil ---@param card? Card
function RandomAI:useActiveSkill(skill, card) function RandomAI:useActiveSkill(skill, card)
local room = self.room local room = self.room
local player = self.player local player = self.player

View File

@ -82,15 +82,15 @@ end
--=================================================== --===================================================
---@class UseReply ---@class UseReply
---@field card integer|string|nil @ string情况下是json.encode后 ---@field card? integer|string @ string情况下是json.encode后
---@field targets integer[]|nil ---@field targets? integer[]
---@field special_skill string @ 出牌阶段空闲点使用实体卡特有 ---@field special_skill string @ 出牌阶段空闲点使用实体卡特有
---@field interaction_data any @ 因技能而异一般都是nil ---@field interaction_data any @ 因技能而异一般都是nil
---@param card integer|table|nil ---@param card integer|table
---@param targets integer[]|nil ---@param targets? integer[]
---@param special_skill string|nil ---@param special_skill? string
---@param interaction_data any ---@param interaction_data? any
function SmartAI:buildUseReply(card, targets, special_skill, interaction_data) function SmartAI:buildUseReply(card, targets, special_skill, interaction_data)
if type(card) == "table" then card = json.encode(card) end if type(card) == "table" then card = json.encode(card) end
return { return {
@ -106,7 +106,7 @@ end
-- * 且原型为 { skill = skillName, subcards = integer[] } -- * 且原型为 { skill = skillName, subcards = integer[] }
---------------------------------------------------------- ----------------------------------------------------------
---@type table<string, fun(self: SmartAI, prompt: string, cancelable: bool, data: any): UseReply | nil> ---@type table<string, fun(self: SmartAI, prompt: string, cancelable?: boolean, data: any): UseReply?>
fk.ai_active_skill = {} fk.ai_active_skill = {}
smart_cb["AskForUseActiveSkill"] = function(self, jsonData) smart_cb["AskForUseActiveSkill"] = function(self, jsonData)
@ -133,7 +133,7 @@ end
--------------------------------------------------------- ---------------------------------------------------------
--- 键是prompt的第一项或者牌名优先prompt其次name实在不行trueName。 --- 键是prompt的第一项或者牌名优先prompt其次name实在不行trueName。
---@type table<string, fun(self: SmartAI, pattern: string, prompt: string, cancelable: bool, extra_data?: UseExtraData): UseReply|nil> ---@type table<string, fun(self: SmartAI, pattern: string, prompt: string, cancelable?: boolean, extra_data?: UseExtraData): UseReply?>
fk.ai_use_card = {} fk.ai_use_card = {}
local defauld_use_card = function(self, pattern, _, cancelable, exdata) local defauld_use_card = function(self, pattern, _, cancelable, exdata)
@ -173,7 +173,7 @@ end
------------------------------------- -------------------------------------
-- 一样的牌名或者prompt做键优先prompt -- 一样的牌名或者prompt做键优先prompt
---@type table<string, fun(self: SmartAI, pattern: string, prompt: string, cancelable: bool, extra_data: any): UseReply|nil> ---@type table<string, fun(self: SmartAI, pattern: string, prompt: string, cancelable?: boolean, extra_data: any): UseReply?>
fk.ai_response_card = {} fk.ai_response_card = {}
local defauld_response_card = function(self, pattern, _, cancelable) local defauld_response_card = function(self, pattern, _, cancelable)

View File

@ -135,8 +135,8 @@ end
-- 从某个区间中找出类型符合且符合func函数检测的至多n个事件。 -- 从某个区间中找出类型符合且符合func函数检测的至多n个事件。
---@param eventType integer @ 要查找的事件类型 ---@param eventType integer @ 要查找的事件类型
---@param n integer @ 最多找多少个 ---@param n integer @ 最多找多少个
---@param func fun(e: GameEvent): boolean @ 过滤用的函数 ---@param func fun(e: GameEvent): boolean? @ 过滤用的函数
---@param endEvent GameEvent|nil @ 区间终止点,默认为本事件结束 ---@param endEvent? GameEvent @ 区间终止点,默认为本事件结束
---@return GameEvent[] @ 找到的符合条件的所有事件最多n个但不保证有n个 ---@return GameEvent[] @ 找到的符合条件的所有事件最多n个但不保证有n个
function GameEvent:searchEvents(eventType, n, func, endEvent) function GameEvent:searchEvents(eventType, n, func, endEvent)
local logic = self.room.logic local logic = self.room.logic

View File

@ -328,8 +328,8 @@ function GameLogic:addTriggerSkill(skill)
end end
---@param event Event ---@param event Event
---@param target ServerPlayer|nil ---@param target? ServerPlayer
---@param data any|nil ---@param data? any
function GameLogic:trigger(event, target, data, refresh_only) function GameLogic:trigger(event, target, data, refresh_only)
local room = self.room local room = self.room
local broken = false local broken = false

View File

@ -264,7 +264,7 @@ end
--- 基本算是私有函数,别去用 --- 基本算是私有函数,别去用
---@param cardId integer ---@param cardId integer
---@param cardArea CardArea ---@param cardArea CardArea
---@param owner nil|integer ---@param owner? integer
function Room:setCardArea(cardId, cardArea, owner) function Room:setCardArea(cardId, cardArea, owner)
self.card_place[cardId] = cardArea self.card_place[cardId] = cardArea
self.owner_map[cardId] = owner self.owner_map[cardId] = owner
@ -282,8 +282,8 @@ function Room:getCardArea(cardId)
end end
--- 获得拥有某一张牌的玩家。 --- 获得拥有某一张牌的玩家。
---@param cardId integer | card @ 要获得主人的那张牌可以是Card实例或者id ---@param cardId integer | Card @ 要获得主人的那张牌可以是Card实例或者id
---@return ServerPlayer | nil @ 这张牌的主人可能返回nil ---@return ServerPlayer? @ 这张牌的主人可能返回nil
function Room:getCardOwner(cardId) function Room:getCardOwner(cardId)
if type(cardId) ~= "number" then if type(cardId) ~= "number" then
assert(cardId and cardId:isInstanceOf(Card)) assert(cardId and cardId:isInstanceOf(Card))
@ -345,7 +345,7 @@ end
--- 获得当前房间中的所有玩家。 --- 获得当前房间中的所有玩家。
--- ---
--- 返回的数组的第一个元素是当前回合玩家,并且按行动顺序进行排序。 --- 返回的数组的第一个元素是当前回合玩家,并且按行动顺序进行排序。
---@param sortBySeat bool @ 是否无视按座位排序直接返回 ---@param sortBySeat? boolean @ 是否无视按座位排序直接返回
---@return ServerPlayer[] @ 房间中玩家的数组 ---@return ServerPlayer[] @ 房间中玩家的数组
function Room:getAllPlayers(sortBySeat) function Room:getAllPlayers(sortBySeat)
if not self.game_started then if not self.game_started then
@ -367,7 +367,7 @@ function Room:getAllPlayers(sortBySeat)
end end
--- 获得所有存活玩家参看getAllPlayers --- 获得所有存活玩家参看getAllPlayers
---@param sortBySeat bool ---@param sortBySeat? boolean
---@return ServerPlayer[] ---@return ServerPlayer[]
function Room:getAlivePlayers(sortBySeat) function Room:getAlivePlayers(sortBySeat)
if sortBySeat == nil or sortBySeat then if sortBySeat == nil or sortBySeat then
@ -394,8 +394,8 @@ end
--- 获得除一名玩家外的其他玩家。 --- 获得除一名玩家外的其他玩家。
---@param player ServerPlayer @ 要排除的玩家 ---@param player ServerPlayer @ 要排除的玩家
---@param sortBySeat bool @ 是否要按座位排序? ---@param sortBySeat? boolean @ 是否要按座位排序?
---@param include_dead bool @ 是否要把死人也算进去? ---@param include_dead? boolean @ 是否要把死人也算进去?
---@return ServerPlayer[] @ 其他玩家列表 ---@return ServerPlayer[] @ 其他玩家列表
function Room:getOtherPlayers(player, sortBySeat, include_dead) function Room:getOtherPlayers(player, sortBySeat, include_dead)
if sortBySeat == nil then if sortBySeat == nil then
@ -416,7 +416,7 @@ end
--- 获得当前房间中的主公。 --- 获得当前房间中的主公。
--- ---
--- 由于某些游戏模式没有主公该函数可能返回nil。 --- 由于某些游戏模式没有主公该函数可能返回nil。
---@return ServerPlayer | nil @ 主公 ---@return ServerPlayer? @ 主公
function Room:getLord() function Room:getLord()
local lord = self.players[1] local lord = self.players[1]
if lord.role == "lord" then return lord end if lord.role == "lord" then return lord end
@ -433,7 +433,7 @@ end
--- ---
--- 如果牌堆中没有足够的牌可以获得,那么会触发洗牌;还是不够的话,游戏就平局。 --- 如果牌堆中没有足够的牌可以获得,那么会触发洗牌;还是不够的话,游戏就平局。
---@param num integer @ 要获得的牌的数量 ---@param num integer @ 要获得的牌的数量
---@param from string|nil @ 获得牌的位置,可以是 ``"top"`` 或者 ``"bottom"``,表示牌堆顶还是牌堆底 ---@param from? string @ 获得牌的位置,可以是 ``"top"`` 或者 ``"bottom"``,表示牌堆顶还是牌堆底
---@return integer[] @ 得到的id ---@return integer[] @ 得到的id
function Room:getNCards(num, from) function Room:getNCards(num, from)
from = from or "top" from = from or "top"
@ -478,7 +478,7 @@ end
--- 将一名玩家的mark标记增加count个。 --- 将一名玩家的mark标记增加count个。
---@param player ServerPlayer @ 要加标记的玩家 ---@param player ServerPlayer @ 要加标记的玩家
---@param mark string @ 标记名称 ---@param mark string @ 标记名称
---@param count integer | nil @ 要增加的数量默认为1 ---@param count? integer @ 要增加的数量默认为1
function Room:addPlayerMark(player, mark, count) function Room:addPlayerMark(player, mark, count)
count = count or 1 count = count or 1
local num = player:getMark(mark) local num = player:getMark(mark)
@ -489,7 +489,7 @@ end
--- 将一名玩家的mark标记减少count个。 --- 将一名玩家的mark标记减少count个。
---@param player ServerPlayer @ 要减标记的玩家 ---@param player ServerPlayer @ 要减标记的玩家
---@param mark string @ 标记名称 ---@param mark string @ 标记名称
---@param count integer | nil @ 要减少的数量默认为1 ---@param count? integer @ 要减少的数量默认为1
function Room:removePlayerMark(player, mark, count) function Room:removePlayerMark(player, mark, count)
count = count or 1 count = count or 1
local num = player:getMark(mark) local num = player:getMark(mark)
@ -517,7 +517,7 @@ end
--- 将一张卡牌的mark标记增加count个。 --- 将一张卡牌的mark标记增加count个。
---@param card Card @ 要被增加标记的那张牌 ---@param card Card @ 要被增加标记的那张牌
---@param mark string @ 标记名称 ---@param mark string @ 标记名称
---@param count integer | nil @ 要增加的数量默认为1 ---@param count? integer @ 要增加的数量默认为1
function Room:addCardMark(card, mark, count) function Room:addCardMark(card, mark, count)
count = count or 1 count = count or 1
local num = card:getMark(mark) local num = card:getMark(mark)
@ -528,7 +528,7 @@ end
--- 将一名玩家的mark标记减少count个。 --- 将一名玩家的mark标记减少count个。
---@param card Card @ 要被减少标记的那张牌 ---@param card Card @ 要被减少标记的那张牌
---@param mark string @ 标记名称 ---@param mark string @ 标记名称
---@param count integer | nil @ 要减少的数量默认为1 ---@param count? integer @ 要减少的数量默认为1
function Room:removeCardMark(card, mark, count) function Room:removeCardMark(card, mark, count)
count = count or 1 count = count or 1
local num = card:getMark(mark) local num = card:getMark(mark)
@ -563,6 +563,7 @@ function Room:removeTag(tag_name)
self.tag[tag_name] = nil self.tag[tag_name] = nil
end end
---@return boolean
local function execGameEvent(type, ...) local function execGameEvent(type, ...)
local event = GameEvent:new(type, ...) local event = GameEvent:new(type, ...)
local _, ret = event:exec() local _, ret = event:exec()
@ -571,8 +572,8 @@ end
---@param player ServerPlayer ---@param player ServerPlayer
---@param general string ---@param general string
---@param changeKingdom bool ---@param changeKingdom? boolean
---@param noBroadcast bool ---@param noBroadcast? boolean
function Room:setPlayerGeneral(player, general, changeKingdom, noBroadcast) function Room:setPlayerGeneral(player, general, changeKingdom, noBroadcast)
if Fk.generals[general] == nil then return end if Fk.generals[general] == nil then return end
player.general = general player.general = general
@ -600,10 +601,10 @@ end
---@param player ServerPlayer @ 要换将的玩家 ---@param player ServerPlayer @ 要换将的玩家
---@param new_general string @ 要变更的武将,若不存在则变身为孙策,孙策不存在变身为士兵 ---@param new_general string @ 要变更的武将,若不存在则变身为孙策,孙策不存在变身为士兵
---@param full bool @ 是否血量满状态变身 ---@param full? boolean @ 是否血量满状态变身
---@param isDeputy bool @ 是否变的是副将 ---@param isDeputy? boolean @ 是否变的是副将
---@param sendLog bool @ 是否发Log ---@param sendLog? boolean @ 是否发Log
---@param maxHpChange bool @ 是否改变体力上限,默认改变 ---@param maxHpChange? boolean @ 是否改变体力上限,默认改变
function Room:changeHero(player, new_general, full, isDeputy, sendLog, maxHpChange, kingdomChange) function Room:changeHero(player, new_general, full, isDeputy, sendLog, maxHpChange, kingdomChange)
local new = Fk.generals[new_general] or Fk.generals["sunce"] or Fk.generals["blank_shibing"] local new = Fk.generals[new_general] or Fk.generals["sunce"] or Fk.generals["blank_shibing"]
@ -641,7 +642,7 @@ end
---@param player ServerPlayer @ 要变更势力的玩家 ---@param player ServerPlayer @ 要变更势力的玩家
---@param kingdom string @ 要变更的势力 ---@param kingdom string @ 要变更的势力
---@param sendLog bool @ 是否发Log ---@param sendLog? boolean @ 是否发Log
function Room:changeKingdom(player, kingdom, sendLog) function Room:changeKingdom(player, kingdom, sendLog)
if kingdom == player.kingdom then return end if kingdom == player.kingdom then return end
sendLog = sendLog or false sendLog = sendLog or false
@ -683,7 +684,7 @@ end
--- 向多名玩家广播一条消息。 --- 向多名玩家广播一条消息。
---@param command string @ 发出这条消息的消息类型 ---@param command string @ 发出这条消息的消息类型
---@param jsonData string @ 消息的数据一般是JSON字符串也可以是普通字符串取决于client怎么处理了 ---@param jsonData string @ 消息的数据一般是JSON字符串也可以是普通字符串取决于client怎么处理了
---@param players ServerPlayer[] | nil @ 要告知的玩家列表,默认为所有人 ---@param players? ServerPlayer[] @ 要告知的玩家列表,默认为所有人
function Room:doBroadcastNotify(command, jsonData, players) function Room:doBroadcastNotify(command, jsonData, players)
players = players or self.players players = players or self.players
for _, p in ipairs(players) do for _, p in ipairs(players) do
@ -695,8 +696,8 @@ end
---@param player ServerPlayer @ 发出这个请求的目标玩家 ---@param player ServerPlayer @ 发出这个请求的目标玩家
---@param command string @ 请求的类型 ---@param command string @ 请求的类型
---@param jsonData string @ 请求的数据 ---@param jsonData string @ 请求的数据
---@param wait bool @ 是否要等待答复默认为true ---@param wait? boolean @ 是否要等待答复默认为true
---@return string | nil @ 收到的答复如果wait为false的话就返回nil ---@return string @ 收到的答复如果wait为false的话就返回nil
function Room:doRequest(player, command, jsonData, wait) function Room:doRequest(player, command, jsonData, wait)
if wait == nil then wait = true end if wait == nil then wait = true end
self.request_queue = {} self.request_queue = {}
@ -713,8 +714,8 @@ end
--- 向多名玩家发出请求。 --- 向多名玩家发出请求。
---@param command string @ 请求类型 ---@param command string @ 请求类型
---@param players ServerPlayer[]|nil @ 发出请求的玩家列表 ---@param players? ServerPlayer[] @ 发出请求的玩家列表
---@param jsonData string|nil @ 请求数据 ---@param jsonData? string @ 请求数据
function Room:doBroadcastRequest(command, players, jsonData) function Room:doBroadcastRequest(command, players, jsonData)
players = players or self.players players = players or self.players
self.request_queue = {} self.request_queue = {}
@ -745,7 +746,7 @@ end
---@param command string @ 请求类型 ---@param command string @ 请求类型
---@param players ServerPlayer[] @ 要竞争这次请求的玩家列表 ---@param players ServerPlayer[] @ 要竞争这次请求的玩家列表
---@param jsonData string @ 请求数据 ---@param jsonData string @ 请求数据
---@return ServerPlayer | nil @ 在这次竞争请求中获胜的角色可能是nil ---@return ServerPlayer? @ 在这次竞争请求中获胜的角色可能是nil
function Room:doRaceRequest(command, players, jsonData) function Room:doRaceRequest(command, players, jsonData)
players = players or self.players players = players or self.players
players = table.simpleClone(players) players = table.simpleClone(players)
@ -819,9 +820,9 @@ function Room:delay(ms)
end end
--- 向多名玩家告知一次移牌行为。 --- 向多名玩家告知一次移牌行为。
---@param players ServerPlayer[] | nil @ 要被告知的玩家列表,默认为全员 ---@param players? ServerPlayer[] @ 要被告知的玩家列表,默认为全员
---@param card_moves CardsMoveStruct[] @ 要告知的移牌信息列表 ---@param card_moves CardsMoveStruct[] @ 要告知的移牌信息列表
---@param forceVisible bool @ 是否让所有牌对告知目标可见 ---@param forceVisible? boolean @ 是否让所有牌对告知目标可见
function Room:notifyMoveCards(players, card_moves, forceVisible) function Room:notifyMoveCards(players, card_moves, forceVisible)
if players == nil or players == {} then players = self.players end if players == nil or players == {} then players = self.players end
for _, p in ipairs(players) do for _, p in ipairs(players) do
@ -913,7 +914,7 @@ end
--- 播放某种动画效果给players看。 --- 播放某种动画效果给players看。
---@param type string @ 动画名字 ---@param type string @ 动画名字
---@param data any @ 这个动画附加的额外信息在这个函数将会被转成json字符串 ---@param data any @ 这个动画附加的额外信息在这个函数将会被转成json字符串
---@param players ServerPlayer[] | nil @ 要观看动画的玩家们,默认为全员 ---@param players? ServerPlayer[] @ 要观看动画的玩家们,默认为全员
function Room:doAnimate(type, data, players) function Room:doAnimate(type, data, players)
players = players or self.players players = players or self.players
data.type = type data.type = type
@ -965,7 +966,7 @@ end
--- 播放技能的语音。 --- 播放技能的语音。
---@param skill_name nil @ 技能名 ---@param skill_name nil @ 技能名
---@param index integer | nil @ 语音编号,默认为-1也就是随机播放 ---@param index? integer @ 语音编号,默认为-1也就是随机播放
function Room:broadcastSkillInvoke(skill_name, index) function Room:broadcastSkillInvoke(skill_name, index)
fk.qCritical 'Room:broadcastSkillInvoke deprecated; use SPlayer:broadcastSkillInvoke' fk.qCritical 'Room:broadcastSkillInvoke deprecated; use SPlayer:broadcastSkillInvoke'
index = index or -1 index = index or -1
@ -988,7 +989,7 @@ end
--- 与此同时在战报里面发一条“xxx发动了xxx” --- 与此同时在战报里面发一条“xxx发动了xxx”
---@param player ServerPlayer @ 发动技能的那个玩家 ---@param player ServerPlayer @ 发动技能的那个玩家
---@param skill_name string @ 技能名 ---@param skill_name string @ 技能名
---@param skill_type string | nil @ 技能的动画效果默认是那个技能的anim_type ---@param skill_type? string @ 技能的动画效果默认是那个技能的anim_type
function Room:notifySkillInvoked(player, skill_name, skill_type) function Room:notifySkillInvoked(player, skill_name, skill_type)
local bigAnim = false local bigAnim = false
if not skill_type then if not skill_type then
@ -1049,11 +1050,11 @@ end
--- 如果发动的话那么会执行一下技能的onUse函数然后返回选择的牌和目标等。 --- 如果发动的话那么会执行一下技能的onUse函数然后返回选择的牌和目标等。
---@param player ServerPlayer @ 询问目标 ---@param player ServerPlayer @ 询问目标
---@param skill_name string @ 主动技的技能名 ---@param skill_name string @ 主动技的技能名
---@param prompt string|nil @ 烧条上面显示的提示文本内容 ---@param prompt? string @ 烧条上面显示的提示文本内容
---@param cancelable bool @ 是否可以点取消 ---@param cancelable? boolean @ 是否可以点取消
---@param extra_data table|nil @ 额外信息,因技能而异了 ---@param extra_data? table @ 额外信息,因技能而异了
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return boolean, table|nil ---@return boolean, table?
function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra_data, no_indicate) function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra_data, no_indicate)
prompt = prompt or "" prompt = prompt or ""
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
@ -1112,13 +1113,13 @@ Room.askForUseViewAsSkill = Room.askForUseActiveSkill
---@param player ServerPlayer @ 弃牌角色 ---@param player ServerPlayer @ 弃牌角色
---@param minNum integer @ 最小值 ---@param minNum integer @ 最小值
---@param maxNum integer @ 最大值 ---@param maxNum integer @ 最大值
---@param includeEquip bool @ 能不能弃装备区? ---@param includeEquip? boolean @ 能不能弃装备区?
---@param skillName string|nil @ 引发弃牌的技能名 ---@param skillName? string @ 引发弃牌的技能名
---@param cancelable bool @ 能不能点取消? ---@param cancelable? boolean @ 能不能点取消?
---@param pattern string|nil @ 弃牌需要符合的规则 ---@param pattern? string @ 弃牌需要符合的规则
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param skipDiscard bool @ 是否跳过弃牌(即只询问选择可以弃置的牌) ---@param skipDiscard? boolean @ 是否跳过弃牌(即只询问选择可以弃置的牌)
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return integer[] @ 弃掉的牌的id列表可能是空的 ---@return integer[] @ 弃掉的牌的id列表可能是空的
function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, skipDiscard, no_indicate) function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, skipDiscard, no_indicate)
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
@ -1192,10 +1193,10 @@ end
---@param targets integer[] @ 可以选的目标范围是玩家id数组 ---@param targets integer[] @ 可以选的目标范围是玩家id数组
---@param minNum integer @ 最小值 ---@param minNum integer @ 最小值
---@param maxNum integer @ 最大值 ---@param maxNum integer @ 最大值
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return integer[] @ 选择的玩家id列表可能为空 ---@return integer[] @ 选择的玩家id列表可能为空
function Room:askForChoosePlayers(player, targets, minNum, maxNum, prompt, skillName, cancelable, no_indicate) function Room:askForChoosePlayers(player, targets, minNum, maxNum, prompt, skillName, cancelable, no_indicate)
if maxNum < 1 then if maxNum < 1 then
@ -1229,17 +1230,17 @@ end
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param minNum integer @ 最小值 ---@param minNum integer @ 最小值
---@param maxNum integer @ 最大值 ---@param maxNum integer @ 最大值
---@param includeEquip bool @ 能不能选装备 ---@param includeEquip? boolean @ 能不能选装备
---@param skillName string @ 技能名 ---@param skillName? string @ 技能名
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param pattern string|nil @ 选牌规则 ---@param pattern? string @ 选牌规则
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param expand_pile string|nil @ 可选私人牌堆名称 ---@param expand_pile? string @ 可选私人牌堆名称
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return integer[] @ 选择的牌的id列表可能是空的 ---@return integer[] @ 选择的牌的id列表可能是空的
function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, expand_pile, no_indicate) function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, expand_pile, no_indicate)
if minNum < 1 then if minNum < 1 then
return nil return {}
end end
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
no_indicate = no_indicate or false no_indicate = no_indicate or false
@ -1285,10 +1286,10 @@ end
---@param targets integer[] @ 选择目标的id范围 ---@param targets integer[] @ 选择目标的id范围
---@param minNum integer @ 选目标最小值 ---@param minNum integer @ 选目标最小值
---@param maxNum integer @ 选目标最大值 ---@param maxNum integer @ 选目标最大值
---@param pattern string|nil @ 选牌规则 ---@param pattern? string @ 选牌规则
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return integer[], integer ---@return integer[], integer
function Room:askForChooseCardAndPlayers(player, targets, minNum, maxNum, pattern, prompt, skillName, cancelable, no_indicate) function Room:askForChooseCardAndPlayers(player, targets, minNum, maxNum, pattern, prompt, skillName, cancelable, no_indicate)
if maxNum < 1 then if maxNum < 1 then
@ -1332,10 +1333,10 @@ end
---@param targets integer[] @ 选择目标的id范围 ---@param targets integer[] @ 选择目标的id范围
---@param minTargetNum integer @ 选目标最小值 ---@param minTargetNum integer @ 选目标最小值
---@param maxTargetNum integer @ 选目标最大值 ---@param maxTargetNum integer @ 选目标最大值
---@param pattern string|nil @ 选牌规则 ---@param pattern? string @ 选牌规则
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return integer[], integer[] ---@return integer[], integer[]
function Room:askForChooseBoth(player, minCardNum, maxCardNum, targets, minTargetNum, maxTargetNum, pattern, prompt, skillName, cancelable, no_indicate) function Room:askForChooseBoth(player, minCardNum, maxCardNum, targets, minTargetNum, maxTargetNum, pattern, prompt, skillName, cancelable, no_indicate)
if minCardNum < 1 or minTargetNum < 1 then if minCardNum < 1 or minTargetNum < 1 then
@ -1376,7 +1377,7 @@ end
--- ---
--- 同getNCards抽出来就没有了所以记得放回去。 --- 同getNCards抽出来就没有了所以记得放回去。
---@param n number @ 数量 ---@param n number @ 数量
---@param position string|nil @位置top/bottom默认top ---@param position? string @位置top/bottom默认top
---@return string[] @ 武将名数组 ---@return string[] @ 武将名数组
function Room:getNGenerals(n, position) function Room:getNGenerals(n, position)
position = position or "top" position = position or "top"
@ -1399,7 +1400,7 @@ end
--- 把武将牌塞回去(……) --- 把武将牌塞回去(……)
---@param g string[] @ 武将名数组 ---@param g string[] @ 武将名数组
---@param position string|nil @位置top/bottom默认bottom ---@param position? string @位置top/bottom默认bottom
---@return boolean @ 是否成功 ---@return boolean @ 是否成功
function Room:returnToGeneralPile(g, position) function Room:returnToGeneralPile(g, position)
position = position or "bottom" position = position or "bottom"
@ -1417,7 +1418,7 @@ end
--- 抽特定名字的武将(抽了就没了) --- 抽特定名字的武将(抽了就没了)
---@param name string @ 武将name如找不到则查找truename再找不到则返回nil ---@param name string @ 武将name如找不到则查找truename再找不到则返回nil
---@return string | nil @ 抽出的武将名 ---@return string? @ 抽出的武将名
function Room:findGeneral(name) function Room:findGeneral(name)
for i, g in ipairs(self.general_pile) do for i, g in ipairs(self.general_pile) do
if g == name or Fk.generals[g].trueName == Fk.generals[name].trueName then if g == name or Fk.generals[g].trueName == Fk.generals[name].trueName then
@ -1429,7 +1430,7 @@ end
--- 自上而下抽符合特定情况的N个武将抽了就没了 --- 自上而下抽符合特定情况的N个武将抽了就没了
---@param func fun(name: string):any @ 武将筛选函数 ---@param func fun(name: string):any @ 武将筛选函数
---@param n integer | nil @ 抽取数量,数量不足则直接抽干净 ---@param n? integer @ 抽取数量,数量不足则直接抽干净
---@return string[] @ 武将组合,可能为空 ---@return string[] @ 武将组合,可能为空
function Room:findGenerals(func, n) function Room:findGenerals(func, n)
n = n or 1 n = n or 1
@ -1449,7 +1450,7 @@ end
---@param player ServerPlayer @ 询问目标 ---@param player ServerPlayer @ 询问目标
---@param generals string[] @ 可选武将 ---@param generals string[] @ 可选武将
---@param n integer @ 可选数量默认为1 ---@param n integer @ 可选数量默认为1
---@param noConvert bool @ 可否变更,默认可 ---@param noConvert? boolean @ 可否变更,默认可
---@return string|string[] @ 选择的武将 ---@return string|string[] @ 选择的武将
function Room:askForGeneral(player, generals, n, noConvert) function Room:askForGeneral(player, generals, n, noConvert)
local command = "AskForGeneral" local command = "AskForGeneral"
@ -1475,7 +1476,7 @@ function Room:askForGeneral(player, generals, n, noConvert)
end end
--- 询问玩家若为神将、双势力需选择一个势力。 --- 询问玩家若为神将、双势力需选择一个势力。
---@param players ServerPlayer[]|nil @ 询问目标 ---@param players? ServerPlayer[] @ 询问目标
function Room:askForChooseKingdom(players) function Room:askForChooseKingdom(players)
players = players or self.alive_players players = players or self.alive_players
local specialKingdomPlayers = table.filter(players, function(p) local specialKingdomPlayers = table.filter(players, function(p)
@ -1521,7 +1522,7 @@ end
---@param target ServerPlayer @ 被选牌的人 ---@param target ServerPlayer @ 被选牌的人
---@param flag any @ 用"hej"三个字母的组合表示能选择哪些区域, h 手牌区, e - 装备区, j - 判定区 ---@param flag any @ 用"hej"三个字母的组合表示能选择哪些区域, h 手牌区, e - 装备区, j - 判定区
---@param reason string @ 原因,一般是技能名 ---@param reason string @ 原因,一般是技能名
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@return integer @ 选择的卡牌id ---@return integer @ 选择的卡牌id
function Room:askForCardChosen(chooser, target, flag, reason, prompt) function Room:askForCardChosen(chooser, target, flag, reason, prompt)
local command = "AskForCardChosen" local command = "AskForCardChosen"
@ -1567,7 +1568,7 @@ end
---@param max integer @ 最大选牌数 ---@param max integer @ 最大选牌数
---@param flag any @ 用"hej"三个字母的组合表示能选择哪些区域, h 手牌区, e - 装备区, j - 判定区 ---@param flag any @ 用"hej"三个字母的组合表示能选择哪些区域, h 手牌区, e - 装备区, j - 判定区
---@param reason string @ 原因,一般是技能名 ---@param reason string @ 原因,一般是技能名
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@return integer[] @ 选择的id ---@return integer[] @ 选择的id
function Room:askForCardsChosen(chooser, target, min, max, flag, reason, prompt) function Room:askForCardsChosen(chooser, target, min, max, flag, reason, prompt)
if min == 1 and max == 1 then if min == 1 and max == 1 then
@ -1619,7 +1620,7 @@ end
---@param poxi_type string ---@param poxi_type string
---@param data any ---@param data any
---@param extra_data any ---@param extra_data any
---@param cancelable nil|bool ---@param cancelable? boolean
---@return integer[] ---@return integer[]
function Room:askForPoxi(player, poxi_type, data, extra_data, cancelable) function Room:askForPoxi(player, poxi_type, data, extra_data, cancelable)
local poxi = Fk.poxi_methods[poxi_type] local poxi = Fk.poxi_methods[poxi_type]
@ -1644,10 +1645,10 @@ end
--- 询问一名玩家从众多选项中选择一个。 --- 询问一名玩家从众多选项中选择一个。
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param choices string[] @ 可选选项列表 ---@param choices string[] @ 可选选项列表
---@param skill_name string|nil @ 技能名 ---@param skill_name? string @ 技能名
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param detailed bool @ 选项详细描述 ---@param detailed? boolean @ 选项详细描述
---@param all_choices string[]|nil @ 所有选项(不可选变灰) ---@param all_choices? string[] @ 所有选项(不可选变灰)
---@return string @ 选择的选项 ---@return string @ 选择的选项
function Room:askForChoice(player, choices, skill_name, prompt, detailed, all_choices) function Room:askForChoice(player, choices, skill_name, prompt, detailed, all_choices)
if #choices == 1 and not all_choices then return choices[1] end if #choices == 1 and not all_choices then return choices[1] end
@ -1668,11 +1669,11 @@ end
---@param choices string[] @ 可选选项列表 ---@param choices string[] @ 可选选项列表
---@param minNum number @ 最少选择项数 ---@param minNum number @ 最少选择项数
---@param maxNum number @ 最多选择项数 ---@param maxNum number @ 最多选择项数
---@param skill_name string|nil @ 技能名 ---@param skill_name? string @ 技能名
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param cancelable bool|nil @ 是否可取消 ---@param cancelable? boolean @ 是否可取消
---@param detailed bool @ 选项详细描述 ---@param detailed? boolean @ 选项详细描述
---@param all_choices string[]|nil @ 所有选项(不可选变灰) ---@param all_choices? string[] @ 所有选项(不可选变灰)
---@return string[] @ 选择的选项 ---@return string[] @ 选择的选项
function Room:askForCheck(player, choices, minNum, maxNum, skill_name, prompt, cancelable, detailed, all_choices) function Room:askForCheck(player, choices, minNum, maxNum, skill_name, prompt, cancelable, detailed, all_choices)
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
@ -1695,8 +1696,8 @@ end
--- 询问玩家是否发动技能。 --- 询问玩家是否发动技能。
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param skill_name string @ 技能名 ---@param skill_name string @ 技能名
---@param data any|nil @ 未使用 ---@param data? any @ 未使用
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@return boolean ---@return boolean
function Room:askForSkillInvoke(player, skill_name, data, prompt) function Room:askForSkillInvoke(player, skill_name, data, prompt)
local command = "AskForSkillInvoke" local command = "AskForSkillInvoke"
@ -1767,12 +1768,12 @@ end
--- 观星完成后相关的牌会被置于牌堆顶或者牌堆底。所以这些cards最好不要来自牌堆一般先用getNCards从牌堆拿出一些牌。 --- 观星完成后相关的牌会被置于牌堆顶或者牌堆底。所以这些cards最好不要来自牌堆一般先用getNCards从牌堆拿出一些牌。
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param cards integer[] @ 可以被观星的卡牌id列表 ---@param cards integer[] @ 可以被观星的卡牌id列表
---@param top_limit integer[]|nil @ 置于牌堆顶的牌的限制(下限,上限),不填写则不限 ---@param top_limit? integer[] @ 置于牌堆顶的牌的限制(下限,上限),不填写则不限
---@param bottom_limit integer[]|nil @ 置于牌堆底的牌的限制(下限,上限),不填写则不限 ---@param bottom_limit? integer[] @ 置于牌堆底的牌的限制(下限,上限),不填写则不限
---@param customNotify string|null @ 自定义读条操作提示 ---@param customNotify? string @ 自定义读条操作提示
---param prompt string|null @ 观星框的标题(暂时雪藏) ---param prompt? string @ 观星框的标题(暂时雪藏)
---@param noPut bool @ 是否进行放置牌操作 ---@param noPut? boolean @ 是否进行放置牌操作
---@param areaNames string[]|null @ 左侧提示信息 ---@param areaNames? string[] @ 左侧提示信息
---@return table<"top"|"bottom", integer[]> ---@return table<"top"|"bottom", integer[]>
function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotify, noPut, areaNames) function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotify, noPut, areaNames)
-- 这一大堆都是来提前报错的 -- 这一大堆都是来提前报错的
@ -1843,10 +1844,10 @@ end
--- 询问玩家任意交换几堆牌堆。 --- 询问玩家任意交换几堆牌堆。
--- ---
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param piles table<cardIds, integer[]> @ 卡牌id列表的列表也就是……几堆牌堆的集合 ---@param piles table<string, integer[]> @ 卡牌id列表的列表也就是……几堆牌堆的集合
---@param piles_name string[] @ 牌堆名必须一一对应否则统一替换为“牌堆X” ---@param piles_name string[] @ 牌堆名必须一一对应否则统一替换为“牌堆X”
---@param customNotify string|null @ 自定义读条操作提示 ---@param customNotify? string @ 自定义读条操作提示
---@return table<cardIds, integer[]> ---@return table<string, integer[]>
function Room:askForExchange(player, piles, piles_name, customNotify) function Room:askForExchange(player, piles, piles_name, customNotify)
local command = "AskForExchange" local command = "AskForExchange"
piles_name = piles_name or Util.DummyTable piles_name = piles_name or Util.DummyTable
@ -1947,13 +1948,13 @@ end
-- * bypass_times: boolean -- * bypass_times: boolean
--- 询问玩家使用一张牌。 --- 询问玩家使用一张牌。
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param card_name string|nil @ 使用牌的牌名若pattern指定了则可随意写它影响的是烧条的提示信息 ---@param card_name? string @ 使用牌的牌名若pattern指定了则可随意写它影响的是烧条的提示信息
---@param pattern string|nil @ 使用牌的规则默认就是card_name的值 ---@param pattern? string @ 使用牌的规则默认就是card_name的值
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param extra_data? UseExtraData @ 额外信息 ---@param extra_data? UseExtraData @ 额外信息
---@param event_data CardEffectEvent|nil @ 事件信息 ---@param event_data? CardEffectEvent @ 事件信息
---@return CardUseStruct | nil @ 返回关于本次使用牌的数据,以便后续处理 ---@return CardUseStruct? @ 返回关于本次使用牌的数据,以便后续处理
function Room:askForUseCard(player, card_name, pattern, prompt, cancelable, extra_data, event_data) function Room:askForUseCard(player, card_name, pattern, prompt, cancelable, extra_data, event_data)
if event_data and (event_data.disresponsive or table.contains(event_data.disresponsiveList or Util.DummyTable, player.id)) then if event_data and (event_data.disresponsive or table.contains(event_data.disresponsiveList or Util.DummyTable, player.id)) then
return nil return nil
@ -2021,12 +2022,12 @@ end
--- 询问一名玩家打出一张牌。 --- 询问一名玩家打出一张牌。
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param card_name string @ 牌名 ---@param card_name string @ 牌名
---@param pattern string|nil @ 牌的规则 ---@param pattern? string @ 牌的规则
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param cancelable bool @ 能否取消 ---@param cancelable? boolean @ 能否取消
---@param extra_data any|nil @ 额外数据 ---@param extra_data? any @ 额外数据
---@param effectData CardEffectEvent|nil @ 关联的卡牌生效流程 ---@param effectData? CardEffectEvent @ 关联的卡牌生效流程
---@return Card | nil @ 打出的牌 ---@return Card? @ 打出的牌
function Room:askForResponse(player, card_name, pattern, prompt, cancelable, extra_data, effectData) function Room:askForResponse(player, card_name, pattern, prompt, cancelable, extra_data, effectData)
if effectData and (effectData.disresponsive or table.contains(effectData.disresponsiveList or Util.DummyTable, player.id)) then if effectData and (effectData.disresponsive or table.contains(effectData.disresponsiveList or Util.DummyTable, player.id)) then
return nil return nil
@ -2072,10 +2073,10 @@ end
---@param players ServerPlayer[] @ 要询问的玩家列表 ---@param players ServerPlayer[] @ 要询问的玩家列表
---@param card_name string @ 询问的牌名,默认为无懈 ---@param card_name string @ 询问的牌名,默认为无懈
---@param pattern string @ 牌的规则 ---@param pattern string @ 牌的规则
---@param prompt string|nil @ 提示信息 ---@param prompt? string @ 提示信息
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param extra_data any|nil @ 额外信息 ---@param extra_data? any @ 额外信息
---@return CardUseStruct | nil @ 最终决胜出的卡牌使用信息 ---@return CardUseStruct? @ 最终决胜出的卡牌使用信息
function Room:askForNullification(players, card_name, pattern, prompt, cancelable, extra_data) function Room:askForNullification(players, card_name, pattern, prompt, cancelable, extra_data)
if #players == 0 then if #players == 0 then
return nil return nil
@ -2110,8 +2111,8 @@ end
--- 询问玩家从AG中选择一张牌。 --- 询问玩家从AG中选择一张牌。
---@param player ServerPlayer @ 要询问的玩家 ---@param player ServerPlayer @ 要询问的玩家
---@param id_list integer[] | Card[] @ 可选的卡牌列表 ---@param id_list integer[] | Card[] @ 可选的卡牌列表
---@param cancelable bool @ 能否点取消 ---@param cancelable? boolean @ 能否点取消
---@param reason string|nil @ 原因 ---@param reason? string @ 原因
---@return integer @ 选择的卡牌 ---@return integer @ 选择的卡牌
function Room:askForAG(player, id_list, cancelable, reason) function Room:askForAG(player, id_list, cancelable, reason)
id_list = Card:getIdList(id_list) id_list = Card:getIdList(id_list)
@ -2132,7 +2133,7 @@ end
--- 给player发一条消息在他的窗口中用一系列卡牌填充一个AG。 --- 给player发一条消息在他的窗口中用一系列卡牌填充一个AG。
---@param player ServerPlayer @ 要通知的玩家 ---@param player ServerPlayer @ 要通知的玩家
---@param id_list integer[] | Card[] @ 要填充的卡牌 ---@param id_list integer[] | Card[] @ 要填充的卡牌
---@param disable_ids integer[] | Card[]|nil @ 未使用 ---@param disable_ids? integer[] | Card[] @ 未使用
function Room:fillAG(player, id_list, disable_ids) function Room:fillAG(player, id_list, disable_ids)
id_list = Card:getIdList(id_list) id_list = Card:getIdList(id_list)
-- disable_ids = Card:getIdList(disable_ids) -- disable_ids = Card:getIdList(disable_ids)
@ -2142,7 +2143,7 @@ end
--- 告诉一些玩家AG中的牌被taker取走了。 --- 告诉一些玩家AG中的牌被taker取走了。
---@param taker ServerPlayer @ 拿走牌的玩家 ---@param taker ServerPlayer @ 拿走牌的玩家
---@param id integer @ 被拿走的牌 ---@param id integer @ 被拿走的牌
---@param notify_list ServerPlayer[]|nil @ 要告知的玩家,默认为全员 ---@param notify_list? ServerPlayer[] @ 要告知的玩家,默认为全员
function Room:takeAG(taker, id, notify_list) function Room:takeAG(taker, id, notify_list)
self:doBroadcastNotify("TakeAG", json.encode{ taker.id, id }, notify_list) self:doBroadcastNotify("TakeAG", json.encode{ taker.id, id }, notify_list)
end end
@ -2150,7 +2151,7 @@ end
--- 关闭player那侧显示的AG。 --- 关闭player那侧显示的AG。
--- ---
--- 若不传参即player为nil那么关闭所有玩家的AG。 --- 若不传参即player为nil那么关闭所有玩家的AG。
---@param player ServerPlayer|nil @ 要关闭AG的玩家 ---@param player? ServerPlayer @ 要关闭AG的玩家
function Room:closeAG(player) function Room:closeAG(player)
if player then player:doNotify("CloseAG", "") if player then player:doNotify("CloseAG", "")
else self:doBroadcastNotify("CloseAG", "") end else self:doBroadcastNotify("CloseAG", "") end
@ -2177,10 +2178,10 @@ end
---@param targetOne ServerPlayer @ 移动的目标1玩家 ---@param targetOne ServerPlayer @ 移动的目标1玩家
---@param targetTwo ServerPlayer @ 移动的目标2玩家 ---@param targetTwo ServerPlayer @ 移动的目标2玩家
---@param skillName string @ 技能名 ---@param skillName string @ 技能名
---@param flag string|null @ 限定可移动的区域值为nil装备区和判定区ej ---@param flag? string @ 限定可移动的区域值为nil装备区和判定区ej
---@param moveFrom ServerPlayer|null @ 是否只是目标1移动给目标2 ---@param moveFrom? ServerPlayer @ 是否只是目标1移动给目标2
---@param excludeIds CardId[]|null @ 本次不可移动的卡牌id ---@param excludeIds? integer[] @ 本次不可移动的卡牌id
---@return table<"card"|"from"|"to">|null @ 选择的卡牌、起点玩家id和终点玩家id列表 ---@return table<"card"|"from"|"to">? @ 选择的卡牌、起点玩家id和终点玩家id列表
function Room:askForMoveCardInBoard(player, targetOne, targetTwo, skillName, flag, moveFrom, excludeIds) function Room:askForMoveCardInBoard(player, targetOne, targetTwo, skillName, flag, moveFrom, excludeIds)
if flag then if flag then
assert(flag == "e" or flag == "j") assert(flag == "e" or flag == "j")
@ -2289,9 +2290,9 @@ end
---@param player ServerPlayer @ 要做选择的玩家 ---@param player ServerPlayer @ 要做选择的玩家
---@param prompt string @ 提示信息 ---@param prompt string @ 提示信息
---@param skillName string @ 技能名 ---@param skillName string @ 技能名
---@param cancelable bool @ 是否可以取消选择 ---@param cancelable? boolean @ 是否可以取消选择
---@param flag string|null @ 限定可移动的区域值为nil装备区和判定区ej ---@param flag? string @ 限定可移动的区域值为nil装备区和判定区ej
---@param no_indicate bool @ 是否不显示指示线 ---@param no_indicate? boolean @ 是否不显示指示线
---@return integer[] @ 选择的玩家id列表可能为空 ---@return integer[] @ 选择的玩家id列表可能为空
function Room:askForChooseToMoveCardInBoard(player, prompt, skillName, cancelable, flag, no_indicate, excludeIds) function Room:askForChooseToMoveCardInBoard(player, prompt, skillName, cancelable, flag, no_indicate, excludeIds)
if flag then if flag then
@ -2753,11 +2754,11 @@ function Room:responseCard(cardResponseEvent)
end end
---@param card_name string @ 想要视为使用的牌名 ---@param card_name string @ 想要视为使用的牌名
---@param subcards integer[]|nil @ 子卡可以留空或者直接nil ---@param subcards? integer[] @ 子卡可以留空或者直接nil
---@param from ServerPlayer @ 使用来源 ---@param from ServerPlayer @ 使用来源
---@param tos ServerPlayer | ServerPlayer[] @ 目标角色(列表) ---@param tos ServerPlayer | ServerPlayer[] @ 目标角色(列表)
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@param extra bool @ 是否不计入次数 ---@param extra? boolean @ 是否不计入次数
function Room:useVirtualCard(card_name, subcards, from, tos, skillName, extra) function Room:useVirtualCard(card_name, subcards, from, tos, skillName, extra)
local card = Fk:cloneCard(card_name) local card = Fk:cloneCard(card_name)
card.skillName = skillName card.skillName = skillName
@ -2791,7 +2792,7 @@ end
--- 传入一系列移牌信息,去实际移动这些牌 --- 传入一系列移牌信息,去实际移动这些牌
---@vararg CardsMoveInfo ---@vararg CardsMoveInfo
---@return boolean ---@return boolean?
function Room:moveCards(...) function Room:moveCards(...)
return execGameEvent(GameEvent.MoveCards, ...) return execGameEvent(GameEvent.MoveCards, ...)
end end
@ -2799,8 +2800,8 @@ end
--- 让一名玩家获得一张牌 --- 让一名玩家获得一张牌
---@param player integer|ServerPlayer @ 要拿牌的玩家 ---@param player integer|ServerPlayer @ 要拿牌的玩家
---@param cid integer|Card @ 要拿到的卡牌 ---@param cid integer|Card @ 要拿到的卡牌
---@param unhide bool @ 是否明着拿 ---@param unhide? boolean @ 是否明着拿
---@param reason CardMoveReason|nil @ 卡牌移动的原因 ---@param reason? CardMoveReason @ 卡牌移动的原因
function Room:obtainCard(player, cid, unhide, reason) function Room:obtainCard(player, cid, unhide, reason)
if type(cid) ~= "number" then if type(cid) ~= "number" then
assert(cid and cid:isInstanceOf(Card)) assert(cid and cid:isInstanceOf(Card))
@ -2828,8 +2829,8 @@ end
--- 让玩家摸牌 --- 让玩家摸牌
---@param player ServerPlayer @ 摸牌的玩家 ---@param player ServerPlayer @ 摸牌的玩家
---@param num integer @ 摸牌数 ---@param num integer @ 摸牌数
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@param fromPlace string|nil @ 摸牌的位置,"top" 或者 "bottom" ---@param fromPlace? string @ 摸牌的位置,"top" 或者 "bottom"
---@return integer[] @ 摸到的牌 ---@return integer[] @ 摸到的牌
function Room:drawCards(player, num, skillName, fromPlace) function Room:drawCards(player, num, skillName, fromPlace)
local drawData = { local drawData = {
@ -2860,14 +2861,14 @@ function Room:drawCards(player, num, skillName, fromPlace)
end end
--- 将一张或多张牌移动到某处 --- 将一张或多张牌移动到某处
---@param card Card | Card[] @ 要移动的牌 ---@param card integer | Card | Card[] @ 要移动的牌
---@param to_place integer @ 移动的目标位置 ---@param to_place integer @ 移动的目标位置
---@param target ServerPlayer @ 移动的目标玩家 ---@param target ServerPlayer @ 移动的目标玩家
---@param reason integer|nil @ 移动时使用的移牌原因 ---@param reason? integer @ 移动时使用的移牌原因
---@param skill_name string|nil @ 技能名 ---@param skill_name? string @ 技能名
---@param special_name string|nil @ 私人牌堆名 ---@param special_name? string @ 私人牌堆名
---@param visible bool @ 是否明置 ---@param visible? boolean @ 是否明置
---@param proposer integer | nil ---@param proposer? integer
function Room:moveCardTo(card, to_place, target, reason, skill_name, special_name, visible, proposer) function Room:moveCardTo(card, to_place, target, reason, skill_name, special_name, visible, proposer)
reason = reason or fk.ReasonJustMove reason = reason or fk.ReasonJustMove
skill_name = skill_name or "" skill_name = skill_name or ""
@ -2917,9 +2918,9 @@ end
--- 改变一名玩家的体力。 --- 改变一名玩家的体力。
---@param player ServerPlayer @ 玩家 ---@param player ServerPlayer @ 玩家
---@param num integer @ 变化量 ---@param num integer @ 变化量
---@param reason string|nil @ 原因 ---@param reason? string @ 原因
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@param damageStruct DamageStruct|null @ 伤害数据 ---@param damageStruct? DamageStruct @ 伤害数据
---@return boolean ---@return boolean
function Room:changeHp(player, num, reason, skillName, damageStruct) function Room:changeHp(player, num, reason, skillName, damageStruct)
return execGameEvent(GameEvent.ChangeHp, player, num, reason, skillName, damageStruct) return execGameEvent(GameEvent.ChangeHp, player, num, reason, skillName, damageStruct)
@ -2938,7 +2939,7 @@ end
--- 令一名玩家失去体力。 --- 令一名玩家失去体力。
---@param player ServerPlayer @ 玩家 ---@param player ServerPlayer @ 玩家
---@param num integer @ 失去的数量 ---@param num integer @ 失去的数量
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@return boolean ---@return boolean
function Room:loseHp(player, num, skillName) function Room:loseHp(player, num, skillName)
return execGameEvent(GameEvent.LoseHp, player, num, skillName) return execGameEvent(GameEvent.LoseHp, player, num, skillName)
@ -2987,8 +2988,8 @@ end
--- 每个skill_name都是要获得的技能的名。如果在skill_name前面加上"-",那就是失去技能。 --- 每个skill_name都是要获得的技能的名。如果在skill_name前面加上"-",那就是失去技能。
---@param player ServerPlayer @ 玩家 ---@param player ServerPlayer @ 玩家
---@param skill_names string[] | string @ 要获得/失去的技能 ---@param skill_names string[] | string @ 要获得/失去的技能
---@param source_skill string | Skill | null @ 源技能 ---@param source_skill? string | Skill @ 源技能
---@param no_trigger bool @ 是否不触发相关时机 ---@param no_trigger? boolean @ 是否不触发相关时机
function Room:handleAddLoseSkills(player, skill_names, source_skill, sendlog, no_trigger) function Room:handleAddLoseSkills(player, skill_names, source_skill, sendlog, no_trigger)
if type(skill_names) == "string" then if type(skill_names) == "string" then
skill_names = skill_names:split("|") skill_names = skill_names:split("|")
@ -3070,8 +3071,8 @@ end
---@param card Card @ 改判的牌 ---@param card Card @ 改判的牌
---@param player ServerPlayer @ 改判的玩家 ---@param player ServerPlayer @ 改判的玩家
---@param judge JudgeStruct @ 要被改判的判定数据 ---@param judge JudgeStruct @ 要被改判的判定数据
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@param exchange bool @ 是否要替换原有判定牌(即类似鬼道那样) ---@param exchange? boolean @ 是否要替换原有判定牌(即类似鬼道那样)
function Room:retrial(card, player, judge, skillName, exchange) function Room:retrial(card, player, judge, skillName, exchange)
if not card then return end if not card then return end
local triggerResponded = self.owner_map[card:getEffectiveId()] == player local triggerResponded = self.owner_map[card:getEffectiveId()] == player
@ -3121,9 +3122,9 @@ end
--- 弃置一名角色的牌。 --- 弃置一名角色的牌。
---@param card_ids integer[] @ 被弃掉的牌 ---@param card_ids integer[] @ 被弃掉的牌
---@param skillName string|nil @ 技能名 ---@param skillName? string @ 技能名
---@param who ServerPlayer @ 被弃牌的人 ---@param who ServerPlayer @ 被弃牌的人
---@param thrower ServerPlayer|nil @ 弃别人牌的人 ---@param thrower? ServerPlayer @ 弃别人牌的人
function Room:throwCard(card_ids, skillName, who, thrower) function Room:throwCard(card_ids, skillName, who, thrower)
if type(card_ids) == "number" then if type(card_ids) == "number" then
card_ids = {card_ids} card_ids = {card_ids}
@ -3143,7 +3144,7 @@ end
--- 重铸一名角色的牌。 --- 重铸一名角色的牌。
---@param card_ids integer[] @ 被重铸的牌 ---@param card_ids integer[] @ 被重铸的牌
---@param who ServerPlayer @ 重铸的角色 ---@param who ServerPlayer @ 重铸的角色
---@param skillName string|nil @ 技能名,默认为“重铸” ---@param skillName? string @ 技能名,默认为“重铸”
function Room:recastCard(card_ids, who, skillName) function Room:recastCard(card_ids, who, skillName)
if type(card_ids) == "number" then if type(card_ids) == "number" then
card_ids = {card_ids} card_ids = {card_ids}
@ -3280,7 +3281,7 @@ function Room:useSkill(player, skill, effect_cb)
end end
---@param player ServerPlayer ---@param player ServerPlayer
---@param sendLog bool ---@param sendLog? boolean
function Room:revivePlayer(player, sendLog) function Room:revivePlayer(player, sendLog)
if not player.dead then return end if not player.dead then return end
self:setPlayerProperty(player, "dead", false) self:setPlayerProperty(player, "dead", false)
@ -3355,7 +3356,7 @@ function Room:gameOver(winner)
end end
---@param card Card ---@param card Card
---@param fromAreas CardArea[]|null ---@param fromAreas? CardArea[]
---@return integer[] ---@return integer[]
function Room:getSubcardsByRule(card, fromAreas) function Room:getSubcardsByRule(card, fromAreas)
if card:isVirtual() and #card.subcards == 0 then if card:isVirtual() and #card.subcards == 0 then
@ -3374,9 +3375,9 @@ function Room:getSubcardsByRule(card, fromAreas)
end end
---@param pattern string ---@param pattern string
---@param num number|null ---@param num? number
---@param fromPile string|null @ 查找的来源区域值为drawPile|discardPile|allPiles ---@param fromPile? string @ 查找的来源区域值为drawPile|discardPile|allPiles
---@return cardId[] ---@return integer[] @ id列表 可能空
function Room:getCardsFromPileByRule(pattern, num, fromPile) function Room:getCardsFromPileByRule(pattern, num, fromPile)
num = num or 1 num = num or 1
local pileToSearch = self.draw_pile local pileToSearch = self.draw_pile
@ -3432,10 +3433,10 @@ function Room:getCardsFromPileByRule(pattern, num, fromPile)
return cardPack return cardPack
end end
---@param flag string|null ---@param flag? string
---@param players ServerPlayer[]|null ---@param players? ServerPlayer[]
---@param excludeIds CardId[]|null ---@param excludeIds? integer[]
---@return PlayerId[] @ 可能为空 ---@return integer[] @ 玩家id列表 可能为空
function Room:canMoveCardInBoard(flag, players, excludeIds) function Room:canMoveCardInBoard(flag, players, excludeIds)
if flag then if flag then
assert(flag == "e" or flag == "j") assert(flag == "e" or flag == "j")
@ -3461,8 +3462,8 @@ end
--- 现场印卡。当然了,这个卡只和这个房间有关。 --- 现场印卡。当然了,这个卡只和这个房间有关。
---@param name string @ 牌名 ---@param name string @ 牌名
---@param suit Suit|nil @ 花色 ---@param suit? Suit @ 花色
---@param number integer|nil @ 点数 ---@param number? integer @ 点数
---@return Card ---@return Card
function Room:printCard(name, suit, number) function Room:printCard(name, suit, number)
local cd = Fk:cloneCard(name, suit, number) local cd = Fk:cloneCard(name, suit, number)

View File

@ -69,7 +69,7 @@ end
--- *timeout* must not be negative. If nil, room.timeout is used. --- *timeout* must not be negative. If nil, room.timeout is used.
---@param command string ---@param command string
---@param jsonData string ---@param jsonData string
---@param timeout integer|nil ---@param timeout? integer
function ServerPlayer:doRequest(command, jsonData, timeout) function ServerPlayer:doRequest(command, jsonData, timeout)
self.client_reply = "" self.client_reply = ""
self.reply_ready = false self.reply_ready = false
@ -191,7 +191,7 @@ function ServerPlayer:waitForReply(timeout)
end end
---@param player ServerPlayer ---@param player ServerPlayer
---@param observe bool ---@param observe? boolean
function ServerPlayer:marshal(player, observe) function ServerPlayer:marshal(player, observe)
local room = self.room local room = self.room
if not room.game_started then if not room.game_started then
@ -492,7 +492,7 @@ function ServerPlayer:gainAnExtraPhase(phase, delay)
room:broadcastProperty(self, "phase") room:broadcastProperty(self, "phase")
end end
---@param phase_table Phase[]|nil ---@param phase_table? Phase[]
function ServerPlayer:play(phase_table) function ServerPlayer:play(phase_table)
phase_table = phase_table or {} phase_table = phase_table or {}
if #phase_table > 0 then if #phase_table > 0 then
@ -639,7 +639,7 @@ end
---@param pile_name string ---@param pile_name string
---@param card integer|Card ---@param card integer|Card
---@param visible boolean ---@param visible boolean
---@param skillName string|nil ---@param skillName? string
function ServerPlayer:addToPile(pile_name, card, visible, skillName) function ServerPlayer:addToPile(pile_name, card, visible, skillName)
local room = self.room local room = self.room
room:moveCardTo(card, Card.PlayerSpecial, self, fk.ReasonJustMove, skillName, pile_name, visible) room:moveCardTo(card, Card.PlayerSpecial, self, fk.ReasonJustMove, skillName, pile_name, visible)
@ -756,10 +756,9 @@ function ServerPlayer:reset()
end end
--- 进行拼点。 --- 进行拼点。
---@param from ServerPlayer
---@param tos ServerPlayer[] ---@param tos ServerPlayer[]
---@param skillName string ---@param skillName string
---@param initialCard Card|nil ---@param initialCard? Card
---@return PindianStruct ---@return PindianStruct
function ServerPlayer:pindian(tos, skillName, initialCard) function ServerPlayer:pindian(tos, skillName, initialCard)
local pindianData = { from = self, tos = tos, reason = skillName, fromCard = initialCard, results = {} } local pindianData = { from = self, tos = tos, reason = skillName, fromCard = initialCard, results = {} }
@ -769,7 +768,7 @@ end
--- 播放技能的语音。 --- 播放技能的语音。
---@param skill_name string @ 技能名 ---@param skill_name string @ 技能名
---@param index integer | nil @ 语音编号,默认为-1也就是随机播放 ---@param index? integer @ 语音编号,默认为-1也就是随机播放
function ServerPlayer:broadcastSkillInvoke(skill_name, index) function ServerPlayer:broadcastSkillInvoke(skill_name, index)
index = index or -1 index = index or -1
self.room:sendLogEvent("PlaySkillSound", { self.room:sendLogEvent("PlaySkillSound", {
@ -829,7 +828,7 @@ function ServerPlayer:isFakeSkill(skill)
end end
---@param skill string | Skill ---@param skill string | Skill
---@param isPrelight bool ---@param isPrelight? boolean
function ServerPlayer:prelightSkill(skill, isPrelight) function ServerPlayer:prelightSkill(skill, isPrelight)
if type(skill) == "string" then skill = Fk.skills[skill] end if type(skill) == "string" then skill = Fk.skills[skill] end
assert(skill:isInstanceOf(Skill)) assert(skill:isInstanceOf(Skill))
@ -858,8 +857,8 @@ function ServerPlayer:prelightSkill(skill, isPrelight)
self:doNotify("PrelightSkill", json.encode{ skill.name, isPrelight }) self:doNotify("PrelightSkill", json.encode{ skill.name, isPrelight })
end end
---@param isDeputy bool ---@param isDeputy? boolean
---@param no_trigger bool ---@param no_trigger? boolean
function ServerPlayer:revealGeneral(isDeputy, no_trigger) function ServerPlayer:revealGeneral(isDeputy, no_trigger)
local room = self.room local room = self.room
local generalName local generalName

View File

@ -4,45 +4,45 @@
---@class CardsMoveInfo ---@class CardsMoveInfo
---@field public ids integer[] ---@field public ids integer[]
---@field public from integer|null ---@field public from? integer
---@field public to integer|null ---@field public to? integer
---@field public toArea CardArea ---@field public toArea? CardArea
---@field public moveReason CardMoveReason|nil ---@field public moveReason? CardMoveReason
---@field public proposer integer|nil ---@field public proposer? integer
---@field public skillName string|null ---@field public skillName? string
---@field public moveVisible bool ---@field public moveVisible? boolean
---@field public specialName string|null ---@field public specialName? string
---@field public specialVisible bool ---@field public specialVisible? boolean
---@class MoveInfo ---@class MoveInfo
---@field public cardId integer ---@field public cardId integer
---@field public fromArea CardArea ---@field public fromArea CardArea
---@field public fromSpecialName string|null ---@field public fromSpecialName? string
---@class CardsMoveStruct ---@class CardsMoveStruct
---@field public moveInfo MoveInfo[] ---@field public moveInfo MoveInfo[]
---@field public from integer|null ---@field public from? integer
---@field public to integer|null ---@field public to? integer
---@field public toArea CardArea ---@field public toArea CardArea
---@field public moveReason CardMoveReason ---@field public moveReason CardMoveReason
---@field public proposer integer|null ---@field public proposer? integer
---@field public skillName string|null ---@field public skillName? string
---@field public moveVisible bool ---@field public moveVisible? boolean
---@field public specialName string|null ---@field public specialName? string
---@field public specialVisible bool ---@field public specialVisible? boolean
---@field public drawPilePosition number|null @ 移至牌堆的索引位置,值为-1代表置入牌堆底或者牌堆牌数+1也为牌堆底 ---@field public drawPilePosition? integer @ 移至牌堆的索引位置,值为-1代表置入牌堆底或者牌堆牌数+1也为牌堆底
---@class PindianResult ---@class PindianResult
---@field public toCard Card ---@field public toCard Card
---@field public winner ServerPlayer|null ---@field public winner? ServerPlayer
--- 描述和一次体力变化有关的数据 --- 描述和一次体力变化有关的数据
---@class HpChangedData ---@class HpChangedData
---@field public num integer @ 体力变化量,可能是正数或者负数 ---@field public num integer @ 体力变化量,可能是正数或者负数
---@field public reason string @ 体力变化原因 ---@field public reason string @ 体力变化原因
---@field public skillName string @ 引起体力变化的技能名 ---@field public skillName string @ 引起体力变化的技能名
---@field public damageEvent DamageStruct|nil @ 引起这次体力变化的伤害数据 ---@field public damageEvent? DamageStruct @ 引起这次体力变化的伤害数据
---@field public preventDying bool @ 是否阻止本次体力变更流程引发濒死流程 ---@field public preventDying? boolean @ 是否阻止本次体力变更流程引发濒死流程
--- 描述跟失去体力有关的数据 --- 描述跟失去体力有关的数据
---@class HpLostData ---@class HpLostData
@ -58,27 +58,27 @@ fk.IceDamage = 4
--- DamageStruct 用来描述和伤害事件有关的数据。 --- DamageStruct 用来描述和伤害事件有关的数据。
---@class DamageStruct ---@class DamageStruct
---@field public from ServerPlayer|null @ 伤害来源 ---@field public from? ServerPlayer @ 伤害来源
---@field public to ServerPlayer @ 伤害目标 ---@field public to ServerPlayer @ 伤害目标
---@field public damage integer @ 伤害值 ---@field public damage integer @ 伤害值
---@field public card Card | nil @ 造成伤害的牌 ---@field public card? Card @ 造成伤害的牌
---@field public chain bool @ 伤害是否是铁索传导的伤害 ---@field public chain? boolean @ 伤害是否是铁索传导的伤害
---@field public damageType DamageType | nil @ 伤害的属性 ---@field public damageType? DamageType @ 伤害的属性
---@field public skillName string | nil @ 造成本次伤害的技能名 ---@field public skillName? string @ 造成本次伤害的技能名
---@field public beginnerOfTheDamage boolean | nil @ 是否是本次铁索传导的起点 ---@field public beginnerOfTheDamage? boolean @ 是否是本次铁索传导的起点
--- 用来描述和回复体力有关的数据。 --- 用来描述和回复体力有关的数据。
---@class RecoverStruct ---@class RecoverStruct
---@field public who ServerPlayer @ 回复体力的角色 ---@field public who ServerPlayer @ 回复体力的角色
---@field public num integer @ 回复值 ---@field public num integer @ 回复值
---@field public recoverBy ServerPlayer|nil @ 此次回复的回复来源 ---@field public recoverBy? ServerPlayer @ 此次回复的回复来源
---@field public skillName string|nil @ 因何种技能而回复 ---@field public skillName? string @ 因何种技能而回复
---@field public card Card|nil @ 造成此次回复的卡牌 ---@field public card? Card @ 造成此次回复的卡牌
---@class DyingStruct ---@class DyingStruct
---@field public who integer ---@field public who integer
---@field public damage DamageStruct ---@field public damage DamageStruct
---@field public ignoreDeath bool ---@field public ignoreDeath? boolean
---@class DeathStruct ---@class DeathStruct
---@field public who integer ---@field public who integer
@ -96,57 +96,57 @@ fk.IceDamage = 4
---@field public from integer ---@field public from integer
---@field public tos TargetGroup ---@field public tos TargetGroup
---@field public card Card ---@field public card Card
---@field public toCard Card|null ---@field public toCard? Card
---@field public responseToEvent CardUseStruct|null ---@field public responseToEvent? CardUseStruct
---@field public nullifiedTargets integer[]|null ---@field public nullifiedTargets? integer[]
---@field public extraUse bool ---@field public extraUse? boolean
---@field public disresponsiveList integer[]|null ---@field public disresponsiveList? integer[]
---@field public unoffsetableList integer[]|null ---@field public unoffsetableList? integer[]
---@field public additionalDamage integer|null ---@field public additionalDamage? integer
---@field public additionalRecover integer|null ---@field public additionalRecover? integer
---@field public customFrom integer|null ---@field public customFrom? integer
---@field public cardsResponded Card[]|null ---@field public cardsResponded? Card[]
---@field public prohibitedCardNames string[]|null ---@field public prohibitedCardNames? string[]
---@field public damageDealt table<PlayerId, number>|null ---@field public damageDealt? table<PlayerId, number>
---@class AimStruct ---@class AimStruct
---@field public from integer ---@field public from integer
---@field public card Card ---@field public card Card
---@field public tos AimGroup ---@field public tos AimGroup
---@field public to integer ---@field public to integer
---@field public subTargets integer[]|null ---@field public subTargets? integer[]
---@field public targetGroup TargetGroup|null ---@field public targetGroup? TargetGroup
---@field public nullifiedTargets integer[]|null ---@field public nullifiedTargets? integer[]
---@field public firstTarget boolean ---@field public firstTarget boolean
---@field public additionalDamage integer|null ---@field public additionalDamage? integer
---@field public additionalRecover integer|null ---@field public additionalRecover? integer
---@field public disresponsive bool ---@field public disresponsive? boolean
---@field public unoffsetableList bool ---@field public unoffsetableList? boolean
---@field public additionalResponseTimes table<string, integer>|integer|null ---@field public additionalResponseTimes? table<string, integer>|integer
---@field public fixedAddTimesResponsors integer[] ---@field public fixedAddTimesResponsors? integer[]
---@class CardEffectEvent ---@class CardEffectEvent
---@field public from integer ---@field public from integer
---@field public to integer ---@field public to integer
---@field public subTargets integer[]|null ---@field public subTargets? integer[]
---@field public tos TargetGroup ---@field public tos TargetGroup
---@field public card Card ---@field public card Card
---@field public toCard Card|null ---@field public toCard? Card
---@field public responseToEvent CardEffectEvent|null ---@field public responseToEvent? CardEffectEvent
---@field public nullifiedTargets integer[]|null ---@field public nullifiedTargets? integer[]
---@field public extraUse bool ---@field public extraUse? boolean
---@field public disresponsiveList integer[]|null ---@field public disresponsiveList? integer[]
---@field public unoffsetableList integer[]|null ---@field public unoffsetableList? integer[]
---@field public additionalDamage integer|null ---@field public additionalDamage? integer
---@field public additionalRecover integer|null ---@field public additionalRecover? integer
---@field public customFrom integer|null ---@field public customFrom? integer
---@field public cardsResponded Card[]|null ---@field public cardsResponded? Card[]
---@field public disresponsive bool ---@field public disresponsive? boolean
---@field public unoffsetable bool ---@field public unoffsetable? boolean
---@field public isCancellOut bool ---@field public isCancellOut? boolean
---@field public fixedResponseTimes table<string, integer>|integer|null ---@field public fixedResponseTimes? table<string, integer>|integer
---@field public fixedAddTimesResponsors integer[] ---@field public fixedAddTimesResponsors? integer[]
---@field public prohibitedCardNames string[]|null ---@field public prohibitedCardNames? string[]
---@class SkillEffectEvent ---@class SkillEffectEvent
---@field public from integer ---@field public from integer
@ -158,14 +158,14 @@ fk.IceDamage = 4
---@field public card Card ---@field public card Card
---@field public reason string ---@field public reason string
---@field public pattern string ---@field public pattern string
---@field public skipDrop bool ---@field public skipDrop? boolean
---@class CardResponseEvent ---@class CardResponseEvent
---@field public from integer ---@field public from integer
---@field public card Card ---@field public card Card
---@field public responseToEvent CardEffectEvent|null ---@field public responseToEvent? CardEffectEvent
---@field public skipDrop bool ---@field public skipDrop? boolean
---@field public customFrom integer|null ---@field public customFrom? integer
---@class AskForCardUse ---@class AskForCardUse
---@field public user ServerPlayer ---@field public user ServerPlayer
@ -202,12 +202,12 @@ fk.ReasonJudge = 11
---@class LogMessage ---@class LogMessage
---@field public type string ---@field public type string
---@field public from integer | nil ---@field public from? integer
---@field public to integer[] | nil ---@field public to? integer[]
---@field public card integer[] | nil ---@field public card? integer[]
---@field public arg any ---@field public arg? any
---@field public arg2 any ---@field public arg2? any
---@field public arg3 any ---@field public arg3? any
---@class SkillUseStruct ---@class SkillUseStruct
---@field public skill Skill ---@field public skill Skill

View File

@ -5,7 +5,7 @@
----------------------------- -----------------------------
--- 弃牌相关判定函数的表。键为技能名,值为原型如下的函数。 --- 弃牌相关判定函数的表。键为技能名,值为原型如下的函数。
---@type table<string, fun(self: SmartAI, min_num: number, num: number, include_equip: bool, cancelable: bool, pattern: string, prompt: string): integer[]|nil> ---@type table<string, fun(self: SmartAI, min_num: number, num: number, include_equip?: boolean, cancelable?: boolean, pattern: string, prompt: string): integer[]?>
fk.ai_discard = {} fk.ai_discard = {}
local default_discard = function(self, min_num, num, include_equip, cancelable, pattern, prompt) local default_discard = function(self, min_num, num, include_equip, cancelable, pattern, prompt)
@ -38,11 +38,11 @@ end
------------------------------------- -------------------------------------
---@class ChoosePlayersReply ---@class ChoosePlayersReply
---@field cardId integer|nil ---@field cardId? integer
---@field targets integer[] ---@field targets integer[]
--- 选人相关判定函数的表。键为技能名,值为原型如下的函数。 --- 选人相关判定函数的表。键为技能名,值为原型如下的函数。
---@type table<string, fun(self: SmartAI, targets: integer[], min_num: number, num: number, cancelable: bool): ChoosePlayersReply|nil> ---@type table<string, fun(self: SmartAI, targets: integer[], min_num: number, num: number, cancelable?: boolean): ChoosePlayersReply?>
fk.ai_choose_players = {} fk.ai_choose_players = {}
fk.ai_active_skill["choose_players_skill"] = function(self, prompt, cancelable, data) fk.ai_active_skill["choose_players_skill"] = function(self, prompt, cancelable, data)