From 46176e2477526cf3855f7a54f16d756a14b86707 Mon Sep 17 00:00:00 2001 From: notify Date: Wed, 5 Apr 2023 02:21:59 +0800 Subject: [PATCH] Fixbug (#102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了势力没有实际赋值给Player的bug 修复了装备牌图标的存放位置 增加了mod中拓展势力的支持(其实就是加载图的位置罢了) --- lua/server/gamelogic.lua | 13 ++---- lua/server/room.lua | 16 +++++++ .../maneuvering/image}/card/equipIcon/fan.png | Bin .../image}/card/equipIcon/guding_blade.png | Bin .../image}/card/equipIcon/silver_lion.png | Bin .../image}/card/equipIcon/vine.png | Bin packages/maneuvering/init.lua | 16 ++++++- .../image}/card/equipIcon/axe.png | Bin .../image}/card/equipIcon/blade.png | Bin .../image}/card/equipIcon/crossbow.png | Bin .../image}/card/equipIcon/double_swords.png | Bin .../image}/card/equipIcon/eight_diagram.png | Bin .../image}/card/equipIcon/halberd.png | Bin .../image}/card/equipIcon/ice_sword.png | Bin .../image}/card/equipIcon/kylin_bow.png | Bin .../image}/card/equipIcon/nioh_shield.png | Bin .../image}/card/equipIcon/qinggang_sword.png | Bin .../image}/card/equipIcon/spear.png | Bin packages/test/init.lua | 2 + qml/Pages/RoomElement/GeneralCardItem.qml | 4 +- qml/Pages/RoomElement/Photo.qml | 6 +-- .../RoomElement/PhotoElement/EquipItem.qml | 2 +- qml/Pages/skin-bank.js | 42 ++++++++++++++++++ 23 files changed, 83 insertions(+), 18 deletions(-) rename {image => packages/maneuvering/image}/card/equipIcon/fan.png (100%) rename {image => packages/maneuvering/image}/card/equipIcon/guding_blade.png (100%) rename {image => packages/maneuvering/image}/card/equipIcon/silver_lion.png (100%) rename {image => packages/maneuvering/image}/card/equipIcon/vine.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/axe.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/blade.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/crossbow.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/double_swords.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/eight_diagram.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/halberd.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/ice_sword.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/kylin_bow.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/nioh_shield.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/qinggang_sword.png (100%) rename {image => packages/standard_cards/image}/card/equipIcon/spear.png (100%) diff --git a/lua/server/gamelogic.lua b/lua/server/gamelogic.lua index d88e935c..598b9838 100644 --- a/lua/server/gamelogic.lua +++ b/lua/server/gamelogic.lua @@ -68,13 +68,6 @@ end function GameLogic:chooseGenerals() local room = self.room local generalNum = room.settings.generalNum - local function setPlayerGeneral(player, general) - if Fk.generals[general] == nil then return end - player.general = general - player.gender = Fk.generals[general].gender - self.room:notifyProperty(player, player, "general") - self.room:broadcastProperty(player, "gender") - end local lord = room:getLord() local lord_general = nil if lord ~= nil then @@ -84,7 +77,7 @@ function GameLogic:chooseGenerals() generals[i] = generals[i].name end lord_general = room:askForGeneral(lord, generals) - setPlayerGeneral(lord, lord_general) + room:setPlayerGeneral(lord, lord_general, true) room:broadcastProperty(lord, "general") end @@ -105,9 +98,9 @@ function GameLogic:chooseGenerals() for _, p in ipairs(nonlord) do if p.general == "" and p.reply_ready then local general = json.decode(p.client_reply)[1] - setPlayerGeneral(p, general) + room:setPlayerGeneral(p, general, true) else - setPlayerGeneral(p, p.default_reply) + room:setPlayerGeneral(p, p.default_reply, true) end p.default_reply = "" end diff --git a/lua/server/room.lua b/lua/server/room.lua index 0dcd1b58..787cdf72 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -378,6 +378,22 @@ function Room:removeTag(tag_name) self.tag[tag_name] = nil end +---@param player ServerPlayer +---@param general string +---@param changeKingdom boolean +function Room:setPlayerGeneral(player, general, changeKingdom) + if Fk.generals[general] == nil then return end + player.general = general + player.gender = Fk.generals[general].gender + self:notifyProperty(player, player, "general") + self:broadcastProperty(player, "gender") + + if changeKingdom then + player.kingdom = Fk.generals[general].kingdom + self:broadcastProperty(player, "kingdom") + end +end + ------------------------------------------------------------------------ -- network functions, notify function ------------------------------------------------------------------------ diff --git a/image/card/equipIcon/fan.png b/packages/maneuvering/image/card/equipIcon/fan.png similarity index 100% rename from image/card/equipIcon/fan.png rename to packages/maneuvering/image/card/equipIcon/fan.png diff --git a/image/card/equipIcon/guding_blade.png b/packages/maneuvering/image/card/equipIcon/guding_blade.png similarity index 100% rename from image/card/equipIcon/guding_blade.png rename to packages/maneuvering/image/card/equipIcon/guding_blade.png diff --git a/image/card/equipIcon/silver_lion.png b/packages/maneuvering/image/card/equipIcon/silver_lion.png similarity index 100% rename from image/card/equipIcon/silver_lion.png rename to packages/maneuvering/image/card/equipIcon/silver_lion.png diff --git a/image/card/equipIcon/vine.png b/packages/maneuvering/image/card/equipIcon/vine.png similarity index 100% rename from image/card/equipIcon/vine.png rename to packages/maneuvering/image/card/equipIcon/vine.png diff --git a/packages/maneuvering/init.lua b/packages/maneuvering/init.lua index 2c51a77d..8aab7ece 100644 --- a/packages/maneuvering/init.lua +++ b/packages/maneuvering/init.lua @@ -188,6 +188,18 @@ local ironChainEffect = fk.CreateTriggerSkill{ end, } Fk:addSkill(ironChainEffect) + +local recast = fk.CreateActiveSkill{ + name = "recast", + target_num = 0, + on_use = function(self, room, effect) + local from = room:getPlayerById(effect.from) + room:throwCard(effect.cards, self.name, from) + room:drawCards(from, #effect.cards, self.name) + end +} +Fk:addSkill(recast) + local ironChainCardSkill = fk.CreateActiveSkill{ name = "iron_chain_skill", min_target_num = 1, @@ -198,11 +210,11 @@ local ironChainCardSkill = fk.CreateActiveSkill{ to:setChainState(not to.chained) end, } + local ironChain = fk.CreateTrickCard{ name = "iron_chain", skill = ironChainCardSkill, - -- FIXME! FIXME! FIXME! - special_skills = { "zhiheng" }, + special_skills = { "recast" }, } extension:addCards{ ironChain:clone(Card.Spade, 11), diff --git a/image/card/equipIcon/axe.png b/packages/standard_cards/image/card/equipIcon/axe.png similarity index 100% rename from image/card/equipIcon/axe.png rename to packages/standard_cards/image/card/equipIcon/axe.png diff --git a/image/card/equipIcon/blade.png b/packages/standard_cards/image/card/equipIcon/blade.png similarity index 100% rename from image/card/equipIcon/blade.png rename to packages/standard_cards/image/card/equipIcon/blade.png diff --git a/image/card/equipIcon/crossbow.png b/packages/standard_cards/image/card/equipIcon/crossbow.png similarity index 100% rename from image/card/equipIcon/crossbow.png rename to packages/standard_cards/image/card/equipIcon/crossbow.png diff --git a/image/card/equipIcon/double_swords.png b/packages/standard_cards/image/card/equipIcon/double_swords.png similarity index 100% rename from image/card/equipIcon/double_swords.png rename to packages/standard_cards/image/card/equipIcon/double_swords.png diff --git a/image/card/equipIcon/eight_diagram.png b/packages/standard_cards/image/card/equipIcon/eight_diagram.png similarity index 100% rename from image/card/equipIcon/eight_diagram.png rename to packages/standard_cards/image/card/equipIcon/eight_diagram.png diff --git a/image/card/equipIcon/halberd.png b/packages/standard_cards/image/card/equipIcon/halberd.png similarity index 100% rename from image/card/equipIcon/halberd.png rename to packages/standard_cards/image/card/equipIcon/halberd.png diff --git a/image/card/equipIcon/ice_sword.png b/packages/standard_cards/image/card/equipIcon/ice_sword.png similarity index 100% rename from image/card/equipIcon/ice_sword.png rename to packages/standard_cards/image/card/equipIcon/ice_sword.png diff --git a/image/card/equipIcon/kylin_bow.png b/packages/standard_cards/image/card/equipIcon/kylin_bow.png similarity index 100% rename from image/card/equipIcon/kylin_bow.png rename to packages/standard_cards/image/card/equipIcon/kylin_bow.png diff --git a/image/card/equipIcon/nioh_shield.png b/packages/standard_cards/image/card/equipIcon/nioh_shield.png similarity index 100% rename from image/card/equipIcon/nioh_shield.png rename to packages/standard_cards/image/card/equipIcon/nioh_shield.png diff --git a/image/card/equipIcon/qinggang_sword.png b/packages/standard_cards/image/card/equipIcon/qinggang_sword.png similarity index 100% rename from image/card/equipIcon/qinggang_sword.png rename to packages/standard_cards/image/card/equipIcon/qinggang_sword.png diff --git a/image/card/equipIcon/spear.png b/packages/standard_cards/image/card/equipIcon/spear.png similarity index 100% rename from image/card/equipIcon/spear.png rename to packages/standard_cards/image/card/equipIcon/spear.png diff --git a/packages/test/init.lua b/packages/test/init.lua index d876f235..804ee384 100644 --- a/packages/test/init.lua +++ b/packages/test/init.lua @@ -86,6 +86,8 @@ local test_active = fk.CreateActiveSkill{ -- room:closeAG(from) local cards = room:askForCardsChosen(from, from, 2, 3, "hej", "") from:addToPile(self.name, cards) + from.kingdom = "wei" + room:broadcastProperty(from, "kingdom") -- p(cards) end, } diff --git a/qml/Pages/RoomElement/GeneralCardItem.qml b/qml/Pages/RoomElement/GeneralCardItem.qml index aa7144c2..63a624b5 100644 --- a/qml/Pages/RoomElement/GeneralCardItem.qml +++ b/qml/Pages/RoomElement/GeneralCardItem.qml @@ -30,7 +30,7 @@ CardItem { } Image { - source: SkinBank.GENERALCARD_DIR + kingdom + source: SkinBank.getGeneralCardDir(kingdom) + kingdom } Row { @@ -40,7 +40,7 @@ CardItem { Repeater { model: (hp > 5 || hp !== maxHp) ? 1 : hp Image { - source: SkinBank.GENERALCARD_DIR + kingdom + "-magatama" + source: SkinBank.getGeneralCardDir(kingdom) + kingdom + "-magatama" } } diff --git a/qml/Pages/RoomElement/Photo.qml b/qml/Pages/RoomElement/Photo.qml index 0dfa13bd..09dd4919 100644 --- a/qml/Pages/RoomElement/Photo.qml +++ b/qml/Pages/RoomElement/Photo.qml @@ -108,7 +108,7 @@ Item { Image { id: back - source: SkinBank.PHOTO_BACK_DIR + root.kingdom + source: SkinBank.getPhotoBack(root.kingdom) } Text { @@ -525,8 +525,8 @@ Item { generalName.text = text; longGeneralName.text = ""; } - let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])); - kingdom = data.kingdom; + // let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])); + // kingdom = data.kingdom; } function chat(msg) { diff --git a/qml/Pages/RoomElement/PhotoElement/EquipItem.qml b/qml/Pages/RoomElement/PhotoElement/EquipItem.qml index 8c29787a..206ddab6 100644 --- a/qml/Pages/RoomElement/PhotoElement/EquipItem.qml +++ b/qml/Pages/RoomElement/PhotoElement/EquipItem.qml @@ -19,7 +19,7 @@ Item { anchors.verticalCenter: parent.verticalCenter x: 3 - source: icon ? SkinBank.EQUIP_ICON_DIR + icon : "" + source: icon ? SkinBank.getEquipIcon(cid, icon) : "" } Image { diff --git a/qml/Pages/skin-bank.js b/qml/Pages/skin-bank.js index 71c38db4..58d2cf11 100644 --- a/qml/Pages/skin-bank.js +++ b/qml/Pages/skin-bank.js @@ -42,3 +42,45 @@ function getCardPicture(cid) { } return CARD_DIR + "unknown.png"; } + +function getEquipIcon(cid, icon) { + let data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid])); + let extension = data.extension; + let name = icon || data.name; + let path = AppPath + "/packages/" + extension + "/image/card/equipIcon/" + name + ".png"; + if (Backend.exists(path)) { + return path; + } else { + for (let dir of Backend.ls(AppPath + "/packages/")) { + path = AppPath + "/packages/" + dir + "/image/card/equipIcon/" + name + ".png"; + if (Backend.exists(path)) return path; + } + } + return EQUIP_ICON_DIR + "unknown.png"; +} + +function getPhotoBack(kingdom) { + let path = PHOTO_BACK_DIR + kingdom + ".png"; + if (!Backend.exists(path)) { + for (let dir of Backend.ls(AppPath + "/packages/")) { + path = AppPath + "/packages/" + dir + "/image/kingdom/" + kingdom + "-back.png"; + if (Backend.exists(path)) return path; + } + } else { + return path; + } + return PHOTO_BACK_DIR + "qun"; +} + +function getGeneralCardDir(kingdom) { + let path = GENERALCARD_DIR + kingdom + ".png"; + if (!Backend.exists(path)) { + for (let dir of Backend.ls(AppPath + "/packages/")) { + path = AppPath + "/packages/" + dir + "/image/kingdom/" + kingdom + "-back.png"; + if (Backend.exists(path)) + return AppPath + "/packages/" + dir + "/image/kingdom/"; + } + } else { + return GENERALCARD_DIR; + } +}