mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 03:32:34 +08:00
9d9217da2c
- 对旁观和重连进行优化,减轻服务器CPU负担 - 加强Lua与C++交互能力,现在可以直接传const QVariant &参数 - 借助上一条,删除了客户端侧代码绝大多数冗余的json.encode/JSON.parse - 微调swig代码减少生成量,将int映射到lua integer而不是number
53 lines
1.7 KiB
Lua
53 lines
1.7 KiB
Lua
-- 作Room和Client的基类,这二者有不少共通之处
|
||
---@class AbstractRoom : Object
|
||
---@fiele public players Player[] @ 房内参战角色们
|
||
---@field public alive_players Player[] @ 所有存活玩家的数组
|
||
---@field public observers Player[] @ 看戏的
|
||
---@field public current Player @ 当前行动者
|
||
---@field public status_skills table<class, Skill[]> @ 这个房间中含有的状态技列表
|
||
---@field public filtered_cards table<integer, Card> @ 见于Engine,其实在这
|
||
---@field public printed_cards table<integer, Card> @ 同上
|
||
---@field public skill_costs table<string, any> @ 用来存skill.cost_data
|
||
---@field public card_marks table<integer, any> @ 用来存实体卡的card.mark
|
||
---@field public banners table<string, any> @ 全局mark
|
||
local AbstractRoom = class("AbstractRoom")
|
||
|
||
function AbstractRoom:initialize()
|
||
self.players = {}
|
||
self.alive_players = {}
|
||
self.observers = {}
|
||
self.current = nil
|
||
|
||
self.status_skills = {}
|
||
for class, skills in pairs(Fk.global_status_skill) do
|
||
self.status_skills[class] = {table.unpack(skills)}
|
||
end
|
||
|
||
self.filtered_cards = {}
|
||
self.printed_cards = {}
|
||
self.skill_costs = {}
|
||
self.card_marks = {}
|
||
self.banners = {}
|
||
end
|
||
|
||
-- 仅供注释,其余空函数一样
|
||
---@param id integer
|
||
---@return Player?
|
||
function AbstractRoom:getPlayerById(id) end
|
||
|
||
--- 获取一张牌所处的区域。
|
||
---@param cardId integer | Card @ 要获得区域的那张牌,可以是Card或者一个id
|
||
---@return CardArea @ 这张牌的区域
|
||
function AbstractRoom:getCardArea(cardId) return Card.Unknown end
|
||
|
||
function AbstractRoom:setBanner(name, value)
|
||
if value == 0 then value = nil end
|
||
self.banners[name] = value
|
||
end
|
||
|
||
function AbstractRoom:getBanner(name)
|
||
return self.banners[name]
|
||
end
|
||
|
||
return AbstractRoom
|