From fcb6ce89a46333c93120498e22eb0f78fc4aeb41 Mon Sep 17 00:00:00 2001 From: jazuo <1421903681@qq.com> Date: Sat, 7 Jan 2023 15:20:44 +0800 Subject: [PATCH 1/2] fankui fankui and fix some bugs --- lua/server/gamelogic.lua | 2 +- packages/standard/init.lua | 23 +++++++++++++++++++++++ qml/Pages/RoomLogic.js | 4 ++-- src/ui/qmlbackend.cpp | 7 ++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lua/server/gamelogic.lua b/lua/server/gamelogic.lua index 8f58b48e..6c923f74 100644 --- a/lua/server/gamelogic.lua +++ b/lua/server/gamelogic.lua @@ -135,7 +135,7 @@ function GameLogic:prepareForStart() end for _, p in ipairs(room.alive_players) do - room:handleAddLoseSkills(p, "zhiheng|mashu", nil, false) + room:handleAddLoseSkills(p, "zhiheng|mashu|fankui", nil, false) end self:addTriggerSkill(GameRule) diff --git a/packages/standard/init.lua b/packages/standard/init.lua index 660aba96..96f7fa90 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -16,9 +16,32 @@ Fk:loadTranslationTable{ ["caocao"] = "曹操", } +local fankui = fk.CreateTriggerSkill{ + name = "fankui", + events = {fk.Damaged}, + frequency = Skill.NotFrequent, + can_trigger = function(self, event, target, player, data) + return target:hasSkill(self.name) + end, + on_trigger = function(self, event, target, player, data) + local damage = data.damage + local room = player.room + local from = room:getPlayerById(damage.from) + if event == fk.Damaged then + if from:isNude() then return false end + if room:askForSkillInvoke(target, self.name) then + local card = room:askForCardChosen(target, from, "he", self.name) + room:obtainCard(target.id, card, false, fk.ReasonPrey) + end + end + end +} + local simayi = General:new(extension, "simayi", "wei", 3) +simayi:addSkill(fankui) Fk:loadTranslationTable{ ["simayi"] = "司马懿", + ["fankui"] = "反馈", } local xiahoudun = General:new(extension, "xiahoudun", "wei", 4) diff --git a/qml/Pages/RoomLogic.js b/qml/Pages/RoomLogic.js index 46a3c336..a1c8f3e4 100644 --- a/qml/Pages/RoomLogic.js +++ b/qml/Pages/RoomLogic.js @@ -172,8 +172,8 @@ function moveCards(moves) { function setEmotion(id, emotion) { let path; if (OS === "Win") { - // Windows: file:/C:/xxx/xxxx - path = (SkinBank.PIXANIM_DIR + emotion).replace("file:/", ""); + // Windows: file:///C:/xxx/xxxx + path = (SkinBank.PIXANIM_DIR + emotion).replace("file:///", ""); } else { path = (SkinBank.PIXANIM_DIR + emotion).replace("file://", ""); } diff --git a/src/ui/qmlbackend.cpp b/src/ui/qmlbackend.cpp index 0f127846..2ba194b6 100644 --- a/src/ui/qmlbackend.cpp +++ b/src/ui/qmlbackend.cpp @@ -89,7 +89,12 @@ void QmlBackend::cd(const QString &path) { } QStringList QmlBackend::ls(const QString &dir) { - return QDir(QUrl(dir).path()).entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + QString d = dir; +#ifdef Q_OS_WIN + if (d.startsWith("file:///")) + d.replace(0, 8, "file://"); +#endif + return QDir(QUrl(d).path()).entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); } QString QmlBackend::pwd() { From 9f3c17b4050eb2a76f30b6e18f2bb226401c8113 Mon Sep 17 00:00:00 2001 From: notify Date: Sat, 7 Jan 2023 15:34:52 +0800 Subject: [PATCH 2/2] fix bug --- lua/server/room.lua | 18 ++++++++++-------- packages/standard/init.lua | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lua/server/room.lua b/lua/server/room.lua index 57a1f103..bb649f9c 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -1475,12 +1475,13 @@ function Room:damage(damageStruct) assert(type(damageStruct.to) == "number") local stages = { - [fk.PreDamage] = damageStruct.from, - [fk.DamageCaused] = damageStruct.from, - [fk.DamageInflicted] = damageStruct.to, + {fk.PreDamage, damageStruct.from}, + {fk.DamageCaused, damageStruct.from}, + {fk.DamageInflicted, damageStruct.to}, } - for event, playerId in ipairs(stages) do + for _, struct in ipairs(stages) do + local event, playerId = table.unpack(struct) local player = playerId and self:getPlayerById(playerId) or nil if self.logic:trigger(event, player, damageStruct) or damageStruct.damage < 1 then return false @@ -1500,12 +1501,13 @@ function Room:damage(damageStruct) end stages = { - [fk.Damage] = damageStruct.from, - [fk.Damaged] = damageStruct.to, - [fk.DamageFinished] = damageStruct.from, + {fk.Damage, damageStruct.from}, + {fk.Damaged, damageStruct.to}, + {fk.DamageFinished, damageStruct.from}, } - for event, playerId in ipairs(stages) do + for _, struct in ipairs(stages) do + local event, playerId = table.unpack(struct) local player = playerId and self:getPlayerById(playerId) or nil self.logic:trigger(event, player, damageStruct) end diff --git a/packages/standard/init.lua b/packages/standard/init.lua index 96f7fa90..11a30afb 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -21,22 +21,22 @@ local fankui = fk.CreateTriggerSkill{ events = {fk.Damaged}, frequency = Skill.NotFrequent, can_trigger = function(self, event, target, player, data) - return target:hasSkill(self.name) + local room = target.room + local from = room:getPlayerById(data.from) + return from ~= nil and + target == player and + target:hasSkill(self.name) end, on_trigger = function(self, event, target, player, data) - local damage = data.damage local room = player.room - local from = room:getPlayerById(damage.from) - if event == fk.Damaged then - if from:isNude() then return false end - if room:askForSkillInvoke(target, self.name) then - local card = room:askForCardChosen(target, from, "he", self.name) - room:obtainCard(target.id, card, false, fk.ReasonPrey) - end + local from = room:getPlayerById(data.from) + if (not from) or from:isNude() then return false end + if room:askForSkillInvoke(player, self.name) then + local card = room:askForCardChosen(player, from, "he", self.name) + room:obtainCard(player.id, card, false, fk.ReasonPrey) end end } - local simayi = General:new(extension, "simayi", "wei", 3) simayi:addSkill(fankui) Fk:loadTranslationTable{