FreeKill/lua/core/abstract_room.lua
notify 9d9217da2c
Cppdev (#350)
- 对旁观和重连进行优化,减轻服务器CPU负担
- 加强Lua与C++交互能力,现在可以直接传const QVariant &参数
- 借助上一条,删除了客户端侧代码绝大多数冗余的json.encode/JSON.parse
- 微调swig代码减少生成量,将int映射到lua integer而不是number
2024-04-19 20:53:19 +08:00

53 lines
1.7 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

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

-- 作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