修几个小bug
This commit is contained in:
notify 2023-06-18 16:24:12 +08:00 committed by GitHub
parent bd42f51b38
commit 0c9701b74a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 30 deletions

View File

@ -112,18 +112,27 @@ Flickable {
screenName.text = extra_data.photo.screenName; screenName.text = extra_data.photo.screenName;
const gamedata = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [id])); if (!config.observing) {
const total = gamedata[0]; const gamedata = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [id]));
const win = gamedata[1]; const total = gamedata[0];
const run = gamedata[2]; const win = gamedata[1];
const winRate = (win / total) * 100; const run = gamedata[2];
const runRate = (run / total) * 100; const winRate = (win / total) * 100;
playerGameData.text = Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2)) const runRate = (run / total) * 100;
.arg(runRate.toFixed(2)).arg(total); playerGameData.text = Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2))
.arg(runRate.toFixed(2)).arg(total);
}
const data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id])); const data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id]));
data.forEach(t => { data.forEach(t => {
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description) skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
}); });
const equips = JSON.parse(Backend.callLuaFunction("GetPlayerEquips", [id]));
equips.forEach(cid => {
const t = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
skillDesc.append("--------------------");
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + Backend.translate(":" + t.name));
});
} }
} }

View File

@ -216,25 +216,12 @@ end
function GetPlayerSkills(id) function GetPlayerSkills(id)
local p = ClientInstance:getPlayerById(id) local p = ClientInstance:getPlayerById(id)
local equip = {} return json.encode(table.map(p.player_skills, function(s)
local ret = {} return s.visible and {
table.forEach(p.player_skills, function(s) name = s.name,
if s:isEquipmentSkill() then description = Fk:getDescription(s.name),
table.insert(equip, s.attached_equip) } or nil
elseif s.visible then
table.insert(ret, {
name = s.name,
description = Fk:getDescription(s.name),
})
end
end)
table.insertTable(ret, table.map(equip, function(e)
return {
name = e,
description = Fk:getDescription(e),
}
end)) end))
return json.encode(ret)
end end
---@param card string | integer ---@param card string | integer
@ -572,6 +559,12 @@ function GetPlayerHandcards(pid)
return json.encode(p.player_cards[Player.Hand]) return json.encode(p.player_cards[Player.Hand])
end end
function GetPlayerEquips(pid)
local c = ClientInstance
local p = c:getPlayerById(pid)
return json.encode(p.player_cards[Player.Equip])
end
function ResetClientLua() function ResetClientLua()
local data = ClientInstance.room_settings local data = ClientInstance.room_settings
Self = ClientPlayer:new(fk.Self) Self = ClientPlayer:new(fk.Self)

View File

@ -710,10 +710,8 @@ function Room:doRaceRequest(command, players, jsonData)
if p.reply_cancel then if p.reply_cancel then
table.removeOne(players, p) table.removeOne(players, p)
table.insertIfNeed(canceled_players, p) table.insertIfNeed(canceled_players, p)
end elseif p.id > 0 then
-- 骗过调度器让他以为自己尚未就绪
-- 骗过调度器让他以为自己尚未就绪
if p.id > 0 then
p.request_timeout = remainTime - elapsed p.request_timeout = remainTime - elapsed
p.serverplayer:setThinking(true) p.serverplayer:setThinking(true)
end end

View File

@ -121,6 +121,8 @@ local function mainLoop()
-- verbose('[.] Sleeping for %d ms...', time) -- verbose('[.] Sleeping for %d ms...', time)
local cur = os.getms() local cur = os.getms()
time = math.min((time <= 0 and 9999999 or time), 200)
-- 调用RoomThread的trySleep函数开始真正的睡眠。会被wakeUp(c++)唤醒。 -- 调用RoomThread的trySleep函数开始真正的睡眠。会被wakeUp(c++)唤醒。
requestRoom.thread:trySleep(time) requestRoom.thread:trySleep(time)