diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index 63c7e3db..2c50b6d7 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -269,7 +269,9 @@ Item { if (typeof card === "number" && card !== -1 && roomScene.state === "playing") { let skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [card])); - skills.unshift("_normal_use"); + if (JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id]))) { + skills.unshift("_normal_use"); + } specialCardSkills.model = skills; } else { specialCardSkills.model = []; @@ -359,7 +361,7 @@ Item { anchors.rightMargin: 20 color: "#88EEEEEE" radius: 8 - visible: roomScene.state == "playing" && specialCardSkills.count > 1 + visible: roomScene.state == "playing" && (specialCardSkills.count > 1 || specialCardSkills.model[0] !== "_normal_use") width: childrenRect.width height: childrenRect.height - 20 @@ -680,6 +682,10 @@ Item { } function getCurrentCardUseMethod() { + if (specialCardSkills.count === 1 && specialCardSkills.model[0] !== "_normal_use") { + return specialCardSkills.model[0]; + } + for (let i = 1; i < specialCardSkills.count; i++) { let item = specialCardSkills.itemAt(i); if (item.checked) { diff --git a/Fk/RoomElement/Dashboard.qml b/Fk/RoomElement/Dashboard.qml index 1d8c68fb..55247b1e 100644 --- a/Fk/RoomElement/Dashboard.qml +++ b/Fk/RoomElement/Dashboard.qml @@ -198,8 +198,19 @@ RowLayout { let ids = [], cards = handcardAreaItem.cards; for (let i = 0; i < cards.length; i++) { - if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id]))) + if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id]))) { ids.push(cards[i].cid); + } else { + // cannot use? considering special_skills + let skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [cards[i].cid])); + for (let j = 0; j < skills.length; j++) { + let s = skills[j]; + if (JSON.parse(Backend.callLuaFunction("ActiveCanUse", [s]))) { + ids.push(cards[i].cid); + break; + } + } + } } handcardAreaItem.enableCards(ids) if (pending_skill === "") { diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 8a2a36c2..b76650bf 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -196,6 +196,17 @@ function CanUseCard(card, player) player = ClientInstance:getPlayerById(player) local ret = c.skill:canUse(player, c) ret = ret and not player:prohibitUse(c) + if ret then + local min_target = c.skill:getMinTargetNum() + if min_target > 0 then + for _, p in ipairs(ClientInstance.players) do + if c.skill:targetFilter(p.id, {}, {}, c) then + return "true" + end + end + return "false" + end + end return json.encode(ret) end @@ -298,7 +309,11 @@ function ActiveCanUse(skill_name) local exp = Exppattern:Parse(skill.pattern) local cnames = {} for _, m in ipairs(exp.matchers) do - if m.name then table.insertTable(cnames, m.name) end + if m.name then + table.insertTable(cnames, m.name) + elseif m.trueName then + table.insertTable(cnames, m.trueName) + end end for _, n in ipairs(cnames) do local c = Fk:cloneCard(n)