无用空表Util.DummyTable化+若干bug fix+若干调整 (#189)

- 将一些作为替代选项的空表替换为Util.DummyTable
- 修复了控制失效bug
- 修复了askForCards的bug
- 为弃牌阶段弃牌禁止取消
- 谋徐盛血量变为100
- setMark追加count为0时设为nil的设定
- 各种国际化
- 观星盒追加旁边的牌堆名
This commit is contained in:
YoumuKon 2023-06-11 16:22:11 +08:00 committed by GitHub
parent b2a963739b
commit 8a11690de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 93 additions and 61 deletions

View File

@ -154,7 +154,7 @@ Item {
if (!skilldata) return; if (!skilldata) return;
const extension = skilldata.extension; const extension = skilldata.extension;
for (let i = 0; i < 999; i++) { for (let i = 0; i < 999; i++) {
let fname = AppPath + "/packages/" + extension + "/audio/skill/" + const fname = AppPath + "/packages/" + extension + "/audio/skill/" +
skill + (i !== 0 ? i.toString() : "") + ".mp3"; skill + (i !== 0 ? i.toString() : "") + ".mp3";
if (Backend.exists(fname)) { if (Backend.exists(fname)) {
@ -163,6 +163,12 @@ Item {
if (i > 0) break; if (i > 0) break;
} }
} }
const fname = AppPath + "/packages/" + extension + "/audio/death/" + general + ".mp3";
if (Backend.exists(fname)) {
audioDeath.visible = true;
} else {
audioDeath.visible = false;
}
} }
function updateGeneral() { function updateGeneral() {
@ -247,6 +253,7 @@ Item {
} }
Button { Button {
id: audioDeath
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout { contentItem: ColumnLayout {
Text { Text {

View File

@ -33,6 +33,28 @@ GraphicsBox {
property int areaCapacity: modelData property int areaCapacity: modelData
property string areaName: index < areaNames.length ? qsTr(areaNames[index]) : "" property string areaName: index < areaNames.length ? qsTr(areaNames[index]) : ""
Rectangle {
anchors.verticalCenter: parent.verticalCenter
color: "#6B5D42"
width: 20
height: 100
radius: 5
Text {
anchors.fill: parent
width: 20
height: 100
text: areaName
color: "white"
font.family: fontLibian.name
font.pixelSize: 18
style: Text.Outline
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
Repeater { Repeater {
id: cardRepeater id: cardRepeater
model: areaCapacity model: areaCapacity

View File

@ -144,14 +144,14 @@ local function parseMsg(msg, nocolor)
local from = getPlayerStr(data.from, "#0C8F0C") local from = getPlayerStr(data.from, "#0C8F0C")
local to = data.to or {} local to = data.to or Util.DummyTable
local to_str = {} local to_str = {}
for _, id in ipairs(to) do for _, id in ipairs(to) do
table.insert(to_str, getPlayerStr(id, "#CC3131")) table.insert(to_str, getPlayerStr(id, "#CC3131"))
end end
to = table.concat(to_str, ", ") to = table.concat(to_str, ", ")
local card = data.card or {} local card = data.card or Util.DummyTable
local allUnknown = true local allUnknown = true
local unknownCount = 0 local unknownCount = 0
for _, id in ipairs(card) do for _, id in ipairs(card) do

View File

@ -145,7 +145,7 @@ function GetCards(pack_name)
end end
function GetCardSpecialSkills(cid) function GetCardSpecialSkills(cid)
return json.encode(Fk:getCardById(cid).special_skills or {}) return json.encode(Fk:getCardById(cid).special_skills or Util.DummyTable)
end end
function DistanceTo(from, to) function DistanceTo(from, to)
@ -159,7 +159,7 @@ function GetPile(id, name)
end end
function GetAllPiles(id) function GetAllPiles(id)
return json.encode(ClientInstance:getPlayerById(id).special_cards or {}) return json.encode(ClientInstance:getPlayerById(id).special_cards or Util.DummyTable)
end end
function GetPlayerSkills(id) function GetPlayerSkills(id)

View File

@ -158,6 +158,7 @@ FreeKill使用的是libgit2的C API与此同时使用Git完成拓展包的下
["AskForGeneral"] = "选择武将", ["AskForGeneral"] = "选择武将",
["AskForGuanxing"] = "观星", ["AskForGuanxing"] = "观星",
["AskForExchange"] = "换牌", ["AskForExchange"] = "换牌",
["Pile"] = "牌堆",
["AskForChoice"] = "选择", ["AskForChoice"] = "选择",
["AskForKingdom"] = "选择势力", ["AskForKingdom"] = "选择势力",
["AskForPindian"] = "拼点", ["AskForPindian"] = "拼点",

View File

@ -315,6 +315,7 @@ end
---@param mark string @ 标记 ---@param mark string @ 标记
---@param count integer @ 为标记删除的数量 ---@param count integer @ 为标记删除的数量
function Card:setMark(mark, count) function Card:setMark(mark, count)
if count == 0 then count = nil end
if self.mark[mark] ~= count then if self.mark[mark] ~= count then
self.mark[mark] = count self.mark[mark] = count
end end

View File

@ -386,7 +386,7 @@ function Engine:filterCard(id, player, data)
return return
end end
local skills = player:getAllSkills() local skills = player:getAllSkills()
local filters = self:currentRoom().status_skills[FilterSkill] or {} local filters = self:currentRoom().status_skills[FilterSkill] or Util.DummyTable
if #filters == 0 then if #filters == 0 then
filtered_cards[id] = nil filtered_cards[id] = nil

View File

@ -185,6 +185,7 @@ end
---@param mark string @ 标记 ---@param mark string @ 标记
---@param count integer @ 为标记删除的数量 ---@param count integer @ 为标记删除的数量
function Player:setMark(mark, count) function Player:setMark(mark, count)
if count == 0 then count = nil end
if self.mark[mark] ~= count then if self.mark[mark] ~= count then
self.mark[mark] = count self.mark[mark] = count
end end
@ -360,7 +361,7 @@ end
function Player:getMaxCards() function Player:getMaxCards()
local baseValue = math.max(self.hp, 0) local baseValue = math.max(self.hp, 0)
local status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or {} local status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or Util.DummyTable
local max_fixed = nil local max_fixed = nil
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
local f = skill:getFixed(self) local f = skill:getFixed(self)
@ -384,7 +385,7 @@ function Player:getAttackRange()
local weapon = Fk:getCardById(self:getEquipment(Card.SubtypeWeapon)) local weapon = Fk:getCardById(self:getEquipment(Card.SubtypeWeapon))
local baseAttackRange = math.max(weapon and weapon.attack_range or 1, 0) local baseAttackRange = math.max(weapon and weapon.attack_range or 1, 0)
local status_skills = Fk:currentRoom().status_skills[AttackRangeSkill] or {} local status_skills = Fk:currentRoom().status_skills[AttackRangeSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
local correct = skill:getCorrect(self) local correct = skill:getCorrect(self)
baseAttackRange = baseAttackRange + correct baseAttackRange = baseAttackRange + correct
@ -424,7 +425,7 @@ function Player:distanceTo(other)
local left = #Fk:currentRoom().alive_players - right local left = #Fk:currentRoom().alive_players - right
local ret = math.min(left, right) local ret = math.min(left, right)
local status_skills = Fk:currentRoom().status_skills[DistanceSkill] or {} local status_skills = Fk:currentRoom().status_skills[DistanceSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
local correct = skill:getCorrect(self, other) local correct = skill:getCorrect(self, other)
if correct == nil then correct = 0 end if correct == nil then correct = 0 end
@ -448,7 +449,7 @@ function Player:inMyAttackRange(other, fixLimit)
fixLimit = fixLimit or 0 fixLimit = fixLimit or 0
local status_skills = Fk:currentRoom().status_skills[AttackRangeSkill] or {} local status_skills = Fk:currentRoom().status_skills[AttackRangeSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:withinAttackRange(self, other) then if skill:withinAttackRange(self, other) then
return true return true
@ -724,7 +725,7 @@ end
---@param card Card @ 特定牌 ---@param card Card @ 特定牌
function Player:isProhibited(to, card) function Player:isProhibited(to, card)
local r = Fk:currentRoom() local r = Fk:currentRoom()
local status_skills = r.status_skills[ProhibitSkill] or {} local status_skills = r.status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:isProhibited(self, to, card) then if skill:isProhibited(self, to, card) then
return true return true
@ -736,7 +737,7 @@ end
--- 确认玩家是否可以使用特定牌。 --- 确认玩家是否可以使用特定牌。
---@param card Card @ 特定的牌 ---@param card Card @ 特定的牌
function Player:prohibitUse(card) function Player:prohibitUse(card)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or {} local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:prohibitUse(self, card) then if skill:prohibitUse(self, card) then
return true return true
@ -748,7 +749,7 @@ end
--- 确认玩家是否可以打出特定牌。 --- 确认玩家是否可以打出特定牌。
---@param card Card @ 特定的牌 ---@param card Card @ 特定的牌
function Player:prohibitResponse(card) function Player:prohibitResponse(card)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or {} local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:prohibitResponse(self, card) then if skill:prohibitResponse(self, card) then
return true return true
@ -760,7 +761,7 @@ end
--- 确认玩家是否可以弃置特定牌。 --- 确认玩家是否可以弃置特定牌。
---@param card Card @ 特定的牌 ---@param card Card @ 特定的牌
function Player:prohibitDiscard(card) function Player:prohibitDiscard(card)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or {} local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:prohibitDiscard(self, card) then if skill:prohibitDiscard(self, card) then
return true return true

View File

@ -83,7 +83,7 @@ function Skill:isEffectable(player)
return true return true
end end
local nullifySkills = Fk:currentRoom().status_skills[InvaliditySkill] or {} local nullifySkills = Fk:currentRoom().status_skills[InvaliditySkill] or Util.DummyTable
for _, nullifySkill in ipairs(nullifySkills) do for _, nullifySkill in ipairs(nullifySkills) do
if self.name ~= nullifySkill.name and nullifySkill:getInvalidity(player, self) then if self.name ~= nullifySkill.name and nullifySkill:getInvalidity(player, self) then
return false return false

View File

@ -79,7 +79,7 @@ function ActiveSkill:getMaxTargetNum(player, card)
ret = ret[#ret] ret = ret[#ret]
end end
local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or {} local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
local correct = skill:getExtraTargetNum(player, self, card) local correct = skill:getExtraTargetNum(player, self, card)
if correct == nil then correct = 0 end if correct == nil then correct = 0 end
@ -122,7 +122,7 @@ end
function ActiveSkill:getDistanceLimit(player, card, to) function ActiveSkill:getDistanceLimit(player, card, to)
local ret = self.distance_limit or 0 local ret = self.distance_limit or 0
local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or {} local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
local correct = skill:getDistanceLimit(player, self, card, to) local correct = skill:getDistanceLimit(player, self, card, to)
if correct == nil then correct = 0 end if correct == nil then correct = 0 end

View File

@ -15,7 +15,7 @@ end
function UsableSkill:getMaxUseTime(player, scope, card, to) function UsableSkill:getMaxUseTime(player, scope, card, to)
scope = scope or Player.HistoryTurn scope = scope or Player.HistoryTurn
local ret = self.max_use_time[scope] local ret = self.max_use_time[scope]
local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or {} local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
local correct = skill:getResidueNum(player, self, scope, card, to) local correct = skill:getResidueNum(player, self, scope, card, to)
if correct == nil then correct = 0 end if correct == nil then correct = 0 end

View File

@ -318,7 +318,7 @@ local function cmd_eval(code)
if chunk == nil then return false end if chunk == nil then return false end
-- Call the chunk and collect the results. -- Call the chunk and collect the results.
local success, err = pcall(chunk, unpack(rawget(env, "...") or {})) local success, err = pcall(chunk, unpack(rawget(env, "...") or Util.DummyTable))
if not success then if not success then
dbg_writeln(COLOR_RED.."错误:"..COLOR_RESET.." "..tostring(err)) dbg_writeln(COLOR_RED.."错误:"..COLOR_RESET.." "..tostring(err))
end end

View File

@ -277,7 +277,7 @@ fkp.CreateActiveSkill = function(spec)
end end
fkp.functions.newVirtualCard = function(number, suit, name, subcards, skill) fkp.functions.newVirtualCard = function(number, suit, name, subcards, skill)
subcards = subcards or {} subcards = subcards or Util.DummyTable
local ret = Fk:cloneCard(name, string2suit[suit], number) local ret = Fk:cloneCard(name, string2suit[suit], number)
if not ret then if not ret then
ret = Fk:cloneCard("slash", string2suit[suit], number) ret = Fk:cloneCard("slash", string2suit[suit], number)

View File

@ -32,7 +32,7 @@ local function useActiveSkill(self, skill, card)
local ret = skill:targetFilter(p.id, selected_targets, selected_cards, card or Fk:cloneCard'zixing') local ret = skill:targetFilter(p.id, selected_targets, selected_cards, card or Fk:cloneCard'zixing')
if ret and card then if ret and card then
local r = self.room local r = self.room
local status_skills = r.status_skills[ProhibitSkill] or {} local status_skills = r.status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:isProhibited(self.player, p, card) then if skill:isProhibited(self.player, p, card) then
ret = false ret = false

View File

@ -288,13 +288,13 @@ GameEvent.functions[GameEvent.Phase] = function(self)
local discardNum = #table.filter( local discardNum = #table.filter(
player:getCardIds(Player.Hand), function(id) player:getCardIds(Player.Hand), function(id)
local card = Fk:getCardById(id) local card = Fk:getCardById(id)
return table.every(room.status_skills[MaxCardsSkill] or {}, function(skill) return table.every(room.status_skills[MaxCardsSkill] or Util.DummyTable, function(skill)
return not skill:excludeFrom(player, card) return not skill:excludeFrom(player, card)
end) end)
end end
) - player:getMaxCards() ) - player:getMaxCards()
if discardNum > 0 then if discardNum > 0 then
room:askForDiscard(player, discardNum, discardNum, false, "game_rule") room:askForDiscard(player, discardNum, discardNum, false, "game_rule", false)
end end
end, end,
[Player.Finish] = function() [Player.Finish] = function()

View File

@ -56,7 +56,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
playCardEmotionAndSound(room, room:getPlayerById(from), card) playCardEmotionAndSound(room, room:getPlayerById(from), card)
room:doAnimate("Indicate", { room:doAnimate("Indicate", {
from = from, from = from,
to = cardUseEvent.tos or {}, to = cardUseEvent.tos or Util.DummyTable,
}) })
local useCardIds = card:isVirtual() and card.subcards or { card.id } local useCardIds = card:isVirtual() and card.subcards or { card.id }
@ -330,7 +330,7 @@ GameEvent.functions[GameEvent.CardEffect] = function(self)
self.logic:breakEvent() self.logic:breakEvent()
end end
if table.contains((cardEffectEvent.nullifiedTargets or {}), cardEffectEvent.to) then if table.contains((cardEffectEvent.nullifiedTargets or Util.DummyTable), cardEffectEvent.to) then
self.logic:breakEvent() self.logic:breakEvent()
end end

View File

@ -381,7 +381,7 @@ function GameLogic:trigger(event, target, data, refresh_only)
local room = self.room local room = self.room
local broken = false local broken = false
local skills = self.skill_table[event] or {} local skills = self.skill_table[event] or {}
local skills_to_refresh = self.refresh_skill_table[event] or {} local skills_to_refresh = self.refresh_skill_table[event] or Util.DummyTable
local _target = room.current -- for iteration local _target = room.current -- for iteration
local player = _target local player = _target

View File

@ -484,7 +484,7 @@ function Room:changeHero(player, new_general, full, isDeputy, sendLog)
local orig = isDeputy and (player.deputyGeneral or "") or player.general local orig = isDeputy and (player.deputyGeneral or "") or player.general
orig = Fk.generals[orig] orig = Fk.generals[orig]
local orig_skills = orig and orig:getSkillNameList() or {} local orig_skills = orig and orig:getSkillNameList() or Util.DummyTable
local new = Fk.generals[new_general] or Fk.generals["sunce"] local new = Fk.generals[new_general] or Fk.generals["sunce"]
local new_skills = new:getSkillNameList() local new_skills = new:getSkillNameList()
@ -884,7 +884,7 @@ function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra
prompt = prompt or "" prompt = prompt or ""
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
no_indicate = (no_indicate == nil) and true or no_indicate no_indicate = (no_indicate == nil) and true or no_indicate
extra_data = extra_data or {} extra_data = extra_data or Util.DummyTable
local skill = Fk.skills[skill_name] local skill = Fk.skills[skill_name]
if not (skill and (skill:isInstanceOf(ActiveSkill) or skill:isInstanceOf(ViewAsSkill))) then if not (skill and (skill:isInstanceOf(ActiveSkill) or skill:isInstanceOf(ViewAsSkill))) then
print("Attempt ask for use non-active skill: " .. skill_name) print("Attempt ask for use non-active skill: " .. skill_name)
@ -956,14 +956,14 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, can
local checkpoint = true local checkpoint = true
local card = Fk:getCardById(id) local card = Fk:getCardById(id)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or {} local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:prohibitDiscard(player, card) then if skill:prohibitDiscard(player, card) then
return false return false
end end
end end
if skillName == "game_rule" then if skillName == "game_rule" then
status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or {} status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:excludeFrom(player, card) then if skill:excludeFrom(player, card) then
return false return false
@ -1078,7 +1078,7 @@ function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancel
expand_pile = expand_pile, expand_pile = expand_pile,
} }
local prompt = prompt or ("#AskForCard:::" .. maxNum .. ":" .. minNum) local prompt = prompt or ("#AskForCard:::" .. maxNum .. ":" .. minNum)
local _, ret = self:askForUseActiveSkill(player, "choose_cards_skill", prompt, cancelable, no_indicate) local _, ret = self:askForUseActiveSkill(player, "choose_cards_skill", prompt, cancelable, data, no_indicate)
if ret then if ret then
chosenCards = ret.cards chosenCards = ret.cards
else else
@ -1292,21 +1292,21 @@ end
---@return table<top|bottom, cardId[]> ---@return table<top|bottom, cardId[]>
function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotify, noPut, areaNames) function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotify, noPut, areaNames)
-- 这一大堆都是来提前报错的 -- 这一大堆都是来提前报错的
top_limit = top_limit or {} top_limit = top_limit or Util.DummyTable
bottom_limit = bottom_limit or {} bottom_limit = bottom_limit or Util.DummyTable
if #top_limit > 0 then if #top_limit > 0 then
assert(top_limit[1] >= 0 and top_limit[2] >= 0, "牌堆顶区间设置错误:数值小于0") assert(top_limit[1] >= 0 and top_limit[2] >= 0, "limits error: The lower limit should be greater than 0")
assert(top_limit[1] <= top_limit[2], "牌堆顶区间设置错误:上限小于下限") assert(top_limit[1] <= top_limit[2], "limits error: The upper limit should be less than the lower limit")
end end
if #bottom_limit > 0 then if #bottom_limit > 0 then
assert(bottom_limit[1] >= 0 and bottom_limit[2] >= 0, "牌堆底区间设置错误:数值小于0") assert(bottom_limit[1] >= 0 and bottom_limit[2] >= 0, "limits error: The lower limit should be greater than 0")
assert(bottom_limit[1] <= bottom_limit[2], "牌堆底区间设置错误:上限小于下限") assert(bottom_limit[1] <= bottom_limit[2], "limits error: The upper limit should be less than the lower limit")
end end
if #top_limit > 0 and #bottom_limit > 0 then if #top_limit > 0 and #bottom_limit > 0 then
assert(#cards >= top_limit[1] + bottom_limit[1] and #cards <= top_limit[2] + bottom_limit[2], "限定区间设置错误:可用空间不能容纳所有牌。") assert(#cards >= top_limit[1] + bottom_limit[1] and #cards <= top_limit[2] + bottom_limit[2], "limits Error: No enough space")
end end
if areaNames then if areaNames then
assert(#areaNames > 1, "左侧提示信息设置错误应有Top和Bottom两个提示信息") assert(#areaNames == 2, "areaNames error: Should have 2 elements")
end end
local command = "AskForGuanxing" local command = "AskForGuanxing"
self:notifyMoveFocus(player, customNotify or command) self:notifyMoveFocus(player, customNotify or command)
@ -1332,8 +1332,8 @@ function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotif
bottom = d[2] bottom = d[2]
end end
else else
top = table.random(cards, top_limit and top_limit[2] or #cards) or {} top = table.random(cards, top_limit and top_limit[2] or #cards) or Util.DummyTable
bottom = table.shuffle(table.filter(cards, function(id) return not table.contains(top, id) end)) or {} bottom = table.shuffle(table.filter(cards, function(id) return not table.contains(top, id) end)) or Util.DummyTable
end end
if not noPut then if not noPut then
@ -1362,13 +1362,13 @@ end
---@param piles_name string[] @ 牌堆名必须一一对应否则统一替换为“牌堆X” ---@param piles_name string[] @ 牌堆名必须一一对应否则统一替换为“牌堆X”
---@param customNotify string|null @ 自定义读条操作提示 ---@param customNotify string|null @ 自定义读条操作提示
---@return table<cardIds, cardId[]> ---@return table<cardIds, cardId[]>
function Room:AskForExchange(player, piles, piles_name, customNotify) function Room:askForExchange(player, piles, piles_name, customNotify)
local command = "AskForExchange" local command = "AskForExchange"
piles_name = piles_name or {} piles_name = piles_name or Util.DummyTable
if #piles_name ~= #piles then if #piles_name ~= #piles then
piles_name = {} piles_name = {}
for i, _ in ipairs(piles) do for i, _ in ipairs(piles) do
table.insert(piles_name, "牌堆" .. i) table.insert(piles_name, "Pile" .. i)
end end
end end
self:notifyMoveFocus(player, customNotify or command) self:notifyMoveFocus(player, customNotify or command)
@ -1465,7 +1465,7 @@ end
---@param event_data CardEffectEvent|nil @ 事件信息 ---@param event_data CardEffectEvent|nil @ 事件信息
---@return CardUseStruct | nil @ 返回关于本次使用牌的数据,以便后续处理 ---@return CardUseStruct | nil @ 返回关于本次使用牌的数据,以便后续处理
function Room:askForUseCard(player, card_name, pattern, prompt, cancelable, extra_data, event_data) function Room:askForUseCard(player, card_name, pattern, prompt, cancelable, extra_data, event_data)
if event_data and (event_data.disresponsive or table.contains(event_data.disresponsiveList or {}, player.id)) then if event_data and (event_data.disresponsive or table.contains(event_data.disresponsiveList or Util.DummyTable, player.id)) then
return nil return nil
end end
@ -1485,7 +1485,7 @@ function Room:askForUseCard(player, card_name, pattern, prompt, cancelable, extr
local command = "AskForUseCard" local command = "AskForUseCard"
self:notifyMoveFocus(player, card_name) self:notifyMoveFocus(player, card_name)
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
extra_data = extra_data or {} extra_data = extra_data or Util.DummyTable
pattern = pattern or card_name pattern = pattern or card_name
prompt = prompt or "" prompt = prompt or ""
@ -1524,14 +1524,14 @@ end
---@param effectData CardEffectEvent @ 关联的卡牌生效流程 ---@param effectData CardEffectEvent @ 关联的卡牌生效流程
---@return Card | nil @ 打出的牌 ---@return Card | nil @ 打出的牌
function Room:askForResponse(player, card_name, pattern, prompt, cancelable, extra_data, effectData) function Room:askForResponse(player, card_name, pattern, prompt, cancelable, extra_data, effectData)
if effectData and (effectData.disresponsive or table.contains(effectData.disresponsiveList or {}, player.id)) then if effectData and (effectData.disresponsive or table.contains(effectData.disresponsiveList or Util.DummyTable, player.id)) then
return nil return nil
end end
local command = "AskForResponseCard" local command = "AskForResponseCard"
self:notifyMoveFocus(player, card_name) self:notifyMoveFocus(player, card_name)
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
extra_data = extra_data or {} extra_data = extra_data or Util.DummyTable
pattern = pattern or card_name pattern = pattern or card_name
prompt = prompt or "" prompt = prompt or ""
@ -1580,7 +1580,7 @@ function Room:askForNullification(players, card_name, pattern, prompt, cancelabl
local command = "AskForUseCard" local command = "AskForUseCard"
card_name = card_name or "nullification" card_name = card_name or "nullification"
cancelable = (cancelable == nil) and true or cancelable cancelable = (cancelable == nil) and true or cancelable
extra_data = extra_data or {} extra_data = extra_data or Util.DummyTable
prompt = prompt or "" prompt = prompt or ""
pattern = pattern or card_name pattern = pattern or card_name
@ -2118,7 +2118,7 @@ function Room:handleCardEffect(event, cardEffectEvent)
if cardEffectEvent.card.skill:aboutToEffect(self, cardEffectEvent) then return end if cardEffectEvent.card.skill:aboutToEffect(self, cardEffectEvent) then return end
if if
cardEffectEvent.card.trueName == "slash" and cardEffectEvent.card.trueName == "slash" and
not (cardEffectEvent.unoffsetable or table.contains(cardEffectEvent.unoffsetableList or {}, cardEffectEvent.to)) not (cardEffectEvent.unoffsetable or table.contains(cardEffectEvent.unoffsetableList or Util.DummyTable, cardEffectEvent.to))
then then
local loopTimes = 1 local loopTimes = 1
if cardEffectEvent.fixedResponseTimes then if cardEffectEvent.fixedResponseTimes then
@ -2160,7 +2160,7 @@ function Room:handleCardEffect(event, cardEffectEvent)
elseif elseif
cardEffectEvent.card.type == Card.TypeTrick and cardEffectEvent.card.type == Card.TypeTrick and
not (cardEffectEvent.disresponsive or cardEffectEvent.unoffsetable) and not (cardEffectEvent.disresponsive or cardEffectEvent.unoffsetable) and
not table.contains(cardEffectEvent.prohibitedCardNames or {}, "nullification") not table.contains(cardEffectEvent.prohibitedCardNames or Util.DummyTable, "nullification")
then then
local players = {} local players = {}
for _, p in ipairs(self.alive_players) do for _, p in ipairs(self.alive_players) do
@ -2169,8 +2169,8 @@ function Room:handleCardEffect(event, cardEffectEvent)
if if
Fk:getCardById(cid).name == "nullification" and Fk:getCardById(cid).name == "nullification" and
not ( not (
table.contains(cardEffectEvent.disresponsiveList or {}, p.id) or table.contains(cardEffectEvent.disresponsiveList or Util.DummyTable, p.id) or
table.contains(cardEffectEvent.unoffsetableList or {}, p.id) table.contains(cardEffectEvent.unoffsetableList or Util.DummyTable, p.id)
) )
then then
table.insert(players, p) table.insert(players, p)
@ -2184,8 +2184,8 @@ function Room:handleCardEffect(event, cardEffectEvent)
Exppattern:Parse("nullification"):matchExp(s.pattern) and Exppattern:Parse("nullification"):matchExp(s.pattern) and
not (s.enabledAtResponse and not s:enabledAtResponse(p)) and not (s.enabledAtResponse and not s:enabledAtResponse(p)) and
not ( not (
table.contains(cardEffectEvent.disresponsiveList or {}, p.id) or table.contains(cardEffectEvent.disresponsiveList or Util.DummyTable, p.id) or
table.contains(cardEffectEvent.unoffsetableList or {}, p.id) table.contains(cardEffectEvent.unoffsetableList or Util.DummyTable, p.id)
) )
then then
table.insert(players, p) table.insert(players, p)
@ -2800,7 +2800,7 @@ function Room:getSubcardsByRule(card, fromAreas)
end end
local cardIds = {} local cardIds = {}
fromAreas = fromAreas or {} fromAreas = fromAreas or Util.DummyTable
for _, cardId in ipairs(card:isVirtual() and card.subcards or { card.id }) do for _, cardId in ipairs(card:isVirtual() and card.subcards or { card.id }) do
if #fromAreas == 0 or table.contains(fromAreas, self:getCardArea(cardId)) then if #fromAreas == 0 or table.contains(fromAreas, self:getCardArea(cardId)) then
table.insert(cardIds, cardId) table.insert(cardIds, cardId)

View File

@ -10,14 +10,14 @@ local discardSkill = fk.CreateActiveSkill{
local checkpoint = true local checkpoint = true
local card = Fk:getCardById(to_select) local card = Fk:getCardById(to_select)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or {} local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:prohibitDiscard(Self, card) then if skill:prohibitDiscard(Self, card) then
return false return false
end end
end end
if Fk.currentResponseReason == "game_rule" then if Fk.currentResponseReason == "game_rule" then
status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or {} status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do for _, skill in ipairs(status_skills) do
if skill:excludeFrom(Self, card) then if skill:excludeFrom(Self, card) then
return false return false

View File

@ -242,8 +242,8 @@ local change_hero = fk.CreateActiveSkill{
room:changeHero(target, general, false, false, true) room:changeHero(target, general, false, false, true)
end, end,
} }
local test2 = General(extension, "mouxusheng", "wu", 4, 4, General.Female) local test2 = General(extension, "mouxusheng", "wu", 100, 100, General.Female)
test2.shield = 4 test2.shield = 5
test2:addSkill("rende") test2:addSkill("rende")
test2:addSkill(cheat) test2:addSkill(cheat)
test2:addSkill(control) test2:addSkill(control)

View File

@ -166,7 +166,7 @@ void QmlBackend::pushLuaValue(lua_State *L, QVariant v) {
} }
break; break;
default: default:
qCritical() << "cannot handle QVariant type" << v.typeId(); // qCritical() << "cannot handle QVariant type" << v.typeId();
lua_pushnil(L); lua_pushnil(L);
break; break;
} }