12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024 |
- EquipAndAppear = {}
- local this = {}
- ---玩家装备信息记录
- local ROLE_EQUIP_INFO_RECORDE = "T$role_equip_info_recorde"
- local ROLE_EQUIP_STRENGTH_TIMES = "T$role_equip_strength_times"
- EquipAndAppear.RecordeType = {
- ---全身最大强化等级
- MAX_STRENGTH_LEVEL = 1,
- ---全身最大追加等级
- MAX_APPEND_LEVEL = 2,
- ---全身最大卓越词条数量
- MAX_ENTRY_COUNT = 3,
- ---全身最大首饰等级
- MAX_JEWELRY_LEVEL = 4
- }
- ---装备信息记录数据结构
- function this.GetNewEquipInfoRecorde()
- local recorde = {
- ---全身最大强化等级
- max_strength_level = 0,
- ---全身最大追加等级
- max_append_level = 0,
- ---全身最大卓越词条数量
- max_entry_count = 0,
- ---全身最大首饰等级
- max_jewelry_level = 0,
- }
- return recorde
- end
- function EquipAndAppear.GetEquipInfoRecorde(actor)
- local equipInfoRecorde = getplaydef(actor, ROLE_EQUIP_INFO_RECORDE)
- if equipInfoRecorde == nil then
- equipInfoRecorde = this.GetNewEquipInfoRecorde()
- end
- return equipInfoRecorde
- end
- function this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- setplaydef(actor, ROLE_EQUIP_INFO_RECORDE, equipInfoRecorde)
- end
- -- 保存角色外观(幻化也走这个方法)
- function EquipAndAppear.settingequipappear(actor, msgData)
- local equipappear = msgData["equipindex"]
- local data = {}
- for _, value in pairs(equipappear) do
- local pos = tonumber(value["slot"])
- local cfgId = tonumber(value["cfgId"])
- if pos ~= nil then
- data[pos] = cfgId
- end
- end
- setitemappeardata(actor, data)
- sendluamsg(actor, LuaMessageIdToClient.RES_SETTING_EQUIP_APPEAR, data)
- end
- -- 初始化角色外观
- function initequipppear(actor)
- local equipappear = {}
- setplaydef(actor, "T$equipappear", equipappear)
- end
- --获取角色外观
- function EquipAndAppear.getequipappear(actor, msgId)
- local data = getrolefield(actor, "role.roleappear.appear")
- if data == nil then
- return
- end
- local result = {}
- for key, value in pairs(data) do
- local appear = {}
- appear["slot"] = key
- appear["cfgId"] = value
- table.insert(result, appear)
- end
- --发送lua消息到客户端
- if LuaMessageIdToSever.GET_EQUIP_APPEAR == msgId then
- sendluamsg(actor, LuaMessageIdToClient.GET_EQUIP_APPEAR, result)
- end
- return result
- end
- -- 外观幻化激活
- function EquipAndAppear.equipfashion(actor, msgData)
- local cfgIds = msgData["cfgIds"]
- local equipFashion = getplaydef(actor, "T$equipfashion")
- if equipFashion == nil then
- equipFashion = {}
- end
- for _, cfgId in pairs(cfgIds) do
- local isExist = table.contains(equipFashion, cfgId)
- if isExist then
- --存在已激活的
- return
- end
- end
- --计算所有消耗
- local allData = getAllEquipAppearCost(cfgIds, 4)
- if allData == nil then
- return
- end
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, allData)
- if enough == false then
- return
- end
- --扣材料
- for _, v in ipairs(allData) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --保存幻化
- for _, v in pairs(cfgIds) do
- table.insert(equipFashion, v)
- end
- setplaydef(actor, "T$equipfashion", equipFashion)
- sendluamsg(actor, LuaMessageIdToClient.RES_ACT_EQUIP_FASHION, equipFashion)
- end
- --获取已激活外观
- function EquipAndAppear.getallequipfashion(actor)
- local equipFashion = getplaydef(actor, "T$equipfashion")
- sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_FASHION, equipFashion)
- end
- --激活染色
- function EquipAndAppear.actquipcolor(actor, msgData)
- local cfgIds = msgData["cfgIds"]
- local color = msgData["color"]
- --计算消耗材料
- local allCost = getAllEquipAppearCost(cfgIds, 5)
- if allCost == nil then
- return
- end
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, allCost)
- if enough == false then
- return
- end
- --扣材料
- for _, v in ipairs(allCost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --染色
- local equipcolor = EquipAndAppear.getequipcolor(actor, 0)
- for i, v in ipairs(cfgIds) do
- local num = 0
- for _, val in pairs(equipcolor) do
- if val["cfgid"] == v then
- table.insert(val["color"], color)
- num = num + 1
- break
- end
- end
- if num == 0 then
- local dt = {}
- dt["cfgid"] = v
- dt["color"] = {}
- table.insert(dt["color"], color)
- table.insert(equipcolor, dt)
- end
- end
- setplaydef(actor, "actequipcolor", equipcolor)
- end
- -- 保存染色
- function EquipAndAppear.settingequipcolor(actor, msgData)
- local cfgId = msgData["cfgid"]
- local color = msgData["color"]
- --先校验是否激活该颜色
- local actequipcolor = getplaydef(actor, "T$actequipcolor")
- local bool = false
- for _, v in pairs(actequipcolor) do
- local cId = v["cfgid"]
- if cId == cfgId then
- bool = table.contains(v["color"], color)
- break
- end
- end
- if bool ~= true then
- return
- end
- local equipcolor = EquipAndAppear.getequipcolor(actor, 0)
- for _, v in ipairs(equipcolor) do
- if v["cfgid"] == cfgId then
- v["color"] = color
- break
- end
- end
- setplaydef(actor, "T$equipcolor", equipcolor)
- end
- --获取角色染色数据
- function EquipAndAppear.getequipcolor(actor, msgId)
- local equipcolor = getplaydef(actor, "T$equipcolor")
- if equipcolor == nil then
- equipcolor = {}
- setplaydef(actor, "T$equipcolor", equipcolor)
- end
- local data = getplaydef(actor, "T$equipcolor")
- --发送lua消息到客户端
- if msgId == LuaMessageIdToClient.GET_EQUIP_COLOR then
- sendluamsg(actor, msgId, data)
- end
- return data
- end
- --计算所有消耗
- function getAllEquipAppearCost(cfgIds, type)
- local allData = {}
- for _, cfgId in pairs(cfgIds) do
- local cost = ConfigDataManager.getTableValue("cfg_fashion", "deplete", "id", cfgId, "type", type)
- if cost == nil then
- return nil
- end
- local data = splitbyshuxianandjinghao(cost)
- for _1, v in pairs(data) do
- local id = v["cfgid"]
- local count = v["count"]
- local num = 0;
- for _2, val in pairs(allData) do
- if val["cfgid"] == id then
- val["count"] = val["count"] + count
- num = num + 1
- break
- end
- end
- if num == 0 then
- local element = {}
- element["cfgid"] = id
- element["count"] = count
- table.insert(allData, element)
- end
- end
- end
- return allData
- end
- function EquipAndAppear.playerequipview(actor, otherActor)
- if otherActor == nil then
- return
- end
- --发送幻化染色数据
- local appear = EquipAndAppear.getequipappear(otherActor, 0)
- local title = EquipAndAppear.gettitleinfo(otherActor, 0)
- local alldata = {}
- alldata["appear"] = appear
- alldata["ring"] = EquipAndAppear.getnowwearshapering(otherActor)
- local curTitle = 0
- if not title.hidden then
- curTitle = title.curEquipTitle
- end
- alldata["title"] = curTitle
- local rid = getbaseinfo(otherActor, "rid")
- alldata["rid"] = rid
- sendluamsg(actor, LuaMessageIdToClient.OTHER_ROLE_APPEAR, alldata)
- end
- --玩家进入视野时发送玩家装备的强化信息
- function EquipAndAppear.playerequipstrength(actor, otherActor)
- if otherActor == 0 then
- otherActor = actor
- end
- local alldata = getplaydef(otherActor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(otherActor)
- local result = {}
- local info = {}
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- local equip = {}
- equip.itemid = itemId
- if data ~= nil then
- if data.strengthlv ~= nil then
- equip.strengthlv = data.strengthlv
- else
- equip.strengthlv = 0
- end
- else
- equip.strengthlv = 0
- end
- table.insert(info, equip)
- end
- result.rid = getbaseinfo(otherActor, "rid")
- result.equip = info
- result = table.valueConvertToString(result)
- sendrefluamsg(actor, LuaMessageIdToClient.RES_PLAYER_EQUIP_STRENGTHLV, result)
- end
- --检查表是否包含某个元素
- -- function table.contains(table, element)
- -- for _, value in pairs(table) do
- -- if value == element then
- -- return true
- -- end
- -- end
- -- return false
- -- end
- -- 分割字符串
- function splitbyshuxianandjinghao(str)
- local dt = {}
- local data = string.split(str, "|")
- for _, v in ipairs(data) do
- local data2 = string.split(v, "#")
- local v2 = {}
- v2["cfgid"] = data2[1]
- v2["count"] = data2[2]
- table.insert(dt, v2)
- end
- return dt
- end
- --称号入包
- function EquipAndAppear.titleenterbag(actor, configId)
- local itemList = ConfigDataManager.getTable("cfg_item", "id", configId)
- if itemList == nil then
- return
- end
- local item = itemList[1]
- if tonumber(item.type) ~= 2 or tonumber(item.subtype) ~= 15 then
- return
- end
- --计算时间
- local fashionList = ConfigDataManager.getTable("cfg_fashion", "id", configId)
- if fashionList == nil then
- return
- end
- if table.count(fashionList) == 0 then
- return
- end
- local fashion = fashionList[1]
- local titledata = EquipAndAppear.gettitleinfo(actor, 0)
- local titles = titledata.title
- --不限时
- local flag = true
- local time = 0
- local type = 0
- local timeType = tonumber(fashion.timetype)
- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- if timeType == 1 then
- type = 1
- for _, value in pairs(titles) do
- if value.confId == configId then
- value.obtainTime = nowTime --获得时间
- value.expiresTime = -1 --到期时间
- flag = false
- end
- end
- time = -1
- end
- --限时
- if timeType == 2 then
- type = 2
- --获取称号的有效期
- local times = fashion.time
- local timestr = string.split(times, "#")
- --总时间
- time = tonumber(timestr[1]) * 60 * 60 + tonumber(timestr[2]) * 60 + tonumber(timestr[3])
- for _, value in pairs(titles) do
- if value.confId == configId then
- value.obtainTime = nowTime --获得时间
- value.expiresTime = value.obtainTime + time --到期时间
- flag = false
- end
- end
- end
- --活动限时
- if timeType == 3 then
- type = 3
- --todo 获取称号的有效期
- local actId = fashion.time
- local actdata = getactivityinfo(actor, actId)
- time = math.ceil(actdata.nextopentime / 1000)
- for _, value in pairs(titles) do
- if value.confId == configId then
- value.obtainTime = nowTime --获得时间
- value.expiresTime = time --到期时间
- flag = false
- end
- end
- end
- if flag then
- local tt = {}
- tt.obtainTime = math.ceil(getbaseinfo("now") / 1000)
- if type == 1 or type == 3 then
- tt.expiresTime = time
- else
- tt.expiresTime = tt.obtainTime + time
- end
- tt.confId = configId
- table.insert(titles, tt)
- end
- setplaydef(actor, "T$titledata", titledata)
- --更新称号属性
- EquipAndAppear.updatetitleattr(actor)
- end
- --更新称号属性信息
- function EquipAndAppear.updatetitleattr(actor)
- local data = getplaydef(actor, "T$titledata")
- local titles = data.title
- local titleattr = {}
- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- for _, value in pairs(titles) do
- --先校验是否过期
- if value.expiresTime == -1 or value.expiresTime > nowTime then
- --计算属性
- local fashion = ConfigDataManager.getTable("cfg_fashion", "id", value.confId)
- local attr = fashion[1].att
- local str = string.split(attr, "|")
- for _, value in pairs(str) do
- local str2 = string.split(value, "#")
- local num = titleattr[str2[1]]
- local nowNum = str2[2]
- if num == nil then
- titleattr[str2[1]] = tonumber(nowNum)
- else
- titleattr[str2[1]] = tonumber(nowNum) + tonumber(num)
- end
- end
- end
- end
- --更新称号属性
- addrolekmlattributes(actor, "titleattr", titleattr)
- end
- --获取称号详细信息
- function EquipAndAppear.gettitleinfo(actor, msgId)
- local data = getplaydef(actor, "T$titledata")
- if data == nil then
- data = EquipAndAppear.inittitledata(actor)
- end
- if msgId == LuaMessageIdToSever.GET_TITLE then
- sendluamsg(actor, LuaMessageIdToClient.GET_TITLE, data)
- end
- return data
- end
- --保存称号外观
- function EquipAndAppear.settingtitleappear(actor, msgId, msgData)
- local data = getplaydef(actor, "T$titledata")
- local titleappear = msgData["title"]
- data.curEquipTitle = titleappear
- setplaydef(actor, "T$titledata", data)
- if msgId == LuaMessageIdToSever.SET_TITLE then
- sendluamsg(actor, LuaMessageIdToClient.SETTING_TITLE_APPEAR, titleappear)
- local result = {}
- result.rid = getbaseinfo(actor, "rid")
- result.curEquipTitle = titleappear
- sendrefluamsg(actor, LuaMessageIdToClient.RES_TITLE_CHANGE_UPDATE, result)
- end
- end
- --初始化数据
- function EquipAndAppear.inittitledata(actor)
- local data = {}
- data.title = {}
- data.hidden = false
- data.curEquipTitle = 0
- setplaydef(actor, "T$titledata", data)
- return data
- end
- --校验称号的过期时间
- function EquipAndAppear.checktitleovertime(actor)
- local data = getplaydef(actor, "T$titledata")
- if table.count(data) == 0 then
- data = EquipAndAppear.inittitledata(actor)
- end
- local titles = data.title
- if table.count(titles) == 0 then
- return
- end
- local curTitle = data.curEquipTitle
- local flag = false
- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- for key, value in pairs(titles) do
- --先校验是否过期
- --jprint("检查称号过期0",value.expiresTime > nowTime, value.expiresTime, nowTime)
- if value.expiresTime ~= -1 and value.expiresTime < nowTime then
- table.remove(titles, key)
- flag = true
- if curTitle == value.confId then
- data.curEquipTitle = 0
- end
- end
- end
- if flag then
- data.title = titles
- setplaydef(actor, "T$titledata", data)
- EquipAndAppear.updatetitleattr(actor)
- --发送消息
- sendluamsg(actor, LuaMessageIdToClient.SETTING_TITLE_APPEAR, 0)
- end
- end
- --获取守护外观
- function EquipAndAppear.getguardappear(actor, msgId)
- local data = getrolefield(actor, "role.roleEquip.guardAppear")
- if data == nil then
- sendluamsg(actor, LuaMessageIdToClient.RES_GUARD_APPEAR, {})
- return {}
- end
- local result = {}
- for key, value in pairs(data) do
- local mm = {}
- mm.att = value.attr
- mm.getTime = math.floor(value.getTime / 1000)
- mm.itemId = key
- if value.time ~= -1 then
- mm.time = mm.getTime + math.floor(value.time / 1000)
- else
- mm.time = -1
- end
- table.insert(result, mm)
- end
- if msgId == LuaMessageIdToSever.GET_GUARD_APPEAR then
- sendluamsg(actor, LuaMessageIdToClient.RES_GUARD_APPEAR, result)
- end
- return data
- end
- --获取变身戒指数据
- function EquipAndAppear.getshapering(actor, msgId)
- local data = getrolefield(actor, "role.roleEquip.shapeRing")
- if data == nil then
- return {}
- end
- local nowwear = EquipAndAppear.getnowwearshapering(actor)
- local rd = {}
- local result = {}
- rd.curWearRing = nowwear
- for key, value in pairs(data) do
- local mm = {}
- mm.monsterId = tonumber(key)
- mm.ringAttr = value.ringAttr
- mm.getTime = math.floor(value.getTime / 1000)
- mm.itemId = value.itemId
- if value.time ~= -1 then
- mm.time = math.floor(value.time / 1000)
- else
- mm.time = -1
- end
- table.insert(result, mm)
- end
- rd.title = result
- if msgId == LuaMessageIdToSever.GET_SHAPE_RING then
- sendluamsg(actor, LuaMessageIdToClient.GET_SHAPE_RING, rd)
- end
- return data
- end
- --穿戴变身戒指
- function EquipAndAppear.wearshapering(actor, msgData)
- local monsterId = msgData["monsterId"]
- setplaydef(actor, "T$wearshapering", monsterId)
- setshaperingdata(actor, monsterId)
- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, monsterId)
- local result = {}
- result.rid = getbaseinfo(actor, "rid")
- result.curEquipRing = monsterId
- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
- end
- --获取当前穿戴的变身戒指
- function EquipAndAppear.getnowwearshapering(actor)
- local data = getplaydef(actor, "T$wearshapering")
- if data == nil then
- return 0
- end
- return data
- end
- --校验变身戒指过期时间
- function EquipAndAppear.checkringovertime(actor)
- local data = EquipAndAppear.getshapering(actor)
- local ringId = EquipAndAppear.getnowwearshapering(actor)
- if ringId == 0 then
- return
- end
- local monsterId = ConfigDataManager.getTableValue("cfg_item", "useParam", "id", ringId)
- if not monsterId then
- return
- end
- if not data[tostring(monsterId)] then
- setplaydef(actor, "T$wearshapering", 0)
- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, 0)
- local result = {}
- result.rid = getbaseinfo(actor, "rid")
- result.curEquipRing = 0
- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
- end
- -- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- -- for index, ring in pairs(data) do
- -- if ring ~= -1 then
- -- --检查
- -- if nowTime > math.floor(ring.time / 1000) then
- -- --删除穿戴外观
- -- local ringId = EquipAndAppear.getnowwearshapering(actor)
- -- if ringId == ring then
- -- setplaydef(actor, "T$wearshapering", 0)
- -- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, 0)
- -- local result = {}
- -- result.rid = getbaseinfo(actor, "rid")
- -- result.curEquipRing = 0
- -- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
- -- end
- -- table.remove(data, index)
- -- end
- -- end
- -- end
- end
- function EquipAndAppear.initequipluaextdata(alldata, itemid)
- local equipdata = {}
- equipdata.strengthlv = 0
- equipdata.appendlv = 0
- equipdata.strengthattr = {}
- equipdata.appendattr = {}
- alldata[itemid] = equipdata
- end
- --装备强化
- function EquipAndAppear.luastrengthequip(actor, msgData)
- local itemid = msgData.itemId
- local equip = getequipinfo(actor, itemid, 1)
- if equip == nil then
- return
- end
- local alldata = EquipAndAppear.getLuaItemExtData(actor)
- local equipdata = alldata[itemid]
- if equipdata == nil then
- EquipAndAppear.initequipluaextdata(alldata, itemid)
- equipdata = alldata[itemid]
- end
- if equipdata.strengthlv == nil then
- equipdata.strengthlv = 0
- equipdata.strengthattr = {}
- end
- local lv = equipdata.strengthlv + 1
- local cfgId = equip.cfgid
- --首饰的强化等级特殊处理
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group ~= nil and group ~= "" then
- local strengthenmaxLevel = ConfigDataManager.getTableValue("cfg_equip_ornaments", "strengthenmaxLevel","ornamentsGroup", group, "lv", equipdata.ssuplv or 0)
- if tonumber(strengthenmaxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已强化到最大等级")
- return
- end
- else
- local maxLevel = ConfigDataManager.getTableValue("cfg_equip_strengthen", "maxLevel", "id", cfgId)
- if tonumber(maxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已强化到最大等级")
- return
- end
- end
- local costId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "costId", "id", cfgId)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "groupId", "id", cfgId)
- --获取消耗
- local coststr = ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "cost", "costGroupId", costId, "level", lv)
- if coststr == nil then
- return
- end
- local cost = splitbyshuxianandjinghao(coststr)
- --校验道具是否足够
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- TimeLimitGift.checkSpecial2Condition(actor)
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣材料
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- TimeLimitGift.checkSpecial2Count(actor)
- --获取成功率
- local rate = ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "rate", "costGroupId", costId, "level", lv)
- local randomNumber = math.random(1, 10000)
- rate = tonumber(rate)
- if rate < randomNumber then
- --失败,校验是否等级回退
- local failLevel = ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "failLevel", "costGroupId", costId, "level", lv)
- failLevel = tonumber(failLevel)
- if failLevel == equipdata.strengthlv then
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.strengthlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
- return
- end
- local att = ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", failLevel)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.strengthlv = failLevel
- equipdata.strengthattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- info(actor,"玩家",actor,"强化装备至" .. lv .. "级失败,失败后等级" .. failLevel,"道具id".. itemid,"cfgId:" .. cfgId)
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.strengthlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
- EquipMaster.strengthMaster(actor)
- --装备强化之后发送装备强化信息
- EquipAndAppear.updateequipgmext(actor, itemid, dddd.strengthlv)
- return
- end
- --获取属性加成
- local att = ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", lv)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.strengthlv = lv
- equipdata.strengthattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- local firstRate = ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "firstRate", "costGroupId", costId, "level", lv)
- firstRate = tonumber(firstRate)
- if firstRate == 1 then
- --发送跑马灯
- local name = getrolefield(actor, "role.basic.name")
- local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- local content = "恭喜" .. name .. "将" .. equipName .. "强化至" .. lv .. "级"
- local horseled = {}
- horseled.content = content
- horseled.cfgId = 109 -- 109是直接写死的
- sendluamsg(actor, LuaMessageIdToClient.HORSE_LAMP, horseled)
- end
- info(actor,"玩家",actor,"强化装备至" .. lv .. "级成功","道具id".. itemid,"cfgId:" .. cfgId)
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.strengthlv = tonumber(lv)
- dddd.issuccess = true
- sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
- EquipMaster.strengthMaster(actor)
- --记录强化次数
- local oldCount = EquipAndAppear.GetEquipStrengthCount(actor)
- setplaydef(actor, ROLE_EQUIP_STRENGTH_TIMES, oldCount + 1)
- ---触发装备强化任务
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- local taskParam = {
- part = strPart,
- level = lv
- }
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.PARTS_STRENGTHEN_LV, taskParam)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_STRENGTHEN_TIMES, lv)
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL)
- --装备强化之后发送装备强化信息
- EquipAndAppear.updateequipgmext(actor, itemid, dddd.strengthlv)
- end
- ---获取玩家装备累计强化次数
- function EquipAndAppear.GetEquipStrengthCount(actor)
- local totalCount = getplaydef(actor, ROLE_EQUIP_STRENGTH_TIMES)
- if totalCount == nil then
- totalCount = 0
- end
- return totalCount
- end
- function EquipAndAppear.updateequipgmext(actor, itemid, strengthlv)
- -- local gmext = getequipgmext(actor,itemid)
- -- if gmext == nil or gmext == "null" then
- -- gmext = {}
- -- end
- local gmext = {}
- gmext.strengthlv = strengthlv
- setequipgmext(actor, itemid, gmext)
- end
- function splitbyshuxianandjinghao2(str)
- local dt = {}
- local data = string.split(str, "|")
- for _, v in ipairs(data) do
- local data2 = string.split(v, "#")
- dt[data2[1]] = data2[2]
- end
- return dt
- end
- --装备追加
- function EquipAndAppear.luaappendequip(actor, msgData)
- local itemid = msgData.itemId
- local equip = getequipinfo(actor, itemid, 1)
- if equip == nil then
- return
- end
- local alldata = EquipAndAppear.getLuaItemExtData(actor)
- local equipdata = alldata[itemid]
- if equipdata == nil then
- EquipAndAppear.initequipluaextdata(alldata, itemid)
- equipdata = alldata[itemid]
- end
- if equipdata.appendlv == nil then
- equipdata.appendlv = 0
- equipdata.appendattr = {}
- end
- local lv = equipdata.appendlv + 1
- local cfgId = equip.cfgid
- --首饰的强化等级特殊处理
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group ~= nil and group ~= "" then
- local appendsmaxLevel = ConfigDataManager.getTableValue("cfg_equip_ornaments", "appendsmaxLevel","ornamentsGroup", group, "lv", equipdata.ssuplv or 0)
- if tonumber(appendsmaxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已追加到最大等级")
- return
- end
- else
- local maxLevel = ConfigDataManager.getTableValue("cfg_equip_appends", "maxLevel", "id", cfgId)
- if tonumber(maxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已追加到最大等级")
- return
- end
- end
- local costId = ConfigDataManager.getTableValue("cfg_equip_appends", "costId", "id", cfgId)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_appends", "groupId", "id", cfgId)
- --获取消耗
- local coststr = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "cost", "costGroupId", costId, "level", lv)
- if coststr == nil then
- return
- end
- local cost = splitbyshuxianandjinghao(coststr)
- --校验道具是否足够
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣材料
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --获取成功率
- local rate = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "rate", "costGroupId", costId, "level", lv)
- local randomNumber = math.random(1, 10000)
- rate = tonumber(rate)
- if rate < randomNumber then
- --失败,校验是否等级回退
- local failLevel = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "failLevel", "costGroupId", costId, "level", lv)
- failLevel = tonumber(failLevel)
- if failLevel == equipdata.appendlv then
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.appendlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
- return
- end
- local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", failLevel)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.appendlv = failLevel
- equipdata.appendattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.appendlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
- EquipMaster.appendMaster(actor)
- return
- end
- --获取属性加成
- local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", lv)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.appendlv = lv
- equipdata.appendattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- local firstRate = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "firstRate", "costGroupId", costId, "level", lv)
- firstRate = tonumber(firstRate)
- if firstRate == 1 then
- --发送跑马灯
- local name = getrolefield(actor, "role.basic.name")
- local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- local content = "恭喜" .. name .. "将" .. equipName .. "追加至" .. lv .. "级"
- local horseled = {}
- horseled.cfgId = 115
- horseled.content = content
- sendluamsg(actor, LuaMessageIdToClient.HORSE_LAMP, horseled)
- end
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.appendlv = tonumber(lv)
- dddd.issuccess = true
- sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
- EquipMaster.appendMaster(actor)
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_APPEND_LEVEL)
- -- 刷新任务进度
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- local taskParam = {
- part = strPart,
- level = lv
- }
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_APPEND, taskParam)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_APPEND_TOTAL_LV)
- end
- --- 获取所有装备数据
- function EquipAndAppear.getLuaItemExtData(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- if alldata == nil then
- --说明还没有进行过锻造
- setplaydef(actor, "T$luaitemextdata", {})
- alldata = getplaydef(actor, "T$luaitemextdata")
- end
- return alldata
- end
- --装备属性转移
- function EquipAndAppear.luatransferequip(actor, msgData)
- local firstId = msgData.firstItem
- local secId = msgData.secondItem
- local equip1 = getequipinfo(actor, firstId, 1)
- if equip1 == nil then
- return
- end
- local equip2 = getequipinfo(actor, secId, 1)
- if equip2 == nil then
- return
- end
- local id1 = equip1.cfgid
- local id2 = equip2.cfgid
- local data1 = ConfigDataManager.getTable("cfg_equip_transfer", "id", id1)
- local data2 = ConfigDataManager.getTable("cfg_equip_transfer", "id", id2)
- if (data1 == nil) or (data2 == nil) or (data1.transferGroup ~= data2.transferGroup) or (data1.transfer ~= data2.transfer) then
- return
- end
- local ts = msgData.transferStrength -- bool类型
- local ta = msgData.transferAppend
- local tr = msgData.transferRegeneration
- if not ts and not ta and not tr then
- return
- end
- --扩展数据
- local extdata = getplaydef(actor, "T$luaitemextdata")
- local ext1 = extdata[firstId]
- local ext2 = extdata[secId]
- if ext2 == nil then
- ext2 = {}
- ext2.appendattr = {}
- ext2.strengthattr = {}
- ext2.appendlv = 0
- ext2.strengthlv = 0
- end
- --转移前强化追加
- info(actor,"转移前强化追加等级,rid:",actor,"强化等级:",ext1.strengthlv,ext2.strengthlv,"追加等级:",ext1.appendlv,ext2.appendlv,"主装备id:"..firstId.."主装备cfgId:"..id1,"副装备id:"..secId.."副装备cfgId:"..id2)
- local allCost = {}
- --强化消耗
- if ts then
- local lv1 = ext1.strengthlv
- local lv2 = ext2.strengthlv
- if lv2 ~= 0 then
- return
- end
- local costItem = data1[1].strengthencost
- local cost = splittransfercoststr(costItem)
- local realLv = 0
- local realCost = {}
- for key, value in pairs(cost) do
- if key > realLv and key <= lv1 then
- realLv = key
- realCost = value
- end
- end
- table.insert(allCost, realCost)
- end
- if table.count(allCost[1]) == 0 then
- allCost[1] = {}
- end
- --追加消耗
- if ta then
- local lv1 = ext1.appendlv
- local lv2 = ext2.appendlv
- if lv2 ~= 0 then
- return
- end
- local costItem = data1[1].appendscost
- local cost = splittransfercoststr(costItem)
- local realLv = 0
- local realCost = {}
- for key, value in pairs(cost) do
- if key > realLv and key <= lv1 then
- realLv = key
- realCost = value
- end
- end
- for _, value in pairs(realCost) do
- local cId = value["cfgid"]
- local num = value["count"]
- local n = 0
- for _1, v in pairs(allCost[1]) do
- if v["cfgid"] == cId then
- v["count"] = v["count"] + num
- n = n + 1
- end
- end
- if n == 0 then
- table.insert(allCost[1], value)
- end
- end
- end
- --再生消耗
- if tr then
- local lv1 = ext1.regenerationlv
- local lv2 = ext2.regenerationlv
- if lv2 == nil then
- ext2.regenerationlv = 0
- lv2 = 0
- end
- if lv2 ~= 0 then
- return
- end
- local costItem = data1[1].regenerationcost
- local cost = splittransfercoststr(costItem)
- local realLv = 0
- local realCost = {}
- for key, value in pairs(cost) do
- if key > realLv and key <= lv1 then
- realLv = key
- realCost = value
- end
- end
- for _, value in pairs(realCost) do
- local cId = value["cfgid"]
- local num = value["count"]
- local n = 0
- for _1, v in pairs(allCost[1]) do
- if v["cfgid"] == cId then
- v["count"] = v["count"] + num
- n = n + 1
- end
- end
- if n == 0 then
- table.insert(allCost[1], value)
- end
- end
- end
- --检查道具是否足够
- local enough = Bag.checkItemEnough(actor, allCost[1])
- if not enough then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣道具
- for _, v in ipairs(allCost[1]) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --转移强化
- if ts then
- local slv1 = ext1.strengthlv
- ext2.strengthlv = slv1
- ext1.strengthlv = 0
- ext1.strengthattr = {}
- --赋值属性
- local maxLv = ConfigDataManager.getTableValue("cfg_equip_strengthen", "maxLevel", "id", equip2.cfgid)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "groupId", "id", equip2.cfgid)
- if ext2.strengthlv > tonumber(maxLv) then
- ext2.strengthlv = tonumber(maxLv)
- end
- local att = ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", ext2.strengthlv)
- local attr = splitbyshuxianandjinghao2(att)
- ext2.strengthattr = attr
- EquipAndAppear.updateequipgmext(actor, firstId, 0)
- EquipAndAppear.updateequipgmext(actor, secId, ext2.strengthlv)
- end
- --转移追加
- if ta then
- local slv1 = ext1.appendlv
- ext2.appendlv = slv1
- ext1.appendlv = 0
- ext1.appendattr = {}
- --赋值属性
- local maxLv = ConfigDataManager.getTableValue("cfg_equip_appends", "maxLevel", "id", equip2.cfgid)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_appends", "groupId", "id", equip2.cfgid)
- if ext2.appendlv > tonumber(maxLv) then
- ext2.appendlv = tonumber(maxLv)
- end
- local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", ext2.appendlv)
- local attr = splitbyshuxianandjinghao2(att)
- ext2.appendattr = attr
- end
- --转移再生
- if tr then
- local relv = ext1.regenerationlv
- ext2.regenerationlv = relv
- ext1.regenerationlv = 0
- ext2.regenerationattr = {}
- --赋值属性
- local maxLv = ConfigDataManager.getTableValue("cfg_equip_regeneration", "levelMax", "id", equip2.cfgid)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_regeneration", "Group", "id", equip2.cfgid)
- if ext2.regenerationlv > tonumber(maxLv) then
- ext2.regenerationlv = tonumber(maxLv)
- end
- local regeattr = ext1.regenerationattr
- for _, value in pairs(regeattr) do
- local id = value.id
- local regenerationgroup = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
- if table.count(regenerationgroup) ~= 0 then
- local sequence = regenerationgroup[1].sequence
- --找对应的表
- local nexttable = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "group", groupId, "sequence", sequence, "level", ext2.regenerationlv)
- if table.count(nexttable) ~= 0 then
- local att = nexttable[1].att
- local str = string.split(att, "#")
- local dd = {}
- dd[str[1]] = tonumber(str[2])
- dd.id = tonumber(nexttable[1].id)
- ext2.regenerationattr[tostring(table.count(ext2.regenerationattr) + 1)] = dd
- end
- end
- end
- ext1.regenerationattr = {}
- end
- --更新数据
- extdata[firstId] = ext1
- extdata[secId] = ext2
- EquipAndAppear.SetItemExtData(actor, firstId, ext1)
- EquipAndAppear.SetItemExtData(actor, secId, ext2)
- setplaydef(actor, "T$luaitemextdata", extdata)
- EquipAndAppear.updateluaextattr(actor)
- --转移后强化追加
- info(actor,"转移后强化追加等级,rid:",actor,"强化等级:",ext1.strengthlv,ext2.strengthlv,"追加等级:",ext1.appendlv,ext2.appendlv,"主装备id:"..firstId.."主装备cfgId:"..id1,"副装备id:"..secId.."副装备cfgId:"..id2)
- EquipMaster.transferTrigger(actor, equip1, equip2, ts, ta)
- --发送lua消息到客户端
- local data = {}
- data.oldItem = firstId
- data.newItem = secId
- data.issuccess = true
- sendluamsg(actor, LuaMessageIdToClient.RES_TRANSFER_EQUIP, data)
- end
- function EquipAndAppear.checkCanTransfer(actor, firstId, secId)
- if firstId == 0 then
- return
- end
- local data = {}
- data.oldItem = firstId
- data.newItem = secId
- sendluamsg(actor, LuaMessageIdToClient.RES_CAN_TRANSFER, data)
- end
- function splittransfercoststr(str)
- local s = string.split(str, "|")
- local data = {}
- for _, value in pairs(s) do
- local x = string.split(value, "#")
- local len = #x
- local itemList = {}
- if len == 3 then
- local item = {}
- item["cfgid"] = x[2]
- item["count"] = x[3]
- table.insert(itemList, item)
- else
- if len > 3 then
- for i = 1, len do
- local item = {}
- if i == 1 then
- item["cfgid"] = x[i + 1]
- item["count"] = x[i + 2]
- i = i + 3
- else
- item["cfgid"] = x[i]
- item["count"] = x[i + 1]
- i = i + 2
- end
- table.insert(itemList, item)
- end
- end
- end
- data[tonumber(x[1])] = itemList
- end
- return data
- end
- function EquipAndAppear.updateluaextattr(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(actor)
- local allattr = {}
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- if data ~= nil then
- --将该装备的属性加到角色身上
- if data.strengthlv ~= nil then
- local strengthattr = data.strengthattr
- table.mergeAdd(allattr, strengthattr)
- end
- if data.appendlv ~= nil then
- local appendattr = data.appendattr
- table.mergeAdd(allattr, appendattr)
- end
- if data.ssuplv ~= nil then
- local ssupattr = data.ssupattr
- local ssactattr = data.ssactattr
- table.mergeAdd(allattr, ssupattr)
- table.mergeAdd(allattr, ssactattr)
- end
- if data.regenerationlv ~= nil then
- local reattr = data.regenerationattr
- local regenerationattr = {}
- for _, att in pairs(reattr) do
- for key, value in pairs(att) do
- if key ~= "id" then
- local num = regenerationattr[key]
- if num == nil then
- num = 0
- end
- regenerationattr[key] = num + value
- end
- end
- end
- table.mergeAdd(allattr, regenerationattr)
- end
- end
- end
- --更新装备记录
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_ENTRY_COUNT)
- --记录强化追加等属性
- if table.count(allattr) == 0 then
- addrolekmlattributes(actor, "luaextdataforever", {})
- return
- end
- addrolekmlattributes(actor, "luaextdataforever", allattr)
- end
- --首饰升级
- function EquipAndAppear.ssupdate(actor, msgData)
- local itemId = msgData["itemId"]
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local equipext = allequip[itemId]
- if equipext == nil then
- equipext = {}
- end
- if equipext.ssuplv == nil then
- equipext.ssupattr = {}
- equipext.ssuplv = 0
- equipext.ssactlv = {}
- equipext.ssactattr = {}
- end
- local equip = getequipinfo(actor, itemId, 1)
- local cfgId = equip.cfgid
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group == nil then
- return
- end
- local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", equipext.ssuplv)
- if ornaments == nil or table.count(ornaments) == 0 then
- return
- end
- local data = ornaments[1]
- local cost = data.lvdeplete
- local costItem = splitbyshuxianandjinghao(cost)
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, costItem)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣材料
- for _, v in ipairs(costItem) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --升级,加属性
- equipext.ssuplv = tonumber(data.lv) + 1
- local att = data.basicatt
- local attr = splitbyshuxianandjinghao2(att)
- equipext.ssupattr = attr
- allequip[itemId] = equipext
- EquipAndAppear.SetItemExtData(actor, itemId, equipext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- --升级成功 回包给客户端
- local result = {}
- result.ssupattr = equipext.ssupattr
- result.ssuplv = tostring(equipext.ssuplv)
- result.ssactlv = equipext.ssactlv
- result.ssactattr = equipext.ssactattr
- result.itemId = itemId
- sendluamsg(actor, LuaMessageIdToClient.RES_UPDATE_EQUIP_ORNAMENTS, result)
- --更新属性
- EquipAndAppear.updateluaextattr(actor)
- --更新等级记录
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL)
- -- 刷新任务进度
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.JEWELRY_LV_UP)
- end
- --首饰等级属性激活
- function EquipAndAppear.actssattr(actor, msgData)
- local itemId = msgData["itemId"]
- local lv = msgData["lv"]
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local equipext = allequip[itemId]
- if equipext.ssuplv == nil then
- return
- end
- local equip = getequipinfo(actor, itemId, 1)
- local cfgId = equip.cfgid
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- local ssuplv = equipext.ssuplv
- if ssuplv < lv then
- return
- end
- if table.contains(equipext.ssactlv, lv) then
- return
- end
- local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", lv)
- if table.count(ornaments) == 0 then
- return
- end
- if ornaments[1].unlockdeplete == nil then
- return
- end
- local unlockDeplete = ornaments[1].unlockdeplete
- if unlockDeplete == nil then
- return
- end
- local costItem = splitbyshuxianandjinghao(unlockDeplete)
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, costItem)
- if enough == false then
- return
- end
- --扣材料
- for _, v in ipairs(costItem) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- equipext.ssactlv[tostring(lv)] = lv
- local att = ornaments[1].excellenceatt
- local attr = splitbyshuxianandjinghao2(att)
- table.mergeAdd(equipext.ssactattr, attr)
- allequip[itemId] = equipext
- EquipAndAppear.SetItemExtData(actor, itemId, equipext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- --发送回包给客户端
- local result = {}
- result.ssupattr = equipext.ssupattr
- result.ssuplv = equipext.ssuplv
- result.ssactlv = equipext.ssactlv
- result.ssactattr = equipext.ssactattr
- result.itemId = itemId
- sendluamsg(actor, LuaMessageIdToClient.RES_ACT_EQUIP_ORNAMENTS, result)
- --更新属性
- EquipAndAppear.updateluaextattr(actor)
- end
- function EquipAndAppear.allequipstrengthlv(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(actor)
- local allequipstrengthlv = 0
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- if data ~= nil then
- if data.strengthlv ~= nil then
- allequipstrengthlv = allequipstrengthlv + data.strengthlv
- end
- end
- end
- return allequipstrengthlv
- end
- --再生
- function EquipAndAppear.regeneration(actor, msgData)
- local itemId = msgData["itemId"]
- local equip = getequipinfo(actor, itemId, 1)
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local ext = allequip[itemId]
- if ext == nil then
- ext = {}
- ext.regenerationlv = 0
- ext.regenerationattr = {}
- end
- if ext.regenerationlv == nil then
- ext.regenerationlv = 0
- ext.regenerationattr = {}
- end
- local lv = ext.regenerationlv
- local tabledata = ConfigDataManager.getTable("cfg_equip_regeneration", "id", equip.cfgid)
- if table.count(tabledata) == 0 then
- return
- end
- local group = tabledata[1].group
- --获取消耗
- local lockattr = msgData["lockattrpos"]
- local startcost = {}
- local type = 0
- if table.count(ext.regenerationattr) == 0 then
- startcost = tabledata[1].start
- type = 1
- else
- if table.count(lockattr) == 0 then
- startcost = tabledata[1].again
- type = 2
- else
- startcost = tabledata[1].lock
- type = 3
- end
- end
- local cost = getlockcost(startcost, lockattr)
- --校验道具是否足够
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣道具
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --随机词条数量
- local attrNum = {}
- if type == 1 then
- attrNum = tabledata[1].startnum
- else
- if type == 2 then
- attrNum = tabledata[1].againnum
- else
- if type == 3 then
- attrNum = tabledata[1].locknum
- end
- end
- end
- local result = random_weighted(attrNum, 1)
- if lv == 0 then
- lv = 1
- end
- --校验词条数是否超过最大值
- local maxAttrNum = tabledata[1].count
- local realNum = result[1] + table.count(lockattr)
- if realNum >= tonumber(maxAttrNum) then
- realNum = tonumber(maxAttrNum) - table.count(lockattr)
- else
- realNum = result[1]
- end
- local attdata = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "group", group, "level", lv)
- local entrytable = build_weight_attr(attdata, ext.regenerationattr, lockattr)
- local entryattr = random_weighted(entrytable, realNum)
- --把这次结果临时存一下
- local xilianattr = {}
- for _, key in pairs(lockattr) do
- xilianattr[tostring(table.count(xilianattr) + 1)] = tonumber(key)
- end
- for _, key in pairs(entryattr) do
- xilianattr[tostring(table.count(xilianattr) + 1)] = tonumber(key)
- end
- local allequiprecord = getplaydef(actor, "T$regeneration")
- if allequiprecord == nil then
- allequiprecord = {}
- end
- local regenerationresult = {}
- regenerationresult.entryAttr = xilianattr
- regenerationresult.itemId = itemId
- allequiprecord[itemId] = regenerationresult
- setplaydef(actor, "T$regeneration", allequiprecord)
- allequip[itemId] = ext
- setplaydef(actor, "T$luaitemextdata", allequip)
- --告诉客户端本次洗练结果
- sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_REGENERATION, xilianattr)
- end
- function EquipAndAppear.getupregenerationattr(actor, msgData)
- local itemId = msgData.itemId
- local data = getplaydef(actor, "T$regeneration")
- if data == nil then
- sendluamsg(actor, LuaMessageIdToClient.RES_UP_REGENERATION_ATTR, {})
- return
- end
- local result = data[itemId]
- if result == nil then
- result = {}
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_UP_REGENERATION_ATTR, result)
- end
- --确认替换词条
- function EquipAndAppear.confirmreplaceentry(actor, msgData)
- -- local lockattr = msgData.lockattrpos
- local itemId = msgData.itemId
- local alldata = getplaydef(actor, "T$regeneration")
- if alldata == nil then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "洗练后再进行替换!")
- return
- end
- local data = alldata[itemId]
- if data == nil then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "洗练后再进行替换!")
- return
- end
- if data.itemId ~= itemId then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "两次itemId不一致!")
- return
- end
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local ext = allequip[itemId]
- ext.regenerationattr = {}
- for _, id in pairs(data.entryAttr) do
- local td = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
- if table.count(td) ~= 0 then
- local attr = td[1].att
- local str = string.split(attr, "#")
- local dd = {}
- dd[str[1]] = tonumber(str[2])
- dd.id = id
- ext.regenerationattr[tostring(table.count(ext.regenerationattr) + 1)] = dd
- ext.regenerationlv = tonumber(td[1].level)
- end
- end
- allequip[itemId] = ext
- EquipAndAppear.SetItemExtData(actor, itemId, ext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- alldata[itemId] = {}
- setplaydef(actor, "T$regeneration", alldata)
- --给客户端发替换结果
- sendluamsg(actor, LuaMessageIdToClient.RES_REPLACE_REGENERATION_ATTR, true)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- end
- --词条强化
- function EquipAndAppear.strengthregenerationattr(actor, msgData)
- local itemId = msgData.itemId
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local ext = allequip[itemId]
- local equip = getequipinfo(actor, itemId, 1)
- local group = ConfigDataManager.getTableValue("cfg_equip_regeneration", "group", "id", equip.cfgid)
- local lv = ext.regenerationlv
- local data = ConfigDataManager.getTable("cfg_equip_regenerationCost", "group", group, "level", lv)
- if table.count(data) == 0 then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "当前装备词条不能强化!")
- return
- end
- local maxLevel = ConfigDataManager.getTableValue("cfg_equip_regeneration", "levelMax", "id", equip.cfgid)
- if tonumber(maxLevel) < lv + 1 then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已再生到最大等级")
- return
- end
- local str = data[1].cost
- local cost = splitbyshuxianandjinghao(str)
- --检查材料
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣道具
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, '装备外观')
- end
- --计算成功率
- local rate = data[1].rate
- local randomNum = math.random(1, 10000)
- if randomNum > tonumber(rate) then
- --强化失败
- sendluamsg(actor, LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR, false)
- return
- end
- --强化成功增加属性
- local regenerationattr = ext.regenerationattr
- for i, value in pairs(regenerationattr) do
- local key = value.id
- local data = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", key)
- if table.count(data) ~= 0 then
- local sequence = data[1].sequence
- --查找下一级属性
- local nextdata = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "group", group, "sequence", sequence, "level", lv + 1)
- if table.count(nextdata) ~= 0 then
- local att = nextdata[1].att
- local attr = string.split(att, "#")
- local dd = {}
- dd[attr[1]] = tonumber(attr[2])
- dd.id = tonumber(nextdata[1].id)
- ext.regenerationattr[i] = dd
- -- table.remove(ext.regenerationattr,key)
- end
- end
- end
- ext.regenerationlv = lv + 1
- allequip[itemId] = ext
- EquipAndAppear.SetItemExtData(actor, itemId, ext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- --给客户端发消息
- sendluamsg(actor, LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR, true)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- --更新洗练未替换的数据
- updateregenoreplaceattr(actor, itemId, ext.regenerationlv, group)
- end
- function updateregenoreplaceattr(actor, itemId, lv, group)
- local alldata = getplaydef(actor, "T$regeneration")
- if alldata == nil then
- return
- end
- local data = alldata[itemId]
- if data == nil then
- return
- end
- local attrs = data.entryAttr
- if attrs == nil then
- return
- end
- for i, id in pairs(data.entryAttr) do
- local td = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
- if table.count(td) ~= 0 then
- local sequence = td[1].sequence
- --查找对应等级属性
- local nextdata = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "group", group, "sequence", sequence, "level", lv)
- if table.count(nextdata) ~= 0 then
- attrs[i] = tonumber(nextdata[1].id)
- end
- end
- end
- data.entryAttr = attrs
- alldata[itemId] = data
- setplaydef(actor, "T$regeneration", alldata)
- end
- function mergeitemcost(cost, lockcost)
- for _, item in pairs(lockcost) do
- local flag = true
- for _, value in pairs(cost) do
- if item.cfgid == value.cfgid then
- value.count = value.count + item.count
- flag = false
- end
- end
- if flag then
- table.insert(cost, item)
- end
- end
- return cost
- end
- function getlockcost(cost, lockattr)
- local result = {}
- local locknum = table.count(lockattr)
- local lc = string.split(cost, "|")
- local str = {}
- if locknum ~= 0 then
- str = string.split(lc[locknum], "&")
- for _, value in pairs(str) do
- local item = string.split(value, "#")
- local i = {}
- i.cfgid = item[1]
- i.count = item[2]
- table.insert(result, i)
- end
- else
- result = splitbyshuxianandjinghao(cost)
- end
- return result
- end
- --根据权重随机词条数量
- function random_weighted(weight_str, count)
- local result = {}
- if count <= 0 then
- return result
- end
- local num = string.split(weight_str, "&")
- local weight_total = 0
- for _, value in pairs(num) do
- local sum = string.split(value, "#")
- weight_total = weight_total + tonumber(sum[2])
- end
- local random_weight = math.random(1, weight_total)
- local cumulative_weight = 0
- for _, value in pairs(num) do
- local sum = string.split(value, "#")
- local weight = tonumber(sum[2])
- cumulative_weight = cumulative_weight + weight
- if cumulative_weight >= random_weight then
- table.insert(result, tonumber(sum[1]))
- if table.count(result) == count then
- return result
- end
- end
- end
- end
- --构造随机词条权重库
- function build_weight_attr(attdata, regenenrationattr, lockattr)
- local entrystr = ""
- for i, value in pairs(attdata) do
- local len = #entrystr
- local id = value.id
- local flag = true
- for _, k in pairs(lockattr) do
- if k == id then
- table.remove(attdata, i)
- flag = false
- end
- end
- if flag then
- local weight = 0
- for key, v in pairs(regenenrationattr) do
- if key == id then
- weight = value.weightdown
- end
- end
- if weight == 0 then
- weight = value.weight
- end
- if len == 0 then
- entrystr = id .. "#" .. weight
- else
- entrystr = entrystr .. "&" .. id .. "#" .. weight
- end
- end
- end
- return entrystr
- end
- function getequipssumstrengthlvtest(actor)
- this.GetSumJewelryLv(actor)
- end
- ---获取角色全身装备强化等级
- function EquipAndAppear.GetEquipsSumStrengthLv(actor)
- return this.GetSumLvByType(actor,EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL)
- end
- ---获取角色全身装备追加等级
- function EquipAndAppear.GetEquipsSumAppendLv(actor)
- return this.GetSumLvByType(actor,EquipAndAppear.RecordeType.MAX_APPEND_LEVEL)
- end
- ---获取角色全身装备卓越词条数量(不包含再生词条)
- function EquipAndAppear.GetEquipsSumExcellentEntryCount(actor)
- return this.GetEquipsSumExcellentEntryCount(actor)
- end
- ---获取角色全身装备卓越词条数量(不包含再生词条)
- function this.GetEquipsSumExcellentEntryCount(actor)
- local allEquip = getputonequipinfo(actor)
- if table.isNullOrEmpty(allEquip) then
- return 0
- end
- local sumCount = 0
- for _, equip in pairs(allEquip) do
- local entryAttrMap = equip.entries
- if not table.isNullOrEmpty(entryAttrMap) then
- sumCount = sumCount + table.count(entryAttrMap)
- end
- end
- return sumCount
- end
- ---获取全身首饰等级
- function this.GetSumJewelryLv(actor)
- return this.GetSumLvByType(actor,EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL)
- end
- function this.GetSumLvByType(actor,lvType)
- local equipList = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipList) then
- return 0
- end
- local allEquip = EquipAndAppear.getLuaItemExtData(actor)
- if table.isNullOrEmpty(allEquip) then
- return 0
- end
- local sumLv = 0
- for _, equipInfo in pairs(equipList) do
- local itemId = equipInfo.id
- local equip = allEquip[itemId]
- local lv = this.GetEquipLvByType(equip, lvType)
- if lv ~= 0 then
- sumLv = sumLv + lv
- end
- end
- return sumLv
- end
- function this.GetEquipLvByType(equip, lvType)
- if table.isNullOrEmpty(equip) then
- return 0
- end
- local lv = 0
- if lvType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
- lv = equip.strengthlv
- elseif lvType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
- lv = equip.appendlv
- elseif lvType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
- lv = equip.ssuplv
- end
- if lv == nil then
- return 0
- end
- return tonumber(lv)
- end
- ---更新装备信息记录
- function EquipAndAppear.TryUpdateEquipInfoRecorde(actor, recordeType)
- this.TryUpdateEquipInfoRecorde(actor, recordeType)
- end
- ---更新装备信息记录
- function this.TryUpdateEquipInfoRecorde(actor, recordeType)
- local equipInfoRecorde = EquipAndAppear.GetEquipInfoRecorde(actor)
- if recordeType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
- local oldLv = equipInfoRecorde.max_strength_level
- local newLv = EquipAndAppear.GetEquipsSumStrengthLv(actor)
- if newLv > oldLv then
- equipInfoRecorde.max_strength_level = newLv
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- end
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.StageRank.EQUIP_MAX_STRENGTHEN_LV, newLv)
- OpenServerCompetition.updateRankData(actor, CompetitionType.STRENGTHEN, newLv)
- elseif recordeType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
- local oldLv = equipInfoRecorde.max_append_level
- local newLv = EquipAndAppear.GetEquipsSumAppendLv(actor)
- if newLv > oldLv then
- equipInfoRecorde.max_append_level = newLv
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- end
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.StageRank.EQUIP_MAX_APPEND_LV, newLv)
- OpenServerCompetition.updateRankData(actor, CompetitionType.APPEND, newLv)
- elseif recordeType == EquipAndAppear.RecordeType.MAX_ENTRY_COUNT then
- local oldCount = equipInfoRecorde.max_entry_count
- local newCount = this.GetEquipsSumExcellentEntryCount(actor)
- if newCount > oldCount then
- equipInfoRecorde.max_entry_count = newCount
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.RealTimeRank.SUPERIOR_ENTRY_COUNT, newCount)
- end
- elseif recordeType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
- local oldLv = equipInfoRecorde.max_jewelry_level
- local newLv = this.GetSumJewelryLv(actor)
- if newLv > oldLv then
- equipInfoRecorde.max_jewelry_level = newLv
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- end
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.RealTimeRank.JEWELRY_LEVEL, newLv)
- end
- end
- function EquipAndAppear.GetEquipInfoRecordeValue(actor, recordeType)
- local equipInfoRecorde = EquipAndAppear.GetEquipInfoRecorde(actor)
- if recordeType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
- return equipInfoRecorde.max_strength_level
- elseif recordeType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
- return equipInfoRecorde.max_append_level
- elseif recordeType == EquipAndAppear.RecordeType.MAX_ENTRY_COUNT then
- return equipInfoRecorde.max_entry_count
- elseif recordeType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
- return equipInfoRecorde.max_jewelry_level
- end
- return 0
- end
- function EquipAndAppear.CheckPartEquipStrengthLv(actor, part, goalLv)
- local equipList = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipList) then
- return false
- end
- local allData = EquipAndAppear.getLuaItemExtData(actor)
- if table.isNullOrEmpty(allData) then
- return false
- end
- for _, equipInfo in pairs(equipList) do
- local itemId = equipInfo.id
- local cfgId = equipInfo.cfgid
- local equipData = allData[itemId]
- if not table.isNullOrEmpty(equipData) then
- local strengthLv = equipData.strengthlv
- if part == nil and strengthLv >= goalLv then
- return true
- end
- if part ~= nil then
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- if tonumber(strPart) == part and strengthLv >= goalLv then
- return true
- end
- end
- end
- end
- return false
- end
- function checkspecificstageequipcounttest(actor)
- EquipAndAppear.CheckSpecificStageEquipCount(actor, stageLimit, equipType)
- end
- ---检查阶段装备数量
- function EquipAndAppear.CheckSpecificStageEquipCount(actor, stageLimit, ratingLimit)
- local allEquip = getputonequipinfo(actor)
- if table.isNullOrEmpty(allEquip) then
- return 0
- end
- local sumCount = 0
- for _, equip in pairs(allEquip) do
- local cfgId = equip.cfgid
- local armor = this.IsArmor(cfgId)
- if armor then
- local stage = tonumber(ConfigDataManager.getTableValue("cfg_item", "rank", "id", cfgId))
- if stage ~= nil and (stageLimit == nil or stage >= stageLimit) then
- local rating = EquipAndAppear.GetEquipRating(cfgId)
- if table.isNullOrEmpty(ratingLimit) or ratingLimit == rating or table.contains(ratingLimit, rating) then
- sumCount = sumCount + 1
- end
- end
- end
- end
- return sumCount
- end
- ---获取装备评级
- function EquipAndAppear.GetEquipRating(itemCfgId)
- local ratingScore = tonumber(ConfigDataManager.getTableValue("cfg_equip_entrylib", "initialrating", "id", itemCfgId))
- if ratingScore == nil then
- return 0
- end
- local equipQualityCfgList = ConfigDataManager.getTable("cfg_equip_quality")
- if table.isNullOrEmpty(equipQualityCfgList) then
- return 0
- end
- for rating, equipQualityCfg in pairs(equipQualityCfgList) do
- local stageParam = string.split(equipQualityCfg["stage"], "#")
- if ratingScore >= tonumber(stageParam[1]) and ratingScore <= tonumber(stageParam[2]) then
- return tonumber(rating)
- end
- end
- return 0
- end
- ---是否防具
- function this.IsArmor(cfgId)
- --策划要求代码写死
- local strPart = tonumber(ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId))
- if strPart == nil then
- return false
- end
- if strPart == 4 or strPart == 5 or strPart == 6 or strPart == 7 or strPart == 8 then
- return true
- end
- return false
- end
- function EquipAndAppear.SetItemExtData(actor, itemId, equipData)
- local result = setitemextdata(actor, itemId, equipData)
- if result == nil or result == false then
- gameDebug.assertPrintTrace(false, actor, "setitemextdata失败!", itemId, equipData)
- end
- end
- --
- --
- --function EquipAndAppear.CheckPartEquipStrengthLv(actor, part,goalLv)
- -- EquipAndAppear.CheckPartEquipInfo(actor, part, goalLv, "strengthlv")
- --end
- --
- --function EquipAndAppear.CheckPartEquipAppendLv(actor, part, goalLv)
- --
- --end
- --
- --function EquipAndAppear.CheckPartEquipInfo(actor, part, goalLv, param)
- -- jprint("--------------1", part, goalLv, param)
- -- local allData = EquipAndAppear.getLuaItemExtData(actor)
- -- if table.isNullOrEmpty(allData) then
- -- return false
- -- end
- -- for itemId, equipData in pairs(allData) do
- -- gameDebug.print("---- equip ----", itemId, equipData)
- -- local strengthLv = equipData[param]
- -- if part == nil and strengthLv >= goalLv then
- -- return true
- -- end
- -- if part ~= nil then
- -- local equip = getequipinfo(actor, itemId,1)
- -- if not table.isNullOrEmpty(equip) then
- -- local cfgId = equip.cfgid
- -- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- -- if tonumber(strPart) == part and strengthLv >= goalLv then
- -- return true
- -- end
- -- end
- -- end
- -- end
- -- return false
- --end
|