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)
|
2023-08-10 19:19:59 +00:00
|
|
|
local room = self.room
|
|
|
|
local logic = room.logic
|
2023-02-28 17:43:44 +00:00
|
|
|
local who = data.who
|
2023-12-10 10:55:16 +00:00
|
|
|
|
|
|
|
data.isJudgeEvent = true
|
2023-08-10 19:19:59 +00:00
|
|
|
logic:trigger(fk.StartJudge, who, data)
|
|
|
|
data.card = data.card or Fk:getCardById(room:getNCards(1)[1])
|
2023-02-28 17:43:44 +00:00
|
|
|
|
|
|
|
if data.reason ~= "" then
|
2023-08-10 19:19:59 +00:00
|
|
|
room:sendLog{
|
2023-02-28 17:43:44 +00:00
|
|
|
type = "#StartJudgeReason",
|
|
|
|
from = who.id,
|
|
|
|
arg = data.reason,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-08-10 19:19:59 +00:00
|
|
|
room:sendLog{
|
2023-02-28 17:43:44 +00:00
|
|
|
type = "#InitialJudge",
|
|
|
|
from = who.id,
|
|
|
|
card = {data.card.id},
|
|
|
|
}
|
2023-08-10 19:19:59 +00:00
|
|
|
room:moveCardTo(data.card, Card.Processing, nil, fk.ReasonJudge)
|
|
|
|
room:sendFootnote({ data.card.id }, {
|
2023-06-09 18:18:51 +00:00
|
|
|
type = "##JudgeCard",
|
|
|
|
arg = data.reason,
|
|
|
|
})
|
2023-02-28 17:43:44 +00:00
|
|
|
|
2023-08-10 19:19:59 +00:00
|
|
|
logic:trigger(fk.AskForRetrial, who, data)
|
|
|
|
logic:trigger(fk.FinishRetrial, who, data)
|
2023-02-28 17:43:44 +00:00
|
|
|
Fk:filterCard(data.card.id, who, data)
|
2023-08-10 19:19:59 +00:00
|
|
|
room:sendLog{
|
2023-02-28 17:43:44 +00:00
|
|
|
type = "#JudgeResult",
|
|
|
|
from = who.id,
|
|
|
|
card = {data.card.id},
|
|
|
|
}
|
2023-08-10 19:19:59 +00:00
|
|
|
room:sendFootnote({ data.card.id }, {
|
2023-06-09 18:18:51 +00:00
|
|
|
type = "##JudgeCard",
|
|
|
|
arg = data.reason,
|
|
|
|
})
|
2023-02-28 17:43:44 +00:00
|
|
|
|
|
|
|
if data.pattern then
|
2023-08-10 19:19:59 +00:00
|
|
|
room:delay(400);
|
|
|
|
room:setCardEmotion(data.card.id, data.card:matchPattern(data.pattern) and "judgegood" or "judgebad")
|
|
|
|
room:delay(900);
|
2023-02-28 17:43:44 +00:00
|
|
|
end
|
|
|
|
|
2023-08-10 19:19:59 +00:00
|
|
|
if logic:trigger(fk.FinishJudge, who, data) then
|
|
|
|
logic:breakEvent()
|
2023-02-28 17:43:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
GameEvent.cleaners[GameEvent.Judge] = function(self)
|
|
|
|
local data = table.unpack(self.data)
|
2023-08-10 19:19:59 +00:00
|
|
|
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)
|
2023-02-28 17:43:44 +00:00
|
|
|
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, {
|
2023-08-10 19:19:59 +00:00
|
|
|
__index = function(s, key)
|
2023-02-28 17:43:44 +00:00
|
|
|
if key == "card" then
|
|
|
|
error("__manuallyBreak")
|
|
|
|
end
|
2023-08-10 19:19:59 +00:00
|
|
|
return rawget(s, key)
|
2023-02-28 17:43:44 +00:00
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|