Dev bugfix (#203)

- 修复泛转化牌的canUse炸锅的bug
- 未上场时显示新手保护

---------

Co-authored-by: notify <notify-ctrl@qq.com>
This commit is contained in:
YoumuKon 2023-06-19 21:56:06 +08:00 committed by GitHub
parent d5330d5bed
commit 1036159d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 15 deletions

View File

@ -119,7 +119,7 @@ Flickable {
const run = gamedata[2]; const run = gamedata[2];
const winRate = (win / total) * 100; const winRate = (win / total) * 100;
const runRate = (run / total) * 100; const runRate = (run / total) * 100;
playerGameData.text = Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2)) playerGameData.text = total === 0 ? "Newbie" : "<br/>" + Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2))
.arg(runRate.toFixed(2)).arg(total); .arg(runRate.toFixed(2)).arg(total);
} }

View File

@ -581,7 +581,7 @@ Item {
Drawer { Drawer {
id: roomDrawer id: roomDrawer
width: roomScene.width * 0.3 / mainWindow.scale width: parent.width * 0.3 / mainWindow.scale
height: parent.height / mainWindow.scale height: parent.height / mainWindow.scale
dim: false dim: false
clip: true clip: true
@ -895,6 +895,13 @@ Item {
const datalist = []; const datalist = [];
for (let i = 0; i < photoModel.count; i++) { for (let i = 0; i < photoModel.count; i++) {
const item = photoModel.get(i); const item = photoModel.get(i);
let gameData;
try {
gameData = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [item.id]));
} catch (e) {
console.log(e);
gameData = [0, 0, 0];
}
if (item.id > 0) { if (item.id > 0) {
datalist.push({ datalist.push({
id: item.id, id: item.id,
@ -902,6 +909,7 @@ Item {
name: item.screenName, name: item.screenName,
isOwner: item.isOwner, isOwner: item.isOwner,
ready: item.ready, ready: item.ready,
gameData: gameData,
}); });
} }
} }
@ -926,6 +934,7 @@ Item {
roomScene.isOwner = d.isOwner; roomScene.isOwner = d.isOwner;
} else { } else {
Backend.callLuaFunction("ResetAddPlayer", [JSON.stringify([d.id, d.name, d.avatar, d.ready])]); Backend.callLuaFunction("ResetAddPlayer", [JSON.stringify([d.id, d.name, d.avatar, d.ready])]);
Backend.callLuaFunction("SetPlayerGameData", [d.id, d.gameData]);
} }
Logic.getPhotoModel(d.id).isOwner = d.isOwner; Logic.getPhotoModel(d.id).isOwner = d.isOwner;
}); });

View File

@ -598,4 +598,10 @@ function GetPlayerGameData(pid)
return json.encode(ret) return json.encode(ret)
end end
function SetPlayerGameData(pid, data)
local c = ClientInstance
local p = c:getPlayerById(pid)
p.player:setGameData(table.unpack(data))
end
dofile "lua/client/i18n/init.lua" dofile "lua/client/i18n/init.lua"

View File

@ -53,6 +53,7 @@ Fk:loadTranslationTable{
["Give Egg"] = "砸蛋", ["Give Egg"] = "砸蛋",
["Give Shoe"] = "拖鞋", ["Give Shoe"] = "拖鞋",
["Kick From Room"] = "踢出房间", ["Kick From Room"] = "踢出房间",
["Newbie"] = "新手保护ing",
["Win=%1 Run=%2 Total=%3"] = "胜率%1% 逃率%2% 总场次%3", ["Win=%1 Run=%2 Total=%3"] = "胜率%1% 逃率%2% 总场次%3",
["$OnlineInfo"] = "大厅人数:%1总在线人数%2", ["$OnlineInfo"] = "大厅人数:%1总在线人数%2",

View File

@ -24,13 +24,14 @@ function UsableSkill:getMaxUseTime(player, scope, card, to)
return ret return ret
end end
function UsableSkill:withinTimesLimit(player, scope, card, to) function UsableSkill:withinTimesLimit(player, scope, card, card_name, to)
scope = scope or Player.HistoryTurn scope = scope or Player.HistoryTurn
local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable 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
if skill:isUnlimited(player, self, scope, card, to) then return true end if skill:isUnlimited(player, self, scope, card, to) then return true end
end end
return player:usedCardTimes(card.trueName, scope) < self:getMaxUseTime(player, scope, card, to) card_name = card_name or card.trueName
return player:usedCardTimes(card_name, scope) < self:getMaxUseTime(player, scope, card, to)
end end
function UsableSkill:withinDistanceLimit(player, isattack, card, to) function UsableSkill:withinDistanceLimit(player, isattack, card, to)

View File

@ -258,7 +258,7 @@ GameEvent.functions[GameEvent.Phase] = function(self)
tos = { {player.id} }, tos = { {player.id} },
} }
room:doCardEffect(effect_data) room:doCardEffect(effect_data)
if effect_data.isCanCellout and card.skill then if effect_data.isCancellOut and card.skill then
card.skill:onNullified(room, effect_data) card.skill:onNullified(room, effect_data)
end end
end end

View File

@ -311,10 +311,10 @@ GameEvent.functions[GameEvent.CardEffect] = function(self)
local self = self.room local self = self.room
for _, event in ipairs({ fk.PreCardEffect, fk.BeforeCardEffect, fk.CardEffecting, fk.CardEffectFinished }) do for _, event in ipairs({ fk.PreCardEffect, fk.BeforeCardEffect, fk.CardEffecting, fk.CardEffectFinished }) do
if cardEffectEvent.isCanCellout then if cardEffectEvent.isCancellOut then
local user = cardEffectEvent.from and self:getPlayerById(cardEffectEvent.from) or nil local user = cardEffectEvent.from and self:getPlayerById(cardEffectEvent.from) or nil
if self.logic:trigger(fk.CardEffectCancelledOut, user, cardEffectEvent) then if self.logic:trigger(fk.CardEffectCancelledOut, user, cardEffectEvent) then
cardEffectEvent.isCanCellout = false cardEffectEvent.isCancellOut = false
else else
self.logic:breakEvent() self.logic:breakEvent()
end end

View File

@ -2236,11 +2236,11 @@ function Room:handleCardEffect(event, cardEffectEvent)
self:useCard(use) self:useCard(use)
end end
if not cardEffectEvent.isCanCellout then if not cardEffectEvent.isCancellOut then
break break
end end
cardEffectEvent.isCanCellout = i == loopTimes cardEffectEvent.isCancellOut = i == loopTimes
end end
elseif elseif
cardEffectEvent.card.type == Card.TypeTrick and cardEffectEvent.card.type == Card.TypeTrick and

View File

@ -133,7 +133,7 @@ fk.IceDamage = 4
---@field public cardsResponded Card[]|null ---@field public cardsResponded Card[]|null
---@field public disresponsive boolean|null ---@field public disresponsive boolean|null
---@field public unoffsetable boolean|null ---@field public unoffsetable boolean|null
---@field public isCanCellout boolean|null ---@field public isCancellOut boolean|null
---@field public fixedResponseTimes table<string, integer>|integer|null ---@field public fixedResponseTimes table<string, integer>|integer|null
---@field public fixedAddTimesResponsors integer[] ---@field public fixedAddTimesResponsors integer[]
---@field public prohibitedCardNames string[]|null ---@field public prohibitedCardNames string[]|null

View File

@ -80,7 +80,7 @@ local analepticSkill = fk.CreateActiveSkill{
name = "analeptic_skill", name = "analeptic_skill",
max_turn_use_time = 1, max_turn_use_time = 1,
can_use = function(self, player, card) can_use = function(self, player, card)
return self:withinTimesLimit(player, Player.HistoryTurn, card, player) return self:withinTimesLimit(player, Player.HistoryTurn, card, "analeptic", player)
end, end,
on_use = function(self, room, use) on_use = function(self, room, use)
if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then

View File

@ -50,14 +50,14 @@ local slashSkill = fk.CreateActiveSkill{
can_use = function(self, player, card) can_use = function(self, player, card)
return return
table.find(Fk:currentRoom().alive_players, function(p) table.find(Fk:currentRoom().alive_players, function(p)
return self:withinTimesLimit(player, Player.HistoryPhase, card, p) return self:withinTimesLimit(player, Player.HistoryPhase, card, "slash", p)
end) end)
end, end,
target_filter = function(self, to_select, selected, _, card) target_filter = function(self, to_select, selected, _, card)
if #selected < self:getMaxTargetNum(Self, card) then if #selected < self:getMaxTargetNum(Self, card) then
local player = Fk:currentRoom():getPlayerById(to_select) local player = Fk:currentRoom():getPlayerById(to_select)
return Self ~= player and self:withinDistanceLimit(Self, true, card, player) and return Self ~= player and self:withinDistanceLimit(Self, true, card, player) and
(#selected > 0 or self:withinTimesLimit(Self, Player.HistoryPhase, card, player)) (#selected > 0 or self:withinTimesLimit(Self, Player.HistoryPhase, card, "slash", player))
end end
end, end,
on_effect = function(self, room, effect) on_effect = function(self, room, effect)
@ -125,7 +125,7 @@ local jinkSkill = fk.CreateActiveSkill{
end, end,
on_effect = function(self, room, effect) on_effect = function(self, room, effect)
if effect.responseToEvent then if effect.responseToEvent then
effect.responseToEvent.isCanCellout = true effect.responseToEvent.isCancellOut = true
end end
end end
} }
@ -436,7 +436,7 @@ local nullificationSkill = fk.CreateActiveSkill{
end, end,
on_effect = function(self, room, effect) on_effect = function(self, room, effect)
if effect.responseToEvent then if effect.responseToEvent then
effect.responseToEvent.isCanCellout = true effect.responseToEvent.isCancellOut = true
end end
end end
} }