2023-04-09 13:35:35 +08:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-12-20 12:51:54 +08:00
|
|
|
---@param killer ServerPlayer
|
|
|
|
local function rewardAndPunish(killer, victim)
|
|
|
|
if killer.dead then return end
|
|
|
|
if victim.role == "rebel" then
|
|
|
|
killer:drawCards(3, "kill")
|
|
|
|
elseif victim.role == "loyalist" and killer.role == "lord" then
|
|
|
|
killer:throwAllCards("he")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
GameRule = fk.CreateTriggerSkill{
|
2022-04-30 15:27:56 +08:00
|
|
|
name = "game_rule",
|
2023-04-22 14:10:06 +08:00
|
|
|
events = {
|
2023-05-20 16:00:03 +08:00
|
|
|
fk.GamePrepared,
|
2022-12-20 12:51:54 +08:00
|
|
|
fk.AskForPeaches, fk.AskForPeachesDone,
|
|
|
|
fk.GameOverJudge, fk.BuryVictim,
|
2022-04-30 15:27:56 +08:00
|
|
|
},
|
|
|
|
priority = 0,
|
2022-04-01 20:51:01 +08:00
|
|
|
|
2023-04-22 14:10:06 +08:00
|
|
|
can_trigger = function(self, event, target, player, data)
|
2022-04-30 15:27:56 +08:00
|
|
|
return (target == player) or (target == nil)
|
|
|
|
end,
|
2022-04-01 20:51:01 +08:00
|
|
|
|
2023-04-22 14:10:06 +08:00
|
|
|
on_trigger = function(self, event, target, player, data)
|
2023-04-08 20:45:55 +08:00
|
|
|
local room = player.room
|
|
|
|
if room:getTag("SkipGameRule") then
|
|
|
|
room:setTag("SkipGameRule", false)
|
2022-04-30 15:27:56 +08:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2023-05-20 16:00:03 +08:00
|
|
|
if event == fk.GamePrepared then
|
2023-04-08 20:45:55 +08:00
|
|
|
room:setTag("FirstRound", true)
|
|
|
|
room:setTag("RoundCount", 0)
|
2022-04-30 15:27:56 +08:00
|
|
|
return false
|
|
|
|
end
|
2022-04-02 21:39:44 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
switch(event, {
|
2022-12-20 12:51:54 +08:00
|
|
|
[fk.AskForPeaches] = function()
|
2023-04-04 16:25:37 +08:00
|
|
|
local dyingPlayer = room:getPlayerById(data.who)
|
2024-01-29 10:19:10 +08:00
|
|
|
while not (player.dead or dyingPlayer.dead) and dyingPlayer.hp < 1 do
|
2023-08-13 12:34:36 +08:00
|
|
|
local cardNames = {"peach"}
|
2023-05-13 13:23:18 +08:00
|
|
|
local prompt = "#AskForPeaches:" .. dyingPlayer.id .. "::" .. tostring(1 - dyingPlayer.hp)
|
2023-04-04 16:25:37 +08:00
|
|
|
if player == dyingPlayer then
|
2023-08-13 12:34:36 +08:00
|
|
|
table.insert(cardNames, "analeptic")
|
2023-05-13 13:23:18 +08:00
|
|
|
prompt = "#AskForPeachesSelf:::" .. tostring(1 - dyingPlayer.hp)
|
2023-04-04 16:25:37 +08:00
|
|
|
end
|
2023-03-14 20:48:08 +08:00
|
|
|
|
2023-08-13 12:34:36 +08:00
|
|
|
cardNames = table.filter(cardNames, function (cardName)
|
2023-06-04 19:40:14 +08:00
|
|
|
local cardCloned = Fk:cloneCard(cardName)
|
2023-08-13 12:34:36 +08:00
|
|
|
return not (player:prohibitUse(cardCloned) or player:isProhibited(dyingPlayer, cardCloned))
|
|
|
|
end)
|
|
|
|
if #cardNames == 0 then return end
|
2023-06-04 19:40:14 +08:00
|
|
|
|
2024-06-10 15:19:47 +08:00
|
|
|
local peach_use = room:askForUseCard(
|
|
|
|
player,
|
|
|
|
"peach",
|
|
|
|
table.concat(cardNames, ","),
|
|
|
|
prompt,
|
|
|
|
true,
|
|
|
|
{analepticRecover = true, must_targets = { dyingPlayer.id }}
|
|
|
|
)
|
2023-04-04 16:25:37 +08:00
|
|
|
if not peach_use then break end
|
|
|
|
peach_use.tos = { {dyingPlayer.id} }
|
|
|
|
if peach_use.card.trueName == "analeptic" then
|
|
|
|
peach_use.extra_data = peach_use.extra_data or {}
|
|
|
|
peach_use.extra_data.analepticRecover = true
|
2022-12-20 12:51:54 +08:00
|
|
|
end
|
2023-04-04 16:25:37 +08:00
|
|
|
room:useCard(peach_use)
|
2022-12-20 12:51:54 +08:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
[fk.AskForPeachesDone] = function()
|
2023-04-04 16:25:37 +08:00
|
|
|
if player.hp < 1 and not data.ignoreDeath then
|
2022-12-20 12:51:54 +08:00
|
|
|
---@type DeathStruct
|
|
|
|
local deathData = {
|
|
|
|
who = player.id,
|
|
|
|
damage = data.damage,
|
|
|
|
}
|
|
|
|
room:killPlayer(deathData)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
[fk.GameOverJudge] = function()
|
2023-07-02 20:39:42 +08:00
|
|
|
local winner = Fk.game_modes[room.settings.gameMode]:getWinner(player)
|
2022-12-20 12:51:54 +08:00
|
|
|
if winner ~= "" then
|
|
|
|
room:gameOver(winner)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
[fk.BuryVictim] = function()
|
|
|
|
player:bury()
|
2023-12-10 18:55:16 +08:00
|
|
|
if room.tag["SkipNormalDeathProcess"] or player.rest > 0 then
|
2022-12-20 12:51:54 +08:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
local damage = data.damage
|
|
|
|
if damage and damage.from then
|
2023-02-15 19:54:35 +08:00
|
|
|
local killer = damage.from
|
2022-12-20 12:51:54 +08:00
|
|
|
rewardAndPunish(killer, player);
|
|
|
|
end
|
|
|
|
end,
|
2022-04-30 15:27:56 +08:00
|
|
|
default = function()
|
|
|
|
print("game_rule: Event=" .. event)
|
|
|
|
room:askForSkillInvoke(player, "rule")
|
2022-04-02 15:11:13 +08:00
|
|
|
end,
|
2022-04-30 15:27:56 +08:00
|
|
|
})
|
|
|
|
return false
|
|
|
|
end,
|
2022-04-02 15:11:13 +08:00
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
}
|
2023-07-02 13:21:13 +08:00
|
|
|
|
|
|
|
local fastchat_m = fk.CreateActiveSkill{ name = "fastchat_m" }
|
|
|
|
local fastchat_f = fk.CreateActiveSkill{ name = "fastchat_f" }
|
|
|
|
Fk:addSkill(fastchat_m)
|
|
|
|
Fk:addSkill(fastchat_f)
|