core_doc_20230412_0844 (#113)

general/gamemode/skill更新

Co-authored-by: YWSC120 <111111@163.com>
This commit is contained in:
deepskybird 2023-04-12 13:28:01 +08:00 committed by GitHub
parent 262d6f2f43
commit 604e1d00b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 26 deletions

View File

@ -1,13 +1,21 @@
-- SPDX-License-Identifier: GPL-3.0-or-later -- SPDX-License-Identifier: GPL-3.0-or-later
--- GameMode用来描述一个游戏模式。
---
--- 可以参考欢乐斗地主。
---
---@class GameMode: Object ---@class GameMode: Object
---@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 TriggerSkill ---@field public rule TriggerSkill @ 规则(通过技能完成,通常用来为特定角色及特定时机提供触发事件)
---@field public logic fun() ---@field public logic fun() @ 逻辑通过function完成通常用来初始化、分配身份及座次
local GameMode = class("GameMode") local GameMode = class("GameMode")
--- 构造函数,不可随意调用。
---@param name string @ 游戏模式名
---@param min integer @ 最小玩家数
---@param max integer @ 最大玩家数
function GameMode:initialize(name, min, max) function GameMode:initialize(name, min, max)
self.name = name self.name = name
self.minPlayer = math.max(min, 2) self.minPlayer = math.max(min, 2)

View File

@ -1,15 +1,21 @@
-- SPDX-License-Identifier: GPL-3.0-or-later -- SPDX-License-Identifier: GPL-3.0-or-later
--- General用来描述一个武将。
---
--- 所谓武将,就是所属包、武将基础信息的集合。
---
--- 也许···类似于身份证?
---
---@class General : Object ---@class General : Object
---@field public package Package ---@field public package Package @ 武将所属包
---@field public name string ---@field public name string @ 武将名字
---@field public trueName string ---@field public trueName string @ 武将真名,也许可以分辨标界?
---@field public kingdom string ---@field public kingdom string @ 武将所属势力
---@field public hp integer ---@field public hp integer @ 武将初始体力
---@field public maxHp integer ---@field public maxHp integer @ 武将初始最大体力
---@field public gender Gender ---@field public gender Gender @ 武将性别
---@field public skills Skill[] ---@field public skills Skill[] @ 武将技能
---@field public other_skills string[] ---@field public other_skills string[] @ 武将身上属于其他武将的技能,通过字符串调用
General = class("General") General = class("General")
---@alias Gender integer ---@alias Gender integer
@ -17,6 +23,13 @@ General = class("General")
General.Male = 1 General.Male = 1
General.Female = 2 General.Female = 2
--- 构造函数,不可随意调用。
---@param package Package @ 武将所属包
---@param name string @ 武将名字
---@param kingdom string @ 武将所属势力
---@param hp integer @ 武将初始体力
---@param maxHp integer @ 武将初始最大体力
---@param gender Gender @ 武将性别
function General:initialize(package, name, kingdom, hp, maxHp, gender) function General:initialize(package, name, kingdom, hp, maxHp, gender)
self.package = package self.package = package
self.name = name self.name = name
@ -34,7 +47,8 @@ function General:initialize(package, name, kingdom, hp, maxHp, gender)
package:addGeneral(self) package:addGeneral(self)
end end
---@param skill Skill --- 为武将增加技能,需要注意增加其他武将技能时的处理方式。
---@param skill Skill @ (单个)武将技能
function General:addSkill(skill) function General:addSkill(skill)
if (type(skill) == "string") then if (type(skill) == "string") then
table.insert(self.other_skills, skill) table.insert(self.other_skills, skill)

View File

@ -1,15 +1,17 @@
-- SPDX-License-Identifier: GPL-3.0-or-later -- SPDX-License-Identifier: GPL-3.0-or-later
--- Skill用来描述一个技能。
---
---@class Skill : Object ---@class Skill : Object
---@field public name string ---@field public name string @ 技能名
---@field public trueName string ---@field public trueName string @ 技能真名
---@field public package Package ---@field public package Package @ 技能所属的包
---@field public frequency Frequency ---@field public frequency Frequency @ 技能发动的频繁程度通常compulsory锁定技及limited限定技用的多。
---@field public visible boolean ---@field public visible boolean @ 技能是否会显示在游戏中
---@field public mute boolean ---@field public mute boolean @ 决定是否关闭技能配音
---@field public anim_type string ---@field public anim_type string @ 技能类型定义
---@field public related_skills Skill[] ---@field public related_skills Skill[] @ 和本技能相关的其他技能,有时候一个技能实际上是通过好几个技能拼接而实现的。
---@field public attached_equip string ---@field public attached_equip string @ 属于什么装备的技能?
local Skill = class("Skill") local Skill = class("Skill")
---@alias Frequency integer ---@alias Frequency integer
@ -20,6 +22,9 @@ Skill.Compulsory = 3
Skill.Limited = 4 Skill.Limited = 4
Skill.Wake = 5 Skill.Wake = 5
--- 构造函数,不可随意调用。
---@param name string @ 技能名
---@param frequency Frequency @ 技能发动的频繁程度通常compulsory锁定技及limited限定技用的多。
function Skill:initialize(name, frequency) function Skill:initialize(name, frequency)
-- TODO: visible, lord, etc -- TODO: visible, lord, etc
self.name = name self.name = name
@ -43,17 +48,24 @@ function Skill:initialize(name, frequency)
self.attached_equip = nil self.attached_equip = nil
end end
---@param skill Skill --- 为一个技能增加相关技能。
---@param skill Skill @ 技能
function Skill:addRelatedSkill(skill) function Skill:addRelatedSkill(skill)
table.insert(self.related_skills, skill) table.insert(self.related_skills, skill)
end end
--- 确认本技能是否为装备技能。
---@return boolean ---@return boolean
function Skill:isEquipmentSkill() function Skill:isEquipmentSkill()
return self.attached_equip and type(self.attached_equip) == 'string' and self.attached_equip ~= "" return self.attached_equip and type(self.attached_equip) == 'string' and self.attached_equip ~= ""
end end
---@param player Player --- 确认技能是否对特定玩家生效。
---
--- 据说你一般用不到这个只要你把on_cost代价和on_use效果区分得当
---
--- 涉及技能无效时,不需要这个函数也可以实现效果。
---@param player Player @ 玩家
---@return boolean ---@return boolean
function Skill:isEffectable(player) function Skill:isEffectable(player)
local nullifySkills = Fk:currentRoom().status_skills[InvaliditySkill] or {} local nullifySkills = Fk:currentRoom().status_skills[InvaliditySkill] or {}