2023-04-09 13:35:35 +08:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-03-01 01:43:44 +08:00
|
|
|
GameEvent.functions[GameEvent.Judge] = function(self)
|
|
|
|
local data = table.unpack(self.data)
|
2023-08-11 03:19:59 +08:00
|
|
|
local room = self.room
|
|
|
|
local logic = room.logic
|
2023-03-01 01:43:44 +08:00
|
|
|
local who = data.who
|
2023-08-11 03:19:59 +08:00
|
|
|
logic:trigger(fk.StartJudge, who, data)
|
|
|
|
data.card = data.card or Fk:getCardById(room:getNCards(1)[1])
|
2023-03-01 01:43:44 +08:00
|
|
|
|
|
|
|
if data.reason ~= "" then
|
2023-08-11 03:19:59 +08:00
|
|
|
room:sendLog{
|
2023-03-01 01:43:44 +08:00
|
|
|
type = "#StartJudgeReason",
|
|
|
|
from = who.id,
|
|
|
|
arg = data.reason,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-08-11 03:19:59 +08:00
|
|
|
room:sendLog{
|
2023-03-01 01:43:44 +08:00
|
|
|
type = "#InitialJudge",
|
|
|
|
from = who.id,
|
|
|
|
card = {data.card.id},
|
|
|
|
}
|
2023-08-11 03:19:59 +08:00
|
|
|
room:moveCardTo(data.card, Card.Processing, nil, fk.ReasonJudge)
|
|
|
|
room:sendFootnote({ data.card.id }, {
|
2023-06-10 02:18:51 +08:00
|
|
|
type = "##JudgeCard",
|
|
|
|
arg = data.reason,
|
|
|
|
})
|
2023-03-01 01:43:44 +08:00
|
|
|
|
2023-08-11 03:19:59 +08:00
|
|
|
logic:trigger(fk.AskForRetrial, who, data)
|
|
|
|
logic:trigger(fk.FinishRetrial, who, data)
|
2023-03-01 01:43:44 +08:00
|
|
|
Fk:filterCard(data.card.id, who, data)
|
2023-08-11 03:19:59 +08:00
|
|
|
room:sendLog{
|
2023-03-01 01:43:44 +08:00
|
|
|
type = "#JudgeResult",
|
|
|
|
from = who.id,
|
|
|
|
card = {data.card.id},
|
|
|
|
}
|
2023-08-11 03:19:59 +08:00
|
|
|
room:sendFootnote({ data.card.id }, {
|
2023-06-10 02:18:51 +08:00
|
|
|
type = "##JudgeCard",
|
|
|
|
arg = data.reason,
|
|
|
|
})
|
2023-03-01 01:43:44 +08:00
|
|
|
|
|
|
|
if data.pattern then
|
2023-08-11 03:19:59 +08:00
|
|
|
room:delay(400);
|
|
|
|
room:setCardEmotion(data.card.id, data.card:matchPattern(data.pattern) and "judgegood" or "judgebad")
|
|
|
|
room:delay(900);
|
2023-03-01 01:43:44 +08:00
|
|
|
end
|
|
|
|
|
2023-08-11 03:19:59 +08:00
|
|
|
if logic:trigger(fk.FinishJudge, who, data) then
|
|
|
|
logic:breakEvent()
|
2023-03-01 01:43:44 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
GameEvent.cleaners[GameEvent.Judge] = function(self)
|
|
|
|
local data = table.unpack(self.data)
|
2023-08-11 03:19:59 +08: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-03-01 01:43:44 +08:00
|
|
|
end
|
2023-03-07 14:55:28 +08:00
|
|
|
if not self.interrupted then return end
|
2023-03-01 01:43:44 +08:00
|
|
|
|
|
|
|
-- prohibit access to judge.card
|
|
|
|
setmetatable(data, {
|
2023-08-11 03:19:59 +08:00
|
|
|
__index = function(s, key)
|
2023-03-01 01:43:44 +08:00
|
|
|
if key == "card" then
|
|
|
|
error("__manuallyBreak")
|
|
|
|
end
|
2023-08-11 03:19:59 +08:00
|
|
|
return rawget(s, key)
|
2023-03-01 01:43:44 +08:00
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|