RedDotConditionUtil_Tips.lua 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524
  1. ---@class RedDotConditionUtil @注释
  2. RedDotConditionUtil = class()
  3. local this = RedDotConditionUtil
  4. ---@class RedDotResult
  5. ---@field compareSign string @比较符号
  6. ---@field compareValue number @目标值
  7. ---@field fieldName string @比较条件中文名
  8. ---@type RedDotResult
  9. this.redDotResult = {}
  10. ---@class redDotFunc
  11. this.redDotFunc = {}
  12. local conditionFunc = {}---判断方法
  13. this.moduleRedConditionFunc = {}
  14. ---@param tbl1 table
  15. ---@param tbl2 table
  16. function this.redDotFunc.CombineTable(tbl1, tbl2)
  17. local count = #tbl1
  18. for i = 1, #tbl2 do
  19. tbl1[count + i] = tbl2[i]
  20. end
  21. end
  22. ---@param tblL table
  23. ---@param tblR table
  24. ---@return table
  25. function this.redDotFunc.FindAllBracketPair(tblL, tblR)
  26. if not tblL or #tblL == 0 then
  27. return tblR
  28. elseif not tblR or #tblR == 0 then
  29. return tblL
  30. end
  31. local tbl = {}
  32. local index = #tblL
  33. local temp = {}
  34. this.redDotFunc.CombineTable(temp, tblL)
  35. for i = 1, #tblR do
  36. local isFind = false
  37. local len = #temp
  38. repeat
  39. if temp[len] < tblR[i] then
  40. local t = {}
  41. t.left = temp[len]
  42. t.right = tblR[i]
  43. tbl[i] = t
  44. index = index - 1
  45. isFind = true
  46. table.remove(temp, len)
  47. end
  48. len = len - 1
  49. until (isFind)
  50. end
  51. return tbl
  52. end
  53. ---@param tbl1 table
  54. ---@param tbl2 table
  55. ---@return table
  56. function this.redDotFunc.BlendTable(tbl1, tbl2)
  57. local tbl = {}
  58. local count = #tbl1
  59. for i = 1, #tbl1 do
  60. tbl[i] = tbl1[i]
  61. end
  62. for i = 1, #tbl2 do
  63. tbl[i + count] = tbl2[i]
  64. end
  65. return tbl
  66. end
  67. ---两个数值比较大小
  68. ---@param num1 number @现有的值
  69. ---@param compareStr string @比较符号
  70. ---@param num2 number @比较目标值
  71. ---@return boolean
  72. function this.redDotFunc.Compare(num1, compareStr, num2)
  73. num1 = tonumber(num1)
  74. num2 = tonumber(num2)
  75. if not num1 or not compareStr or not num2 then
  76. logError("比较参数传递错误")
  77. return nil
  78. end
  79. this.redDotResult.compareSign = compareStr
  80. this.redDotResult.compareValue = num2
  81. if compareStr == ">" then
  82. return num1 > num2
  83. elseif compareStr == "=" then
  84. return num1 == num2
  85. elseif compareStr == "<" then
  86. return num1 < num2
  87. elseif compareStr == ">=" then
  88. return num1 >= num2
  89. elseif compareStr == "<=" then
  90. return num1 <= num2
  91. elseif compareStr == "!=" then
  92. return num1 ~= num2
  93. end
  94. return nil
  95. end
  96. ---判断两个值是否相等
  97. ---@param num1 number @现有值
  98. ---@param num2 number @比较值
  99. ---@return boolean
  100. function this.redDotFunc.Equal(num1, num2)
  101. this.redDotResult.compareValue = num2
  102. this.redDotResult.compareSign = "="
  103. return num1 == num2
  104. end
  105. ---找到指定符号在字符串中的所有下标
  106. ---@param str string
  107. ---param char string
  108. ---return table
  109. function this.redDotFunc.FindAllIndex(str, char)
  110. if not this.FindAllIndexTables then
  111. this.FindAllIndexTables = {}
  112. end
  113. if not this.FindAllIndexTables[str] then
  114. this.FindAllIndexTables[str] = {}
  115. end
  116. local t = this.FindAllIndexTables[str][char]
  117. if t then
  118. return t
  119. end
  120. local isFind = true
  121. local index = -1
  122. local sign = 1
  123. local tbl = {}
  124. local num = 1
  125. char = "%" .. char
  126. while isFind do
  127. _, index = string .find(str, char, sign)
  128. if index then
  129. isFind = true
  130. sign = index + 1
  131. tbl[num] = index --保存第x个左括号的下标)
  132. num = num + 1
  133. else
  134. isFind = false
  135. end
  136. end
  137. return tbl
  138. end
  139. ---获取比较符,和比较符后面一位的字符串下标
  140. ---@param condition string
  141. ---@return string,string
  142. function this.redDotFunc.GetComparerSign(condition)
  143. local firstIndex, lastIndex = nil, nil
  144. if string.find(condition, ">=", 1) then
  145. firstIndex, lastIndex = string.find(condition, ">=", 1)
  146. return ">=", lastIndex
  147. elseif string.find(condition, "<=", 1) then
  148. firstIndex, lastIndex = string.find(condition, "<=", 1)
  149. return "<=", lastIndex
  150. elseif string.find(condition, "!=", 1) then
  151. firstIndex, lastIndex = string.find(condition, "!=", 1)
  152. return "!=", lastIndex
  153. elseif string.find(condition, ">", 1) then
  154. firstIndex, lastIndex = string.find(condition, ">", 1)
  155. return ">", lastIndex
  156. elseif string.find(condition, "<", 1) then
  157. firstIndex, lastIndex = string.find(condition, "<", 1)
  158. return "<", lastIndex
  159. elseif string.find(condition, "=", 1) then
  160. firstIndex, lastIndex = string.find(condition, "=", 1)
  161. return "=", lastIndex
  162. else
  163. return nil, nil
  164. end
  165. end
  166. ---获取符号后的到结尾的目标值
  167. ---@param condition string
  168. ---@param index number
  169. ---@return number
  170. function this.redDotFunc.GetTargetValue(condition, index)
  171. local targetValue = string.match(condition, "(%d+)", index)
  172. targetValue = tonumber(targetValue) or 0
  173. return targetValue
  174. end
  175. ---(通过条件)获取符号后的到结尾的目标值
  176. function this.redDotFunc.GetTargetValueByCondition(condition)
  177. local _, lastIndex = this.redDotFunc.GetComparerSign(condition)
  178. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  179. return target
  180. end
  181. ---比较条件格式为 目标类型#比较符#参数,例:checkLevel#>=#40
  182. ---@param condition string
  183. ---@param currentValue number
  184. ---@return boolean
  185. function this.redDotFunc.ComparerForABType(condition, currentValue)
  186. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  187. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  188. this.redDotResult.compareSign = sign
  189. this.redDotResult.compareValue = target
  190. ---@type boolean
  191. local value = this.redDotFunc.Compare(currentValue, sign, target)
  192. return value
  193. end
  194. ---获取中括号之间的数值
  195. ---@param condition string
  196. ---@return string
  197. function this.redDotFunc.GetStringInParentheses(condition)
  198. local firstIndex = string.find(condition, "%[", 1)
  199. local lastIndex = string .find(condition, "%]", firstIndex + 1)
  200. local str = string.sub(condition, firstIndex + 1, lastIndex - 1)
  201. return str
  202. end
  203. ---根据指定字符切割字符串
  204. function this.redDotFunc.SplitString(condition, sign, startIndex, tbl)
  205. local index = string.find(condition, sign, startIndex)
  206. if index ~= nil then
  207. local str = string.sub(condition, startIndex, index - 1)
  208. table.insert(tbl, str)
  209. this.redDotFunc.SplitString(condition, sign, index + 1, tbl)
  210. else
  211. local str = string.sub(condition, startIndex, #condition)
  212. table.insert(tbl, str)
  213. end
  214. end
  215. ---@param condition string
  216. ---@return boolean
  217. conditionFunc[EConditionType.CheckLevel] = function(condition)
  218. if not RoleManager.meData then
  219. return false
  220. end
  221. ---@type number
  222. local level = RoleManager.meData.Level
  223. return this.redDotFunc.ComparerForABType(condition, level)
  224. end
  225. ---@param condition string
  226. ---@return boolean
  227. conditionFunc[EConditionType.CheckReNewLevel] = function(condition)
  228. --0415 目前还没有转生,后期补充
  229. return false
  230. end
  231. ---@param condition string
  232. ---@return boolean
  233. conditionFunc[EConditionType.CheckRunDay] = function(condition)
  234. local openTime = Time.FormatTimeYMDHMS(LoginManager.EnterRoleRes.openServerTime / 1000)
  235. --local curTime = Time.GetServerTime() --时间戳,单位毫秒
  236. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  237. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  238. --开服年月日时分秒
  239. local year = string.sub(openTime, 1, 4)
  240. local month = string.sub(openTime, 6, 7)
  241. local day = string.sub(openTime, 9, 10)
  242. --local hour = string .sub(openTime, 12, 13)
  243. --local minute = string .sub(openTime, 15, 16)
  244. --local second = string.sub(openTime, 18, 19)
  245. --当前时间年月日
  246. local curYear = Time.GetYear()
  247. local curMonth = Time.GetMonth()
  248. local curDay = Time.GetDay()
  249. local days = 0
  250. --开服时间,天
  251. local openDate = os.time({ year = year, month = month, day = day })
  252. --当前时间,天
  253. local curDate = os.time({ year = curYear, month = curMonth, day = curDay })
  254. --以相隔24小时为一天
  255. --local disparity = curTime - openDate * 1000
  256. --local days = disparity / (24 * 60 * 60 * 1000)
  257. --days = math.ceil(days)
  258. --以自然日为一天
  259. days = math.abs(curDate - openDate) / (3600 * 24) + 1
  260. target = tonumber(target)
  261. return this.redDotFunc.Compare(days, sign, target)
  262. end
  263. ---@param condition string
  264. ---@return boolean
  265. conditionFunc[EConditionType.CheckVipLevel] = function(condition)
  266. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  267. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  268. return this.redDotFunc.Compare(vipLevel, sign, target)
  269. end
  270. ---@param condition string
  271. ---@return boolean
  272. conditionFunc[EConditionType.CheckGender] = function(condition)
  273. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  274. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  275. local gender = RoleManager.meData.sex
  276. target = tonumber(target)
  277. return this.redDotFunc.Equal(gender, Gender)
  278. end
  279. ---@param condition string
  280. ---@return boolean
  281. conditionFunc[EConditionType.CheckAbility] = function(condition)
  282. local number = this.redDotFunc.GetStringInParentheses(condition)
  283. number = tonumber(number)
  284. local ability = RoleManager.meData:GetRoleDate(number)
  285. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  286. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  287. target = tonumber(target)
  288. return this.redDotFunc.Compare(ability, sign, target)
  289. end
  290. ---@param condition string
  291. ---@return boolean
  292. conditionFunc[EConditionType.CheckHasUnion] = function(condition)
  293. local unionId = RoleManager.meData.roleExtInfo.unionId
  294. if unionId == nil then
  295. return false
  296. end
  297. return not this.redDotFunc.Equal(unionId, 0)
  298. end
  299. ---@param condition string
  300. ---@return boolean
  301. conditionFunc[EConditionType.CheckHasTeam] = function(condition)
  302. local teamId = RoleManager.meData.teamId
  303. if teamId == nil then
  304. return false
  305. end
  306. return not this.redDotFunc.Equal(teamId, 0)
  307. end
  308. ---@param condition string
  309. ---@return boolean
  310. conditionFunc[EConditionType.CheckPKPoint] = function(condition)
  311. local pkPoint = RoleManager.meData.PkValue
  312. return this.redDotFunc.ComparerForABType(condition, pkPoint)
  313. end
  314. ---@param condition string
  315. ---@return boolean
  316. conditionFunc[EConditionType.CheckJob] = function(condition)
  317. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  318. local career = RoleManager.meData.career.baseCareer
  319. local job = this.redDotFunc.GetTargetValue(condition, lastIndex)
  320. return this.redDotFunc.Equal(career, job)
  321. end
  322. ---@param condition string
  323. ---@return boolean
  324. conditionFunc[EConditionType.CheckBagItem] = function(condition)
  325. local itemId = this.redDotFunc.GetStringInParentheses(condition)
  326. local itemCount = RoleManager.meData.bagInfo:GetItemCount(tonumber(itemId))
  327. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  328. local targetValue = this.redDotFunc.GetTargetValue(condition, lastIndex)
  329. tonumber(targetValue)
  330. return this.redDotFunc.Compare(itemCount, sign, targetValue)
  331. end
  332. ---@param condition string
  333. ---@return boolean
  334. conditionFunc[EConditionType.CheckVar] = function(condition)
  335. return false
  336. end
  337. ---@param condition string
  338. ---@return boolean
  339. conditionFunc[EConditionType.CheckHandWeapon] = function(condition)
  340. local type = this.redDotFunc.GetStringInParentheses(condition)
  341. local target = string.sub(condition, #condition)
  342. target = tonumber(target)
  343. local weaponId = nil
  344. if type == "Left" then
  345. weaponId = RoleManager.meData.weaponItemId
  346. elseif type == "Right" then
  347. weaponId = RoleManager.meData.weapon2ItemId
  348. end
  349. if weaponId == 0 then
  350. return false
  351. end
  352. local tbl = ConfigManager.Get_cfg_item(weaponId)
  353. return this.redDotFunc.Equal(tbl.twoHanded, target)
  354. end
  355. ---@param condition string
  356. ---@return boolean
  357. conditionFunc[EConditionType.CheckWearEquip] = function(condition)
  358. local typeStr = this.redDotFunc.GetStringInParentheses(condition)
  359. ---local type = EEquipSlotType[typeStr]
  360. typeStr = tonumber(typeStr)
  361. local equips = SL:GetMetaValue("EQUIP_DATA_LIST", typeStr) --穿戴在指定部位的所有装备
  362. if table.count(equips) > 0 then
  363. return true
  364. else
  365. if EEquipStrPartName[typeStr] then
  366. return false, "未穿戴" .. EEquipStrPartName[typeStr]
  367. end
  368. return false
  369. end
  370. end
  371. ---@param condition string
  372. ---@return boolean
  373. conditionFunc[EConditionType.CheckBagSize] = function(condition)
  374. local emptyGrid = RoleManager.meData.bagInfo:GetRemainTileCount()
  375. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  376. local targetValue = this.redDotFunc.GetTargetValue(condition, lastIndex)
  377. targetValue = tonumber(targetValue)
  378. return this.redDotFunc.Compare(emptyGrid, sign, targetValue)
  379. end
  380. ---@param condition string
  381. ---@return boolean
  382. conditionFunc[EConditionType.CanPutInBag] = function(condition)
  383. local str = this.redDotFunc.GetStringInParentheses(condition)
  384. local splitIndex = string .find(str, ',')
  385. local itemName = string.sub(str, 1, splitIndex - 1)
  386. local count = string.sub(str, splitIndex + 1)
  387. ---@type cfg_item_column
  388. local cfgItem = nil
  389. local cfgTbl = ConfigManager.GetConfigTable("cfg_item")
  390. for i = 1, #cfgTbl do
  391. if cfgTbl[i].name == itemName then
  392. cfgItem = cfgTbl[i]
  393. end
  394. end
  395. ---@type CommonProtos.Item
  396. local item = {}
  397. item.cfgId = cfgItem.id
  398. item.count = count
  399. return RoleManager.meData.bagInfo:CanPutToBag(item)
  400. end
  401. ---@param condition string
  402. ---@return boolean
  403. conditionFunc[EConditionType.Random] = function(condition)
  404. local value = this.redDotFunc.GetStringInParentheses(condition)
  405. value = tonumber(value)
  406. return value / 10000
  407. end
  408. ---@param condition string
  409. ---@return boolean
  410. conditionFunc[EConditionType.CheckUnusedAbility] = function(condition)
  411. local count = RoleManager.meData.roleExtInfo.remainAttrPoint
  412. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  413. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  414. target = tonumber(target)
  415. return this.redDotFunc.Compare(count, sign, target)
  416. end
  417. ---@param condition string
  418. ---@return boolean
  419. conditionFunc[EConditionType.CheckUnreadMail] = function(condition)
  420. --local slotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "UnreadEmailCount", 1)
  421. local count = 0
  422. for _, v in pairs(DataManager.mailInfo.mailTbl) do
  423. if v.state == 0 then
  424. count = count + 1
  425. end
  426. end
  427. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  428. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  429. target = tonumber(target)
  430. return this.redDotFunc.Compare(count, sign, target)
  431. end
  432. ---@param condition string
  433. ---@return boolean
  434. conditionFunc[EConditionType.CheckFriendRequest] = function(condition)
  435. local count = DataManager.friendInfo.GetFriendApplyCount()
  436. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  437. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  438. target = tonumber(target)
  439. return this.redDotFunc.Compare(count, sign, target)
  440. end
  441. ---@param condition string
  442. ---@return boolean
  443. conditionFunc[EConditionType.CheckUnreadMessage] = function(condition)
  444. local count = DataManager.chatInfo.GetUnreadMsgCount()
  445. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  446. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  447. target = tonumber(target)
  448. return this.redDotFunc.Compare(count, sign, target)
  449. end
  450. ---检测转装备是否可强化
  451. conditionFunc[EConditionType.CheckEquipStrengthen] = function(condition)
  452. --return RoleManager.meData.equipInfo:CheckEquipStrength()
  453. local r = RedDotManager.GetCheckComparer(ERedCheckComparerType.CheckEquipStrength)
  454. if r == nil then
  455. r = RoleManager.meData.equipInfo:CheckEquipStrength()
  456. RedDotManager.SetCheckComparer(ERedCheckComparerType.CheckEquipStrength, r)
  457. end
  458. return r
  459. end
  460. ---检测装备是否可追加
  461. conditionFunc[EConditionType.CheckEquipAppends] = function(condition)
  462. --return RoleManager.meData.equipInfo:CheckEquipAppend()
  463. local r = RedDotManager.GetCheckComparer(ERedCheckComparerType.CheckEquipAppend)
  464. if r == nil then
  465. r = RoleManager.meData.equipInfo:CheckEquipAppend()
  466. RedDotManager.SetCheckComparer(ERedCheckComparerType.CheckEquipAppend, r)
  467. end
  468. return r
  469. end
  470. ---检测装备是否可转移
  471. conditionFunc[EConditionType.CheckEquipTransfer] = function(condition)
  472. local r = RedDotManager.GetCheckComparer(ERedCheckComparerType.CheckCanTrans)
  473. if r == nil then
  474. r = RoleManager.meData.equipInfo:CheckCanTrans()
  475. RedDotManager.SetCheckComparer(ERedCheckComparerType.CheckCanTrans, r)
  476. end
  477. return r
  478. end
  479. ---检测装备是否可镶嵌宝石
  480. conditionFunc[EConditionType.CheckEquipGem] = function(condition)
  481. local r = RedDotManager.GetCheckComparer(ERedCheckComparerType.CheckCanEquipGem)
  482. if r == nil then
  483. r = RoleManager.meData.equipInfo:CheckCanEquipGem()
  484. RedDotManager.SetCheckComparer(ERedCheckComparerType.CheckCanEquipGem, r)
  485. end
  486. return r
  487. end
  488. ---检测技能是否可升级
  489. conditionFunc[EConditionType.CheckSkillLevelUp] = function(condition)
  490. local r = RedDotManager.GetCheckComparer(ERedCheckComparerType.SKillIsConditionUpGarde)
  491. if r == nil then
  492. r = DataManager.muskillInfo.IsConditionUpGarde()
  493. RedDotManager.SetCheckComparer(ERedCheckComparerType.SKillIsConditionUpGarde, r)
  494. end
  495. return r
  496. end
  497. ---检测会员是否可升级
  498. conditionFunc[EConditionType.CheckVipLevelUp] = function(condition)
  499. return RoleManager.meDat
  500. end
  501. ---检测可回收装备数量
  502. conditionFunc[EConditionType.CheckRetrieve] = function(condition)
  503. local count = RoleManager.meData.equipInfo:GetRecycleCount()
  504. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  505. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  506. target = tonumber(target)
  507. return this.redDotFunc.Compare(count, sign, target)
  508. end
  509. ---检测职业等级
  510. conditionFunc[EConditionType.CheckCareerRank] = function(condition)
  511. local count = RoleManager.meData.career.careerRank
  512. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  513. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  514. target = tonumber(target)
  515. return this.redDotFunc.Compare(count, sign, target)
  516. end
  517. ---检测玩家在地图中的时间
  518. conditionFunc[EConditionType.CheckMapTime] = function(condition)
  519. local count = Time.time - LoginManager.enterMapTime
  520. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  521. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  522. target = tonumber(target)
  523. return this.redDotFunc.Compare(count, sign, target)
  524. end
  525. ---检测玩家血量比例
  526. conditionFunc[EConditionType.CheckHP] = function(condition)
  527. local count = RoleManager.meData.Hp / RoleManager.meData.MaxHp
  528. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  529. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  530. target = tonumber(target)
  531. target = target / 10000
  532. return this.redDotFunc.Compare(count, sign, target)
  533. end
  534. conditionFunc[EConditionType.checkMap] = function(condition)
  535. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  536. --return SL:MapLevelConditionCheck()
  537. local target = tonumber(string.sub(condition, #condition))
  538. if target == 0 then
  539. return not (Scene.mapConfig.id == tonumber(targetValueStr))
  540. else
  541. return Scene.mapConfig.id == tonumber(targetValueStr)
  542. end
  543. end
  544. ---检测对比玩家等级和[世界等级-条件参数]
  545. conditionFunc[EConditionType.CheckWorldLevel] = function(condition)
  546. local number = this.redDotFunc.GetStringInParentheses(condition)
  547. number = tonumber(number)
  548. local sign = this.redDotFunc.GetComparerSign(condition)
  549. local roleLevel = RoleManager.meData.Level
  550. local worldLevel = DataManager.worldLevel.worldLevel - number
  551. return this.redDotFunc.Compare(roleLevel, sign, worldLevel)
  552. end
  553. ---检测套装所有装备equip_extraAtt_cost强化等级 CheckExtraAttSuitLevel[套装ID#附加属性分组#附加等级]=1
  554. conditionFunc[EConditionType.CheckExtraAttSuitLevel] = function(condition)
  555. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  556. local targetValues = {}
  557. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  558. ---@type cfg_equip_suit_column
  559. this.redDotResult = targetValues
  560. local retCount = 0
  561. local suitItemId = ConfigManager.Get_cfg_equip_suit(tonumber(targetValues[1])).suitItemId
  562. for _, n in pairs(suitItemId) do
  563. local valueList = RoleManager.meData.equipInfo:GetWear380LevelListByCfgIdAndAttrType(n, tonumber(targetValues[2]))
  564. for _, value in pairs(valueList) do
  565. if this.redDotFunc.Compare(value, ">=", tonumber(targetValues[3])) then
  566. retCount = retCount + 1
  567. end
  568. end
  569. end
  570. if retCount == 7 then
  571. return true
  572. end
  573. return false
  574. end
  575. ---检测身上指定部位(位置代码[itme表strPart字段id])装备,只有要可强化(强化材料满足条件)的就return 1
  576. conditionFunc[EConditionType.CheckExtraAttLevel] = function(condition)
  577. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  578. return RoleManager.meData.equipInfo.equip380Info:CheckExtraAttCanStrength(tonumber(targetValueStr))
  579. end
  580. local function GetIsNeedRed(condition)
  581. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  582. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  583. return target == 1
  584. end
  585. ---检测出战中的伙伴是否可以升级
  586. conditionFunc[EConditionType.CheckPartnerUpgrade] = function(condition)
  587. if GetIsNeedRed(condition) then
  588. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerUpgrade", 1)
  589. if funSlotConfig then
  590. return funSlotConfig:jumpFun()
  591. end
  592. else
  593. return false
  594. end
  595. end
  596. local function CheckIsShowRedByType(condition, slotName)
  597. if GetIsNeedRed(condition) then
  598. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, slotName, 1)
  599. if funSlotConfig then
  600. return funSlotConfig:jumpFun()
  601. end
  602. else
  603. return false
  604. end
  605. end
  606. ---检测出战中的伙伴是否可以洗髓
  607. conditionFunc[EConditionType.CheckPartnerWashing] = function(condition)
  608. if GetIsNeedRed(condition) then
  609. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerWashing", 1)
  610. if funSlotConfig then
  611. return funSlotConfig:jumpFun()
  612. end
  613. else
  614. return false
  615. end
  616. end
  617. conditionFunc[EConditionType.CheckPartnerArray] = function(condition)
  618. if GetIsNeedRed(condition) then
  619. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerLineUp", 1)
  620. if funSlotConfig then
  621. return funSlotConfig:jumpFun()
  622. end
  623. else
  624. return false
  625. end
  626. end
  627. ---检测任意玩家拥有的伙伴是否可以升星
  628. conditionFunc[EConditionType.CheckPartnerUpstar] = function(condition)
  629. if GetIsNeedRed(condition) then
  630. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerUpstar", 1)
  631. if funSlotConfig then
  632. return funSlotConfig:jumpFun()
  633. end
  634. else
  635. return false
  636. end
  637. end
  638. ---检测升星所需的本体材料是否满足
  639. local function CheckPartneroneself()
  640. end
  641. ---检测升星所需的同阵营材料是否满足
  642. local function CheckPartnercamp()
  643. end
  644. ---检测升星所需的任意材料星级是否满足
  645. local function CheckPartnerany()
  646. end
  647. ---检测伙伴可洗髓的次数
  648. local function CheckPartnerWashingtimes()
  649. end
  650. ---检测伙伴可升级的次数
  651. local function CheckPartnerUpgradetimes()
  652. end
  653. ---检测伙伴是否达到洗髓上限
  654. local function CheckPartnerWashinglimit()
  655. end
  656. ---检测伙伴是否达到升级上限
  657. local function CheckPartnerWUpgradelimit()
  658. end
  659. ---检测孵化蛋是否可以开启
  660. conditionFunc[EConditionType.CheckPartnerEgg] = function(condition)
  661. if GetIsNeedRed(condition) then
  662. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerEgg", 1)
  663. if funSlotConfig then
  664. return funSlotConfig:jumpFun()
  665. end
  666. else
  667. return false
  668. end
  669. end
  670. ---检测是否有免费招募次数
  671. conditionFunc[EConditionType.CheckPartnerReffle] = function(condition)
  672. if GetIsNeedRed(condition) then
  673. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerReffle", 1)
  674. if funSlotConfig then
  675. return funSlotConfig:jumpFun()
  676. end
  677. else
  678. return false
  679. end
  680. end
  681. ---检测是否可以突破
  682. conditionFunc[EConditionType.CheckPartnerBreak] = function(condition)
  683. if GetIsNeedRed(condition) then
  684. local funSlotConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerBreak", 1)
  685. if funSlotConfig then
  686. return funSlotConfig:jumpFun()
  687. end
  688. else
  689. return false
  690. end
  691. end
  692. ---检测是否可以免费刷新派遣任务
  693. conditionFunc[EConditionType.CheckPartnerReffledispatch] = function(condition)
  694. if GetIsNeedRed(condition) then
  695. local funConfig = SlotManager.GetSlotConfigByIndex(SlotType.FunSlot, "CheckPartnerReffledispatch", 1)
  696. if funConfig then
  697. return funConfig:jumpFun()
  698. end
  699. else
  700. return false
  701. end
  702. end
  703. ---检测自身是攻城方还是守城方
  704. conditionFunc[EConditionType.CheckSiegeCamp] = function(condition)
  705. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  706. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  707. --TODO 红点条件
  708. --0 判断自身是否为守城方
  709. if target == 0 then
  710. --local me = RoleManager.meData.
  711. --1 判断自身是否为攻城方
  712. elseif target == 1 then
  713. end
  714. end
  715. ---检测时装是否满足激活
  716. conditionFunc[EConditionType.CheckFashionActivation] = function(condition)
  717. end
  718. ---检测是否获取新称号
  719. conditionFunc[EConditionType.CheckNewTitle] = function(condition)
  720. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  721. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  722. end
  723. ---检测玩家是否购买对应的礼包
  724. conditionFunc[EConditionType.CheckSponsorShip] = function(condition)
  725. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  726. local targetValues = {}
  727. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  728. local welfares = RoleManager.meData.roleExtInfo.alreadyBuyWelfare
  729. local alreadyBuyWelfare = {}
  730. for m, v in pairs(welfares) do
  731. table.insert(alreadyBuyWelfare, tonumber(v))
  732. end
  733. for k, v in pairs(targetValues) do
  734. if not table.contains(alreadyBuyWelfare, tonumber(v)) then
  735. return false
  736. end
  737. end
  738. return true
  739. end
  740. -----检测是否完成成就任务
  741. conditionFunc[EConditionType.CheckAchievementTask] = function(condition)
  742. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  743. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  744. if target == 0 then
  745. return not this.HasFinishTask()
  746. elseif target == 1 then
  747. return this.HasFinishTask()
  748. end
  749. end
  750. ---检测战阶经验是否满足升级经验
  751. conditionFunc[EConditionType.CheckAchievementLevelExp] = function(condition)
  752. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  753. local target = this.redDotFunc.GetTargetValue(condition, lastIndex)
  754. if target == 0 then
  755. return not this.CanUpWarStage()
  756. elseif target == 1 then
  757. return this.CanUpWarStage()
  758. end
  759. end
  760. -----检测效率指定类型任务是否完成
  761. conditionFunc[EConditionType.CheckEfficiencyTask] = function(condition)
  762. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  763. end
  764. ---检测守护装备是否可以进阶
  765. conditionFunc[EConditionType.CheckGuardstage] = function(condition)
  766. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  767. local targetValues = {}
  768. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  769. return RoleManager.meData.equipInfo.equipGuardInfo:CheckGuardCanUp(tonumber(targetValues[1]))
  770. end
  771. conditionFunc[EConditionType.CheckEquipWearingBar] = function(condition)
  772. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  773. local targetValues = {}
  774. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  775. return table.count(RoleManager.meData.bagInfo:GetSpecialWearBarEquipInBag(tonumber(targetValues[1]))) > 0 or
  776. table.count(RoleManager.meData.equipInfo:GetEquipListByWearBar(tonumber(targetValues[1]))) > 0
  777. end
  778. conditionFunc[EConditionType.CheckItemMail] = function(condition)
  779. for _, v in pairs(DataManager.mailInfo.mailTbl) do
  780. if v.state ~= 2 and table.count(v.items) > 0 then
  781. return true
  782. end
  783. end
  784. return false
  785. end
  786. conditionFunc[EConditionType.CheckFirstRechargep] = function(condition)
  787. end
  788. conditionFunc[EConditionType.CheckConductTask] = function(condition)
  789. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  790. return DataManager.taskInfo:GetIsInTask(tonumber(targetValueStr))
  791. end
  792. conditionFunc[EConditionType.checkTaskProgress] = function(condition)
  793. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  794. return DataManager.taskInfo:GetIsFinishTask(tonumber(targetValueStr))
  795. end
  796. ---检测赞助是否激活
  797. conditionFunc[EConditionType.CheckSponsorActive] = function(condition)
  798. end
  799. ---检测赞助是否激活
  800. conditionFunc[EConditionType.CheckSponsorLevel] = function(condition)
  801. return false
  802. end
  803. ---检测守护装备是否可以觉醒
  804. conditionFunc[EConditionType.CheckGuardawaken] = function(condition)
  805. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  806. local targetValues = {}
  807. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  808. return RoleManager.meData.equipInfo.equipGuardInfo:CheckGuardCanAwake(tonumber(targetValues[1]))
  809. end
  810. ---检测装备是否可以激活卓越属性
  811. conditionFunc[EConditionType.CheckequipActivation] = function(condition)
  812. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  813. local targetValues = {}
  814. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  815. if tonumber(targetValues[1]) == 1 then
  816. return RoleManager.meData.equipInfo.equipStrengthInfo:GetHaveEquipCanActiveEntryAttr()
  817. end
  818. return RoleManager.meData.equipInfo.equipStrengthInfo:GetEquipCanActiveEntryAttr(tonumber(targetValues[2]))
  819. end
  820. --检测按钮是否首次开启
  821. conditionFunc[EConditionType.CheckButtonFirstOpen] = function(condition)
  822. --TODO 0419
  823. --local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  824. local value = PlayerPrefs.GetInt(RoleManager.meData.id .. "isShowUnion", 0)
  825. return value == 0
  826. end
  827. --检测是否收到战盟审核信息
  828. conditionFunc[EConditionType.CheckAuditInf] = function(condition)
  829. --local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  830. --if tonumber(targetValue) == 1 then
  831. -- return DataManager.unionInfo:IsUnionCheckRedDot()
  832. --else
  833. -- return not DataManager.unionInfo:IsUnionCheckRedDot()
  834. --end
  835. return DataManager.unionInfo:IsUnionCheckRedDot()
  836. end
  837. --检测战盟臂章是否可以升级
  838. conditionFunc[EConditionType.CheckGardarmbands] = function(condition)
  839. --local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  840. --if tonumber(targetValue) == 1 then
  841. -- return DataManager.armBandInfo:CheckGardarmbands()
  842. --else
  843. -- return not DataManager.armBandInfo:CheckGardarmbands()
  844. --end
  845. return DataManager.armBandInfo:CheckGardarmbands()
  846. end
  847. --检测是否有可领取的战盟任务奖励
  848. conditionFunc[EConditionType.CheckGardTaskreward] = function(condition)
  849. --local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  850. --if tonumber(targetValue) == 1 then
  851. -- return DataManager.armBandInfo:CheckGardTaskReward()
  852. --else
  853. -- return not DataManager.armBandInfo:CheckGardTaskReward()
  854. --end
  855. return DataManager.armBandInfo:CheckGardTaskReward()
  856. end
  857. --检测是否有可领取的战盟工资
  858. conditionFunc[EConditionType.CheckGardsalary] = function(condition)
  859. --TODO 0419
  860. --local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  861. return DataManager.unionInfo:IsGetUnionSalaryRedDot()
  862. end
  863. --检测是否满足激活强化大师
  864. conditionFunc[EConditionType.CheckStrengthenMaster] = function(condition)
  865. local targetValue = this.redDotFunc.GetTargetValueByCondition(condition)
  866. if tonumber(targetValue) == 1 then
  867. return RoleManager.meData.masterInfo:CheckStrengthMasterCanActive()
  868. else
  869. return not RoleManager.meData.masterInfo:CheckStrengthMasterCanActive()
  870. end
  871. end
  872. --检测是否满足激活追加大师
  873. conditionFunc[EConditionType.CheckAppendMaster] = function(condition)
  874. local targetValue = this.redDotFunc.GetTargetValueByCondition(condition)
  875. if tonumber(targetValue) == 1 then
  876. return RoleManager.meData.masterInfo:CheckAppendMasterCanActive()
  877. else
  878. return not RoleManager.meData.masterInfo:CheckAppendMasterCanActive()
  879. end
  880. end
  881. --检测是否满足激活星级大师
  882. conditionFunc[EConditionType.CheckStarMaster] = function(condition)
  883. local targetValue = this.redDotFunc.GetTargetValueByCondition(condition)
  884. if tonumber(targetValue) == 1 then
  885. return RoleManager.meData.masterInfo:CheckStarMasterCanActive()
  886. else
  887. return not RoleManager.meData.masterInfo:CheckStarMasterCanActive()
  888. end
  889. end
  890. --检测指定装备部位是否可强化
  891. conditionFunc[EConditionType.CheckEquipAreaStrengthen] = function(condition)
  892. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  893. local targetValue = this.redDotFunc.GetTargetValueByCondition(condition)
  894. if tonumber(targetValue) == 1 then
  895. return RoleManager.meData.equipInfo.equipStrengthInfo:GetEquipCanStrength(tonumber(targetValueStr))
  896. else
  897. return not RoleManager.meData.equipInfo.equipStrengthInfo:GetEquipCanStrength(tonumber(targetValueStr))
  898. end
  899. end
  900. --检测指定装备部位是否可追加
  901. conditionFunc[EConditionType.CheckEquipAreaAppends] = function(condition)
  902. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  903. local targetValue = this.redDotFunc.GetTargetValueByCondition(condition)
  904. if tonumber(targetValue) == 1 then
  905. return RoleManager.meData.equipInfo.equipStrengthInfo:GetEquipCanAppend(tonumber(targetValueStr))
  906. else
  907. return not RoleManager.meData.equipInfo.equipStrengthInfo:GetEquipCanAppend(tonumber(targetValueStr))
  908. end
  909. end
  910. --检测天赋是否可升级
  911. conditionFunc[EConditionType.CheckGiftLevelUp] = function(condition)
  912. return false
  913. end
  914. --检测首充礼包是否可领取
  915. conditionFunc[EConditionType.CheckFirstChargeCanGetReward] = function(condition)
  916. return DataManager.firstChargeInfo:GetFirstChargeRedDot()
  917. end
  918. --检测首充礼包对应天数是否可领取
  919. conditionFunc[EConditionType.CheckFirstChargeDay] = function(condition)
  920. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  921. return DataManager.firstChargeInfo:GetFirstChargeRedDotState(tonumber(targetValueStr))
  922. end
  923. --检测每日礼包对应天数是否可领取
  924. conditionFunc[EConditionType.CheckRechargeDaily] = function(condition)
  925. return DataManager.dailyGiftInfo:IsHasDailyAward()
  926. end
  927. --检测角色指定掉落包终生总计掉落次数
  928. conditionFunc[EConditionType.CheckPropDropTime] = function(condition)
  929. ---TODO
  930. return false
  931. end
  932. ---vip礼包是否可领取
  933. conditionFunc[EConditionType.CheckVIPGiftPackClaimable] = function()
  934. return this.IsVIPGiftPackClaimable()
  935. end
  936. conditionFunc[EConditionType.CheckLogOn] = function(condition)
  937. if GetIsNeedRed(condition) then
  938. if DataManager.pinkDiamondInfo:IsActivePinkDiamondActivity() then
  939. local value = PlayerPrefs.GetInt(RoleManager.meData.id .. "CheckClickPinkDiamond", 0)
  940. return value == 0
  941. end
  942. return false
  943. else
  944. return false
  945. end
  946. end
  947. local function CheckActivityExchange(condition)
  948. if GetIsNeedRed(condition) then
  949. else
  950. return false
  951. end
  952. end
  953. ---@param condition string
  954. ---@return boolean
  955. conditionFunc[EConditionType.CheckWearItem] = function(condition)
  956. --logError("ItemWearComparer>>>>>>>>>>>>>>>>>>>>>>>>qiji5")
  957. local itemId = this.redDotFunc.GetStringInParentheses(condition)
  958. local count = 0
  959. local equipTbl = RoleManager.meData.equipInfo.equips
  960. for k, v in pairs(equipTbl) do
  961. for _, itemInfo in pairs(v) do
  962. if itemInfo.cfgId == tonumber(itemId) then
  963. count = count + 1
  964. end
  965. end
  966. end
  967. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  968. local targetCount = this.redDotFunc.GetTargetValue(condition, lastIndex)
  969. targetCount = tonumber(targetCount)
  970. return this.redDotFunc.Compare(count, sign, targetCount)
  971. end
  972. ---@param condition string
  973. ---@return boolean
  974. conditionFunc[EConditionType.CheckItems] = function(condition)
  975. --logError("ItemsComparer>>>>>>>>>>>>>>>>>>>>>>>>qiji5")
  976. local itemId = tonumber(this.redDotFunc.GetStringInParentheses(condition))
  977. local count = RoleManager.meData.bagInfo:GetItemCount(itemId)
  978. --local haveInBag = RoleManager.meData.bagInfo:IsHaveCfgIdItem(itemId)
  979. --if haveInBag then
  980. -- count = count + RoleManager.meData.bagInfo:GetItemCount(itemId)
  981. --end
  982. local equips = RoleManager.meData.equipInfo.equips
  983. for k, v in pairs(equips) do
  984. if v == itemId then
  985. count = count + 1
  986. end
  987. end
  988. local sign, lastIndex = this.redDotFunc.GetComparerSign(condition)
  989. local targetValue = this.redDotFunc.GetTargetValue(condition, lastIndex)
  990. targetValue = tonumber(targetValue)
  991. return this.redDotFunc.Compare(count, sign, targetValue)
  992. end
  993. ---e
  994. conditionFunc[EConditionType.CheckGoldTask] = function()
  995. return false
  996. end
  997. ---[参数1=时间下限#参数2=时间上限];检测玩家是否处于离线挂机状态的时间区间;例如:checkMultipleTime[5#10]=1,表示检测玩家是否处于离线挂机状态的第5-10秒之间
  998. --local function CheckMultipleTime(condition)
  999. -- local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  1000. -- local targetValues = {}
  1001. -- this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  1002. -- --等待多倍挂机提供真实数据接口
  1003. --
  1004. --
  1005. --
  1006. -- return false
  1007. --end
  1008. ---@param condition string
  1009. ---@param return number
  1010. local function GetSignIndex(condition)
  1011. local firstIndex, lastIndex = nil, nil
  1012. if string.find(condition, ">", 1) then
  1013. firstIndex, lastIndex = string.find(condition, ">", 1)
  1014. elseif string.find(condition, "<", 1) then
  1015. firstIndex, lastIndex = string.find(condition, "<", 1)
  1016. elseif string.find(condition, "=", 1) then
  1017. firstIndex, lastIndex = string.find(condition, "=", 1)
  1018. elseif string.find(condition, "%[", 1) then
  1019. firstIndex, lastIndex = string.find(condition, "%[", 1)
  1020. end
  1021. return firstIndex
  1022. end
  1023. ---@param type EConditionType
  1024. ---@param condition string
  1025. ---@return boolean
  1026. local function CalculateSingleState(condition)
  1027. local state = true
  1028. local temp = false
  1029. local errorMsg = ""
  1030. local typeLastIndex = GetSignIndex(condition)
  1031. local tp = nil
  1032. if typeLastIndex == nil then
  1033. return
  1034. end
  1035. local lastIndex = string.find(condition, "%[", 1)
  1036. if lastIndex then
  1037. tp = string.sub(condition, 1, lastIndex - 1)
  1038. else
  1039. tp = string.sub(condition, 1, typeLastIndex - 1)
  1040. end
  1041. if not this.typeToconditions then
  1042. this.typeToconditions = {}
  1043. --local tt = ConfigManager.GetConfigTable("cfg_conditions")
  1044. if tt then
  1045. for k, v in pairs(tt) do
  1046. if v.conditionType == tp then
  1047. this.typeToconditions[v.conditionType] = v
  1048. end
  1049. end
  1050. end
  1051. end
  1052. if this.typeToconditions[tp] then
  1053. this.redDotResult.fieldName = this.typeToconditions[tp].name
  1054. end
  1055. local condFunc = conditionFunc[tp]
  1056. if condFunc then
  1057. temp, errorMsg = condFunc(condition)
  1058. else
  1059. local conditionTbl = this.moduleRedConditionFunc[tp]
  1060. if conditionTbl then
  1061. local func = conditionTbl[1]
  1062. local base = conditionTbl[2]
  1063. local args = conditionTbl[3]
  1064. temp = func(base, condition, args)
  1065. end
  1066. end
  1067. state = state and temp
  1068. return state, errorMsg
  1069. end
  1070. ---@param tbl table
  1071. ---@return boolean
  1072. local function GetResult(tbl)
  1073. local signs = tbl.signs
  1074. local condition = tbl.condition
  1075. local isLoop = false
  1076. local signIndex = 1
  1077. local condIndex = 1
  1078. local result = false
  1079. local errorMsg
  1080. result, errorMsg = CalculateSingleState(condition[condIndex])
  1081. condIndex = condIndex + 1
  1082. if #signs > 0 and signs then
  1083. repeat
  1084. if signs[signIndex] == "&" then
  1085. result = result and CalculateSingleState(condition[condIndex])
  1086. elseif signs[signIndex] == "|" then
  1087. result = result or CalculateSingleState(condition[condIndex])
  1088. end
  1089. signIndex = signIndex + 1
  1090. condIndex = condIndex + 1
  1091. if signIndex > #signs or condIndex > #condition then
  1092. isLoop = true
  1093. end
  1094. until isLoop
  1095. end
  1096. return result, errorMsg
  1097. end
  1098. ---@param cond string
  1099. ---@return table
  1100. local function AnalyzingBracket(cond)
  1101. if not this.AnalyzingBracketCond then
  1102. this.AnalyzingBracketCond = {}
  1103. end
  1104. if this.AnalyzingBracketCond[cond] then
  1105. local tbl = this.AnalyzingBracketCond[cond]
  1106. tbl.result = false
  1107. local isFindSign = string.find(cond, "%(")
  1108. if not isFindSign then
  1109. tbl.result, tbl.errorMsg = GetResult(tbl)
  1110. else
  1111. for i = 1, #tbl.condition do
  1112. tbl.childs[i] = AnalyzingBracket(tbl.condition[i], tbl)
  1113. end
  1114. local result = tbl.childs[1] .result
  1115. local childIndex = 2
  1116. for i = 1, #tbl.signs do
  1117. if tbl.signs[i] == "&" then
  1118. result = result and tbl.childs[childIndex].result
  1119. elseif tbl.signs[i] == "|" then
  1120. result = result or tbl.childs[childIndex].result
  1121. end
  1122. childIndex = childIndex + 1
  1123. end
  1124. tbl.result = result
  1125. end
  1126. return tbl
  1127. else
  1128. local tbl = {}
  1129. tbl.condition = {}
  1130. tbl.signs = {}
  1131. tbl.childs = {}
  1132. tbl.result = false
  1133. local isFindSign = string.find(cond, "%(")
  1134. if not isFindSign then
  1135. local signV = this.redDotFunc.FindAllIndex(cond, "|")
  1136. local signH = this.redDotFunc.FindAllIndex(cond, "&")
  1137. local allSigns = this.redDotFunc.BlendTable(signV, signH)
  1138. table.sort(allSigns)
  1139. for i = 1, #allSigns do
  1140. local sign = string.sub(cond, allSigns[i], allSigns[i])
  1141. tbl.signs[i] = sign
  1142. end
  1143. local index = 1
  1144. for i = 1, #allSigns do
  1145. local condi = string.sub(cond, index, allSigns[i] - 1)
  1146. index = allSigns[i] + 1
  1147. tbl.condition[i] = condi
  1148. end
  1149. local condi = string.sub(cond, index)
  1150. local count = #tbl.condition
  1151. tbl.condition[count + 1] = condi
  1152. tbl.result = GetResult(tbl)
  1153. else
  1154. local leftBracket = this.redDotFunc.FindAllIndex(cond, "(")
  1155. local rightBracket = this.redDotFunc.FindAllIndex(cond, ")")
  1156. local BracketPairs = this.redDotFunc.FindAllBracketPair(leftBracket, rightBracket)
  1157. tbl = CreateConditionTree(BracketPairs, cond)
  1158. for i = 1, #tbl.condition do
  1159. tbl.childs[i] = AnalyzingBracket(tbl.condition[i], tbl)
  1160. end
  1161. local result = tbl.childs[1] .result
  1162. local childIndex = 2
  1163. for i = 1, #tbl.signs do
  1164. if tbl.signs[i] == "&" then
  1165. result = result and tbl.childs[childIndex].result
  1166. elseif tbl.signs[i] == "|" then
  1167. result = result or tbl.childs[childIndex].result
  1168. end
  1169. childIndex = childIndex + 1
  1170. end
  1171. tbl.result = result
  1172. end
  1173. this.AnalyzingBracketCond[cond] = tbl
  1174. return tbl
  1175. end
  1176. end
  1177. ---@param allPairs table
  1178. ---@param conditions string
  1179. ---@param table
  1180. local function CreateConditionTree(allPairs, conditions)
  1181. local tbl = {}
  1182. tbl.condition = {}
  1183. tbl.signs = {}
  1184. tbl.childs = {}
  1185. tbl.result = false
  1186. local tblIndex = 1
  1187. local isRepeat = false
  1188. local sIndex = 1
  1189. local strIndex = 1
  1190. repeat
  1191. if sIndex > #conditions then
  1192. isRepeat = true
  1193. else
  1194. local index = string.find(conditions, "%(", sIndex)
  1195. if index then
  1196. local subStr = string.sub(conditions, strIndex, index - 1)
  1197. local signTblV = this.redDotFunc.FindAllIndex(subStr, "|")
  1198. local signTblH = this.redDotFunc.FindAllIndex(subStr, "&")
  1199. local signTbl = this.redDotFunc.BlendTable(signTblV, signTblH)
  1200. table.sort(signTbl)
  1201. local splitIndex = 1
  1202. local count = #tbl.signs + 1
  1203. for i = 1, #signTbl do
  1204. local sign = string.sub(subStr, signTbl[i], signTbl[i])
  1205. tbl.signs[count] = sign
  1206. count = count + 1
  1207. end
  1208. for i = 1, #signTbl do
  1209. local st = string.sub(subStr, splitIndex, signTbl[i] - 1)
  1210. tbl.condition[tblIndex] = st
  1211. tblIndex = tblIndex + 1
  1212. splitIndex = signTbl[i] + 1
  1213. end
  1214. local pair = {}
  1215. pair.left = nil
  1216. pair.right = nil
  1217. for i = 1, #allPairs do
  1218. if allPairs[i].left == index then
  1219. pair .left = index
  1220. pair .right = allPairs[i].right
  1221. end
  1222. end
  1223. st = string.sub(conditions, pair.left + 1, pair.right - 1)
  1224. tbl.condition[tblIndex] = st
  1225. local index = pair.right + 1
  1226. if index < #conditions then
  1227. local lastSign = string.sub(conditions, index, index)
  1228. local count = #tbl.signs + 1
  1229. tbl.signs[count] = lastSign
  1230. end
  1231. tblIndex = tblIndex + 1
  1232. sIndex = pair.right + 2
  1233. strIndex = pair.right + 2
  1234. else
  1235. if sIndex < #conditions then
  1236. local subStr = string.sub(conditions, sIndex, #conditions)
  1237. local signTblV = this.redDotFunc.FindAllIndex(subStr, "|")
  1238. local signTblH = this.redDotFunc.FindAllIndex(subStr, "&")
  1239. local signTbl = this.redDotFunc.BlendTable(signTblV, signTblH)
  1240. table.sort(signTbl)
  1241. local count = #tbl.signs + 1
  1242. for i = 1, #signTbl do
  1243. local sign = string.sub(subStr, signTbl[i], signTbl[i])
  1244. tbl.signs[count] = sign
  1245. count = count + 1
  1246. end
  1247. local splitIndex = 1
  1248. for i = 1, #signTbl do
  1249. local st = string.sub(subStr, splitIndex, signTbl[i] - 1)
  1250. tbl.condition[tblIndex] = st
  1251. tblIndex = tblIndex + 1
  1252. splitIndex = signTbl[i] + 1
  1253. end
  1254. local st = string.sub(subStr, splitIndex, #subStr)
  1255. tbl.condition[tblIndex] = st
  1256. tblIndex = tblIndex + 1
  1257. end
  1258. isRepeat = true
  1259. end
  1260. end
  1261. until isRepeat
  1262. return tbl
  1263. end
  1264. ---计算条件组合的返回结果
  1265. ---@param conditions string @条件组合 示例 CheckLevel>=90&(CheckJob=1|CheckJob=2)
  1266. ---@return boolean @条件组合是否达到条件
  1267. function this.CalculateConditionGroup(conditions)
  1268. if not RoleManager or not RoleManager.meData then
  1269. return false
  1270. end
  1271. if string.isNullOrEmpty(conditions) then
  1272. return true
  1273. end
  1274. if not this.sameFrameConditions then
  1275. this.sameFrameConditions = {}
  1276. end
  1277. local cache = this.sameFrameConditions[conditions]
  1278. if not cache then
  1279. cache = {}
  1280. cache.frameCount = 0
  1281. this.sameFrameConditions[conditions] = cache
  1282. end
  1283. if cache.frameCount == Time.frameCount then
  1284. return cache.result, cache.redDotResult, cache.tbl
  1285. end
  1286. local tblL = {}
  1287. tblL = this.redDotFunc.FindAllIndex(conditions, "(")
  1288. local tblR = {}
  1289. tblR = this.redDotFunc.FindAllIndex(conditions, ")")
  1290. local allPairs = {}
  1291. allPairs = this.redDotFunc.FindAllBracketPair(tblL, tblR)
  1292. local tbl = CreateConditionTree(allPairs, conditions)
  1293. for i = 1, #tbl.condition do
  1294. tbl.childs[i] = AnalyzingBracket(tbl.condition[i], tbl)
  1295. end
  1296. local result = tbl.childs[1].result
  1297. local index = 2
  1298. for i = 1, #tbl.signs do
  1299. if tbl.signs[i] == "&" then
  1300. if tbl.childs[index] ~= nil then
  1301. result = result and tbl.childs[index].result
  1302. end
  1303. elseif tbl.signs[i] == "|" then
  1304. if tbl.childs[index] ~= nil then
  1305. result = result or tbl.childs[index].result
  1306. end
  1307. end
  1308. index = index + 1
  1309. end
  1310. cache.frameCount = Time.frameCount
  1311. cache.result = result
  1312. cache.redDotResult = this.redDotResult
  1313. cache.tbl = tbl
  1314. return result, this.redDotResult, tbl
  1315. end
  1316. ---解析XXXX[套装ID#附加属性分组#附加等级]=1类型的条件,以数组形式返回中括号中的数据
  1317. function this.GetInfoBetweenBraces(condition)
  1318. if string.isNullOrEmpty(condition) then
  1319. return
  1320. end
  1321. local targetValueStr = this.redDotFunc.GetStringInParentheses(condition)
  1322. local targetValues = {}
  1323. this.redDotFunc.SplitString(targetValueStr, "#", 1, targetValues)
  1324. return targetValues
  1325. end
  1326. ---@param conditionType EConditionType
  1327. ---@param conditionFunc function
  1328. function this.RegisterConditionFunc(conditionType, conditionFunc, base, args)
  1329. if not conditionFunc then
  1330. return
  1331. end
  1332. if not this.moduleRedConditionFunc[conditionType] then
  1333. this.moduleRedConditionFunc[conditionType] = {}
  1334. end
  1335. this.moduleRedConditionFunc[conditionType][1] = conditionFunc
  1336. this.moduleRedConditionFunc[conditionType][2] = base
  1337. this.moduleRedConditionFunc[conditionType][3] = args
  1338. end
  1339. ----@param id string @表数据 condition
  1340. --- @return boolean @是否满足
  1341. function this.CheckRedPointId(id)
  1342. local keys = cfg_redDot_new_post.GetCfgById(id).tCondStr
  1343. local conditions = cfg_redDot_new_post.GetCfgById(id).cfg.condition
  1344. conditions = string.split(conditions, ",")
  1345. if keys and #keys > 0 then
  1346. local isSatisfy = false
  1347. ---有可能多个条件,一个不满足直接返回
  1348. for k, v in pairs(keys) do
  1349. if conditionFunc[v] then
  1350. isSatisfy = conditionFunc[v](conditions[k])
  1351. if not isSatisfy then
  1352. return false
  1353. end
  1354. end
  1355. end
  1356. return isSatisfy
  1357. end
  1358. return false
  1359. end
  1360. ----@param panelName string @面板名字
  1361. function this.RefreshPanelALLRedStateKml(panelName)
  1362. RedDotManager.RefreshPanelALLRedStateKml(panelName)
  1363. end
  1364. ----@param condition string @根据条件刷新
  1365. function this.RefreshPanelALLRedStateKmlByCondition(condition)
  1366. RedDotManager.RefreshPanelALLRedStateKmlByCondition(condition)
  1367. end
  1368. ----@param condition string @根据条件刷新
  1369. ----@param callBack function @根据条件刷新
  1370. function this.AddRedDotConditionFunc(condition,callBack)
  1371. if conditionFunc then
  1372. conditionFunc[condition] = callBack
  1373. end
  1374. end