FreeKill/lua/core/game_mode.lua
Ho-spair cec18e0614
Modify game core (#294)
- 新增船新“休整”机制;
- 修改作废逻辑,并可在当前响应读条禁用该技能(出牌阶段空闲时间点尚未完成限制);
- 修复锁视技的相关bug,其cardFilter新增标识是否为判定的参数;
- 将护甲扣减融合进体力扣减流程,为伤害流程增加“虚拟伤害”概念,为伤害流程增加“造成过伤害”标识id以供记录搜索使用;
- 为变将新增可删除副将。

---------

Co-authored-by: notify <notify-ctrl@qq.com>
2023-12-10 18:55:16 +08:00

75 lines
2.0 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- SPDX-License-Identifier: GPL-3.0-or-later
--- GameMode用来描述一个游戏模式。
---
--- 可以参考欢乐斗地主。
---
---@class GameMode: Object
---@field public name string @ 游戏模式名
---@field public minPlayer integer @ 最小玩家数
---@field public maxPlayer integer @ 最大玩家数
---@field public rule? TriggerSkill @ 规则(通过技能完成,通常用来为特定角色及特定时机提供触发事件)
---@field public logic? fun(): GameLogic @ 逻辑通过function完成通常用来初始化、分配身份及座次
---@field public whitelist? string[] @ 白名单
---@field public blacklist? string[] @ 黑名单
local GameMode = class("GameMode")
--- 构造函数,不可随意调用。
---@param name string @ 游戏模式名
---@param min integer @ 最小玩家数
---@param max integer @ 最大玩家数
function GameMode:initialize(name, min, max)
self.name = name
self.minPlayer = math.max(min, 2)
self.maxPlayer = math.min(max, 12)
end
---@param victim ServerPlayer @ 死者
---@return string @ 胜者阵营
function GameMode:getWinner(victim)
if victim.rest > 0 then
return ""
end
local room = victim.room
local winner = ""
local alive = table.filter(room.players, function(p)
return not p.surrendered and not (p.dead and p.rest == 0)
end)
if victim.role == "lord" then
if #alive == 1 and alive[1].role == "renegade" then
winner = "renegade"
else
winner = "rebel"
end
elseif victim.role ~= "loyalist" then
local lord_win = true
for _, p in ipairs(alive) do
if p.role == "rebel" or p.role == "renegade" then
lord_win = false
break
end
end
if lord_win then
winner = "lord+loyalist"
end
end
return winner
end
---@param playedTime number @ 游戏时长(单位:秒)
---@return table
function GameMode:surrenderFunc(playedTime)
return {}
end
---@param room Room @ 游戏房间
---@return boolean
function GameMode:countInFunc(room)
return true
end
return GameMode