2023-04-09 05:35:35 +00:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-28 17:43:44 +00:00
|
|
|
GameEvent.functions[GameEvent.Judge] = function(self)
|
|
|
|
local data = table.unpack(self.data)
|
|
|
|
local self = self.room
|
|
|
|
local who = data.who
|
|
|
|
self.logic:trigger(fk.StartJudge, who, data)
|
2023-03-14 12:48:08 +00:00
|
|
|
data.card = data.card or Fk:getCardById(self:getNCards(1)[1])
|
2023-02-28 17:43:44 +00:00
|
|
|
|
|
|
|
if data.reason ~= "" then
|
|
|
|
self:sendLog{
|
|
|
|
type = "#StartJudgeReason",
|
|
|
|
from = who.id,
|
|
|
|
arg = data.reason,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
self:sendLog{
|
|
|
|
type = "#InitialJudge",
|
|
|
|
from = who.id,
|
|
|
|
card = {data.card.id},
|
|
|
|
}
|
2023-03-14 12:48:08 +00:00
|
|
|
self:moveCardTo(data.card, Card.Processing, nil, fk.ReasonPut)
|
2023-02-28 17:43:44 +00:00
|
|
|
|
|
|
|
self.logic:trigger(fk.AskForRetrial, who, data)
|
|
|
|
self.logic:trigger(fk.FinishRetrial, who, data)
|
|
|
|
Fk:filterCard(data.card.id, who, data)
|
|
|
|
self:sendLog{
|
|
|
|
type = "#JudgeResult",
|
|
|
|
from = who.id,
|
|
|
|
card = {data.card.id},
|
|
|
|
}
|
|
|
|
|
|
|
|
if data.pattern then
|
|
|
|
self:delay(400);
|
|
|
|
self:setCardEmotion(data.card.id, data.card:matchPattern(data.pattern) and "judgegood" or "judgebad")
|
|
|
|
self:delay(900);
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.logic:trigger(fk.FinishJudge, who, data) then
|
|
|
|
self.logic:breakEvent()
|
|
|
|
end
|
|
|
|
if self:getCardArea(data.card.id) == Card.Processing then
|
|
|
|
self:moveCardTo(data.card, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
GameEvent.cleaners[GameEvent.Judge] = function(self)
|
|
|
|
local data = table.unpack(self.data)
|
|
|
|
local self = self.room
|
|
|
|
if self:getCardArea(data.card.id) == Card.Processing then
|
|
|
|
self:moveCardTo(data.card, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile)
|
|
|
|
end
|
2023-03-07 06:55:28 +00:00
|
|
|
if not self.interrupted then return end
|
2023-02-28 17:43:44 +00:00
|
|
|
|
|
|
|
-- prohibit access to judge.card
|
|
|
|
setmetatable(data, {
|
|
|
|
__index = function(self, key)
|
|
|
|
if key == "card" then
|
|
|
|
error("__manuallyBreak")
|
|
|
|
end
|
|
|
|
return rawget(self, key)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|