FreeKill/lua/server/events/judge.lua
notify a82b8c1b0a
Nfeature (#243)
- 15秒后其他人可以将房主踢出
- event中的从room.lua复制过来的self都规范成room
- 删了feasible的deprecate警告
- 虚空印卡

关于虚空印卡的说明:
* 印的卡id为负数,但依然属于实体卡。
* 这也就是说今后判断虚拟牌的依据是id == 0而不是 <= 0。
* 不过其实虚拟牌的id自古以来就固定是0啦,所以不用担心。
* 虚空印的卡自然只和当前运行的房间有关。
* 虚空印卡的id从-2开始,每印一张其id便减少1。
* 之所以不从-1开始是因为UI把-1认定为未知牌。Bot的玩家id也从-2开始,这是一个道理。
* 除此之外,印出的卡就如同一张普通的实体卡一样,洗入牌堆啥的都没问题,用来作其他虚拟卡的子卡也没啥问题。
* 坐等后面测试出bug吧,当然我希望直接不出bug。
2023-08-11 03:19:59 +08:00

72 lines
1.8 KiB
Lua

-- SPDX-License-Identifier: GPL-3.0-or-later
GameEvent.functions[GameEvent.Judge] = function(self)
local data = table.unpack(self.data)
local room = self.room
local logic = room.logic
local who = data.who
logic:trigger(fk.StartJudge, who, data)
data.card = data.card or Fk:getCardById(room:getNCards(1)[1])
if data.reason ~= "" then
room:sendLog{
type = "#StartJudgeReason",
from = who.id,
arg = data.reason,
}
end
room:sendLog{
type = "#InitialJudge",
from = who.id,
card = {data.card.id},
}
room:moveCardTo(data.card, Card.Processing, nil, fk.ReasonJudge)
room:sendFootnote({ data.card.id }, {
type = "##JudgeCard",
arg = data.reason,
})
logic:trigger(fk.AskForRetrial, who, data)
logic:trigger(fk.FinishRetrial, who, data)
Fk:filterCard(data.card.id, who, data)
room:sendLog{
type = "#JudgeResult",
from = who.id,
card = {data.card.id},
}
room:sendFootnote({ data.card.id }, {
type = "##JudgeCard",
arg = data.reason,
})
if data.pattern then
room:delay(400);
room:setCardEmotion(data.card.id, data.card:matchPattern(data.pattern) and "judgegood" or "judgebad")
room:delay(900);
end
if logic:trigger(fk.FinishJudge, who, data) then
logic:breakEvent()
end
end
GameEvent.cleaners[GameEvent.Judge] = function(self)
local data = table.unpack(self.data)
local room = self.room
if (self.interrupted or not data.skipDrop) and room:getCardArea(data.card.id) == Card.Processing then
room:moveCardTo(data.card, Card.DiscardPile, nil, fk.ReasonJudge)
end
if not self.interrupted then return end
-- prohibit access to judge.card
setmetatable(data, {
__index = function(s, key)
if key == "card" then
error("__manuallyBreak")
end
return rawget(s, key)
end
})
end