12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775 |
- --- 大天使圣杯
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by zhoutao.
- --- DateTime: 2024/11/19 20:36
- AngelMajorGrail = {}
- local this = AngelMajorGrail
- this.RedId = 102
- this.canWorshipRedId = 107
- --- 获取所有圣杯词条信息
- --- @param actor table 角色对象
- --- @param isInlaid boolean 是否镶嵌
- function AngelMajorGrail.sendGrailInfo(actor, isInlaid)
- local grailIds = AngelMajorGrail.getInlaidGrailIds(actor)
- local allGrailInfo = this.getAllGrailInfo(actor)
- local res = {}
- if not table.isNullOrEmpty(allGrailInfo) then
- for grailId, entry in pairs(allGrailInfo) do
- if not table.isNullOrEmpty(entry) then
- if not table.hasKey(entry, "score") then
- entry = this.calcGrailScore(entry)
- end
- if table.contains(grailIds, grailId) then
- entry["active"] = true
- if isInlaid then
- res[grailId] = entry
- end
- else
- if not isInlaid then
- res[grailId] = entry
- end
- end
- end
- end
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_GRAIL_INFO, res)
- end
- -- 判断单个圣杯是否激活
- function this.isActiveGrail(actor, grailId)
- local grailIds = AngelMajorGrail.getInlaidGrailIds(actor)
- return table.contains(grailIds, grailId)
- end
- --- 获取装备下镶嵌的圣杯词条信息
- --- @param actor table 角色对象
- --- @param equipId number 装备id
- --- @param itemId number 圣杯id
- function AngelMajorGrail.getEquipAllEntryInfo(actor, equipId, itemId)
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipAttr) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.getEquipAllEntryInfo equipAttr is nil")
- return
- end
- local equipInfo = equipAttr[equipId]
- if table.isNullOrEmpty(equipInfo) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.getEquipAllEntryInfo equipInfo is nil")
- return
- end
- local grails = equipInfo["grails"]
- local res = {}
- if not table.isNullOrEmpty(grails) then
- if itemId then
- local info = grails[itemId]
- local temp = this.combineRes(itemId, info, this.getGrailInfo(actor, itemId))
- local attrInfo = temp["attrInfo"]
- if attrInfo and this.isActiveGrail(actor, itemId) then
- attrInfo["active"] = true
- end
- table.insert(res, temp)
- else
- for grailId, info in pairs(grails) do
- local temp = this.combineRes(grailId, info, this.getGrailInfo(actor, grailId))
- local attrInfo = temp["attrInfo"]
- if attrInfo and this.isActiveGrail(actor, grailId) then
- attrInfo["active"] = true
- end
- table.insert(res, temp)
- end
- end
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_ALL_ENTRY_INFO, res)
- end
- --- 镶嵌圣杯
- --- @param actor table 角色对象
- --- @param msgData table 消息数据
- function AngelMajorGrail.inlayGrail(actor, msgData)
- -- 装备id
- local equipId = msgData["equipId"]
- -- 装备配置id
- local equipConfigId = msgData["equipConfigId"]
- -- 圣杯id
- local grailId = msgData["itemId"]
- -- 圣杯配置id
- local itemConfigId = msgData["itemConfigId"]
- local tableValue = this.isAngelGrail(itemConfigId)
- if not tableValue then
- return
- end
- -- 圣杯在背包中的索引,因为目前没有根据唯一id删除道具的接口,所以使用索引进行删除
- local index = msgData["index"]
- -- 镶嵌孔位
- local position = msgData["position"]
- -- 判断部位是否符合镶嵌
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", equipConfigId)
- local partSplit = string.split(strPart, "#")
- local grailPart = tableValue[1]["strpart"]
- local grailParts = string.split(grailPart, "#")
- local isMatch = false
- for _, v in pairs(partSplit) do
- if table.contains(grailParts, v) then
- isMatch = true
- end
- end
- if not isMatch then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.inlayGrail part match false equipConfigId",
- equipConfigId, " grailConfigId", itemConfigId)
- return
- end
- -- 获取装备成长属性信息
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipAttr) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.inlayGrail equipAttr is nil")
- return
- end
- local equipInfo = equipAttr[equipId]
- if table.isNullOrEmpty(equipInfo) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.inlayGrail equipInfo is nil")
- return
- end
- -- 获取圣杯词条信息
- local entryInfo = this.getGrailInfo(actor, grailId)
- -- 判断圣杯等阶是否满足融合条件
- local equipRank = equipInfo["rank"]
- if table.isNullOrEmpty(entryInfo) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.inlayGrail entryInfo is nil")
- return
- end
- local grailGrade = entryInfo["grailGrade"]
- if grailGrade > equipRank then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.inlayGrail grailGrade > equipRank")
- return
- end
- local grails = equipInfo["grails"]
- if not table.isNullOrEmpty(grails) then
- if table.getValue(grails, grailId) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.inlayGrail equip already has this grail")
- return
- else
- grails[grailId] = {
- ["itemConfigId"] = itemConfigId,
- ["grailPosition"] = position,
- ["level"] = entryInfo["level"]
- }
- end
- else
- grails = {}
- grails[grailId] = {
- ["itemConfigId"] = itemConfigId,
- ["grailPosition"] = position,
- ["level"] = entryInfo["level"]
- }
- end
- equipInfo["grails"] = grails
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
- entryInfo["inlaid"] = true
- info(actor, actor, "镶嵌圣杯后的信息", "装备id", equipId, "圣杯id", grailId)
- this.saveOrRemoveGrailInfo(actor, grailId, entryInfo)
- -- 给角色添加属性
- AngelMajorGrail.grailAttrHandle(actor, entryInfo, grailId, true)
- -- 移除背包中的圣杯
- removeitembyidxlist(actor, {
- [index] = 1
- })
- AngelMajorGrail.getEquipAllEntryInfo(actor, equipId, grailId)
- -- 红点判断
- AngelMajorGrail.sendRedPoint(actor)
- -- 触发任务刷新
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.TAKE_ON_GRAIL_COUNT)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.STRENGTHEN_GRAIL)
- -- 判断是否满足大天使圣杯套装并增加属性
- AngelMajorGrail.checkAngelGrailSuitCondition(actor)
- end
- --- 卸下圣杯
- --- @param actor table 角色对象
- --- @param msgData table 消息数据
- function AngelMajorGrail.unloadGrail(actor, msgData)
- -- 装备id
- local equipId = msgData["equipId"]
- -- 圣杯id
- local grailId = msgData["itemId"]
- local entryInfo = this.getGrailInfo(actor, grailId)
- if table.isNullOrEmpty(entryInfo) then
- error("grailId error")
- return
- end
- -- 道具配置id
- local itemConfigId = msgData["itemConfigId"]
- -- 判断背包是否能放得下,放不下不能卸并提示
- local paramMap = {}
- paramMap["cfgid"] = itemConfigId
- paramMap["itemcount"] = 1
- local param = { paramMap }
- local canPut = checkitemscanputbag(actor, param)
- if tonumber(canPut) == 0 then
- noticeTip.noticeinfo(actor, StringIdConst.TEXT29001)
- return
- end
- -- 去除装备属性中的指定圣杯信息
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if not table.isNullOrEmpty(equipInfo) then
- local equipAttr = equipInfo[equipId]
- if not table.isNullOrEmpty(equipAttr) then
- local grails = equipAttr["grails"] or {}
- if not table.hasKey(grails, grailId) then
- tipinfo(actor, "该装备下没有该圣杯")
- info(actor, actor, "该装备下没有该圣杯" .. " 装备id:" .. equipId .. " 圣杯id:" .. grailId)
- return
- end
- grails[grailId] = nil
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipInfo)
- end
- end
- -- 生成道具放入背包
- local itemId = additemtobag(actor, itemConfigId, 1, 0, 9999, ItemAction.ANGEL_GRAIL_UNLOAD)
- if not itemId or tonumber(itemId) <= 0 then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.unloadGrail additemtobag failed")
- return
- end
- entryInfo["inlaid"] = false
- entryInfo["active"] = false
- this.saveOrRemoveGrailInfo(actor, grailId)
- this.saveOrRemoveGrailInfo(actor, itemId, entryInfo)
- -- 移除之前增加的属性
- AngelMajorGrail.grailAttrHandle(actor, entryInfo, grailId, false)
- -- 响应客户端镶嵌的圣杯信息
- AngelMajorGrail.getEquipAllEntryInfo(actor, equipId)
- -- 响应圣杯信息
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_ENTRY_INFO, {
- [itemId] = entryInfo and entryInfo or {}
- })
- -- 红点判断
- AngelMajorGrail.sendRedPoint(actor)
- -- 触发任务刷新
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.TAKE_ON_GRAIL_COUNT)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.STRENGTHEN_GRAIL)
- -- 判断是否满足大天使圣杯套装并增加属性
- AngelMajorGrail.checkAngelGrailSuitCondition(actor)
- end
- --- 强化圣杯词条
- --- @param actor table 角色对象
- --- @param msgData table 消息数据
- function AngelMajorGrail.strengthenGrail(actor, msgData)
- -- 圣杯id
- local grailId = msgData["itemId"]
- -- 道具配置id
- local itemConfigId = msgData["itemConfigId"]
- -- 获取道具对应的强化组
- local strengthenGroup = ConfigDataManager.getTableValue("cfg_equip_angelStrengthen", "costGroup", "id", itemConfigId)
- -- 获取当前圣杯的等级
- local entryInfo = this.getGrailInfo(actor, grailId)
- if not table.isNullOrEmpty(entryInfo) then
- local grailLevel = entryInfo["level"]
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelStrengthenCost", "AngelstrengthenGroup",
- strengthenGroup, "AngelstrengthenLv", grailLevel)
- if table.isNullOrEmpty(tableValue) then
- gameDebug.print(getbaseinfo(actor, "rolename"),
- " AngelMajorGrail.strengthenGrail cfg_equip_angelStrengthenCost is nil")
- return
- end
- -- 强化消耗材料充足判断
- local strengthenCost = tableValue[1]["angelstrengthencost"]
- local costMap = string.toIntIntMap(strengthenCost, "#", "|")
- local enough = Bag.checkCostMap(actor, costMap)
- if not enough then
- noticeTip.noticeinfo(actor, StringIdConst.TEXT351)
- return
- end
- -- 具体强化逻辑
- -- 消耗道具
- for cfgId, count in pairs(costMap) do
- Bag.cost(actor, cfgId, count, ItemAction.ANGEL_GRAIL_STRENGTHEN_COST)
- end
- -- 强化成功率
- local successRate = tableValue[1]["angelstrengthensuccessrate"]
- local success = math.random(1, 100) <= (tonumber(successRate) and tonumber(successRate) or 0)
- if success then
- -- 获取主副词条信息
- local mainEntry = entryInfo["main"]
- local secondaryEntry = entryInfo["secondary"]
- -- 主词条强化
- for _, entry in pairs(mainEntry) do
- if not entry["isMax"] then
- this.strengthen(entry)
- end
- end
- -- 副词条强化
- local entryWeightMap = {}
- for _, v in pairs(secondaryEntry) do
- for _, entry in pairs(v) do
- if not entry["isMax"] then
- entryWeightMap[entry] = entry["weight"]
- end
- end
- end
- -- 根据权重选择一条词条强化
- if not table.isNullOrEmpty(entryWeightMap) then
- local entry = randombyweight(entryWeightMap, 1, false)[1]
- this.strengthen(entry)
- -- 保存强化后的词条信息
- for k1, v in pairs(secondaryEntry) do
- for k2, value in pairs(v) do
- if value["id"] == entry["id"] then
- secondaryEntry[k1][k2] = entry
- end
- end
- end
- entryInfo["level"] = grailLevel + 1
- end
- entryInfo = this.calcGrailScore(entryInfo)
- -- 先去除属性再增加属性
- AngelMajorGrail.grailAttrHandle(actor, entryInfo, grailId, false)
- AngelMajorGrail.grailAttrHandle(actor, entryInfo, grailId, true)
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_ENTRY_STRENGTHEN_RESULT, success)
- if this.isActiveGrail(actor, grailId) then
- -- 正常这里应该是激活的
- entryInfo["active"] = true
- end
- this.saveOrRemoveGrailInfo(actor, grailId, entryInfo)
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_ENTRY_INFO, {
- [grailId] = entryInfo and entryInfo or {}
- })
- -- 增加大天使装备下的圣杯等级
- AngelMajorEquipment.addGrailLevel(actor, grailId, grailLevel + 1)
- -- 触发任务刷新
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.STRENGTHEN_GRAIL)
- else
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_ENTRY_STRENGTHEN_RESULT, success)
- end
- end
- end
- --- 初始化大天使圣杯词条信息
- --- @param actor table 角色对象
- --- @param itemId number 道具id
- --- @param itemConfigId number 道具配置id
- function AngelMajorGrail.initGrailEntry(actor, itemId, itemConfigId)
- -- 延迟执行
- -- intervalcalldelay(actor, 500, 1000, 1, "initgrailinfo", itemId, itemConfigId)
- AngelMajorGrail.initGrailInfo(actor, itemId, itemConfigId)
- end
- function AngelMajorGrail.initGrailInfo(actor, itemId, itemConfigId)
- -- 判断道具是否为圣杯
- local tableValue = this.isAngelGrail(itemConfigId)
- if not tableValue then
- return
- end
- local entryInfo = this.getGrailInfo(actor, itemId)
- if not table.isNullOrEmpty(entryInfo) then
- AngelMajorGrail.sendGrailInfo(actor, false)
- AngelMajorGrail.sendRedPoint(actor)
- return
- end
- info(actor, actor, "尝试初始化圣杯词条信息", itemId, itemConfigId)
- -- 获取圣杯主词条组
- local mainEntryGroup = tableValue[1]["mainattgroup"]
- -- 获取圣杯随机词条组
- local randomEntryGroup = tableValue[1]["randomattgroup"]
- -- 获取圣杯词条数量权重
- local entryCountWeight = tableValue[1]["attcountweight"]
- -- 获取圣杯等阶
- local grailGrade = tableValue[1]["grailgrade"]
- -- 获取圣杯孔位
- local gradePosition = tableValue[1]["gradeposition"]
- local itemEntry = {}
- -- 圣杯主词条信息初始化
- local mainEntryInfo = ConfigDataManager.getTable("cfg_equip_angelEntry", "group", mainEntryGroup)
- if table.isNullOrEmpty(mainEntryInfo) then
- jprint("AngelMajorGrail.initGrailAttr cfg_equip_angelEntry data is nil")
- return
- end
- local mainEntry = this.initEntry(mainEntryInfo[1])
- itemEntry["main"] = mainEntry
- -- 圣杯副词条信息初始化
- local secondary = {}
- local secondaryEntryInfo
- local secondaryCount
- --[[
- 1代表从1词条组随一个 1#2代表从1和2词条组中随一个 1|1代表从1词条组随两个
- 分两种情况:
- 1.randomAttGroup字符串带竖线,需要根据attCountWeight计算出词条数量再随机生成对应条数的词条
- 2.randomAttGroup字符串不带竖线,判断是否带井号,带井号分割字符串,根据获得的词条组随机生成一条词条
- 3.randomAttGroup字符串不带竖线也不带井号,根据词条组随机生成一条词条
- ]]
- if string.contains(randomEntryGroup, "|") then
- -- 第一种情况
- local weightMap = string.toIntIntMap(entryCountWeight, "#", "|")
- -- 副词条初始化条数
- secondaryCount = randombyweight(weightMap, 1, true)[1]
- local entryGroup = string.split(randomEntryGroup, "|")[1]
- secondaryEntryInfo = ConfigDataManager.getTable("cfg_equip_angelEntry", "group", entryGroup)
- elseif string.contains(randomEntryGroup, "#") then
- -- 第二种情况
- local group1 = string.split(randomEntryGroup, "#")[1]
- local group2 = string.split(randomEntryGroup, "#")[2]
- secondaryEntryInfo = ConfigDataManager.getTable("cfg_equip_angelEntry", "group", group1)
- local tempEntry = ConfigDataManager.getTable("cfg_equip_angelEntry", "group", group2)
- table.insertArray(secondaryEntryInfo, tempEntry)
- secondaryCount = 1
- else
- -- 第三种情况
- secondaryEntryInfo = ConfigDataManager.getTable("cfg_equip_angelEntry", "group", randomEntryGroup)
- secondaryCount = 1
- end
- -- 获取根据权重生成的随机词条并设置
- if not table.isNullOrEmpty(secondaryEntryInfo) then
- local randomResult = this.getRandomEntry(secondaryEntryInfo, secondaryCount)
- for _, v in pairs(randomResult) do
- local secondaryEntry = this.initEntry(secondaryEntryInfo[v])
- table.insert(secondary, secondaryEntry)
- end
- itemEntry["secondary"] = secondary
- end
- itemEntry["grailGrade"] = tonumber(grailGrade)
- itemEntry["itemConfigId"] = itemConfigId
- itemEntry["grailPosition"] = tonumber(gradePosition)
- itemEntry["level"] = 0
- itemEntry["inlaid"] = false
- info(actor, actor, "初始化圣杯 id:", itemId)
- -- 计算评分
- itemEntry = this.calcGrailScore(itemEntry)
- this.saveOrRemoveGrailInfo(actor, itemId, itemEntry)
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_ENTRY_INFO, {
- [itemId] = itemEntry and itemEntry or {}
- })
- -- 红点判断
- AngelMajorGrail.sendRedPoint(actor)
- -- end
- end
- --- 销毁圣杯
- --- @param actor table 角色对象
- --- @param cfgId number 道具配置id
- --- @param itemId number 道具id
- function AngelMajorGrail.destroyAngelGrail(actor, cfgId, itemId)
- local tableValue = this.isAngelGrail(cfgId)
- if not table.isNullOrEmpty(tableValue) then
- info(actor, actor, "销毁圣杯", itemId)
- local entryInfo = this.getGrailInfo(actor, itemId)
- if not table.isNullOrEmpty(entryInfo) then
- if entryInfo["inlaid"] then
- tipinfo(actor, "含有镶嵌的圣杯不能销毁")
- return
- end
- end
- this.saveOrRemoveGrailInfo(actor, itemId)
- -- 红点判断
- local result = AngelMajorGrail.checkEnter(actor)
- RedPoint.sendOneRedPoint(actor, this.RedId, result)
- end
- end
- --- 给角色增加圣杯词条属性
- --- @param actor table 角色对象
- --- @param entryInfo table 词条信息
- --- @param grailId number 圣杯唯一id
- --- @param isAdd boolean 是否增加词条
- function AngelMajorGrail.grailAttrHandle(actor, entryInfo, grailId, isAdd)
- if isAdd then
- local attrMap = {}
- local mainAttr = entryInfo["main"]
- if table.isNullOrEmpty(mainAttr) then
- return
- end
- for _, v in pairs(mainAttr) do
- local attrId = tonumber(v["attrId"])
- local attrValue = tonumber(v["value"])
- if table.getValue(attrMap, attrId) then
- attrMap[attrId] = attrMap[attrId] + attrValue
- else
- attrMap[attrId] = attrValue
- end
- end
- local secondaryAttr = entryInfo["secondary"]
- if table.isNullOrEmpty(secondaryAttr) then
- return
- end
- for _, v in pairs(secondaryAttr) do
- for _, value in pairs(v) do
- local attrId = tonumber(value["attrId"])
- local attrValue = tonumber(value["value"])
- if table.getValue(attrMap, attrId) then
- attrMap[attrId] = attrMap[attrId] + attrValue
- else
- attrMap[attrId] = attrValue
- end
- end
- end
- RoleAttr.addAndSaveRoleAttr(actor, string.format(RoleAttrKey.ANGEL_GRAIL, grailId), attrMap)
- else
- RoleAttr.clearRoleAttrAndDB(actor, string.format(RoleAttrKey.ANGEL_GRAIL, grailId))
- end
- end
- --- 大天使圣杯分解
- --- @param actor table 角色对象
- --- @param msgData table 消息数据
- function AngelMajorGrail.grailDecompose(actor, msgData)
- -- 圣杯索引集合
- local indexList = msgData["indexList"]
- -- 圣杯唯一id集合
- local grailIds = msgData["grailIds"]
- info(actor, actor, "大天使圣杯分解", "圣杯ids:", grailIds)
- if table.isNullOrEmpty(grailIds) then
- return
- end
- local costMap = {}
- local getMap = {}
- for _, grailId in pairs(grailIds) do
- local entryInfo = this.getGrailInfo(actor, grailId)
- if not table.isNullOrEmpty(entryInfo) then
- if entryInfo["inlaid"] then
- tipinfo(actor, "含有镶嵌的圣杯不能分解")
- return
- end
- local itemConfigId = entryInfo["itemConfigId"]
- local level = entryInfo["level"]
- local group = ConfigDataManager.getTableValue("cfg_equip_angelStrengthen", "SplitGroup", "id", itemConfigId)
- if group then
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelStrengthenCost", "AngelstrengthenGroup",
- group, "AngelstrengthenLv", level)
- local recoveryCost = tableValue[1]["recoverycost"]
- if recoveryCost then
- -- 检查消耗道具是否充足
- costMap = string.putIntIntMap(costMap, recoveryCost, "#", "|")
- local enough = Bag.checkCostMap(actor, costMap)
- if not enough then
- noticeTip.noticeinfo(actor, StringIdConst.TEXT351)
- return
- end
- end
- local angelStrengthenGet = tableValue[1]["angelstrengthenget"]
- if angelStrengthenGet then
- -- 封装奖励map
- local itemMap = string.toIntIntMap(angelStrengthenGet, "#", "|")
- for k, v in pairs(itemMap) do
- local itemId = tonumber(k)
- local count = tonumber(v)
- if getMap[itemId] then
- getMap[itemId] = getMap[itemId] + count
- else
- getMap[itemId] = count
- end
- end
- end
- end
- end
- end
- -- 消耗道具并发放奖励
- if not table.isNullOrEmpty(getMap) and not table.isNullOrEmpty(costMap) then
- Bag.costMap(actor, costMap, ItemAction.ANGEL_GRAIL_DECOMPOSE_RECOVERY)
- Bag.sendRewards(actor, getMap, ItemAction.ANGEL_GRAIL_DECOMPOSE_REWARD)
- removeitembyidxlist(actor, indexList, 9999, ItemAction.ANGEL_GRAIL_DECOMPOSE)
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_DECOMPOSE_RESULT, true)
- -- 删除存储的圣杯词条信息
- for _, grailId in pairs(grailIds) do
- this.saveOrRemoveGrailInfo(actor, grailId)
- end
- -- 红点判断
- local result = AngelMajorGrail.checkEnter(actor)
- RedPoint.sendOneRedPoint(actor, this.RedId, result)
- return
- end
- -- 红点判断
- AngelMajorGrail.sendRedPoint(actor)
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_DECOMPOSE_RESULT, false)
- end
- --- 登录红点判断
- --- @param actor table 角色对象
- --- @return boolean 是否展示红点
- function AngelMajorGrail.checkEnter(actor)
- -- 获取所有圣杯
- local grailInfo = AngelMajorGrail.getBagGrailIds(actor)
- if not table.isNullOrEmpty(grailInfo) then
- for _, grailId in pairs(grailInfo) do
- local entryInfo = this.getGrailInfo(actor, grailId)
- if not table.isNullOrEmpty(entryInfo) then
- if not entryInfo["inlaid"] and
- this.checkRedPoint(actor, entryInfo["grailGrade"], entryInfo["grailPosition"],
- entryInfo["itemConfigId"]) then
- return true
- end
- end
- end
- end
- return false
- end
- --- 获取指定玩家的指定大天使圣杯词条信息
- ---@param actor table 角色对象
- ---@param msgData table 消息数据
- function AngelMajorGrail.getPlayerAngelGrailInfo(actor, msgData)
- local rid = msgData["rid"]
- local itemId = msgData["itemId"]
- local targetActor = getactor(actor, rid)
- local entryInfo = this.getGrailInfo(targetActor, itemId)
- sendluamsg(actor, LuaMessageIdToClient.RES_OTHER_ANGE_GRAIL_INFO, {
- [itemId] = entryInfo or {}
- })
- end
- --- 获取身上穿戴的大天使装备镶嵌的所有圣杯id
- ---@param actor table 角色对象
- ---@return table 圣杯id列表
- function AngelMajorGrail.getInlaidGrailIds(actor)
- local grailIds = {}
- local grailInfo = this.getAllGrailInfo(actor)
- if table.isNullOrEmpty(grailInfo) then
- return grailIds
- end
- for grailId, v in pairs(grailInfo) do
- local inlaid = v["inlaid"]
- if inlaid then
- table.insert(grailIds, grailId)
- end
- end
- return grailIds
- end
- --- 获取指定玩家的指定大天使圣杯数量
- ---@param actor table 角色对象
- ---@param grailGrade number 圣杯等阶
- ---@param grailQuality number 圣杯品质
- ---@return number 数量
- function AngelMajorGrail.getGrailCountByCondition(actor, grailGrade, grailQuality)
- grailGrade = tonumber(grailGrade)
- grailQuality = tonumber(grailQuality)
- local count = 0
- local inlaidGrailIds = AngelMajorGrail.getInlaidGrailIds(actor)
- if table.isNullOrEmpty(inlaidGrailIds) then
- return 0
- end
- for _, grailId in pairs(inlaidGrailIds) do
- local entryInfo = this.getGrailInfo(actor, grailId)
- if table.isNullOrEmpty(entryInfo) then
- goto next
- end
- if grailGrade ~= 0 then
- local grade = entryInfo["grailGrade"]
- if grade < grailGrade then
- goto next
- end
- end
- if grailQuality ~= 0 then
- local cfgId = entryInfo["itemConfigId"]
- local quality = ConfigDataManager.getTableValue("cfg_equip_angelGrail", "grailQuality", "id", cfgId)
- if tonumber(quality) < grailQuality then
- goto next
- end
- end
- count = count + 1
- :: next ::
- end
- return count
- end
- --- 获取身上所有已镶嵌的大天使圣杯达到指定强化等级的数量
- ---@param actor table 角色对象
- ---@param strengthLevel number 强化等级
- ---@return number 数量
- function AngelMajorGrail.getGrailCountByStrengthLevel(actor, strengthLevel)
- local inlaidGrailIds = AngelMajorGrail.getInlaidGrailIds(actor)
- if table.isNullOrEmpty(inlaidGrailIds) then
- return 0
- end
- local count = 0
- for _, grailId in pairs(inlaidGrailIds) do
- local entryInfo = this.getGrailInfo(actor, grailId)
- if not table.isNullOrEmpty(entryInfo) then
- local level = entryInfo["level"]
- if level >= tonumber(strengthLevel) then
- count = count + 1
- end
- end
- end
- return count
- end
- --- 检查是否满足大天使圣杯套装
- ---@param actor table 角色对象
- function AngelMajorGrail.checkAngelGrailSuitCondition(actor)
- local maxGrade = 0
- local temp = {}
- -- 获取身上镶嵌的所有圣杯id
- local inlaidGrailIds = AngelMajorGrail.getInlaidGrailIds(actor)
- -- 遍历获取圣杯数量与最大圣杯阶数
- for _, grailId in pairs(inlaidGrailIds) do
- local v = this.getGrailInfo(actor, grailId)
- if not table.isNullOrEmpty(v) then
- local cfgId = v["itemConfigId"]
- temp[cfgId] = (temp[cfgId] and temp[cfgId] or 0) + 1
- maxGrade = v["grailGrade"] > maxGrade and v["grailGrade"] or maxGrade
- end
- end
- local grailSuitId = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_SUIT_ID)
- local tableId
- local attrInfo = {}
- -- 倒序循环判断是否满足套装
- for i = maxGrade, 1, -1 do
- local total = 0
- for j = 4, 1, -1 do
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelGrailSuit", "group", i, "level", j)
- if table.isNullOrEmpty(tableValue) then
- error("cfg_equip_angelGrailSuit is null group:", i, " level:", j)
- return
- end
- local value = tableValue[1]
- local suitGrailId = value["suitgrailid"]
- local suitEffect = value["suiteffect"]
- if not string.isNullOrEmpty(suitGrailId) and not string.isNullOrEmpty(suitEffect) then
- local grailIds = string.split(suitGrailId, "#")
- for _, configId in pairs(grailIds) do
- configId = tonumber(configId)
- total = total + (temp[configId] and temp[configId] or 0)
- end
- if total > 0 then
- local split = string.split(suitEffect, "|")
- for _, item in pairs(split) do
- local split2 = string.split(item, "#")
- local count = tonumber(split2[1])
- if total >= count then
- tableId = tonumber(value["id"])
- local attrId = tonumber(split2[2])
- local attrValue = tonumber(split2[3])
- attrInfo[attrId] = attrValue
- end
- end
- if not table.isNullOrEmpty(attrInfo) then
- if tableId ~= grailSuitId then
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_SUIT_ID, tableId)
- RoleAttr.clearRoleAttrAndDB(actor, RoleAttrKey.ANGEL_GRAIL_SUIT)
- end
- local attr = getplaydef(actor, "T$_" .. RoleAttrKey.ANGEL_GRAIL_SUIT)
- if not table.isNullOrEmpty(attr) then
- local attrLength = table.count(attr)
- local attrInfoLength = table.count(attrInfo)
- if attrLength > attrInfoLength then
- for attrId, _ in pairs(attr) do
- if table.hasKey(attrInfo, attrId) then
- attrInfo[attrId] = 0
- else
- attrInfo[attrId] = -attr[attrId]
- end
- end
- else
- for attrId, _ in pairs(attrInfo) do
- if table.hasKey(attr, attrId) and attr[attrId] > 0 then
- attrInfo[attrId] = 0
- end
- end
- end
- end
- RoleAttr.addAndSaveRoleAttr(actor, RoleAttrKey.ANGEL_GRAIL_SUIT, attrInfo)
- return
- end
- end
- end
- end
- end
- -- 清除套装属性加成
- RoleAttr.clearRoleAttrAndDB(actor, RoleAttrKey.ANGEL_GRAIL_SUIT)
- end
- --- 初始化大天使圣杯排行榜信息
- function AngelMajorGrail.initGrailRanking()
- -- 本服圣杯排行榜初始化
- local allRole = getsysvar("Q$allRankRoles")
- if not table.isNullOrEmpty(allRole) then
- -- gameDebug.print(string.format("初始化大天使圣杯排行榜信息 now:%s", TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- local ranking = getsysvar(SystemVarConst.ANGEL_GRAIL_RANKING_INFO) or {}
- local rankingInfo = ranking["rankingInfo"]
- local actor
- if table.isNullOrEmpty(rankingInfo) then
- rankingInfo = {}
- for _, v in pairs(allRole) do
- actor = v["actor"]
- local career = v["career"]
- local roleName = v["name"]
- local serverId = v["serverid"]
- this.grailRankingHandle(actor, career, roleName, serverId, rankingInfo)
- end
- else
- for _, v in pairs(allRole) do
- actor = v["actor"]
- local career = v["career"]
- local roleName = v["name"]
- local serverId = v["serverid"]
- local onlineState = getbaseinfo(actor, "onlinestate")
- if onlineState == 1 then
- for key, value in pairs(rankingInfo) do
- if value["roleId"] == tonumber(actor:toString()) then
- table.remove(rankingInfo, key)
- break
- end
- end
- this.grailRankingHandle(actor, career, roleName, serverId, rankingInfo)
- end
- end
- end
- if not table.isNullOrEmpty(rankingInfo) then
- rankingInfo = this.calcGrailRanking(rankingInfo)
- end
- ranking = {}
- ranking["rankingInfo"] = rankingInfo
- local rankingIndex = {}
- for key, rank in pairs(rankingInfo) do
- rankingIndex[rank["roleId"]] = key
- end
- ranking["rankingIndex"] = rankingIndex
- setsysvar(actor, SystemVarConst.ANGEL_GRAIL_RANKING_INFO, ranking)
- end
- -- 跨服圣杯排行榜数据初始化
- local serverType = getbaseinfo("servertype")
- if serverType == 2 then
- return
- -- local hosts = gethosts()
- -- if not table.isNullOrEmpty(hosts) then
- -- --gameDebug.print(string.format("初始化大天使圣杯跨服排行榜信息 now:%s", TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- -- local rankingInfo = {}
- -- for _, host in pairs(hosts) do
- -- local all = getallrolesummaryinfos(host)
- -- if not table.isNullOrEmpty(all) then
- -- for _, v in pairs(all) do
- -- local actor = v["actor"]
- -- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- -- if not table.isNullOrEmpty(grailInfo) then
- -- this.grailRankingHandle(actor, grailInfo, rankingInfo)
- -- end
- -- end
- -- end
- -- end
- -- if not table.isNullOrEmpty(rankingInfo) then
- -- rankingInfo = this.calcGrailRanking(rankingInfo)
- -- end
- -- local ranking = {}
- -- ranking["rankingInfo"] = rankingInfo
- -- local rankingIndex = {}
- -- for key, rank in pairs(rankingInfo) do
- -- rankingIndex[rank["roleId"]] = key
- -- end
- -- ranking["rankingIndex"] = rankingIndex
- -- for _, host in ipairs(hosts) do
- -- setsysvar(host, SystemVarConst.ANGEL_GRAIL_CROSS_RANKING_INFO, ranking)
- -- end
- -- end
- end
- end
- --- 获取大天使圣杯排行榜信息
- ---@param actor table 角色对象
- ---@param grailGrade number 圣杯等阶
- function AngelMajorGrail.getGrailRankingInfo(actor, msgData)
- -- 排行榜类型
- local type = msgData["type"]
- local ranking = {}
- if type == 1 then
- -- ranking = getsysvar(SystemVarConst.ANGEL_GRAIL_CROSS_RANKING_INFO, 1)
- return
- else
- ranking = getsysvar(actor, SystemVarConst.ANGEL_GRAIL_RANKING_INFO)
- end
- local worshipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_WORSHIP_INFO)
- worshipInfo = worshipInfo or {}
- local crossWorshipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_CROSS_WORSHIP_INFO)
- crossWorshipInfo = crossWorshipInfo or {}
- local res = {}
- res["worshipCount"] = table.count(worshipInfo) + table.count(crossWorshipInfo)
- res["roleIds"] = type == 1 and crossWorshipInfo or worshipInfo
- local rankingInfo = ranking["rankingInfo"]
- local rankingIndex = ranking["rankingIndex"]
- local roleId = tonumber(actor:toString())
- local my = {}
- if table.hasKey(rankingIndex, roleId) then
- my = rankingInfo[rankingIndex[roleId]]
- end
- if not table.isNullOrEmpty(rankingInfo) then
- res["rankingInfo"] = {
- ["all"] = { table.unpack(rankingInfo, 1, 30) },
- ["my"] = my
- }
- else
- res["rankingInfo"] = {}
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_RANKING_INFO, res)
- end
- --- 膜拜圣杯
- ---@param actor table 角色对象
- ---@param msgData table 消息数据
- function AngelMajorGrail.worshipGrail(actor, msgData)
- -- 排行榜类型
- local type = tonumber(msgData["type"])
- -- 圣杯id
- local roleId = tonumber(msgData["roleId"])
- local worshipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_WORSHIP_INFO)
- worshipInfo = worshipInfo or {}
- local crossWorshipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_CROSS_WORSHIP_INFO)
- crossWorshipInfo = crossWorshipInfo or {}
- if type == 1 then
- if not table.isNullOrEmpty(crossWorshipInfo) then
- if table.hasKey(crossWorshipInfo, roleId) then
- gameDebug.print(string.format("玩家%s重复膜拜跨服圣杯排行榜的%s",
- getbaseinfo(actor, "rolename"), roleId))
- return
- end
- end
- else
- if not table.isNullOrEmpty(worshipInfo) then
- if table.hasKey(worshipInfo, roleId) then
- gameDebug.print(string.format("玩家%s重复膜拜圣杯排行榜的%s",
- getbaseinfo(actor, "rolename"), roleId))
- return
- end
- end
- end
- -- 已经膜拜次数
- local count = table.count(worshipInfo) + table.count(crossWorshipInfo)
- -- 每日膜拜次数限制校验
- local limit = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.ANGEL_GRAIL_WORSHIP_LIMIT)
- if string.isNullOrEmpty(limit) then
- error("cfg_global is null id:", GlobalConfigId.ANGEL_GRAIL_WORSHIP_LIMIT)
- return
- end
- if count >= tonumber(limit) then
- gameDebug.print(string.format("玩家%s超过每日膜拜次数限制", getbaseinfo(actor, "rolename")))
- return
- end
- local reward = ConfigDataManager.getTableValue("cfg_global", "value", "id",
- GlobalConfigId.ANGEL_GRAIL_WORSHIP_REWARD)
- if not string.isNullOrEmpty(reward) then
- if type == 1 then
- crossWorshipInfo[roleId] = 1
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_CROSS_WORSHIP_INFO, crossWorshipInfo)
- else
- worshipInfo[roleId] = 1
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_WORSHIP_INFO, worshipInfo)
- end
- Bag.sendRewards4String(actor, reward, ItemAction.ANGEL_GRAIL_RANKING_WORSHIP_REWARD)
- -- 发送膜拜圣杯红点
- RedPoint.sendOneRedPoint(actor, this.canWorshipRedId, this.checkWorshipRedPoint(actor))
- -- 响应客户端
- sendluamsg(actor, LuaMessageIdToClient.RES_GRAIL_RANKING_WORSHIP_INFO, {
- ["worshipCount"] = count + 1,
- ["grailIds"] = type == 1 and crossWorshipInfo or worshipInfo
- })
- end
- end
- --- 获取指定玩家身上穿着的大天使装备与镶嵌的圣杯信息
- ---@param actor table 角色对象
- ---@param rid number 玩家id
- function AngelMajorGrail.getPlayerAllAngelEquipAndGrail(actor, rid)
- local player = getactor(rid)
- if not player then
- return
- end
- local res = {}
- -- 获取大天使装备信息
- local equipAttr = {}
- local equipInfo = getplaydef(player, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- local putOnIds = AngelMajorEquipment.getPutOnEquipIds(player)
- if not table.isNullOrEmpty(equipInfo) then
- for _, v in pairs(putOnIds) do
- equipAttr[v] = equipInfo[v]
- end
- end
- -- 获取大天使圣杯信息
- local grailInfo = {}
- local grailIds = AngelMajorGrail.getInlaidGrailIds(player)
- if not table.isNullOrEmpty(grailIds) then
- for _, v in pairs(grailIds) do
- local entryInfo = this.getGrailInfo(player, v)
- if not table.isNullOrEmpty(entryInfo) then
- grailInfo[v] = entryInfo
- end
- end
- end
- res["equip"] = equipAttr
- res["grail"] = grailInfo
- sendluamsg(actor, LuaMessageIdToClient.RES_PLAYER_EQUIP_GRAIL_INFO, res)
- end
- ---登录事件检查红点
- function this.loginRed(red_data, actor)
- if AngelMajorGrail.checkEnter(actor) then
- -- 上线false可以不发送
- red_data[this.RedId] = true
- end
- if this.checkWorshipRedPoint(actor) then
- red_data[this.canWorshipRedId] = true
- end
- end
- --- 圣杯镶嵌红点判断
- --- @param actor table 角色对象
- --- @param grailGrade number 圣杯等阶
- --- @param grailPosition number 孔位
- --- @param grailConfigId number 圣杯配置id
- --- @return boolean 是否展示红点
- function this.checkRedPoint(actor, grailGrade, grailPosition, grailConfigId)
- local equipData = getputonequipinfo(actor)
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipAttr) then
- return false
- end
- for _, v in pairs(equipData) do
- local attr = equipAttr[v["id"]]
- if table.isNullOrEmpty(attr) then
- goto next
- end
- local cfgId = v["cfgid"]
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
- local partSplit = string.split(strPart, "#")
- local grailStrPart = ConfigDataManager.getTableValue("cfg_equip_angelGrail", "strPart", "id", grailConfigId)
- local grailPartSplit = string.split(grailStrPart, "#")
- local flag = false
- for _, part in pairs(partSplit) do
- if table.contains(grailPartSplit, part) then
- flag = true
- end
- end
- if not flag then
- goto next
- end
- local equipRank = attr["rank"]
- if equipRank < grailGrade then
- goto next
- else
- local grails = attr["grails"]
- if not table.isNullOrEmpty(grails) then
- for _, value in pairs(grails) do
- if value["grailPosition"] == grailPosition then
- goto next
- end
- end
- return true
- else
- return true
- end
- end
- :: next ::
- end
- return false
- end
- --- 圣杯排行榜膜拜红点判断
- --- @param actor table 角色对象
- function this.checkWorshipRedPoint(actor)
- local worshipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_WORSHIP_INFO)
- worshipInfo = worshipInfo or {}
- local crossWorshipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_CROSS_WORSHIP_INFO)
- crossWorshipInfo = crossWorshipInfo or {}
- local ranking = getsysvar(actor, SystemVarConst.ANGEL_GRAIL_RANKING_INFO)
- if table.isNullOrEmpty(ranking) then
- return false
- end
- local rankingInfo = ranking["rankingInfo"]
- if table.isNullOrEmpty(rankingInfo) then
- return false
- end
- if table.isNullOrEmpty(worshipInfo) and table.isNullOrEmpty(crossWorshipInfo) then
- return true
- end
- local limit = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.ANGEL_GRAIL_WORSHIP_LIMIT)
- local count = table.count(worshipInfo) + table.count(crossWorshipInfo)
- if count < tonumber(limit) then
- return true
- end
- return false
- end
- --- 组装圣杯信息
- --- @param itemId number 道具id
- --- @param info table 孔位信息
- --- @param entryInfo table 词条信息
- function this.combineRes(itemId, info, entryInfo)
- local temp = {}
- temp["itemId"] = itemId
- temp["itemConfigId"] = info["itemConfigId"]
- temp["position"] = info["grailPosition"]
- temp["attrInfo"] = entryInfo
- temp["inlaid"] = info["inlaid"]
- return temp
- end
- --- 强化词条
- --- @param entry table 词条对象
- function this.strengthen(entry)
- local id = entry["id"]
- local attrValue = entry["value"]
- local entryTableValue = ConfigDataManager.getTable("cfg_equip_angelEntry", "id", id)
- local max = entryTableValue[1]["attmax"]
- local maxSplit = string.split(max, "#")
- local index = 1
- -- 获取最大值索引
- if string.contains(max, "#") then
- local attrId = entry["attrId"]
- local att = entryTableValue[1]["att"]
- local attSplit = string.split(att, "|")
- for k, v in pairs(attSplit) do
- if tonumber(string.split(v, "#")[1]) == attrId then
- index = k
- break
- end
- end
- end
- local strengthen = entryTableValue[1]["strengthen"]
- local split = string.split(strengthen, "|")
- local temp = {}
- for _, v in pairs(split) do
- local split2 = string.split(v, "#")
- local randomValue = math.random(split2[1], split2[2])
- temp[{
- [index] = randomValue
- }] = split2[3]
- end
- local randomInfo = randombyweight(temp)[1]
- if not table.isNullOrEmpty(randomInfo) then
- for k, v in pairs(randomInfo) do
- -- 判断增加完的词条是否超过了最大值,如果超过了最大值则赋值为最大值
- if attrValue + tonumber(v) >= tonumber(maxSplit[k] and maxSplit[k] or max) then
- entry["value"] = maxSplit[k] and maxSplit[k] or max
- entry["isMax"] = true
- else
- entry["value"] = attrValue + v
- end
- end
- end
- end
- --- 获取圣杯词条信息
- --- @param entryInfo table cfg_equip_angelEntry表词条信息
- --- @return table 随机词条信息
- function this.initEntry(entryInfo)
- local split = string.split(entryInfo["att"], "|")
- local res = {}
- for _, v in pairs(split) do
- local attSplit = string.split(v, "#")
- local attrId = tonumber(attSplit[1])
- local minValue = tonumber(attSplit[2])
- local maxValue = tonumber(attSplit[3])
- local weight = tonumber(attSplit[4])
- local randomValue = math.random(minValue, maxValue)
- table.insert(res, {
- ["id"] = tonumber(entryInfo["id"]),
- ["attrId"] = attrId,
- ["value"] = randomValue,
- ["weight"] = weight,
- ["isMax"] = false
- })
- end
- return res
- end
- --- 根据权重随机生成词条
- --- @param secondaryEntryInfo table 词条信息
- --- @param secondaryCount number 词条数量
- --- @return table 随机词条索引集合
- function this.getRandomEntry(secondaryEntryInfo, secondaryCount)
- local temp = {}
- for k, v in pairs(secondaryEntryInfo) do
- local att = v["att"]
- if string.contains(att, "|") then
- local split = string.split(att, "|")
- for _, value in pairs(split) do
- local weight = string.split(value, "#")[4]
- temp[k] = weight
- end
- else
- local weight = string.split(att, "#")[4]
- temp[k] = weight
- end
- end
- local randomResult = randombyweight(temp, secondaryCount, false)
- return randomResult
- end
- --- 判断是否开启大天使圣杯
- --- @param actor table 角色对象
- --- @return boolean 是否开启
- function this.isOpen(actor)
- -- 获取当前角色等级
- local level = getbaseinfo(actor, "level")
- -- 获取等级限制配置
- local levelLimit = ConfigDataManager.getTableValue("cfg_global", "value", "id",
- GlobalConfigId.ANGEL_EQUIPMENT_LEVEL_LIMIT)
- if string.isNullOrEmpty(levelLimit) then
- return false
- end
- -- 返回结果
- return level >= tonumber(levelLimit)
- end
- --- 判断是否是大天使圣杯
- --- @param itemConfigId number 道具配置id
- --- @return table 大天使圣杯信息
- function this.isAngelGrail(itemConfigId)
- return ConfigDataManager.getTable("cfg_equip_angelGrail", "id", itemConfigId)
- end
- --- 计算圣杯评分
- ---@param grailEntry table 圣杯属性信息
- function this.calcGrailScore(grailEntry)
- local score = 0
- if not table.isNullOrEmpty(grailEntry) then
- local main = grailEntry["main"]
- score = score + this.scoreHandle(main)
- local secondary = grailEntry["secondary"]
- for _, v in pairs(secondary) do
- score = score + this.scoreHandle(v)
- end
- grailEntry["score"] = score
- end
- return grailEntry
- end
- --- 评分处理
- --- @param entry table 词条数据
- function this.scoreHandle(entry)
- if not table.isNullOrEmpty(entry) then
- local score = 0
- for _, v in pairs(entry) do
- local attrId = v["attrId"]
- local value = v["value"]
- local tableValue = ConfigDataManager.getTable("cfg_att_info", "id", attrId)
- if not table.isNullOrEmpty(tableValue) then
- local remarks = tableValue[1]["remarks"]
- if tonumber(remarks) == 2 then
- value = value / 100
- end
- local tableScore = tableValue[1]["score"]
- score = math.ceil(score + value * tableScore)
- end
- end
- return score
- end
- end
- --- 计算圣杯排名
- --- @param rankingTable table 要排的圣杯数据
- --- @return table 排序后的圣杯数据
- function this.calcGrailRanking(rankingTable)
- -- 快速排序算法,对score进行降序排序,对于大数据集速度相较于插入排序更快,长远考虑选择快排
- this.quickSortRecursive(rankingTable, 1, #rankingTable)
- -- 更新排名
- for i = 1, #rankingTable do
- rankingTable[i].ranking = i
- end
- -- 返回排序结果
- return rankingTable
- end
- --- 快速排序的分区函数
- --- @param arr table 要排序的列表
- --- @param low number 排序区间的下界
- --- @param high number 排序区间的上界
- function this.partition(arr, low, high)
- local pivot = arr[high].score
- local i = low - 1
- for j = low, high - 1 do
- if arr[j].score > pivot then
- i = i + 1
- -- 交换 arr[i] 和 arr[j]
- local temp = arr[i]
- arr[i] = arr[j]
- arr[j] = temp
- end
- end
- -- 交换 arr[i+1] 和 arr[high] (或者 pivot)
- local temp = arr[i + 1]
- arr[i + 1] = arr[high]
- arr[high] = temp
- return i + 1
- end
- --- 快速排序的递归函数
- --- @param arr table 要排序的列表
- --- @param low number 排序区间的下界
- --- @param high number 排序区间的上界
- function this.quickSortRecursive(arr, low, high)
- if low < high then
- local pi = this.partition(arr, low, high)
- this.quickSortRecursive(arr, low, pi - 1)
- this.quickSortRecursive(arr, pi + 1, high)
- end
- end
- --- 圣杯排名处理
- --- @param actor table 角色对象
- --- @param career number 职业
- --- @param roleName string 角色名
- --- @param serverId number 服务器id
- --- @param rankingInfo table 排行榜信息
- function this.grailRankingHandle(actor, career, roleName, serverId, rankingInfo)
- local inlaidGrailIds = AngelMajorGrail.getInlaidGrailIds(actor)
- local score = 0
- for _, itemId in pairs(inlaidGrailIds) do
- local info = this.getGrailInfo(actor, itemId)
- if not table.isNullOrEmpty(info) then
- if not table.hasKey(info, "score") then
- info = this.calcGrailScore(info)
- end
- score = score + info["score"]
- end
- end
- if score > 0 then
- table.insert(rankingInfo, {
- ["roleId"] = tonumber(actor:toString()),
- ["roleName"] = roleName,
- ["career"] = career,
- ["score"] = score,
- ["ranking"] = 0,
- ["serverId"] = serverId
- })
- end
- end
- --- 凌晨事件
- function this.zeroEvent(play)
- local allRole = getallrolesummaryinfos()
- if not table.isNullOrEmpty(allRole) then
- local logText = "开始重置大天使圣杯排行榜膜拜信息 now:%s"
- gameDebug.print(string.format(logText, TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- for _, v in pairs(allRole) do
- local actor = v["actor"]
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_WORSHIP_INFO, {})
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_CROSS_WORSHIP_INFO, {})
- end
- end
- end
- --- 玩家登录清除圣杯分解造成的脏数据
- --- @param actor table 角色对象
- function this.loginDirtyDataClear(actor)
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if table.isNullOrEmpty(grailInfo) then
- return
- end
- local flag = "2024_03_28_10_00"
- local mark = getplaydef(actor, "T$_angelGrailDirtyDataClear")
- if type(mark) ~= "string" or mark ~= flag then
- jprint(string.format("==============================>%s开始清除圣杯脏数据now:%s",
- getbaseinfo(actor, "rolename"), TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- local itemIds = {}
- -- 交易行圣杯id汇总,不做脏数据清理
- local goodsList = getsysvar(actor, SYS_TRADE_WORLD_GOODS)
- if not table.isNullOrEmpty(goodsList) then
- local goods = goodsList[actor:toString()]
- if not table.isNullOrEmpty(goods) then
- for itemId, value in pairs(goods) do
- local itemCfgId = value["itemcfgid"]
- if this.isAngelGrail(itemCfgId) then
- table.insert(itemIds, tonumber(itemId))
- end
- end
- end
- end
- local bagItems = getallbagitem(actor)
- if not table.isNullOrEmpty(bagItems) then
- for _, v in pairs(bagItems) do
- local cfgId = v["cfg_id"]
- if this.isAngelGrail(cfgId) then
- local id = v["id"]
- if table.isNullOrEmpty(grailInfo[id]) then
- this.initGrailInfo(actor, id, cfgId)
- end
- table.insert(itemIds, id)
- end
- end
- end
- local storeMaxPage = getstoremaxpage(actor)
- for i = 1, storeMaxPage do
- local storeItem = getalliteminfoinstore(actor, i)
- if not table.isNullOrEmpty(storeItem) then
- for _, v in pairs(storeItem) do
- local cfgId = v["cfgid"]
- if this.isAngelGrail(cfgId) then
- local id = v["id"]
- if table.isNullOrEmpty(grailInfo[id]) then
- this.initGrailInfo(actor, id, cfgId)
- end
- table.insert(itemIds, id)
- end
- end
- end
- end
- -- fixtodo 如果玩家存在卸下的带有圣杯的装备,这样清理会把玩家卸下装备上面的圣杯数据丢失
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if not table.isNullOrEmpty(equipInfo) then
- for _, v in pairs(equipInfo) do
- local grails = v["grails"]
- if not table.isNullOrEmpty(grails) then
- for grailId, value in pairs(grails) do
- local cfgId = value["itemConfigId"]
- if table.isNullOrEmpty(grailInfo[grailId]) then
- this.initGrailInfo(actor, grailId, cfgId)
- end
- table.insert(itemIds, grailId)
- end
- end
- end
- end
- grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- local allGrailIds = {}
- for itemId, _ in pairs(grailInfo) do
- if not table.contains(itemIds, itemId) then
- grailInfo[itemId] = nil
- end
- table.insert(allGrailIds, itemId)
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
- -- 大天使装备上圣杯数据清理
- if not table.isNullOrEmpty(equipInfo) then
- for k, v in pairs(equipInfo) do
- local grails = v["grails"]
- if not table.isNullOrEmpty(grails) then
- for grailId, _ in pairs(grails) do
- if not table.contains(allGrailIds, grailId) then
- grails[grailId] = nil
- end
- end
- end
- end
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipInfo)
- -- 设置脏数据清理标识符
- setplaydef(actor, "T$_angelGrailDirtyDataClear", flag)
- end
- end
- --- 定时清除圣杯的脏数据
- --- @param actor table 角色对象
- function this.dirtyDataClear(actor)
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if table.isNullOrEmpty(grailInfo) then
- return
- end
- jprint(string.format("==============================>%s开始清除圣杯脏数据now:%s",
- getbaseinfo(actor, "rolename"), TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- local itemIds = {}
- local existsGrailId = {}
- -- 交易行圣杯id汇总,不做脏数据清理
- local goodsList = getsysvar(actor, SYS_TRADE_WORLD_GOODS)
- if not table.isNullOrEmpty(goodsList) then
- local goods = goodsList[actor:toString()]
- if not table.isNullOrEmpty(goods) then
- for itemId, value in pairs(goods) do
- local itemCfgId = value["itemcfgid"]
- if this.isAngelGrail(itemCfgId) then
- table.insert(itemIds, tonumber(itemId))
- end
- end
- end
- end
- local bagItems = getallbagitem(actor)
- if not table.isNullOrEmpty(bagItems) then
- for _, v in pairs(bagItems) do
- local cfgId = v["cfg_id"]
- if this.isAngelGrail(cfgId) then
- local id = v["id"]
- if table.isNullOrEmpty(grailInfo[id]) then
- this.initGrailInfo(actor, id, cfgId)
- end
- table.insert(itemIds, id)
- table.insert(existsGrailId, id)
- end
- end
- end
- local storeMaxPage = getstoremaxpage(actor)
- for i = 1, storeMaxPage do
- local storeItem = getalliteminfoinstore(actor, i)
- if not table.isNullOrEmpty(storeItem) then
- for _, v in pairs(storeItem) do
- local cfgId = v["cfgid"]
- if this.isAngelGrail(cfgId) then
- local id = v["id"]
- if table.isNullOrEmpty(grailInfo[id]) then
- this.initGrailInfo(actor, id, cfgId)
- end
- table.insert(itemIds, id)
- end
- end
- end
- end
- -- fixtodo 如果玩家存在卸下的带有圣杯的装备,这样清理会把玩家卸下装备上面的圣杯数据丢失
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if not table.isNullOrEmpty(equipInfo) then
- for _, v in pairs(equipInfo) do
- local grails = v["grails"]
- if not table.isNullOrEmpty(grails) then
- for grailId, value in pairs(grails) do
- local cfgId = value["itemConfigId"]
- if table.isNullOrEmpty(grailInfo[grailId]) then
- this.initGrailInfo(actor, grailId, cfgId)
- end
- table.insert(itemIds, grailId)
- end
- end
- end
- end
- grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- local allGrailIds = {}
- for itemId, _ in pairs(grailInfo) do
- if not table.contains(itemIds, itemId) then
- local itemExtData = getitemextdata(actor, itemId)
- if table.isNullOrEmpty(itemExtData) then
- grailInfo[itemId] = nil
- end
- end
- table.insert(allGrailIds, itemId)
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
- -- 大天使装备上圣杯数据清理
- if not table.isNullOrEmpty(equipInfo) then
- for _, v in pairs(equipInfo) do
- local grails = v["grails"]
- if not table.isNullOrEmpty(grails) then
- for grailId, _ in pairs(grails) do
- if not table.contains(allGrailIds, grailId) then
- grails[grailId] = nil
- end
- end
- end
- end
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipInfo)
- for _, grailId in pairs(existsGrailId) do
- local entryInfo = this.getGrailInfo(actor, grailId)
- if not table.isNullOrEmpty(entryInfo) then
- info(actor, "将玩家变量中的圣杯信息放入道具lua扩展数据中 grailId", grailId, "entryInfo", entryInfo)
- setitemextdata(actor, grailId, entryInfo)
- end
- end
- end
- --- 合服清空排行榜数据
- function AngelMajorGrail.combine()
- local hosts = gethosts()
- for _, host in ipairs(hosts) do
- setsysvar(host, SystemVarConst.ANGEL_GRAIL_RANKING_INFO, {})
- setsysvar(host, SystemVarConst.ANGEL_GRAIL_CROSS_RANKING_INFO, {})
- end
- end
- --- 保存/移除圣杯信息
- --- @param actor table 角色对象
- --- @param grailId number 圣杯id
- --- @param itemEntry table 圣杯信息
- function this.saveOrRemoveGrailInfo(actor, grailId, itemEntry)
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if table.isNullOrEmpty(grailInfo) then
- grailInfo = {}
- end
- if table.isNullOrEmpty(itemEntry) then
- grailInfo[grailId] = nil
- else
- grailInfo[grailId] = itemEntry
- setitemextdata(actor, grailId, itemEntry)
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
- end
- --- 获取圣杯信息
- --- @param actor table 角色对象
- --- @param grailId number 圣杯id
- --- @return table 所有圣杯信息
- function this.getGrailInfo(actor, grailId)
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if table.isNullOrEmpty(grailInfo) then
- grailInfo = {}
- end
- local itemExtData = getitemextdata(actor, grailId)
- if not table.isNullOrEmpty(grailInfo) and not table.isNullOrEmpty(grailInfo[grailId]) then
- local entryInfo = grailInfo[grailId]
- local inlaid = entryInfo["inlaid"]
- if table.isNullOrEmpty(itemExtData) and not inlaid then
- setitemextdata(actor, grailId, grailInfo[grailId])
- end
- return grailInfo[grailId]
- else
- if not table.isNullOrEmpty(itemExtData) then
- grailInfo[grailId] = itemExtData
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
- end
- return itemExtData
- end
- end
- --- 获取所有圣杯信息
- --- @param actor table 角色对象
- --- @return table 所有圣杯信息
- function this.getAllGrailInfo(actor)
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- return grailInfo
- end
- --- 发送圣杯红点
- --- @param actor table 角色对象
- function AngelMajorGrail.sendRedPoint(actor)
- local result = AngelMajorGrail.checkEnter(actor)
- local res = getplaydef(actor, "@tempangelgrailredpointresult")
- if string.isNullOrEmpty(res) or res ~= result then
- setplaydef(actor, "@tempangelgrailredpointresult", result)
- RedPoint.sendOneRedPoint(actor, this.RedId, result)
- end
- end
- --- 获取背包中的圣杯id
- function AngelMajorGrail.getBagGrailIds(actor)
- local bagItems = getallbagitem(actor)
- local grailIds = {}
- if not table.isNullOrEmpty(bagItems) then
- for _, v in pairs(bagItems) do
- local cfgId = v["cfg_id"]
- if this.isAngelGrail(cfgId) then
- table.insert(grailIds, v["id"])
- end
- end
- end
- return grailIds
- end
- --- 获取圣杯融合总数与平均强化等级
- --- @param actor table 角色对象
- --- @param mathType number 计算方式 1:向下取整 2:向上取整 3:四舍五入
- --- @return number count, number level 融合总数,平均强化等级
- function AngelMajorGrail.getAverageInfo(actor, mathType)
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if table.isNullOrEmpty(grailInfo) then
- return 0, 0
- end
- local level = 0
- local count = 0
- for _, v in pairs(grailInfo) do
- if v["inlaid"] then
- level = level + v["level"]
- count = count + 1
- end
- end
- if MathType.FLOOR == mathType then
- return count, math.floor(level / count)
- elseif MathType.CEIL == mathType then
- return count, math.ceil(level / count)
- else
- return count, math.round(level / count)
- end
- end
- --- 配表修改后数据错乱清理
- --- @param actor table 角色对象
- function this.angelGrailDataClean(actor)
- local isClean = getplaydef(actor, "T$_angelGrailDataClean")
- if string.isNullOrEmpty(isClean) then
- jprint(string.format("==============================>%s圣杯数据开始清洗now:%s",
- getbaseinfo(actor, "rolename"), TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if not table.isNullOrEmpty(grailInfo) then
- for _, entry in pairs(grailInfo) do
- local mainEntry = entry["main"]
- local secondaryEntry = entry["secondary"]
- if not table.isNullOrEmpty(mainEntry) then
- for _, v in pairs(mainEntry) do
- local id = v["id"]
- local fixValues = ConfigDataManager.getTable("cfg_equip_angelEntry_fixes", "oldid", id)
- if not table.isNullOrEmpty(fixValues) then
- local newId = tonumber(fixValues[1]["newid"])
- local oldAttMax = tonumber(fixValues[1]["oldattmax"])
- local value = tonumber(v["value"])
- local attMax = ConfigDataManager.getTableValue("cfg_equip_angelEntry", "attMax", "id", newId)
- if not string.isNullOrEmpty(attMax) then
- if string.contains(attMax, "#") then
- local att = ConfigDataManager.getTableValue("cfg_equip_angelEntry", "att", "id", newId)
- local attrId = v["attrId"]
- local split1 = string.split(att, "|")
- local split2 = string.split(split1[1], "#")
- if table.contains(split2, tostring(attrId)) then
- attMax = tonumber(string.split(attMax, "#")[1])
- else
- attMax = tonumber(string.split(attMax, "#")[2])
- end
- else
- attMax = tonumber(attMax)
- end
- if value > tonumber(attMax) then
- value = tonumber(math.floor(tonumber(attMax) * (value / oldAttMax)))
- end
- end
- v["id"] = newId
- v["value"] = value
- end
- end
- end
- if not table.isNullOrEmpty(secondaryEntry) then
- for _, v in pairs(secondaryEntry) do
- for _, secondEntry in pairs(v) do
- local id = secondEntry["id"]
- local fixValues = ConfigDataManager.getTable("cfg_equip_angelEntry_fixes", "oldid", id)
- if not table.isNullOrEmpty(fixValues) then
- local newId = tonumber(fixValues[1]["newid"])
- local oldAttMax = tonumber(fixValues[1]["oldattmax"])
- local value = tonumber(secondEntry["value"])
- local attMax = ConfigDataManager.getTableValue("cfg_equip_angelEntry", "attMax", "id", newId)
- if not string.isNullOrEmpty(attMax) then
- if string.contains(attMax, "#") then
- local att = ConfigDataManager.getTableValue("cfg_equip_angelEntry", "att", "id", newId)
- local attrId = v["attrId"]
- local split1 = string.split(att, "|")
- local split2 = string.split(split1[1], "#")
- if table.contains(split2, tostring(attrId)) then
- attMax = tonumber(string.split(attMax, "#")[1])
- else
- attMax = tonumber(string.split(attMax, "#")[2])
- end
- else
- attMax = tonumber(attMax)
- end
- if value > tonumber(attMax) then
- value = tonumber(math.floor(tonumber(attMax) * (value / oldAttMax)))
- end
- end
- secondEntry["id"] = newId
- secondEntry["value"] = value
- end
- end
- end
- end
- end
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
- setplaydef(actor, "T$_angelGrailDataClean", 1)
- end
- end
- RedPointEventListerTable:eventLister("0", "大天使圣杯", this.loginRed)
- ZeroEventListerTable:eventLister("0", "大天使圣杯排行榜膜拜重置", this.zeroEvent)
- ZeroEventListerTable:eventLister("0", "大天使圣杯脏数据清理", this.dirtyDataClear)
- LoginEventListerTable:eventLister("0", "大天使圣杯脏数据清理", this.loginDirtyDataClear)
- LoginEventListerTable:eventLister("0", "大天使圣杯改表数据错乱清理", this.angelGrailDataClean)
|