From 89c4f04db4947ea9a2858a091aa9fe8cbd6dce6e Mon Sep 17 00:00:00 2001 From: YoumuKon <38815081+YoumuKon@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=9D=E7=A6=BB=E6=98=BE=E7=A4=BA+=E6=97=A0?= =?UTF-8?q?=E6=8C=87=E7=A4=BA=E7=BA=BF=E5=B1=9E=E6=80=A7=20(#186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了距离显示的限制,现在可以显示玩家与自己之间0距离 - 为askForUseActiveSkill添加了是否取消指示线的参数 --- Fk/Pages/Room.qml | 2 +- Fk/RoomElement/Photo.qml | 4 ++-- lua/server/room.lua | 39 +++++++++++++++++++++++++++------------ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index f0dff654..1874bc06 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -866,7 +866,7 @@ Item { const dis = Backend.callLuaFunction("DistanceTo",[Self.id, item.playerid]); item.distance = parseInt(dis); } else { - item.distance = 0; + item.distance = -1; } } } diff --git a/Fk/RoomElement/Photo.qml b/Fk/RoomElement/Photo.qml index c054aedc..72617eeb 100644 --- a/Fk/RoomElement/Photo.qml +++ b/Fk/RoomElement/Photo.qml @@ -31,7 +31,7 @@ Item { property int drank: 0 property bool isOwner: false property bool ready: false - property int distance: 0 + property int distance: -1 property string status: "normal" property int maxCard: 0 @@ -567,7 +567,7 @@ Item { color: "white" height: 20 width: 20 - visible: distance != 0 + visible: distance != -1 Text { text: distance anchors.centerIn: parent diff --git a/lua/server/room.lua b/lua/server/room.lua index 7df048b6..50df3efa 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -878,10 +878,12 @@ end ---@param prompt string @ 烧条上面显示的提示文本内容 ---@param cancelable boolean @ 是否可以点取消 ---@param extra_data table @ 额外信息,因技能而异了 +---@param no_indicate boolean @ 是否不显示指示线 ---@return boolean, table -function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra_data) +function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra_data, no_indicate) prompt = prompt or "" cancelable = (cancelable == nil) and true or cancelable + no_indicate = (no_indicate == nil) and true or no_indicate extra_data = extra_data or {} local skill = Fk.skills[skill_name] if not (skill and (skill:isInstanceOf(ActiveSkill) or skill:isInstanceOf(ViewAsSkill))) then @@ -906,7 +908,9 @@ function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra local targets = data.targets local card_data = json.decode(card) local selected_cards = card_data.subcards - self:doIndicate(player.id, targets) + if not no_indicate then + self:doIndicate(player.id, targets) + end if skill.interaction then skill.interaction.data = data.interaction_data @@ -940,9 +944,11 @@ Room.askForUseViewAsSkill = Room.askForUseActiveSkill ---@param pattern string @ 弃牌需要符合的规则 ---@param prompt string @ 提示信息 ---@param skipDiscard boolean @ 是否跳过弃牌(即只询问选择可以弃置的牌) +---@param no_indicate boolean @ 是否不显示指示线 ---@return integer[] @ 弃掉的牌的id列表,可能是空的 -function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, skipDiscard) +function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, skipDiscard, no_indicate) cancelable = (cancelable == nil) and true or cancelable + no_indicate = no_indicate or false pattern = pattern or "" local canDiscards = table.filter( @@ -988,7 +994,7 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, can pattern = pattern, } local prompt = prompt or ("#AskForDiscard:::" .. maxNum .. ":" .. minNum) - local _, ret = self:askForUseActiveSkill(player, "discard_skill", prompt, cancelable, data) + local _, ret = self:askForUseActiveSkill(player, "discard_skill", prompt, cancelable, data, no_indicate) if ret then toDiscard = ret.cards @@ -1012,12 +1018,14 @@ end ---@param prompt string @ 提示信息 ---@param skillName string @ 技能名 ---@param cancelable boolean @ 能否点取消 +---@param no_indicate boolean @ 是否不显示指示线 ---@return integer[] @ 选择的玩家id列表,可能为空 -function Room:askForChoosePlayers(player, targets, minNum, maxNum, prompt, skillName, cancelable) +function Room:askForChoosePlayers(player, targets, minNum, maxNum, prompt, skillName, cancelable, no_indicate) if maxNum < 1 then return {} end cancelable = (cancelable == nil) and true or cancelable + no_indicate = no_indicate or false local data = { targets = targets, @@ -1026,7 +1034,7 @@ function Room:askForChoosePlayers(player, targets, minNum, maxNum, prompt, skill pattern = "", skillName = skillName } - local _, ret = self:askForUseActiveSkill(player, "choose_players_skill", prompt or "", cancelable, data) + local _, ret = self:askForUseActiveSkill(player, "choose_players_skill", prompt or "", cancelable, data, no_indicate) if ret then return ret.targets else @@ -1050,12 +1058,14 @@ end ---@param pattern string @ 选牌规则 ---@param prompt string @ 提示信息 ---@param expand_pile string @ 可选私人牌堆名称 +---@param no_indicate boolean @ 是否不显示指示线 ---@return integer[] @ 选择的牌的id列表,可能是空的 -function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, expand_pile) +function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancelable, pattern, prompt, expand_pile, no_indicate) if minNum < 1 then return nil end cancelable = (cancelable == nil) and true or cancelable + no_indicate = no_indicate or false pattern = pattern or "" local chosenCards = {} @@ -1068,7 +1078,7 @@ function Room:askForCard(player, minNum, maxNum, includeEquip, skillName, cancel expand_pile = expand_pile, } local prompt = prompt or ("#AskForCard:::" .. maxNum .. ":" .. minNum) - local _, ret = self:askForUseActiveSkill(player, "choose_cards_skill", prompt, cancelable, data) + local _, ret = self:askForUseActiveSkill(player, "choose_cards_skill", prompt, cancelable, no_indicate) if ret then chosenCards = ret.cards else @@ -1097,12 +1107,14 @@ end ---@param pattern string @ 选牌规则 ---@param prompt string @ 提示信息 ---@param cancelable boolean @ 能否点取消 +---@param no_indicate boolean @ 是否不显示指示线 ---@return integer[], integer -function Room:askForChooseCardAndPlayers(player, targets, minNum, maxNum, pattern, prompt, skillName, cancelable) +function Room:askForChooseCardAndPlayers(player, targets, minNum, maxNum, pattern, prompt, skillName, cancelable, no_indicate) if maxNum < 1 then return {} end cancelable = (cancelable == nil) and true or cancelable + no_indicate = no_indicate or false pattern = pattern or "." local pcards = table.filter(player:getCardIds({ Player.Hand, Player.Equip }), function(id) @@ -1118,7 +1130,7 @@ function Room:askForChooseCardAndPlayers(player, targets, minNum, maxNum, patter pattern = pattern, skillName = skillName } - local _, ret = self:askForUseActiveSkill(player, "choose_players_skill", prompt or "", cancelable, data) + local _, ret = self:askForUseActiveSkill(player, "choose_players_skill", prompt or "", cancelable, data, no_indicate) if ret then return ret.targets, ret.cards[1] else @@ -1758,12 +1770,14 @@ end ---@param skillName string @ 技能名 ---@param cancelable boolean|null @ 是否可以取消选择 ---@param flag string|null @ 限定可移动的区域,值为nil(装备区和判定区)、‘e’或‘j’ +---@param no_indicate boolean @ 是否不显示指示线 ---@return integer[] @ 选择的玩家id列表,可能为空 -function Room:askForChooseToMoveCardInBoard(player, prompt, skillName, cancelable, flag) +function Room:askForChooseToMoveCardInBoard(player, prompt, skillName, cancelable, flag, no_indicate) if flag then assert(flag == "e" or flag == "j") end cancelable = (cancelable == nil) and true or cancelable + no_indicate = (no_indicate == nil) and true or no_indicate local data = { flag = flag, @@ -1774,7 +1788,8 @@ function Room:askForChooseToMoveCardInBoard(player, prompt, skillName, cancelabl "choose_players_to_move_card_in_board", prompt or "", cancelable, - data + data, + no_indicate ) if ret then