2023-03-26 09:32:45 +00:00
|
|
|
--- Package用来描述一个FreeKill拓展包。
|
|
|
|
---
|
|
|
|
--- 所谓拓展包,就是武将/卡牌/游戏模式的一个集合而已。
|
|
|
|
---
|
2022-03-30 08:33:56 +00:00
|
|
|
---@class Package : Object
|
2023-03-26 09:32:45 +00:00
|
|
|
---@field public name string @ 拓展包的名字
|
|
|
|
---@field public extensionName string @ 拓展包对应的mod的名字。 `详情... <extension name_>`_
|
|
|
|
---@field public type PackageType @ 拓展包的类别,只会影响到选择拓展包的界面
|
|
|
|
---@field public generals General[] @ 拓展包包含的所有武将的列表
|
|
|
|
---@field public extra_skills Skill[] @ 拓展包包含的额外技能,即不属于武将的技能
|
|
|
|
---@field public related_skills table<string, string> @ 对于额外技能而言的关联技能
|
|
|
|
---@field public cards Card[] @ 拓展包包含的卡牌
|
|
|
|
---@field public game_modes GameMode[] @ 拓展包包含的游戏模式
|
2022-03-28 14:24:30 +00:00
|
|
|
local Package = class("Package")
|
|
|
|
|
2022-04-01 12:51:01 +00:00
|
|
|
---@alias PackageType integer
|
|
|
|
|
|
|
|
Package.GeneralPack = 1
|
|
|
|
Package.CardPack = 2
|
|
|
|
Package.SpecialPack = 3
|
2022-03-28 14:24:30 +00:00
|
|
|
|
2023-03-26 09:32:45 +00:00
|
|
|
--- 拓展包的构造函数。
|
|
|
|
---@param name string @ 包的名字
|
|
|
|
---@param _type integer|nil @ 包的类型,默认为武将包
|
2022-03-28 14:24:30 +00:00
|
|
|
function Package:initialize(name, _type)
|
2022-04-30 07:27:56 +00:00
|
|
|
assert(type(name) == "string")
|
|
|
|
assert(type(_type) == "nil" or type(_type) == "number")
|
|
|
|
self.name = name
|
2023-02-15 11:54:35 +00:00
|
|
|
self.extensionName = name -- used for get assets
|
2022-04-30 07:27:56 +00:00
|
|
|
self.type = _type or Package.GeneralPack
|
|
|
|
|
|
|
|
self.generals = {}
|
|
|
|
self.extra_skills = {} -- skill not belongs to any generals, like "jixi"
|
|
|
|
self.related_skills = {}
|
|
|
|
self.cards = {}
|
2023-03-13 16:12:02 +00:00
|
|
|
self.game_modes = {}
|
2022-03-28 14:24:30 +00:00
|
|
|
end
|
|
|
|
|
2023-03-26 09:32:45 +00:00
|
|
|
--- 获得这个包涉及的所有技能。
|
|
|
|
---
|
|
|
|
--- 这也就是说,所有的武将技能再加上和武将无关的技能。
|
2022-04-02 13:39:44 +00:00
|
|
|
---@return Skill[]
|
2022-03-28 14:24:30 +00:00
|
|
|
function Package:getSkills()
|
2022-04-30 07:27:56 +00:00
|
|
|
local ret = {table.unpack(self.related_skills)}
|
|
|
|
if self.type == Package.GeneralPack then
|
|
|
|
for _, g in ipairs(self.generals) do
|
|
|
|
for _, s in ipairs(g.skills) do
|
|
|
|
table.insert(ret, s)
|
|
|
|
end
|
2022-03-28 14:24:30 +00:00
|
|
|
end
|
2022-04-30 07:27:56 +00:00
|
|
|
end
|
|
|
|
return ret
|
2022-03-28 14:24:30 +00:00
|
|
|
end
|
|
|
|
|
2023-03-26 09:32:45 +00:00
|
|
|
--- 向拓展包中添加武将。
|
|
|
|
---@param general General @ 要添加的武将
|
2022-03-28 14:24:30 +00:00
|
|
|
function Package:addGeneral(general)
|
2022-04-30 07:27:56 +00:00
|
|
|
assert(general.class and general:isInstanceOf(General))
|
2023-01-04 06:21:29 +00:00
|
|
|
table.insertIfNeed(self.generals, general)
|
2022-03-28 14:24:30 +00:00
|
|
|
end
|
|
|
|
|
2023-03-26 09:32:45 +00:00
|
|
|
--- 向拓展包中添加卡牌。
|
|
|
|
---@param card Card @ 要添加的卡牌
|
2022-03-31 05:29:23 +00:00
|
|
|
function Package:addCard(card)
|
2022-04-30 07:27:56 +00:00
|
|
|
assert(card.class and card:isInstanceOf(Card))
|
|
|
|
card.package = self
|
|
|
|
table.insert(self.cards, card)
|
2022-03-31 05:29:23 +00:00
|
|
|
end
|
|
|
|
|
2023-03-26 09:32:45 +00:00
|
|
|
--- 向拓展包中一次添加许多牌。
|
|
|
|
---@param cards Card[] @ 要添加的卡牌的数组
|
2022-03-31 05:29:23 +00:00
|
|
|
function Package:addCards(cards)
|
2022-04-30 07:27:56 +00:00
|
|
|
for _, card in ipairs(cards) do
|
|
|
|
self:addCard(card)
|
|
|
|
end
|
2022-03-31 05:29:23 +00:00
|
|
|
end
|
|
|
|
|
2023-03-26 09:32:45 +00:00
|
|
|
--- 向拓展包中添加游戏模式。
|
|
|
|
---@param game_mode GameMode @ 要添加的游戏模式。
|
2023-03-13 16:12:02 +00:00
|
|
|
function Package:addGameMode(game_mode)
|
|
|
|
table.insert(self.game_modes, game_mode)
|
|
|
|
end
|
|
|
|
|
2022-03-28 14:24:30 +00:00
|
|
|
return Package
|