| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788 |
- --- 大天使圣杯
- --- 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
- }, 9999, "镶嵌圣杯")
- 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
- -- 备用
- ---- 只对传入的 play 做重置,不再遍历所有玩家
- -- if not play then
- -- return
- -- end
- -- -- 记录一次性日志(可选)
- -- local logText = "重置大天使圣杯排行榜膜拜信息 for play:%s now:%s"
- -- gameDebug.print(string.format(logText, tostring(getbaseinfo(play, "rolename") or "unknown"), TimeUtil.timeFormat(getbaseinfo("nowsec"))))
- -- setplaydef(play, PlayerDefKey.angel.ANGEL_GRAIL_WORSHIP_INFO, {})
- -- setplaydef(play, PlayerDefKey.angel.ANGEL_GRAIL_CROSS_WORSHIP_INFO, {})
- 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)
|