From 37757abbadeea890fdb733e801d9ff48415ee119 Mon Sep 17 00:00:00 2001 From: notify Date: Sat, 24 Jun 2023 14:48:49 +0800 Subject: [PATCH] Bugfix2 (#209) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 拼点牌套壳虚拟牌; * 修复展示牌相关bug * 反选! * 不可用的手牌暂且下移 --- Fk/Config.qml | 3 +++ Fk/LobbyElement/AudioSetting.qml | 9 +++++++++ Fk/Pages/Room.qml | 7 ++++++- Fk/RoomElement/CardArea.qml | 4 ++-- Fk/RoomElement/Dashboard.qml | 20 ++++++++++++++++++++ Fk/RoomElement/HandcardArea.qml | 23 +++++++++++++---------- lua/client/i18n/zh_CN.lua | 1 + lua/server/events/pindian.lua | 13 ++++++++----- 8 files changed, 62 insertions(+), 18 deletions(-) diff --git a/Fk/Config.qml b/Fk/Config.qml index c854bc20..ad9bfb27 100644 --- a/Fk/Config.qml +++ b/Fk/Config.qml @@ -22,6 +22,7 @@ QtObject { property string ladyImg property real bgmVolume property bool disableMsgAudio + property bool hideUseless property var disabledGenerals: [] property int preferredTimeout @@ -60,6 +61,7 @@ QtObject { Backend.volume = conf.effectVolume ?? 50.; bgmVolume = conf.bgmVolume ?? 50.; disableMsgAudio = conf.disableMsgAudio ?? false; + hideUseless = conf.hideUseless ?? false; preferredTimeout = conf.preferredTimeout ?? 15; preferredLuckTime = conf.preferredLuckTime ?? 0; disabledGenerals = conf.disabledGenerals ?? []; @@ -84,6 +86,7 @@ QtObject { conf.effectVolume = Backend.volume; conf.bgmVolume = bgmVolume; conf.disableMsgAudio = disableMsgAudio; + conf.hideUseless = hideUseless; conf.preferredTimeout = preferredTimeout; conf.preferredLuckTime = preferredLuckTime; conf.disabledGenerals = disabledGenerals; diff --git a/Fk/LobbyElement/AudioSetting.qml b/Fk/LobbyElement/AudioSetting.qml index f7e45652..235bdd9d 100644 --- a/Fk/LobbyElement/AudioSetting.qml +++ b/Fk/LobbyElement/AudioSetting.qml @@ -38,4 +38,13 @@ ColumnLayout { checked: config.disableMsgAudio onCheckedChanged: config.disableMsgAudio = checked; } + + Switch { + text: Backend.translate("Hide unselectable cards") + checked: config.hideUseless + onCheckedChanged: { + config.hideUseless = checked; + } + } + } diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index cd268865..9d1df6ec 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -300,8 +300,13 @@ Item { anchors.bottom: parent.bottom ColumnLayout { MetroButton { - text: Backend.translate("Trust") + text: Backend.translate("Revert Selection") + enabled: dashboard.pending_skill !== "" + onClicked: dashboard.revertSelection(); } + // MetroButton { + // text: Backend.translate("Trust") + // } MetroButton { text: Backend.translate("Sort Cards") } diff --git a/Fk/RoomElement/CardArea.qml b/Fk/RoomElement/CardArea.qml index f35ceb19..54a7b1ce 100644 --- a/Fk/RoomElement/CardArea.qml +++ b/Fk/RoomElement/CardArea.qml @@ -23,8 +23,8 @@ Item { function remove(outputs) { let result = []; - for (let i = 0; i < cards.length; i++) { - for (let j = 0; j < outputs.length; j++) { + for (let j = 0; j < outputs.length; j++) { + for (let i = cards.length - 1; i >= 0; i--) { if (outputs[j] === cards[i].cid) { const state = JSON.parse(Backend.callLuaFunction("GetCardData", [cards[i].cid])); cards[i].setData(state); diff --git a/Fk/RoomElement/Dashboard.qml b/Fk/RoomElement/Dashboard.qml index 232fc6d5..c73152dc 100644 --- a/Fk/RoomElement/Dashboard.qml +++ b/Fk/RoomElement/Dashboard.qml @@ -240,6 +240,26 @@ RowLayout { } } + function revertSelection() { + if (pending_skill !== "") { + let to_select_cards = handcardAreaItem.cards.filter(cd => { + if (pendings.indexOf(cd.cid) === -1) { + return true; + } else { + cd.selected = !cd.selected; + cd.clicked(); + } + }); + + to_select_cards.forEach(cd => { + if (cd.selectable) { + cd.selected = !cd.selected; + cd.clicked(); + } + }); + } + } + function getSelectedCard() { if (pending_skill !== "") { return JSON.stringify({ diff --git a/Fk/RoomElement/HandcardArea.qml b/Fk/RoomElement/HandcardArea.qml index c9c20228..3b282ff1 100644 --- a/Fk/RoomElement/HandcardArea.qml +++ b/Fk/RoomElement/HandcardArea.qml @@ -55,30 +55,33 @@ Item { function enableCards(cardIds) { let card, i; - for (i = 0; i < cards.length; i++) { - card = cards[i]; + cards.forEach(card => { card.selectable = cardIds.contains(card.cid); if (!card.selectable) { card.selected = false; unselectCard(card); } - } + }); + updateCardPosition(true); } function updateCardPosition(animated) { cardArea.updateCardPosition(false); - let i, card; - for (i = 0; i < cards.length; i++) { - card = cards[i]; - if (card.selected) + cards.forEach(card => { + if (card.selected) { card.origY -= 20; - } + } + if (!card.selectable) { + if (config.hideUseless) { + card.origY += 60; + } + } + }); if (animated) { - for (i = 0; i < cards.length; i++) - cards[i].goBack(true) + cards.forEach(card => card.goBack(true)); } } diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index bd58b8f9..29082efb 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -23,6 +23,7 @@ Fk:loadTranslationTable{ ["BG Settings"] = "游戏背景", ["Audio Settings"] = "音频", ["Disable message audio"] = "禁用聊天语音", + ["Hide unselectable cards"] = "下移不可选卡牌", ["Back"] = "返回", ["Create Room"] = "创建房间", diff --git a/lua/server/events/pindian.lua b/lua/server/events/pindian.lua index d71998f3..2c9d4680 100644 --- a/lua/server/events/pindian.lua +++ b/lua/server/events/pindian.lua @@ -41,14 +41,17 @@ GameEvent.functions[GameEvent.Pindian] = function(self) local moveInfos = {} for _, p in ipairs(targets) do - local pindianCard + local _pindianCard if p.reply_ready then local replyCard = json.decode(p.client_reply).card - pindianCard = Fk:getCardById(json.decode(replyCard).subcards[1]) + _pindianCard = Fk:getCardById(json.decode(replyCard).subcards[1]) else - pindianCard = Fk:getCardById(p:getCardIds(Player.Hand)[1]) + _pindianCard = Fk:getCardById(p:getCardIds(Player.Hand)[1]) end + local pindianCard = _pindianCard:clone(_pindianCard.suit, _pindianCard.number) + pindianCard:addSubcard(_pindianCard.id) + if p == pindianData.from then pindianData.fromCard = pindianCard else @@ -57,7 +60,7 @@ GameEvent.functions[GameEvent.Pindian] = function(self) end table.insert(moveInfos, { - ids = { pindianCard.id }, + ids = { _pindianCard.id }, from = p.id, toArea = Card.Processing, moveReason = fk.ReasonPut, @@ -68,7 +71,7 @@ GameEvent.functions[GameEvent.Pindian] = function(self) room:sendLog{ type = "#ShowPindianCard", from = p.id, - card = { pindianCard.id }, + card = { _pindianCard.id }, } end