| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- --涉及到的相关属性在属性表配置
- ItemExchange = {}
- local this = ItemExchange;
- local filename = "ItemExchange";
- local exchangeType = {
- [5] = {
- type = 5,
- items = {
- [50030001] = 20,
- [50030002] = 80,
- [50030003] = 50,
- [50030005] = 100,
- }
- },
- [2] = {
- type = 2,
- pos = {
- [1] = 1,
- [2] = 1,
- [3] = 1,
- [4] = 1,
- [5] = 1,
- [6] = 1,
- [7] = 1,
- [8] = 1,
- [9] = 1,
- },
- },
- }
- function ItemExchange.onLoginEnd(actor)
- end
- -- 回收
- function ItemExchange.exchange(actor, msgData)
- local allItemInfo = getallbagiteminfo(actor)
- if table.isEmpty(allItemInfo) then
- return
- end
- if table.isEmpty(msgData) then
- return
- end
- local allObtainList = {}
- local allequip = getplaydef(actor, "T$luaitemextdata")
- for bagIndex, count in pairs(msgData) do
- for _, itemInfo in pairs(allItemInfo) do
- if itemInfo.bagindex == tonumber(bagIndex) then
- local itemCfgId = itemInfo.cfgid
- local itemType = tonumber(ConfigDataManager.getTableValue("cfg_item", "type", "id", itemCfgId))
- local itemExchange = tonumber(ConfigDataManager.getTableValue("cfg_item", "itemExchange", "id", itemCfgId))
- local itemSubtype = tonumber(ConfigDataManager.getTableValue("cfg_item", "subType", "id", itemCfgId))
- local qutstanding = tonumber(ConfigDataManager.getTableValue("cfg_item", "Outstanding", "id", itemCfgId))
- local canExchange = true
- if itemExchange == nil or itemExchange == "" or tonumber(itemExchange) == 0 then
- canExchange = false
- end
- -- if itemType == 1 and exchangeType[itemType].items[itemCfgId] == nil then
- -- canExchange = false
- -- end
- -- if itemType == 2 and (exchangeType[itemType].pos[itemSubtype] == nil or qutstanding < 1) then
- -- canExchange = false
- -- end
- if canExchange == false then
- tipinfo(actor, "选择的道具中拥有不能兑换的道具,请重新选择")
- return
- end
- if not table.isNullOrEmpty(allequip) then
- local equipext = allequip[tonumber(itemInfo.id)]
- if not table.isNullOrEmpty(equipext) then
- allequip[tonumber(itemInfo.id)] = nil
- end
- end
- local cfgId = tostring(10020001)
- local num = itemExchange
- if itemType == 2 then
- num = num + EquipFunc.getEquipExchangeCost(itemInfo)
- if not string.isNullOrEmpty(qutstanding) and tonumber(qutstanding) >= 1 then
- local level = API.GetItemData(actor, itemInfo.id, "strengthlv") or 0
- if level > 3 then
- num = num + (level - 3) * 100
- end
- end
- end
- -- 乘以兑换数量
- num = num * count
- if allObtainList[cfgId] ~= nil then
- allObtainList[cfgId] = allObtainList[cfgId] + num
- else
- allObtainList[cfgId] = num
- end
- end
- end
- end
- itemrecovery(actor, msgData, allObtainList)
- sendluamsg(actor, LuaMessageIdToClient.RES_EXCHANGE_REWARD, allObtainList)
- sendluamsg(actor, LuaMessageIdToClient.COMMON_REWARD_PANEL, allObtainList)
- setplaydef(actor, "T$luaitemextdata", allequip)
- -- sendluamsg(actor,LuaMessageIdToClient.RES_ITEM_RECOVERY,allObtainList)
- end
|