| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- -- 装备图鉴
- local Msg = require("core.Msg")
- local EquipExcel = require("excel.equip").equip
- local EquipRareExcel = require("excel.equip").rare
- local ItemDefine = require("bag.ItemDefine")
- local Grid = require("bag.Grid")
- local EquipLogic = require("equip.EquipLogic")
- local BagLogic = require("bag.BagLogic")
- local EquipLogicGrid = require("equip.EquipLogicGrid")
- local Lang = require("common.Lang")
- local Broadcast = require("broadcast.Broadcast")
- local HeroLogic = require("hero.HeroLogic")
- local Util = require("common.Util")
- local HeroGrowUp = require("absAct.HeroGrowUp")
- local ObjHuman = require("core.ObjHuman")
- local TriggerLogic = require("trigger.TriggerLogic")
- local TriggerDefine = require("trigger.TriggerDefine")
- -- 取出合适的装备
- local function getEquipGrid(human, bagIndex, heroUuid, pos)
- local equipGrid = human.db.equipBag[bagIndex]
- if not equipGrid then
- -- 取英雄身上的
- local heroGrid, heroIndex = HeroLogic.getHeroGridByUuid(human, heroUuid)
- if not heroGrid then return end
- equipGrid = heroGrid.equip and heroGrid.equip[pos]
- return equipGrid, heroGrid, heroIndex
- end
- return equipGrid, nil, nil
- end
- -- 查询装备图鉴 全部信息
- function fenjieQuey(human, inputList)
- local indexTable = { }
- for i = 1, inputList[0] do
- local index = inputList[i]
- local equipGrid = human.db.equipBag[index]
- if not equipGrid then
- return
- end
- if not EquipRareExcel[equipGrid.quality] then return end
- if indexTable[index] then
- -- 重复id
- return
- end
- indexTable[index] = true
- end
- local itemList = { }
- for i = 1, inputList[0] do
- local index = inputList[i]
- local equipGrid = human.db.equipBag[index]
- local equipConfig = EquipExcel[equipGrid.id]
- if not equipConfig then return end
- for k, v in ipairs(EquipRareExcel[equipGrid.quality].disassembly) do
- itemList[v[1]] = itemList[v[1]] or 0
- itemList[v[1]] = itemList[v[1]] + v[2]
- end
- end
- local msgRet = Msg.gc.GC_EQUIP_FEN_JIE_QUERY
- local len = 0
- for k, v in pairs(itemList) do
- len = len + 1
- Grid.makeItem(msgRet.list[len], k, v)
- end
- msgRet.list[0] = len
- Msg.send(msgRet, human.fd)
- end
- -- 查询装备图鉴 全部信息
- function fenjieDo(human, inputList)
- local indexTable = { }
- for i = 1, inputList[0] do
- local index = inputList[i]
- local equipGrid = human.db.equipBag[index]
- if not equipGrid then
- return
- end
- if not EquipRareExcel[equipGrid.quality] then return end
- if indexTable[index] then
- -- 重复id
- return
- end
- indexTable[index] = true
- end
- local itemList = { }
- for i = 1, inputList[0] do
- local index = inputList[i]
- local equipGrid = human.db.equipBag[index]
- local equipConfig = EquipExcel[equipGrid.id]
- if not equipConfig then return end
- for k, v in ipairs(EquipRareExcel[equipGrid.quality].disassembly) do
- itemList[v[1]] = itemList[v[1]] or 0
- itemList[v[1]] = itemList[v[1]] + v[2]
- end
- EquipLogic.delEquip(human, index, "equip_fenjie")
- HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE21, 1)
- end
- BagLogic.addItemList(human, itemList, "equip_fenjie")
- local msgRet = Msg.gc.GC_EQUIP_FEN_JIE_DO
- Msg.send(msgRet, human.fd)
- end
- -- 洗练查询
- function randomQuery(human, bagIndex, heroUuid, pos)
- local equipGrid = getEquipGrid(human, bagIndex, heroUuid, pos)
- if not equipGrid then return end
- local rareExcel = EquipRareExcel[equipGrid.quality]
- if not rareExcel then return end
- local msgRet = Msg.gc.GC_EQUIP_RAMDOM_QUERY
- Grid.makeItem(msgRet.equipOld, equipGrid.id, 1, nil, equipGrid, bagIndex)
- -- 当前洗练属性
- local washAttr = equipGrid.washAttr
- local washQuality = equipGrid.washQuality
- msgRet.equipNew[0] = 0
- if washAttr and washQuality then
- local washEquipGrid = EquipLogicGrid.createTempGrid(equipGrid.id, equipGrid.washAttr, equipGrid.washQuality)
- Grid.makeItem(msgRet.equipNew[1], washEquipGrid.id, 1, nil, washEquipGrid, bagIndex)
- msgRet.equipNew[0] = 1
- end
- msgRet.needItem[0] = #rareExcel.rebirth
- for i = 1, msgRet.needItem[0] do
- Grid.makeItem(msgRet.needItem[i], rareExcel.rebirth[i][1], rareExcel.rebirth[i][2])
- end
- Msg.send(msgRet, human.fd)
- end
- -- 已穿戴的装备
- function putList(human, pos)
- local msgRet = Msg.gc.GC_EQUIP_PUT_LIST
- local cnt = 0
- for index = 1, human.db.heroBag[0] do
- local heroGrid = human.db.heroBag[index]
- if heroGrid and heroGrid.lv >= 2 then
- -- 所有部位
- if pos == 0 then
- for i = 1, ItemDefine.EQUIP_MAX_CNT do
- local equipGrid = heroGrid.equip and heroGrid.equip[i]
- if equipGrid then
- cnt = cnt + 1
- local net = msgRet.putList[cnt]
- if i ~= ItemDefine.EQUIP_SUBTYPE_SHUIJIN then
- Grid.makeItem(net.equip, equipGrid.id, 1, nil, equipGrid)
- net.pos = i
- end
- if cnt >= 10 then
- msgRet.isEnd = 0
- msgRet.putList[0] = cnt
- Msg.send(msgRet, human.fd)
- cnt = 0
- end
- end
- end
- else
- local equipGrid = heroGrid.equip and heroGrid.equip[pos]
- if equipGrid then
- cnt = cnt + 1
- local net = msgRet.putList[cnt]
- if i ~= ItemDefine.EQUIP_SUBTYPE_SHUIJIN then
- Grid.makeItem(net.equip, equipGrid.id, 1, nil, equipGrid)
- net.pos = pos
- end
- if cnt >= 10 then
- msgRet.isEnd = 0
- msgRet.putList[0] = cnt
- Msg.send(msgRet, human.fd)
- cnt = 0
- end
- end
- end
- end
- end
- msgRet.isEnd = 1
- msgRet.putList[0] = cnt
- Msg.send(msgRet, human.fd)
- end
- -- 洗练
- function randomDo(human, bagIndex, heroUuid, pos)
- local equipGrid = getEquipGrid(human, bagIndex, heroUuid, pos)
- if not equipGrid then return end
- local rareExcel = EquipRareExcel[equipGrid.quality]
- if not rareExcel then return end
- for i = 1, #rareExcel.rebirth do
- local needItemID = rareExcel.rebirth[i][1]
- local needItemCnt = rareExcel.rebirth[i][2]
- local nowItemCnt = BagLogic.getItemCnt(human, needItemID)
- if nowItemCnt < needItemCnt then
- return Broadcast.sendErr(human, Util.format(Lang.XIANZHI_NO_ITEM, ItemDefine.getValue(needItemID,"name")))
- end
- end
- for i = 1, #rareExcel.rebirth do
- local needItemID = rareExcel.rebirth[i][1]
- local needItemCnt = rareExcel.rebirth[i][2]
- BagLogic.delItem(human, needItemID, needItemCnt, "equip_wash")
- end
-
- local attr, quality = EquipLogic.randomAttr(equipGrid.id, true, equipGrid.quality)
- equipGrid.washAttr = attr
- equipGrid.washQuality = quality
- HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE19, 1)
- Broadcast.sendErr(human, Lang.EQUIP_WASH_RANDOM_SUC)
- randomQuery(human, bagIndex, heroUuid, pos)
- TriggerLogic.PublishEvent(TriggerDefine.EQUIP_REFINEMENT, human.db._id, 1)
- end
- -- 洗练保存
- function randomSave(human, bagIndex, heroUuid, pos)
- local equipGrid, heroGrid, heroIndex = getEquipGrid(human, bagIndex, heroUuid, pos)
- if not equipGrid then return end
- local washAttr = equipGrid.washAttr
- local washQuality = equipGrid.washQuality
- if not washAttr or not washQuality then return end
- equipGrid.attr = washAttr
- equipGrid.quality = washQuality
- equipGrid.washAttr = nil
- equipGrid.washQuality = nil
- EquipLogic.checkAttr(equipGrid)
- -- 更新背包的
- if not heroGrid then
- EquipLogic.sendEquipChange(human, bagIndex, equipGrid, EquipLogic.EQUIP_BAG_OP_CHANGE)
- end
- Broadcast.sendErr(human, Lang.EQUIP_WASH_SAVE_SUC)
- randomQuery(human, bagIndex, heroUuid, pos)
- --刷新属性
- if heroGrid and heroIndex and heroGrid.id then
- -- if not heroGrid or not heroIndex or not then
- -- return Broadcast.sendErr(human, Lang.DRILL_CHOOSE_FRIEND_ERR_INFO)
- -- end
- ObjHuman.doCalcHero(human, heroIndex)
- HeroLogic.sendHeroBagDynamic(human, heroGrid.id, heroIndex)
- end
- end
|