| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- --涉及到的相关属性在属性表配置
- WarFlag = {}
- local this = WarFlag;
- local filename = "WarFlag";
- function WarFlag.canUseWarFlagItem(actor, itemInfo)
- if itemInfo == nil then
- return true
- end
-
- local cfgItem = ConfigDataManager.getTable("cfg_item", "id",itemInfo.cfgid)[1]
- if cfgItem.useparam == nil then
- return true
- end
- local useParams = string.split(cfgItem.useparam, "#")
- if #useParams < 2 or useParams[2] ~= "20" then
- return true
- end
- local equipInfos = getallequipinfo(actor)
- local oldFlag = nil
- for key, equipInfo in pairs(equipInfos) do
- if equipInfo.equipindex ~= nil and equipInfo.equipindex ~= 0 and equipInfo.cfgid == 23100001 then
- oldFlag = equipInfo
- break
- end
- end
- if oldFlag == nil then
- messagebox(actor,"没有装备战旗,无法使用该道具")
- return false
- end
- return true
- end
- --设置当前sd 并同步客户端
- function WarFlag.useWarFlagItem(actor, cfgId, count)
- local cfgItem = ConfigDataManager.getTable("cfg_item", "id",cfgId)[1]
- if cfgItem.useparam == nil then
- return
- end
- local useParams = string.split(cfgItem.useparam, "#")
- if #useParams < 2 or useParams[2] ~= "20" then
- return
- end
- local newWarFlagId = tonumber(useParams[1])
- local equipInfos = getallequipinfo(actor)
- local oldFlag = nil
- for key, equipInfo in pairs(equipInfos) do
- if equipInfo.equipindex ~= nil and equipInfo.equipindex ~= 0 and equipInfo.cfgid == 23100001 then
- oldFlag = equipInfo
- break
- end
- end
- if oldFlag == nil then
- messagebox(actor,"没有装备战旗,无法使用该道具")
- additemtobag(actor, cfgId, count, 0, 9999, '战旗使用失败重新添加')
- return
- end
- local newItemId = additemtobag(actor, newWarFlagId, 1, 0, 9999, '战旗合成')
- local bagList = getallbagiteminfo(actor)
- local newEquip=nil
- for _, itemInfo in pairs(bagList) do
- if itemInfo.id == newItemId then
- newEquip = itemInfo
- break
- end
- end
- takeofftheequip(actor, oldFlag.equipindex)
- putontheequip(actor, newEquip.bagindex, oldFlag.equipindex)
- local bagIndex = gainbagidxbyitemid(actor, oldFlag.id)
- destroyitemafter(actor, bagIndex, "战旗合成")
- end
- function WarFlag.printTable(t, indent)
- indent = indent or 0
- local spaces = string.rep(" ", indent)
-
- for k, v in pairs(t) do
- if type(v) == "table" then
- print(spaces .. tostring(k) .. ":")
- printTable(v, indent + 4)
- else
- print(spaces .. tostring(k) .. " = " .. tostring(v))
- end
- end
- end
- -- function getitem(actor,cfgId)
- -- local config = ConfigDataManager.getById("cfg_fruit", cfgId)
- -- if config == nil or next(config) == nil then
- -- -- lg('果实表中没有找到主键', cfgId)
- -- return 0, 0
- -- end
- -- -- lg(cfgId, count)
- -- local hasCount = getbagitemcountbyid(actor, cfgId)
- -- -- lg('拥有道具' .. cfgId .. '数量' .. hasCount)
- -- -- 这里加上count是因为判断的逻辑在消耗了果实之后,要判断消耗之前的
- -- if tonumber(hasCount)== 0 then
- -- -- lg('道具数量不足')
- -- return 0, 0
- -- end
- -- local canUse = self:canUseFruit(actor, cfgId)
- -- if not canUse then
- -- return 0, 0
- -- end
- -- end
- -- 检查装备栏中是否存在指定cfgid的装备
- -- @param actor 玩家对象
- -- @param cfgArray 装备配置ID
- -- @return boolean 是否存在
- function WarFlag.hasEquipInSlot(equipInfos, cfgArray)
- if table.isNullOrEmpty(equipInfos) then
- return false
- end
- for _, equipInfo in pairs(equipInfos) do
- -- info("WarFlag: 身上的装备,cfgId:", equipInfo.cfgid)
- for _, cfgId in ipairs(cfgArray) do
- if equipInfo.cfgid == cfgId then
- return true
- end
- end
- end
-
- return false
- end
|