You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

script-skill-parser.js 95 kB

5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656
  1. let merge_skill = false;
  2. const Attributes = {
  3. /*0: "Fire",
  4. 1: "Water",
  5. 2: "Wood",
  6. 3: "Light",
  7. 4: "Dark",
  8. 5: "Heart",
  9. 6: "Jammer",
  10. 7: "Poison",
  11. 8: "MPoison",
  12. 9: "Bomb",*/
  13. Fire: 0,
  14. Water: 1,
  15. Wood: 2,
  16. Light: 3,
  17. Dark: 4,
  18. Heart: 5,
  19. Jammer: 6,
  20. Poison: 7,
  21. MPoison: 8,
  22. Bomb: 9,
  23. }
  24. for (let name in Attributes)
  25. {
  26. Attributes[Attributes[name]] = name;
  27. }
  28. Attributes.all = function () {
  29. return [
  30. this.Fire,
  31. this.Water,
  32. this.Wood,
  33. this.Light,
  34. this.Dark
  35. ];
  36. }
  37. Attributes._6color = function () {
  38. return [
  39. this.Fire,
  40. this.Water,
  41. this.Wood,
  42. this.Light,
  43. this.Dark,
  44. this.Heart
  45. ];
  46. }
  47. Attributes.orbs = function () {
  48. return [
  49. this.Fire,
  50. this.Water,
  51. this.Wood,
  52. this.Light,
  53. this.Dark,
  54. this.Heart,
  55. this.Jammer,
  56. this.Poison,
  57. this.MPoison,
  58. this.Bomb,
  59. ];
  60. }
  61. //代码来自于 https://www.jianshu.com/p/3644833bca33
  62. function isEqual(obj1,obj2) {
  63. //判断是否是对象或数组
  64. function isObject(obj) {
  65. return typeof obj === 'object' && obj !== null;
  66. }
  67. // 两个数据有任何一个不是对象或数组
  68. if (!isObject(obj1) || !isObject(obj2)) {
  69. // 值类型(注意:参与equal的一般不会是函数)
  70. return obj1 === obj2;
  71. }
  72. // 如果传的两个参数都是同一个对象或数组
  73. if (obj1 === obj2) {
  74. return true;
  75. }
  76. // 两个都是对象或数组,而且不相等
  77. // 1.先比较obj1和obj2的key的个数,是否一样
  78. const obj1Keys = Object.keys(obj1);
  79. const obj2Keys = Object.keys(obj2);
  80. if (obj1Keys.length !== obj2Keys.length) {
  81. return false;
  82. }
  83. // 如果key的个数相等,就是第二步
  84. // 2.以obj1为基准,和obj2依次递归比较
  85. for (let key in obj1) {
  86. // 比较当前key的value --- 递归
  87. const res = isEqual(obj1[key], obj2[key]);
  88. if (!res) {
  89. return false;
  90. }
  91. }
  92. // 3.全相等
  93. return true
  94. }
  95. class Board
  96. {
  97. #rowCount = 6;
  98. #columnCount = 7;
  99. #data = [];
  100. constructor(def = null)
  101. {
  102. for (let ri=0;ri<this.#rowCount;ri++)
  103. {
  104. this.#data.push(new Array(this.#columnCount).fill(Array.isArray(def) ? null : def));
  105. }
  106. if (Array.isArray(def))
  107. {
  108. this.randomFill(def);
  109. }
  110. }
  111. //填充序列
  112. sequenceFill(sequence, exclude)
  113. {
  114. if (!Array.isArray(exclude) && exclude != null)
  115. exclude = [exclude];
  116. const o = sequence.entries();
  117. //65版部分
  118. for (let ri=0;ri<this.#data.length;ri++)
  119. {
  120. if (ri == 2) ri++;
  121. const row = this.#data[ri];
  122. for (let ci=0;ci<row.length;ci++)
  123. {
  124. if (ci == 3) ci++;
  125. //从数组中随机取出一个
  126. if (exclude && exclude.includes(row[ci])) continue;
  127. row[ci] = o.next().value?.[1] ?? row[ci];
  128. }
  129. }
  130. //填充剩下的部分
  131. for (let ri=0;ri<this.#data.length;ri++)
  132. {
  133. if (ri == 2) ri++;
  134. const row = this.#data[ri];
  135. if (exclude && exclude.includes(row[3])) continue;
  136. row[3] = o.next().value?.[1] ?? row[3] ;
  137. }
  138. const row = this.#data[2];
  139. for (let ci=0;ci<row.length;ci++)
  140. {
  141. if (exclude && exclude.includes(row[ci])) continue;
  142. row[ci] = o.next().value?.[1] ?? row[ci] ;
  143. }
  144. }
  145. //将有序数组转为随机的数组
  146. sequenceToRandom(valueArray)
  147. {
  148. const randomData = [];
  149. //将65版之后的的提出来
  150. const maxCount = this.#rowCount * this.#columnCount
  151. let secondaryData = valueArray.splice((this.#rowCount - 1) * (this.#columnCount - 1) - (maxCount - valueArray.length));
  152. while(valueArray.length > 0)
  153. {
  154. randomData.push(valueArray.randomShift());
  155. }
  156. while(secondaryData.length > 0)
  157. {
  158. randomData.push(secondaryData.randomShift());
  159. }
  160. return randomData;
  161. }
  162. //洗版的填充
  163. randomFill(attrs)
  164. {
  165. let valueArray = new Uint8Array(this.#rowCount * this.#columnCount);
  166. crypto.getRandomValues(valueArray); //获取符合密码学要求的安全的随机值
  167. valueArray = Array.from(valueArray.map(x => attrs[x % attrs.length])); //用所有宝珠随机填充
  168. //之后用每种颜色填充前3个
  169. attrs.forEach((attr,idx)=>{
  170. valueArray.fill(attr, idx * 3, (idx + 1) * 3);
  171. });
  172. //将上方数据重新乱序排列
  173. const randomData = this.sequenceToRandom(valueArray);
  174. this.sequenceFill(randomData);
  175. }
  176. //生成珠子的填充
  177. generateOrbs(attrs, count, exclude)
  178. {
  179. let space = this.#rowCount * this.#columnCount;
  180. if (exclude?.length > 0)
  181. {
  182. space -= this.#data.flat().filter(o=>exclude.includes(o)).length;
  183. }
  184. let valueArray = new Array(space);
  185. attrs.forEach((attr,idx)=>{
  186. valueArray.fill(attr, idx * count, (idx + 1) * count);
  187. });
  188. //将上方数据重新乱序排列
  189. const randomData = this.sequenceToRandom(valueArray);
  190. this.sequenceFill(randomData, exclude);
  191. }
  192. //设定横行
  193. setRow(rows, attr = 0)
  194. {
  195. for (let row of rows)
  196. {
  197. if (row >= 2) row++;
  198. const rowData = this.#data[row];
  199. for (let ri=0;ri<rowData.length;ri++)
  200. {
  201. rowData[ri] = attr;
  202. }
  203. }
  204. }
  205. //设定竖列
  206. setColumn(cols, attr = 0)
  207. {
  208. for (let col of cols)
  209. {
  210. if (col >= 3) col++;
  211. for (let row of this.#data)
  212. {
  213. row[col] = attr;
  214. }
  215. }
  216. }
  217. //设定形状
  218. setShape(matrix, attr = 0)
  219. {
  220. function fillRow(rowData, inputRow, attr)
  221. {
  222. for (let col of inputRow)
  223. {
  224. if (col == 3) rowData[col] = attr;
  225. if (col >= 3) col++;
  226. rowData[col] = attr;
  227. }
  228. }
  229. for (let ri=0;ri<matrix.length;ri++)
  230. {
  231. if (ri == 2)
  232. {
  233. fillRow(this.#data[ri], matrix[ri], attr);
  234. }
  235. fillRow(this.#data[ri >= 2 ? ri+1 : ri], matrix[ri], attr);
  236. }
  237. }
  238. //面板叠加
  239. overlayBoard(board)
  240. {
  241. for (let ri=0;ri<board.length;ri++)
  242. {
  243. const rowNew = board[ri];
  244. const rowOld = this.#data[ri];
  245. for (let ci=0;ci<rowNew.length;ci++)
  246. {
  247. rowOld[ci] = rowNew[ci] ?? rowOld[ci];
  248. }
  249. }
  250. }
  251. //导出数组
  252. valueOf()
  253. {
  254. return this.#data;
  255. }
  256. //输出表格
  257. toTable()
  258. {
  259. const table = document.createElement("table");
  260. table.className = "board";
  261. this.#data.forEach((rowData, ri, rArr) => {
  262. const row = table.insertRow();
  263. if (ri == 2 && rArr.length > 5) row.classList.add("board-row4");
  264. rowData.forEach((orbType, ci, cArr) => {
  265. const cell = row.insertCell();
  266. const orb = cell.appendChild(document.createElement('icon'));
  267. orb.className = "orb";
  268. if (orbType != null) orb.setAttribute("data-orb-icon", orbType);
  269. if (ci == 3 && cArr.length > 6) cell.classList.add("board-cell5");
  270. });
  271. });
  272. if (this.#data.length > 5)
  273. {
  274. table.onclick = function() {
  275. this.classList.toggle("board-76");
  276. };
  277. }
  278. return table;
  279. }
  280. }
  281. const SkillValue = {
  282. isLess: function (value) {
  283. if (value.kind === SkillValueKind.Percent) return value.value < 1;
  284. if (value.kind === SkillValueKind.Constant) return value.value < 0;
  285. return false;
  286. }
  287. };
  288. const SkillValueKind = {
  289. Percent: 'mul',
  290. Constant: 'const',
  291. ConstantTo: 'const-to',
  292. xMaxHP: 'mul-maxhp',
  293. xHP: 'mul-hp',
  294. xCHP: 'mul-chp',
  295. xATK: 'mul-atk',
  296. xRCV: 'mul-rcv',
  297. RandomATK: 'random-atk',
  298. HPScale: 'hp-scale',
  299. xTeamHP: 'mul-team-hp',
  300. xTeamATK: 'mul-team-atk',
  301. xTeamRCV: 'mul-team-rcv',
  302. xAwakenings: 'mul-awakenings',
  303. };
  304. const SkillPowerUpKind = {
  305. Multiplier: 'mul',
  306. ScaleAttributes: 'scale-attrs',
  307. ScaleCombos: 'scale-combos',
  308. ScaleMatchLength: 'scale-match-len',
  309. ScaleMatchAttrs: 'scale-match-attrs',
  310. ScaleCross: 'scale-cross',
  311. ScaleStateKindCount: 'scale-state-kind-count',
  312. };
  313. const SkillKinds = {
  314. Unknown: "unknown",
  315. ActiveTurns: "active-turns",
  316. DamageEnemy: "damage-enemy",
  317. Vampire: "vampire",
  318. ReduceDamage: "reduce-damage",
  319. SelfHarm: "self-harm",
  320. Heal: "heal",
  321. AutoHealBuff: "auto-heal-buff",
  322. ChangeOrbs: "change-orbs",
  323. GenerateOrbs: "generate-orbs",
  324. FixedOrbs: "fixed-orbs",
  325. PowerUp: "power-up",
  326. CounterAttack: "counter-attack",
  327. SetOrbState: "set-orb-state",
  328. RateMultiply: "rate-mul",
  329. OrbDropIncrease: "orb-drop-incr",
  330. Resolve: "resolve",
  331. Delay: "delay",
  332. DefenseBreak: "def-break",
  333. MassAttack: "mass-attack",
  334. BoardChange: "board-change",
  335. Unbind: "unbind",
  336. BindSkill: "bind-skill",
  337. RandomSkills: "random-skills",
  338. SkillProviso: "skill-proviso",
  339. ChangeAttribute: "change-attr",
  340. SkillBoost: "skill-boost",
  341. AddCombo: "add-combo",
  342. VoidEnemyBuff: "void-enemy-buff",
  343. Poison: "poison",
  344. CTW: "ctw",
  345. Gravity: "gravity",
  346. FollowAttack: "follow-attack",
  347. FollowAttackFixed: "follow-attack-fixed",
  348. AutoHeal: "auto-heal",
  349. TimeExtend: "time-extend",
  350. DropRefresh: "drop-refresh",
  351. LeaderChange: "leader-change",
  352. MinMatchLength: "min-match-len",
  353. FixedTime: "fixed-time",
  354. Drum: "drum",
  355. AutoPath: "auto-path",
  356. Board7x6: "7x6-board",
  357. NoSkyfall: "no-skyfall",
  358. Henshin: "henshin",
  359. VoidPoison: "void-poison",
  360. SkillProviso: "skill-proviso",
  361. }
  362. function skillParser(skillId)
  363. {
  364. function merge(skills)
  365. {
  366. //解封部分的合并
  367. let unbinds = skills.filter(skill=>skill.kind == SkillKinds.Unbind);
  368. if (unbinds.length>1)
  369. { //把后面的全都合并到第一个
  370. unbinds.reduce((pre,cur)=>{
  371. pre.normal = pre.normal || cur.normal;
  372. pre.awakenings = pre.awakenings || cur.awakenings;
  373. pre.matches = pre.matches || cur.matches;
  374. return pre
  375. });
  376. unbinds.shift(); //从筛选中去除第一个
  377. unbinds.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  378. }
  379. //破吸部分的合并
  380. let voidBuff = skills.filter(skill=>skill.kind == SkillKinds.ActiveTurns &&
  381. skill.skill.kind == SkillKinds.VoidEnemyBuff);
  382. if (voidBuff.length>1 && voidBuff.every((s,i,a)=>s.turns == a[0].turns))
  383. { //把后面的全都合并到第一个
  384. voidBuff[0].skill.buffs = voidBuff.flatMap(s=>s.skill.buffs);
  385. voidBuff.shift(); //从筛选中去除第一个
  386. voidBuff.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  387. }
  388. let fixedDamages = skills.filter(skill=>skill.kind == SkillKinds.DamageEnemy && skill.attr === 'fixed').filter((skill,idx,arr)=>skill.id==arr[0].id);
  389. if (fixedDamages.length>1)
  390. { //把后面的全都合并到第一个
  391. fixedDamages[0].times = fixedDamages.length;
  392. fixedDamages.shift(); //从筛选中去除第一个
  393. fixedDamages.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  394. }
  395. let skillPowerUp = skills.filter(skill=>skill.kind == SkillKinds.PowerUp);
  396. if (skillPowerUp.length>1)
  397. {
  398. //十字
  399. let scaleCross = skillPowerUp.filter(skill=>skill.value.kind === SkillPowerUpKind.ScaleCross);
  400. function mergeScaleCrossAttr(skill)
  401. {
  402. let crosses = skill.value.crosses;
  403. let atk = crosses[0].atk;
  404. let rcv = crosses[0].rcv;
  405. if (crosses.length >= 2 &&
  406. crosses.every(cross=>cross.atk === atk && cross.rcv === rcv)
  407. ) {
  408. //所有值一样
  409. crosses.reduce((pre,cur)=>{
  410. pre.attr = pre.attr.concat(cur.attr);
  411. return pre;
  412. });
  413. skill.value.crosses.splice(1);
  414. }
  415. }
  416. //每个十字技能,先把所有属性合并
  417. scaleCross.forEach(mergeScaleCrossAttr);
  418. //筛选出所有倍率一样的子技能
  419. scaleCross = scaleCross.filter((skill,idx,arr)=>{
  420. let atk = arr[0].value.crosses[0].atk;
  421. let rcv = arr[0].value.crosses[0].rcv;
  422. let crosses = skill.value.crosses;
  423. return crosses.every(cross=>cross.atk === atk && cross.rcv === rcv);
  424. });
  425. //先合并属性倍率
  426. if (scaleCross.length >= 1)
  427. { //把后面的全都合并到第一个
  428. scaleCross.reduce((pre,cur)=>{
  429. pre.value.crosses = pre.value.crosses.concat(cur.value.crosses);
  430. return pre
  431. });
  432. let _skill = scaleCross.shift(); //从筛选中去除第一个
  433. scaleCross.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  434. mergeScaleCrossAttr(_skill);
  435. }
  436. //重新找出来十字,合并附加内容
  437. scaleCross = skills.filter(skill=>skill.kind == SkillKinds.PowerUp && skill.value.kind === SkillPowerUpKind.ScaleCross);
  438. scaleCross = scaleCross.filter((skill,idx,arr)=>{
  439. let s0 = arr[0];
  440. let attr0 = s0.value.crosses[0].attr.concat().sort();
  441. let attr1 = skill.value.crosses[0].attr.concat().sort();
  442. return isEqual(skill.condition, s0.condition) &&
  443. isEqual(skill.attrs, s0.attrs) &&
  444. isEqual(skill.types, s0.types) &&
  445. isEqual(attr0, attr1)
  446. ;
  447. });
  448. if (scaleCross.length > 1)
  449. { //把后面的全都合并到第一个
  450. scaleCross.reduce((pre,cur)=>{
  451. if (cur.additional?.length) pre.additional = pre.additional.concat(cur.additional);
  452. if (cur.reduceDamage)
  453. {
  454. if (!pre.reduceDamage)
  455. pre.ReduceDamage = cur.reduceDamage;
  456. else if (pre.reduceDamage.kind == cur.reduceDamage.kind)
  457. pre.reduceDamage.value *= cur.reduceDamage.value;
  458. }
  459. return pre
  460. });
  461. scaleCross.shift(); //从筛选中去除第一个
  462. scaleCross.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  463. }
  464. //长串匹配
  465. let scaleMatchLength = skillPowerUp.filter(skill=>skill.value.kind === SkillPowerUpKind.ScaleMatchLength);
  466. scaleMatchLength = scaleMatchLength.filter((skill,idx,arr)=>{
  467. let s0 = arr[0];
  468. let v0 = s0.value;
  469. let v1 = skill.value;
  470. return isEqual(skill.condition, s0.condition) &&
  471. isEqual(skill.attrs, s0.attrs) &&
  472. isEqual(skill.types, s0.types) &&
  473. v0.min === v1.min &&
  474. v0.max === v1.max &&
  475. (v0.matchAll === v1.matchAll || v0.attrs.length <= 1) && isEqual(v0.attrs, v1.attrs)
  476. ;
  477. });
  478. if (scaleMatchLength.length > 1)
  479. { //把后面的全都合并到第一个
  480. scaleMatchLength.reduce((pre,cur)=>{
  481. if (cur.additional?.length) pre.additional = pre.additional.concat(cur.additional);
  482. if (cur.reduceDamage)
  483. {
  484. if (!pre.reduceDamage)
  485. pre.ReduceDamage = cur.reduceDamage;
  486. else if (pre.reduceDamage.kind == cur.reduceDamage.kind)
  487. pre.reduceDamage.value *= cur.reduceDamage.value;
  488. }
  489. if (cur.value.baseAtk !== 1) pre.value.baseAtk *= cur.value.baseAtk;
  490. if (cur.value.baseRcv !== 1) pre.value.baseRcv *= cur.value.baseRcv;
  491. pre.value.bonusAtk += cur.value.bonusAtk;
  492. pre.value.bonusRcv += cur.value.bonusRcv;
  493. return pre
  494. });
  495. scaleMatchLength.shift(); //从筛选中去除第一个
  496. scaleMatchLength.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  497. }
  498. //多串匹配
  499. let scaleMatchAttrs = skillPowerUp.filter(skill=>skill.value.kind === SkillPowerUpKind.ScaleMatchAttrs);
  500. scaleMatchAttrs = scaleMatchAttrs.filter((skill,idx,arr)=>{
  501. let s0 = arr[0];
  502. let v0 = s0.value;
  503. let v1 = skill.value;
  504. return isEqual(skill.condition, s0.condition) &&
  505. isEqual(skill.attrs, s0.attrs) &&
  506. isEqual(skill.types, s0.types) &&
  507. v0.min === v1.min &&
  508. v0.max === v1.max &&
  509. isEqual(v0.matches, v1.matches)
  510. ;
  511. });
  512. if (scaleMatchAttrs.length > 1)
  513. { //把后面的全都合并到第一个
  514. scaleMatchAttrs.reduce((pre,cur)=>{
  515. if (cur.additional?.length) pre.additional = pre.additional.concat(cur.additional);
  516. if (cur.reduceDamage)
  517. {
  518. if (!pre.reduceDamage)
  519. pre.ReduceDamage = cur.reduceDamage;
  520. else if (pre.reduceDamage.kind == cur.reduceDamage.kind)
  521. pre.reduceDamage.value *= cur.reduceDamage.value;
  522. }
  523. if (cur.value.baseAtk !== 1) pre.value.baseAtk *= cur.value.baseAtk;
  524. if (cur.value.baseRcv !== 1) pre.value.baseRcv *= cur.value.baseRcv;
  525. pre.value.bonusAtk += cur.value.bonusAtk;
  526. pre.value.bonusRcv += cur.value.bonusRcv;
  527. return pre
  528. });
  529. scaleMatchAttrs.shift(); //从筛选中去除第一个
  530. scaleMatchAttrs.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  531. }
  532. //多色匹配
  533. let scaleAttributes = skillPowerUp.filter(skill=>skill.value.kind === SkillPowerUpKind.ScaleAttributes);
  534. scaleAttributes = scaleAttributes.filter((skill,idx,arr)=>{
  535. let s0 = arr[0];
  536. let v0 = s0.value;
  537. let v1 = skill.value;
  538. return isEqual(skill.condition, s0.condition) &&
  539. isEqual(skill.attrs, s0.attrs) &&
  540. isEqual(skill.types, s0.types) &&
  541. v0.min === v1.min &&
  542. v0.max === v1.max &&
  543. isEqual(v0.attrs, v1.attrs)
  544. ;
  545. });
  546. if (scaleAttributes.length > 1)
  547. { //把后面的全都合并到第一个
  548. scaleAttributes.reduce((pre,cur)=>{
  549. if (cur.additional?.length) pre.additional = pre.additional.concat(cur.additional);
  550. if (cur.reduceDamage)
  551. {
  552. if (!pre.reduceDamage)
  553. pre.ReduceDamage = cur.reduceDamage;
  554. else if (pre.reduceDamage.kind == cur.reduceDamage.kind)
  555. pre.reduceDamage.value *= cur.reduceDamage.value;
  556. }
  557. if (cur.value.baseAtk !== 1) pre.value.baseAtk *= cur.value.baseAtk;
  558. if (cur.value.baseRcv !== 1) pre.value.baseRcv *= cur.value.baseRcv;
  559. pre.value.bonusAtk += cur.value.bonusAtk;
  560. pre.value.bonusRcv += cur.value.bonusRcv;
  561. return pre
  562. });
  563. scaleAttributes.shift(); //从筛选中去除第一个
  564. scaleAttributes.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  565. }
  566. //连击数
  567. let scaleCombos = skillPowerUp.filter(skill=>skill.value.kind === SkillPowerUpKind.ScaleCombos);
  568. scaleCombos = scaleCombos.filter((skill,idx,arr)=>{
  569. let s0 = arr[0];
  570. let v0 = s0.value;
  571. let v1 = skill.value;
  572. return isEqual(skill.condition, s0.condition) &&
  573. isEqual(skill.attrs, s0.attrs) &&
  574. isEqual(skill.types, s0.types) &&
  575. v0.min === v1.min &&
  576. v0.max === v1.max
  577. ;
  578. });
  579. if (scaleCombos.length > 1)
  580. { //把后面的全都合并到第一个
  581. scaleCombos.reduce((pre,cur)=>{
  582. if (cur.additional?.length) pre.additional = pre.additional.concat(cur.additional);
  583. if (cur.reduceDamage)
  584. {
  585. if (!pre.reduceDamage)
  586. pre.ReduceDamage = cur.reduceDamage;
  587. else if (pre.reduceDamage.kind == cur.reduceDamage.kind)
  588. pre.reduceDamage.value *= cur.reduceDamage.value;
  589. }
  590. if (cur.value.baseAtk !== 1) pre.value.baseAtk *= cur.value.baseAtk;
  591. if (cur.value.baseRcv !== 1) pre.value.baseRcv *= cur.value.baseRcv;
  592. pre.value.bonusAtk += cur.value.bonusAtk;
  593. pre.value.bonusRcv += cur.value.bonusRcv;
  594. return pre
  595. });
  596. scaleCombos.shift(); //从筛选中去除第一个
  597. scaleCombos.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  598. }
  599. //普通倍率
  600. let multiplier = skillPowerUp.filter(skill=>skill.value.kind === SkillPowerUpKind.Multiplier
  601. && skill.condition?.LShape);
  602. multiplier = multiplier.filter((skill,idx,arr)=>{
  603. let s0 = arr[0];
  604. return !!skill.condition && isEqual(skill.condition, s0.condition) &&
  605. isEqual(skill.attrs, s0.attrs) &&
  606. isEqual(skill.types, s0.types)
  607. ;
  608. });
  609. if (multiplier.length)
  610. { //把后面的全都合并到第一个
  611. multiplier.reduce((pre,cur)=>{
  612. if (cur.additional?.length) pre.additional = pre.additional.concat(cur.additional);
  613. if (cur.reduceDamage)
  614. {
  615. if (!pre.reduceDamage)
  616. pre.ReduceDamage = cur.reduceDamage;
  617. else if (pre.reduceDamage.kind == cur.reduceDamage.kind)
  618. pre.reduceDamage.value *= cur.reduceDamage.value;
  619. }
  620. pre.value.atk *= cur.value.atk;
  621. pre.value.hp *= cur.value.hp;
  622. pre.value.rcv *= cur.value.rcv;
  623. return pre
  624. });
  625. multiplier.shift(); //从筛选中去除第一个
  626. multiplier.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  627. }
  628. }
  629. return skills;
  630. }
  631. const skill = Skills[skillId];
  632. if (!skill) return [];
  633. if (!parsers[skill.type]) {
  634. return [{ kind: SkillKinds.Unknown }];
  635. }
  636. //此处用apply将这个parser传递到后面解析函数的this里,用于递归解析
  637. const result = parsers[skill.type].apply({ parser: skillParser }, skill.params);
  638. let skills = (Array.isArray(result) ? result : [result])
  639. .filter(s => Boolean(s))
  640. .map(s => ({ id: skillId, type: skill.type, params: skill.params, ...s }));
  641. function splitProvisoSkill(skills)
  642. {
  643. let idx = skills.findIndex(skill=>skill.kind == SkillKinds.SkillProviso);
  644. if (idx>=0)
  645. {
  646. return [
  647. skills.slice(0,idx),
  648. skills.slice(idx, idx+1),
  649. skills.slice(idx+1),
  650. ];
  651. }else
  652. {
  653. return [skills];
  654. }
  655. }
  656. if (merge_skill)
  657. {
  658. let skillsSplit = splitProvisoSkill(skills).map(_skills=>merge(_skills));
  659. skills = skillsSplit.flat(1);
  660. }
  661. return skills;
  662. }
  663. //返回flag里值为true的数组,如[1,4,7]
  664. function flags(num){
  665. /*
  666. return Array.from(new Array(32),(i,n)=>n).filter(n => num & (1 << n)); //性能太差
  667. return new Array(32).fill(null).map((i,n)=>n).filter(n => num & (1 << n)); //性能比上者好,但还是不够快
  668. */
  669. const arr = [];
  670. for (let i = 0; i<32;i++)
  671. {
  672. if (num & (1<<i))
  673. {
  674. arr.push(i);
  675. }
  676. }
  677. return arr;
  678. }
  679. const v = {
  680. percent: function(value) {
  681. return { kind: SkillValueKind.Percent, value: (value / 100) ?? 1 };
  682. },
  683. constant: function(value) {
  684. return { kind: SkillValueKind.Constant, value: value ?? 0 };
  685. },
  686. constantTo: function(value) {
  687. return { kind: SkillValueKind.ConstantTo, value: value ?? 1 };
  688. },
  689. xMaxHP: function(value) {
  690. return { kind: SkillValueKind.xMaxHP, value: (value / 100) ?? 1 };
  691. },
  692. xHP: function(value) {
  693. return { kind: SkillValueKind.xHP, value: (value / 100) ?? 1 };
  694. },
  695. xCHP: function(value) {
  696. return { kind: SkillValueKind.xCHP, value: (value / 100) ?? 1 };
  697. },
  698. xATK: function(value) {
  699. return { kind: SkillValueKind.xATK, value: (value / 100) ?? 1 };
  700. },
  701. xRCV: function(value) {
  702. return { kind: SkillValueKind.xRCV, value: (value / 100) ?? 1 };
  703. },
  704. randomATK: function(min, max) {
  705. return { kind: SkillValueKind.RandomATK, min: (min / 100) ?? 1, max: (max / 100) ?? 1, scale: 1 };
  706. },
  707. hpScale: function(min, max, scale) {
  708. return { kind: SkillValueKind.HPScale, min: (min / 100) ?? 1, max: (max / 100) ?? 1, scale: (scale / 100) ?? 1 };
  709. },
  710. xTeamHP: function(value) {
  711. return { kind: SkillValueKind.xTeamHP, value: (value / 100) ?? 1 };
  712. },
  713. xTeamATK: function(attrs, value) {
  714. return { kind: SkillValueKind.xTeamATK, attrs: attrs, value: (value / 100) ?? 1 };
  715. },
  716. xTeamRCV: function(value) {
  717. return { kind: SkillValueKind.xTeamRCV, value: (value / 100) ?? 1 };
  718. },
  719. percentAwakenings: function(awakenings, value) {
  720. return { kind: SkillValueKind.xAwakenings, awakenings: awakenings, value: value };
  721. },
  722. };
  723. const c = {
  724. hp: function (min, max) {
  725. return { hp: { min: min / 100, max: max / 100 } };
  726. },
  727. exact: function (type, value, attrs) {
  728. if (attrs === void 0) { attrs = Attributes.all(); }
  729. return { exact: { type: type, value: value, attrs: attrs } };
  730. },
  731. compo: function (type, ids) {
  732. return { compo: { type: type, ids: ids } };
  733. },
  734. remainOrbs: function (count) { return { remainOrbs: { count: count } }; },
  735. useSkill: function () { return { useSkill: true }; },
  736. multiplayer: function () { return { multiplayer: true }; },
  737. prob: function (percent) { return { prob: percent }; },
  738. LShape: function (attrs) { return { LShape: { attrs: attrs } }; },
  739. heal: function (min) { return { heal: { min: min } }; },
  740. }
  741. const p = {
  742. mul: function (values) {
  743. if (Array.isArray(values)) {
  744. return {
  745. kind: SkillPowerUpKind.Multiplier,
  746. hp: 1,
  747. atk: values[0] / 100,
  748. rcv: values[1] / 100
  749. };
  750. }
  751. else {
  752. return {
  753. kind: SkillPowerUpKind.Multiplier,
  754. hp: (values.hp ?? 100) / 100,
  755. atk: (values.atk ?? 100) / 100,
  756. rcv: (values.rcv ?? 100) / 100
  757. };
  758. }
  759. },
  760. stats: function (value) {
  761. let statTypes = Array.from(arguments).slice(1);
  762. return [
  763. statTypes.indexOf(1) >= 0 ? value : 100,
  764. statTypes.indexOf(2) >= 0 ? value : 100
  765. ];
  766. },
  767. scale: function (min, max, baseMul, bonusMul) {
  768. return {
  769. min: min,
  770. max: max ?? min,
  771. baseAtk: (baseMul[0] / 100) ?? 1,
  772. baseRcv: (baseMul[1] / 100) ?? 1,
  773. bonusAtk: (bonusMul[0] / 100) ?? 0,
  774. bonusRcv: (bonusMul[1] / 100) ?? 0
  775. };
  776. },
  777. scaleAttrs: function (attrs, min, max, baseMul, bonusMul) {
  778. return { kind: SkillPowerUpKind.ScaleAttributes, attrs: attrs ,...this.scale(min, max, baseMul, bonusMul) };
  779. },
  780. scaleCombos: function (min, max, baseMul, bonusMul) {
  781. return { kind: SkillPowerUpKind.ScaleCombos ,...this.scale(min, max, baseMul, bonusMul) };
  782. },
  783. scaleMatchLength: function (attrs, min, max, baseMul, bonusMul, matchAll = false) {
  784. return { kind: SkillPowerUpKind.ScaleMatchLength, attrs: attrs, matchAll: matchAll ,...this.scale(min, max, baseMul, bonusMul) };
  785. },
  786. scaleMatchAttrs: function (matches, min, max, baseMul, bonusMul) {
  787. return { kind: SkillPowerUpKind.ScaleMatchAttrs, matches: matches ,...this.scale(min, max, baseMul, bonusMul) };
  788. },
  789. scaleCross: function (crosses) {
  790. return { kind: SkillPowerUpKind.ScaleCross, crosses: crosses.map(cross => ({ ...cross, atk: ((cross.atk ?? 100) / 100), rcv: ((cross.rcv ?? 100) / 100)})) };
  791. },
  792. scaleStateKindCount: function (awakenings, attrs, types, value) {
  793. return { kind: SkillPowerUpKind.ScaleStateKindCount, awakenings: awakenings, attrs: attrs, types: types, value: value };
  794. },
  795. }
  796. function activeTurns(turns, skill) {
  797. return skill ? { kind: SkillKinds.ActiveTurns, turns: turns, skill: skill } : null;
  798. }
  799. function damageEnemy(target, attr, damage) {
  800. return { kind: SkillKinds.DamageEnemy, target: target, attr: attr, damage: damage };
  801. }
  802. function vampire(attr, damageValue, healValue) {
  803. return { kind: SkillKinds.Vampire, attr: attr, damage: damageValue, heal: healValue };
  804. }
  805. function reduceDamage(attrs, percent, condition) {
  806. return { kind: SkillKinds.ReduceDamage, attrs: attrs, percent: percent, condition: condition };
  807. }
  808. function selfHarm(value) {
  809. return { kind: SkillKinds.SelfHarm, value: value };
  810. }
  811. function heal(value) {
  812. return { kind: SkillKinds.Heal, value: value };
  813. }
  814. function autoHealBuff(value) {
  815. return { kind: SkillKinds.AutoHealBuff, value: value };
  816. }
  817. function fromTo(from, to) {
  818. return { from: from, to: to };
  819. }
  820. function changeOrbs() {
  821. return { kind: SkillKinds.ChangeOrbs, changes: Array.from(arguments) };
  822. }
  823. function generateOrbs(orbs, exclude, count, time) {
  824. return { kind: SkillKinds.GenerateOrbs, orbs: orbs, exclude: exclude, count: count, time: time};
  825. }
  826. function fixedOrbs() {
  827. return { kind: SkillKinds.FixedOrbs, generates: Array.from(arguments) };
  828. }
  829. function powerUp(attrs, types, value, condition = null, reduceDamageValue = null, additional = []) {
  830. if (value.kind === SkillPowerUpKind.Multiplier) {
  831. let hp = value.hp, atk = value.atk, rcv = value.rcv;
  832. if (hp === 1 && atk === 1 && rcv === 1 && !reduceDamage)
  833. return null;
  834. }
  835. return { kind: SkillKinds.PowerUp, attrs: attrs, types: types, condition: condition, value: value, reduceDamage: reduceDamageValue, additional: additional};
  836. }
  837. function counterAttack(attr, prob, value) {
  838. return { kind: SkillKinds.CounterAttack, attr: attr, prob: prob, value: value };
  839. }
  840. function setOrbState(orbs, state, arg) {
  841. return { kind: SkillKinds.SetOrbState, orbs: orbs, state: state, arg: arg};
  842. }
  843. function rateMultiply(value, rate) {
  844. return { kind: SkillKinds.RateMultiply, value: value, rate: rate };
  845. }
  846. function orbDropIncrease(value, attrs, flag) {
  847. return { kind: SkillKinds.OrbDropIncrease, value: value, attrs: attrs, flag: flag };
  848. }
  849. function resolve(min, max) {
  850. return { kind: SkillKinds.Resolve, min: min, max: max };
  851. }
  852. function unbind(normal, awakenings, matches) {
  853. return { kind: SkillKinds.Unbind, normal: normal, awakenings: awakenings , matches: matches};
  854. }
  855. function bindSkill() { return { kind: SkillKinds.BindSkill}; }
  856. function boardChange(attrs) {
  857. return { kind: SkillKinds.BoardChange, attrs: attrs };
  858. }
  859. function randomSkills(skills) {
  860. return { kind: SkillKinds.RandomSkills, skills: skills };
  861. }
  862. function changeAttr(target, attr) {
  863. return { kind: SkillKinds.ChangeAttribute, target: target, attr: attr ?? 0 };
  864. }
  865. function gravity(value) {
  866. return { kind: SkillKinds.Gravity, value: value };
  867. }
  868. function voidEnemyBuff(buffs) {
  869. return { kind: SkillKinds.VoidEnemyBuff, buffs: buffs };
  870. }
  871. function skillBoost(value) { return { kind: SkillKinds.SkillBoost, value: value }; }
  872. function minMatch(value) { return { kind: SkillKinds.MinMatchLength, value: value }; }
  873. function fixedTime(value) { return { kind: SkillKinds.FixedTime, value: v.constant(value) }; }
  874. function addCombo(value) { return { kind: SkillKinds.AddCombo, value: value }; }
  875. function defBreak(value) { return { kind: SkillKinds.DefenseBreak, value: value }; }
  876. function poison(value) { return { kind: SkillKinds.Poison, value: value }; }
  877. function CTW(value) { return { kind: SkillKinds.CTW, value: value }; }
  878. function followAttack(value) { return { kind: SkillKinds.FollowAttack, value: value }; }
  879. function followAttackFixed(value) { return { kind: SkillKinds.FollowAttackFixed, value: v.constant(value) }; }
  880. function autoHeal(value) { return { kind: SkillKinds.AutoHeal, value: value }; }
  881. function timeExtend(value) { return { kind: SkillKinds.TimeExtend, value: value }; }
  882. function delay() { return { kind: SkillKinds.Delay }; }
  883. function massAttack() { return { kind: SkillKinds.MassAttack }; }
  884. function dropRefresh() { return { kind: SkillKinds.DropRefresh }; }
  885. function drum() { return { kind: SkillKinds.Drum }; }
  886. function autoPath() { return { kind: SkillKinds.AutoPath }; }
  887. function leaderChange(type = 0) { return { kind: SkillKinds.LeaderChange, type: type }; }
  888. function board7x6() { return { kind: SkillKinds.Board7x6 }; }
  889. function noSkyfall() { return { kind: SkillKinds.NoSkyfall }; }
  890. function henshin(id) { return { kind: SkillKinds.Henshin, id: id }; }
  891. function voidPoison() { return { kind: SkillKinds.VoidPoison }; }
  892. function skillProviso(cond) { return { kind: SkillKinds.SkillProviso, cond: cond }; }
  893. const parsers = {
  894. parser: (() => []), //这个用来解决代码提示的报错问题,不起实际作用
  895. [0](attr, mul) { return damageEnemy('all', attr, v.xATK(mul)); },
  896. [1](attr, value) { return damageEnemy('all', attr, v.constant(value)); },
  897. [2](mul, _) { return damageEnemy('single', 'self', v.xATK(mul)); },
  898. [3](turns, percent) { return activeTurns(turns, reduceDamage('all', v.percent(percent))); },
  899. [4](mul) { return poison(v.xATK(mul)); },
  900. [5](time) { return CTW(v.constant(time)); },
  901. [6](percent) { return gravity(v.xCHP(percent)); },
  902. [7](mul) { return heal(v.xRCV(mul)); },
  903. [8](value) { return heal(v.constant(value)); },
  904. [9](from, to) { return changeOrbs(fromTo([from ?? 0], [to ?? 0])); },
  905. [10]() { return dropRefresh(); },
  906. [11](attr, mul) { return powerUp([attr], null, p.mul({ atk: mul })); },
  907. [12](mul) { return followAttack(v.xATK(mul)); },
  908. [13](mul) { return autoHeal(v.xRCV(mul)); },
  909. [14](min, max) { return resolve(v.percent(min), v.percent(max ?? 100)); },
  910. [15](time) { return timeExtend(v.constant(time / 100)); },
  911. [16](percent) { return reduceDamage('all', v.percent(percent)); },
  912. [17](attr, percent) { return reduceDamage([attr], v.percent(percent)); },
  913. [18](turns) { return activeTurns(turns, delay()); },
  914. [19](turns, percent) { return activeTurns(turns, defBreak(v.percent(percent))); },
  915. [20](from1, to1, from2, to2) {
  916. if ((to1 ?? 0) == (to2 ?? 0))
  917. return changeOrbs(fromTo([from1 ?? 0, from2 ?? 0], [to1 ?? 0]));
  918. else
  919. return changeOrbs(
  920. fromTo([from1 ?? 0], [to1 ?? 0]),
  921. fromTo([from2 ?? 0], [to2 ?? 0])
  922. );
  923. },
  924. [21](turns, attr, percent) { return activeTurns(turns, reduceDamage([attr], v.percent(percent))); },
  925. [22](type, mul) { return powerUp(null, [type], p.mul({ atk: mul })); },
  926. [23](type, mul) { return powerUp(null, [type], p.mul({ hp: mul })); },
  927. [24](type, mul) { return powerUp(null, [type], p.mul({ rcv: mul })); },
  928. [26](mul) { return powerUp(null, null, p.mul({ atk: mul })); },
  929. [28](attr, mul) { return powerUp([attr], null, p.mul({ atk: mul, rcv: mul })); },
  930. [29](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, atk: mul, rcv: mul })); },
  931. [30](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ hp: mul })); },
  932. [31](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ atk: mul })); },
  933. [33]() { return drum(); },
  934. [35](mul, percent) { return vampire('self', v.xATK(mul), v.percent(percent)); },
  935. [36](attr1, attr2, percent) { return reduceDamage([attr1, attr2], v.percent(percent)); },
  936. [37](attr, mul) { return damageEnemy('single', attr, v.xATK(mul)); },
  937. [38](max, _, percent) { return reduceDamage('all', v.percent(percent), max === 100 ? c.hp(max, max) : c.hp(0, max)); },
  938. [39](percent, stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  939. [40](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ atk: mul })); },
  940. [41](prob, mul, attr) { return counterAttack(attr ?? 0, v.percent(prob), v.percent(mul)); },
  941. [42](targetAttr, dmgAttr, value) { return damageEnemy(targetAttr, dmgAttr, v.constant(value)); },
  942. [43](min, max, percent) { return reduceDamage('all', v.percent(percent), c.hp(min, max)); },
  943. [44](percent, stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  944. [45](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, atk: mul })); },
  945. [46](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul })); },
  946. [48](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul })); },
  947. [49](attr, mul) { return powerUp([attr], null, p.mul({ rcv: mul })); },
  948. [50](turns, attr, mul) { return activeTurns(turns, powerUp([attr], null, p.mul({ atk: mul ?? 0 }))); },
  949. [51](turns) { return activeTurns(turns, massAttack()); },
  950. [52](attr, mul) { return setOrbState([attr], 'enhanced', {enhance: v.percent(mul)}); },
  951. [53](mul) { return rateMultiply(v.percent(mul), 'drop'); },
  952. [54](mul) { return rateMultiply(v.percent(mul), 'coin'); },
  953. [55](value) { return damageEnemy('single', 'fixed', v.constant(value)); },
  954. [56](value) { return damageEnemy('all', 'fixed', v.constant(value)); },
  955. [58](attr, min, max) { return damageEnemy('all', attr, v.randomATK(min, max)); },
  956. [59](attr, min, max) { return damageEnemy('single', attr, v.randomATK(min, max)); },
  957. [60](turns, mul, attr) { return activeTurns(turns, counterAttack(attr, v.percent(100), v.percent(mul))); },
  958. [61](attrs, min, base, bonus, incr) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min + (incr ?? 0), [base, 100], [bonus, 0])); },
  959. [62](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, atk: mul })); },
  960. [63](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, rcv: mul })); },
  961. [64](type, mul) { return powerUp(null, [type], p.mul({ atk: mul, rcv: mul })); },
  962. [65](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, atk: mul, rcv: mul })); },
  963. [66](combo, mul) { return powerUp(null, null, p.scaleCombos(combo, combo, [mul, 100], [0, 0])); },
  964. [67](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, rcv: mul })); },
  965. [69](attr, type, mul) { return powerUp([attr], [type], p.mul({ atk: mul })); },
  966. [71](...attrs) { return boardChange(attrs.filter(attr => attr >= 0)); },
  967. [73](attr, type, mul) { return powerUp([attr], [type], p.mul({ hp: mul, atk: mul })); },
  968. [75](attr, type, mul) { return powerUp([attr], [type], p.mul({ atk: mul, rcv: mul })); },
  969. [76](attr, type, mul) { return powerUp([attr], [type], p.mul({ hp: mul, atk: mul, rcv: mul })); },
  970. [77](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ hp: mul, atk: mul })); },
  971. [79](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ atk: mul, rcv: mul })); },
  972. [84](attr, min, max, percent) {
  973. return [
  974. selfHarm(percent ? v.xCHP(100 - percent) : v.constantTo(1)),
  975. damageEnemy('single', attr, v.randomATK(min, max))
  976. ];
  977. },
  978. [85](attr, min, max, percent) {
  979. return [
  980. selfHarm(percent ? v.xCHP(100 - percent) : v.constantTo(1)),
  981. damageEnemy('all', attr, v.randomATK(min, max))
  982. ];
  983. },
  984. [86](attr, value, _, percent) {
  985. return [
  986. selfHarm(percent ? v.xCHP(100 - percent) : v.constantTo(1)),
  987. damageEnemy('single', attr, v.constant(value))
  988. ];
  989. },
  990. [87](attr, value, _, percent) {
  991. return [
  992. selfHarm(percent ? v.xCHP(100 - percent) : v.constantTo(1)),
  993. damageEnemy('all', attr, v.constant(value))
  994. ];
  995. },
  996. [88](turns, type, mul) { return activeTurns(turns, powerUp(null, [type], p.mul({ atk: mul }))); },
  997. [90](turns, attr1, attr2, mul) { return activeTurns(turns, powerUp([attr1, attr2], null, p.mul({ atk: mul }))); },
  998. [91](attr1, attr2, mul) { return setOrbState([attr1, attr2], 'enhanced', {enhance: v.percent(mul)}); },
  999. [92](turns, type1, type2, mul) { return activeTurns(turns, powerUp(null, [type1, type2], p.mul({ atk: mul }))); },
  1000. [93]() { return leaderChange(); },
  1001. [94](percent, attr, stats1, stats2, mul) { return powerUp([attr], null, p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  1002. [95](percent, type, stats1, stats2, mul) { return powerUp(null, [type], p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  1003. [96](percent, attr, stats1, stats2, mul) { return powerUp([attr], null, p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  1004. [97](percent, type, stats1, stats2, mul) { return powerUp(null, [type], p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  1005. [98](min, base, bonus, max) { return powerUp(null, null, p.scaleCombos(min, max, [base, 100], [bonus, 0])); },
  1006. [100](stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.useSkill()); },
  1007. [101](combo, mul) { return powerUp(null, null, p.mul({ atk: mul }), c.exact('combo', combo)); },
  1008. [103](combo, stats1, stats2, mul) { return powerUp(null, null, p.scaleCombos(combo, combo, p.stats(mul, stats1, stats2), [0, 0])); },
  1009. [104](combo, attrs, stats1, stats2, mul) { return powerUp(flags(attrs), null, p.scaleCombos(combo, combo, p.stats(mul, stats1, stats2), [0, 0])); },
  1010. [105](rcv, atk) { return powerUp(null, null, p.mul({ rcv, atk })); },
  1011. [106](hp, atk) { return powerUp(null, null, p.mul({ hp, atk })); },
  1012. [107](hp, attrs, atk) {
  1013. return [
  1014. powerUp(null, null, p.mul({ hp })),
  1015. attrs && powerUp(flags(attrs), null, p.mul({ atk: atk ?? 100 })) || null,
  1016. ].filter(Boolean);
  1017. },
  1018. [108](hp, type, atk) { return [powerUp(null, null, p.mul({ hp })), powerUp(null, [type], p.mul({ atk }))]; },
  1019. [109](attrs, len, mul) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul, 100], [0, 0])); },
  1020. [110](single, attr, min, max, scale) { return damageEnemy(single ? 'single' : 'all', attr, v.hpScale(min, max, scale)); },
  1021. [111](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul, atk: mul })); },
  1022. [114](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul, atk: mul, rcv: mul })); },
  1023. [115](attr, mul, percent) { return vampire(attr, v.xATK(mul), v.percent(percent)); },
  1024. [116](...ids) { return ids.flatMap(id => this.parser(id)); },
  1025. [117](bind, rcv, constant, hp, awokenBind) {
  1026. return [
  1027. rcv ? heal(v.xRCV(rcv)) : hp ? heal(v.xMaxHP(hp)) : constant ? heal(v.constant(constant)) : null,
  1028. (bind || awokenBind) ? unbind(bind ?? 0, awokenBind ?? 0) : null,
  1029. ].filter(Boolean);
  1030. },
  1031. [118](...ids) { return randomSkills(ids.map(id => this.parser(id))); },
  1032. [119](attrs, min, base, bonus, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [base || 100, 100], [bonus, 0])); },
  1033. [121](attrs, types, hp, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })); },
  1034. [122](percent, attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk: atk || 100, rcv: rcv || 100 }), c.hp(0, percent)); },
  1035. [123](percent, attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk: atk || 100, rcv: rcv || 100 }), c.hp(percent, 100)); },
  1036. [124](attrs1, attrs2, attrs3, attrs4, attrs5, min, mul, bonus) {
  1037. const attrs = [attrs1, attrs2, attrs3, attrs4, attrs5].filter(Boolean);
  1038. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, bonus ? attrs.length : min, [mul, 100], [bonus, 0]));
  1039. },
  1040. [125](mon1, mon2, mon3, mon4, mon5, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 }), c.compo('card', [mon1, mon2, mon3, mon4, mon5].filter(Boolean))); },
  1041. [126](attrs, turns, turns2, percent) { return activeTurns(turns === turns2 ? turns : [turns, turns2], orbDropIncrease(v.percent(percent), flags(attrs))); },
  1042. [127](cols1, attrs1, cols2, attrs2) {
  1043. return fixedOrbs(
  1044. { orbs: flags(attrs1), type: 'col', positions: flags(cols1) },
  1045. { orbs: flags(attrs2), type: 'col', positions: flags(cols2) }
  1046. );
  1047. },
  1048. [128](rows1, attrs1, rows2, attrs2) {
  1049. return fixedOrbs(
  1050. { orbs: flags(attrs1), type: 'row', positions: flags(rows1) },
  1051. { orbs: flags(attrs2), type: 'row', positions: flags(rows2) }
  1052. );
  1053. },
  1054. [129](attrs, types, hp, atk, rcv, rAttrs, rPercent) {
  1055. return [
  1056. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })) || null,
  1057. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent)) || null
  1058. ].filter(Boolean);
  1059. },
  1060. [130](percent, attrs, types, atk, rcv, rAttrs, rPercent) {
  1061. return [
  1062. (atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ atk: atk || 100, rcv: rcv || 100 }), c.hp(0, percent)) || null,
  1063. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent), c.hp(0, percent)) || null
  1064. ].filter(Boolean);
  1065. },
  1066. [131](percent, attrs, types, atk, rcv, rAttrs, rPercent) {
  1067. return [
  1068. (atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ atk: atk || 100, rcv: rcv || 100 }), c.hp(percent, 100)) || null,
  1069. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent), c.hp(percent, 100)) || null
  1070. ].filter(Boolean);
  1071. },
  1072. [132](turns, time, percent) { return activeTurns(turns, timeExtend(time ? v.constant(time / 10) : v.percent(percent))); },
  1073. [133](attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk: atk || 100, rcv: rcv || 100 }), c.useSkill()); },
  1074. [136](attrs1, hp1, atk1, rcv1, attrs2, hp2, atk2, rcv2) {
  1075. return [
  1076. powerUp(flags(attrs1), null, p.mul({ hp: hp1 || 100, atk: atk1 || 100, rcv: rcv1 || 100 })),
  1077. powerUp(flags(attrs2), null, p.mul({ hp: hp2 || 100, atk: atk2 || 100, rcv: rcv2 || 100 })),
  1078. ];
  1079. },
  1080. [137](types1, hp1, atk1, rcv1, types2, hp2, atk2, rcv2) {
  1081. return [
  1082. powerUp(null, flags(types1), p.mul({ hp: hp1 || 100, atk: atk1 || 100, rcv: rcv1 || 100 })),
  1083. powerUp(null, flags(types2), p.mul({ hp: hp2 || 100, atk: atk2 || 100, rcv: rcv2 || 100 })),
  1084. ];
  1085. },
  1086. [138](...ids) { return ids.flatMap(id => this.parser(id)); },
  1087. [139](attrs, types, percent1, less1, mul1, percent2, less2, mul2) {
  1088. return [
  1089. powerUp(flags(attrs), flags(types), p.mul({ atk: mul1 || 100 }), less1 ? c.hp(0, percent1) : c.hp(percent1, 100)),
  1090. powerUp(flags(attrs), flags(types), p.mul({ atk: mul2 || 100 }), less1 ?
  1091. (less2 ? c.hp(percent1, percent2) : c.hp(percent2, 100)) :
  1092. (less2 ? c.hp(0, percent2) : c.hp(percent2, percent1))
  1093. ),
  1094. ];
  1095. },
  1096. [140](attrs, mul) { return setOrbState(flags(attrs), 'enhanced', {enhance: v.percent(mul)}); },
  1097. [141](count, to, exclude) { return generateOrbs(flags(to), flags(exclude), count); },
  1098. [142](turns, attr) { return activeTurns(turns, changeAttr('self', attr)); },
  1099. [143](mul, dmgAttr) { return damageEnemy('all', dmgAttr ?? 0, v.xTeamHP(mul)); },
  1100. [144](teamAttrs, mul, single, dmgAttr) { return damageEnemy(single ? 'single' : 'all', dmgAttr, v.xTeamATK(flags(teamAttrs), mul)); },
  1101. [145](mul) { return heal(v.xTeamRCV(mul)); },
  1102. [146](turns) { return skillBoost(v.constant(turns)); },
  1103. [148](percent) { return rateMultiply(v.percent(percent), 'exp'); },
  1104. [149](mul) { return powerUp(null, null, p.mul({ rcv: mul }), c.exact('match-length', 4, [Attributes.Heart])); },
  1105. [150](_, mul) { return powerUp(null, null, p.mul({ atk: mul }), c.exact('match-length', 5, 'enhanced')); },
  1106. [151](mul1, mul2, percent) {
  1107. return powerUp(null, null, p.scaleCross([{ single: true, attr: [Attributes.Heart], atk: mul1 || 100, rcv: mul2 || 100 }]), null, v.percent(percent));
  1108. },
  1109. [152](attrs, count) { return setOrbState(flags(attrs), 'locked', {count: v.constant(count)}); },
  1110. [153](attr, _) { return changeAttr('opponent', attr); },
  1111. [154](from, to) { return changeOrbs(fromTo(flags(from), flags(to))); },
  1112. [155](attrs, types, hp, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 }), c.multiplayer()); },
  1113. [156](turns, awoken1, awoken2, awoken3, type, mul) {
  1114. if (type == 1)
  1115. {
  1116. return heal(v.percentAwakenings([awoken1, awoken2, awoken3].filter(Boolean), v.xRCV(mul)));
  1117. }else
  1118. {
  1119. return activeTurns(turns, type === 2 ?
  1120. powerUp(null, null, p.scaleStateKindCount([awoken1, awoken2, awoken3].filter(Boolean), null, null, p.mul({atk: mul - 100, hp:0, rcv:0}))) :
  1121. reduceDamage('all', v.percentAwakenings([awoken1, awoken2, awoken3].filter(Boolean), v.percent(mul)))
  1122. );
  1123. }
  1124. },
  1125. [157](attr1, mul1, attr2, mul2, attr3, mul3) {
  1126. let crosses = [
  1127. { single: false, attr: [attr1], atk: mul1 },
  1128. { single: false, attr: [attr2], atk: mul2 },
  1129. { single: false, attr: [attr3], atk: mul3 }
  1130. ].filter(cross => cross.atk);
  1131. return powerUp(null, null, p.scaleCross(crosses));
  1132. },
  1133. [158](len, attrs, types, atk, hp, rcv) {
  1134. return [
  1135. minMatch(len),
  1136. powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 }))
  1137. ];
  1138. },
  1139. [159](attrs, min, base, bonus, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [base, 100], [bonus, 0])); },
  1140. [160](turns, combo) { return activeTurns(turns, addCombo(combo)); },
  1141. [161](percent) { return gravity(v.xMaxHP(percent)); },
  1142. [162]() { return board7x6(); },
  1143. [163](attrs, types, hp, atk, rcv, rAttrs, rPercent) {
  1144. return [
  1145. noSkyfall(),
  1146. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })) || null,
  1147. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent)) || null,
  1148. ].filter(Boolean);
  1149. },
  1150. [164](attrs1, attrs2, attrs3, attrs4, min, atk, rcv, bonus) {
  1151. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  1152. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, attrs.length, [atk, rcv], [bonus, bonus]));
  1153. },
  1154. [165](attrs, min, baseAtk, baseRcv, bonusAtk, bonusRcv, incr) {
  1155. const attrsArr = flags(attrs);
  1156. return powerUp(null, null, p.scaleAttrs(attrsArr, min, min + (min < attrsArr.length ? (incr ?? 0) : 0), [baseAtk || 100, baseRcv || 100], [bonusAtk, bonusRcv]));
  1157. },
  1158. [166](min, baseAtk, baseRcv, bonusAtk, bonusRcv, max) { return powerUp(null, null, p.scaleCombos(min, max, [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  1159. [167](attrs, min, baseAtk, baseRcv, bonusAtk, bonusRcv, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  1160. [168](turns, awoken1, awoken2, awoken3, awoken4, awoken5, awoken6, mul) {
  1161. return activeTurns(turns,
  1162. powerUp(null, null, p.scaleStateKindCount([awoken1, awoken2, awoken3, awoken4, awoken5, awoken6].filter(Boolean), null, null, p.mul({atk: mul, hp:0, rcv:0})))
  1163. );
  1164. },
  1165. [169](min, base, percent, bonus, max) { return powerUp(null, null, p.scaleCombos(min, max ?? min, [base || 100, 100], [bonus, 0]), null, v.percent(percent)); },
  1166. [170](attrs, min, base, percent, bonus, stage) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min + stage - 1, [base, 100], [bonus ?? 0, 0]), null, v.percent(percent)); },
  1167. [171](attrs1, attrs2, attrs3, attrs4, min, mul, percent) {
  1168. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  1169. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, min, [mul, 100], [0, 0]), null, v.percent(percent));
  1170. },
  1171. [172]() { return setOrbState(null, 'unlocked'); },
  1172. [173](turns, attrAbsorb, comboAbsorb, damageAbsorb) {
  1173. return activeTurns(turns, voidEnemyBuff(
  1174. [
  1175. attrAbsorb && 'attr-absorb',
  1176. comboAbsorb && 'combo-absorb',
  1177. damageAbsorb && 'damage-absorb'
  1178. ].filter((buff) => typeof buff === 'string')
  1179. ));
  1180. },
  1181. [175](series1, series2, series3, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 }), c.compo('series', [series1, series2, series3].filter(Boolean))); },
  1182. [176](row1, row2, row3, row4, row5, attrs) {
  1183. return fixedOrbs(
  1184. { orbs: [attrs ?? 0], type: 'shape', positions: [row1, row2, row3, row4, row5].map(row=>flags(row)) }
  1185. );
  1186. },
  1187. [177](attrs, types, hp, atk, rcv, remains, mul) {
  1188. return [
  1189. noSkyfall(),
  1190. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })) || null,
  1191. mul && powerUp(null, null, p.mul({ atk: mul }), c.remainOrbs(remains)) || null
  1192. ].filter(Boolean);
  1193. },
  1194. [178](time, attrs, types, hp, atk, rcv, attrs2, percent) {
  1195. return [
  1196. fixedTime(time),
  1197. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })),
  1198. percent && reduceDamage(flags(attrs2), v.percent(percent)) || null,
  1199. ].filter(Boolean);
  1200. /*const reduceAttrs = flags(attrs2);
  1201. const isAllAttr = isEqual(reduceAttrs, Attributes.attr);
  1202. return [
  1203. fixedTime(time),
  1204. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 }), null, isAllAttr ? v.percent(percent) : null),
  1205. percent && !isAllAttr && reduceDamage(reduceAttrs, v.percent(percent)) || null,
  1206. ].filter(Boolean);*/
  1207. },
  1208. [179](turns, value, percent, bind, awokenBind) {
  1209. return [
  1210. (bind || awokenBind) ? unbind(bind ?? 0, awokenBind ?? 0) : null,
  1211. activeTurns(turns, autoHealBuff(value ? v.constant(value) : v.xMaxHP(percent)))
  1212. ].filter(Boolean);
  1213. },
  1214. [180](turns, percent) { return activeTurns(turns, orbDropIncrease(v.percent(percent), [], 'enhanced')); },
  1215. [182](attrs, len, mul, percent) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul || 100, 100], [0, 0]), null, v.percent(percent)); },
  1216. [183](attrs, types, percent1, atk1, reduce, percent2, atk2, rcv2) {
  1217. return [
  1218. (percent1 > 0) && powerUp(flags(attrs), flags(types), p.mul({ atk: atk1 || 100 }), c.hp(percent1, 100), v.percent(reduce)) || null,
  1219. (atk2 || rcv2) && powerUp(flags(attrs), flags(types), p.mul({ atk: atk2 || 100, rcv: rcv2 || 100 }), c.hp(0, percent2 || percent1)) || null
  1220. ].filter(Boolean);
  1221. },
  1222. [184](turns) { return activeTurns(turns, noSkyfall()); },
  1223. [185](time, attrs, types, hp, atk, rcv) {
  1224. return [
  1225. timeExtend(v.constant(time / 100)),
  1226. powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })),
  1227. ];
  1228. },
  1229. [186](attrs, types, hp, atk, rcv) {
  1230. return [
  1231. board7x6(),
  1232. (hp || atk ||rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 })) || null,
  1233. ].filter(Boolean);
  1234. },
  1235. [188](value) {
  1236. return damageEnemy('single', 'fixed', v.constant(value));
  1237. },
  1238. [189]() {
  1239. return [
  1240. setOrbState(null, 'unlocked'),
  1241. boardChange([0,1,2,3]),
  1242. autoPath(),
  1243. ];
  1244. },
  1245. [191](turns) {
  1246. return activeTurns(turns, voidEnemyBuff(['damage-void']));
  1247. },
  1248. [192](attrs, len, mul, combo) {
  1249. return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul || 100, 100], [0, 0], true), null, null, [addCombo(combo)]);
  1250. },
  1251. [193](attrs, atk, rcv, percent) {
  1252. return powerUp(null, null, p.mul([atk || 100, rcv || 100]), c.LShape(flags(attrs)), v.percent(percent));
  1253. },
  1254. [194](attrs, min, mul, combo) {
  1255. return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min, [mul || 100, 100], [0, 0]), null, null, [addCombo(combo)]);
  1256. },
  1257. [195](percent) {
  1258. return selfHarm(percent ? v.xCHP(percent) : v.constantTo(1));
  1259. },
  1260. [196](matches) {
  1261. return unbind(0,0,matches);
  1262. },
  1263. [197]() {
  1264. return voidPoison();
  1265. },
  1266. [198](heal, atk, percent, awokenBind) {
  1267. return powerUp(null, null, p.mul([atk || 100, 100]), c.heal(heal), percent && v.percent(percent), awokenBind && [unbind(0, awokenBind ?? 0)]);
  1268. },
  1269. [199](attrs, min, damage) {
  1270. return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min, [100, 100], [0, 0]), null, null, [followAttackFixed(damage)]);
  1271. },
  1272. [200](attrs, len, damage) {
  1273. return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [100, 100], [0, 0]), null, null, [followAttackFixed(damage)]);
  1274. },
  1275. [201](attrs1, attrs2, attrs3, attrs4, min, damage) {
  1276. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  1277. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, attrs.length, [100, 100], [0, 0]), null, null, [followAttackFixed(damage)]);
  1278. },
  1279. [202](id) {
  1280. return henshin(id);
  1281. },
  1282. [203](evotype, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp: hp || 100, atk: atk || 100, rcv: rcv || 100 }), c.compo('evolution', [evotype])); },
  1283. [205](attrs, turns) { return activeTurns(turns, orbDropIncrease(null, flags(attrs == -1 ? 1023: attrs), 'locked')); },
  1284. [206](attrs1, attrs2, attrs3, attrs4, attrs5, min, combo) {
  1285. const attrs = [attrs1, attrs2, attrs3, attrs4, attrs5].filter(Boolean);
  1286. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, attrs.length, [100, 100], [0, 0]), null, null, [addCombo(combo)]);
  1287. },
  1288. [207](turns, time, row1, row2, row3, row4, row5, count) {
  1289. return activeTurns(turns, count ?
  1290. generateOrbs( ['variation'], null, count, time/100):
  1291. fixedOrbs( { orbs: ['variation'], time: time/100, type: 'shape', positions: [row1, row2, row3, row4, row5].map(row=>flags(row)) })
  1292. );
  1293. },
  1294. [208](count1, to1, exclude1, count2, to2, exclude2) {
  1295. return [
  1296. generateOrbs(flags(to1), flags(exclude1), count1),
  1297. generateOrbs(flags(to2), flags(exclude2), count2),
  1298. ];
  1299. },
  1300. [209](combo) {
  1301. return powerUp(null, null, p.scaleCross([{ single: true, attr: [Attributes.Heart], atk: 100, rcv: 100}]), null, null, [addCombo(combo)]);
  1302. },
  1303. [210](attrs, _, combo) {
  1304. return powerUp(null, null, p.scaleCross([{ single: false, attr: flags(attrs), atk: 100, rcv: 100}]), null, null, [addCombo(combo)]);
  1305. },
  1306. [214](turns) { return activeTurns(turns, bindSkill()); },
  1307. [215](turns, attrs) { return activeTurns(turns, setOrbState(flags(attrs), 'bound')); },
  1308. [218](turns) { return skillBoost(v.constant(-turns)); },
  1309. [219](attrs, len, combo) {
  1310. return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [100, 100], [0, 0]), null, null, [addCombo(combo)]);
  1311. },
  1312. [220](attrs, combo) {
  1313. return powerUp(null, null, p.mul([100,100]), c.LShape(flags(attrs)), null, [addCombo(combo)]);
  1314. },
  1315. [223](combo, damage) {
  1316. return powerUp(null, null, p.scaleCombos(combo, combo, [100, 100], [0, 0]), null, null, [followAttackFixed(damage)]);
  1317. },
  1318. [224](turns, attr) { return activeTurns(turns, changeAttr('opponent', attr)); },
  1319. [225](min, max) { return skillProviso(c.hp(min ?? 0, max ?? 100)); },
  1320. [226](turns, percent) { return activeTurns(turns, orbDropIncrease(v.percent(percent), [], 'nail')); },
  1321. [227]() { return leaderChange(1); },
  1322. [228](turns, attrs, types, atk, rcv) {
  1323. return activeTurns(turns,
  1324. powerUp(null, null, p.scaleStateKindCount(null, flags(attrs), flags(types), p.mul({atk: atk, rcv: rcv, hp:0})))
  1325. );
  1326. },
  1327. [229](attrs, types, hp, atk, rcv) {
  1328. return powerUp(null, null, p.scaleStateKindCount(null, flags(attrs), flags(types), p.mul({hp: hp, atk: atk, rcv: rcv})));
  1329. },
  1330. };
  1331. //将内容添加到代码片段
  1332. DocumentFragment.prototype.ap = function(arg)
  1333. {
  1334. if (Array.isArray(arg)) //数组,递归自身
  1335. {
  1336. arg.forEach(element=>this.ap(element));
  1337. }
  1338. else if (arg instanceof Node) //属于Node的直接添加
  1339. {
  1340. this.appendChild(arg);
  1341. }
  1342. else //其他内容的转换为文字添加
  1343. {
  1344. this.appendChild(document.createTextNode(arg));
  1345. }
  1346. return this;
  1347. }
  1348. //将数组和分隔符添加到一个代码片段,类似join
  1349. Array.prototype.nodeJoin = function(separator)
  1350. {
  1351. const frg = document.createDocumentFragment();
  1352. this.forEach((item, idx, arr)=>{
  1353. frg.ap(item);
  1354. if (idx < (arr.length - 1) && separator != null)
  1355. frg.ap(separator instanceof Node ? separator.cloneNode(true) : separator);
  1356. });
  1357. return frg;
  1358. }
  1359. //按住Ctrl点击技能在控制台输出技能的对象
  1360. function showParsedSkill(event) {
  1361. if (event.ctrlKey) {
  1362. console.log(this.skill);
  1363. }
  1364. }
  1365. function renderSkillEntry(skills)
  1366. {
  1367. const ul = document.createElement("ul");
  1368. ul.className = "card-skill-list";
  1369. skills.forEach(skill=>{
  1370. const li = ul.appendChild(document.createElement("li"));
  1371. li.className = skill.kind;
  1372. li.appendChild(renderSkill(skill));
  1373. li.skill = skill;
  1374. li.addEventListener("click", showParsedSkill);
  1375. });
  1376. if (merge_skill)
  1377. {
  1378. let boardChange = skills.filter(skill=>
  1379. skill.kind == SkillKinds.BoardChange ||
  1380. skill.kind == SkillKinds.GenerateOrbs ||
  1381. skill.kind == SkillKinds.FixedOrbs
  1382. );
  1383. if (boardChange.length > 0)
  1384. {
  1385. const board = new Board();
  1386. for (let skill of boardChange)
  1387. {
  1388. switch (skill.kind)
  1389. {
  1390. case SkillKinds.BoardChange: { //洗版
  1391. const attrs = skill.attrs;
  1392. board.randomFill(attrs);
  1393. break;
  1394. }
  1395. case SkillKinds.GenerateOrbs: { //产生珠子
  1396. let orbs = skill.orbs, exclude = skill.exclude, count = skill.count;
  1397. console.log(orbs)
  1398. board.generateOrbs(orbs, count, exclude);
  1399. break;
  1400. }
  1401. case SkillKinds.FixedOrbs: { //固定位置产生珠子
  1402. let generates = skill.generates;
  1403. for (const generate of generates)
  1404. {
  1405. let orb = generate.orbs?.[0];
  1406. if (generate.type == 'shape') {
  1407. board.setShape(generate.positions, orb);
  1408. } else {
  1409. if (generate.type == 'row')
  1410. board.setRow(generate.positions, orb);
  1411. else
  1412. board.setColumn(generate.positions, orb);
  1413. }
  1414. }
  1415. break;
  1416. }
  1417. }
  1418. }
  1419. const li = ul.appendChild(document.createElement("li"));
  1420. li.appendChild(board.toTable());
  1421. li.className = "merge-board";
  1422. }
  1423. }
  1424. return ul;
  1425. }
  1426. function renderSkill(skill, option = {})
  1427. {
  1428. const frg = document.createDocumentFragment();
  1429. if (typeof localTranslating == "undefined") return frg;
  1430. const tsp = localTranslating.skill_parse;
  1431. function createIcon(iconType, className){
  1432. const idoc = document.createElement("icon");
  1433. idoc.className = `icon-skill${className ? ` ${className}` : ''}`;
  1434. idoc.setAttribute("data-icon-type", iconType);
  1435. return idoc;
  1436. }
  1437. if (Array.isArray(skill))
  1438. {
  1439. frg.ap(skill.map(_skill=>renderSkill(_skill)));
  1440. return frg;
  1441. }
  1442. switch (skill.kind) {
  1443. case SkillKinds.Unknown: {
  1444. let dict = {
  1445. type: skill.kind
  1446. };
  1447. frg.ap(tsp.skill.unknown(dict));
  1448. break;
  1449. }
  1450. case SkillKinds.ActiveTurns: { //有回合的行动
  1451. let turns = skill.turns, actionSkill = skill.skill;
  1452. let dict = {
  1453. turns: Array.isArray(turns) ? turns.join(tsp.word.range_hyphen().textContent) : turns,
  1454. actionSkill: renderSkill(actionSkill),
  1455. };
  1456. frg.ap(tsp.skill.active_turns(dict));
  1457. break;
  1458. }
  1459. case SkillKinds.RandomSkills: { //随机技能
  1460. let skills = skill.skills;
  1461. const ul = document.createElement("ul");
  1462. ul.className = "random-active-skill";
  1463. skills.forEach(subSkills=>{
  1464. const li = ul.appendChild(document.createElement("li"));
  1465. li.appendChild(renderSkillEntry(subSkills));
  1466. });
  1467. let dict = {
  1468. skills: ul,
  1469. };
  1470. frg.ap(tsp.skill.random_skills(dict));
  1471. break;
  1472. }
  1473. case SkillKinds.Delay: { //威吓
  1474. let dict = {
  1475. icon: createIcon(skill.kind),
  1476. };
  1477. frg.ap(tsp.skill.delay(dict));
  1478. break;
  1479. }
  1480. case SkillKinds.MassAttack: { //全体攻击
  1481. let dict = {
  1482. icon: createIcon(skill.kind),
  1483. };
  1484. frg.ap(tsp.skill.mass_attack(dict));
  1485. break;
  1486. }
  1487. case SkillKinds.LeaderChange: { //切换队长
  1488. let type = skill.type;
  1489. let dict = {
  1490. icon: createIcon(skill.kind),
  1491. target: type ? tsp.target.team_last() : tsp.target.self(),
  1492. };
  1493. frg.ap(tsp.skill.leader_change(dict));
  1494. break;
  1495. }
  1496. case SkillKinds.NoSkyfall: { //无天降
  1497. let dict = {
  1498. icon: createIcon(skill.kind),
  1499. };
  1500. frg.ap(tsp.skill.no_skyfall(dict));
  1501. break;
  1502. }
  1503. case SkillKinds.SelfHarm: { //主动自残
  1504. let value = skill.value;
  1505. let dict = {
  1506. icon: createIcon("heal", "hp-decr"),
  1507. value: renderValue(value, {percent: true}),
  1508. stats: tsp.stats.hp(),
  1509. };
  1510. frg.ap(tsp.skill.self_harm(dict));
  1511. break;
  1512. }
  1513. case SkillKinds.Heal: { //主动回血buff
  1514. let value = skill.value;
  1515. let dict = {
  1516. icon: createIcon("heal", "hp-incr"),
  1517. //icon: createIcon("auto-heal"),
  1518. value: renderValue(value, {unit: tsp.unit.point, percent: value.kind == SkillValueKind.xRCV ? false : true}),
  1519. stats: tsp.stats.hp(),
  1520. };
  1521. frg.ap(tsp.skill.heal(dict));
  1522. break;
  1523. }
  1524. case SkillKinds.AutoHealBuff: { //自动回血buff
  1525. let dict = {
  1526. icon: createIcon("auto-heal"),
  1527. value: renderValue(skill.value, {unit: tsp.unit.point, percent: true}),
  1528. stats: tsp.stats.hp(),
  1529. };
  1530. frg.ap(tsp.skill.auto_heal_buff(dict));
  1531. break;
  1532. }
  1533. case SkillKinds.DefenseBreak: { //破防
  1534. let dict = {
  1535. icon: createIcon(skill.kind),
  1536. value: renderValue(skill.value, {percent: true}),
  1537. };
  1538. frg.ap(tsp.skill.defense_break(dict));
  1539. break;
  1540. }
  1541. case SkillKinds.Poison: { //毒
  1542. let dict = {
  1543. icon: createIcon(skill.kind),
  1544. belong_to: tsp.target.self(),
  1545. target: tsp.target.enemy_all(),
  1546. stats: tsp.stats.hp(),
  1547. value: renderValue(skill.value),
  1548. };
  1549. frg.ap(tsp.skill.poison(dict));
  1550. break;
  1551. }
  1552. case SkillKinds.TimeExtend: { //时间变化buff
  1553. let value = skill.value;
  1554. let dict = {
  1555. icon: createIcon("status-time", SkillValue.isLess(value) ? "time-decr" : "time-incr"),
  1556. value: renderValue(value, { unit:tsp.unit.seconds, plusSign: value.kind != SkillValueKind.Percent, percent: SkillValue.isLess(value) }),
  1557. };
  1558. frg.ap(tsp.skill.time_extend(dict));
  1559. break;
  1560. }
  1561. case SkillKinds.FollowAttack: { //队长技追打
  1562. let dict = {
  1563. //icon: createIcon("follow_attack"),
  1564. belong_to: tsp.target.self(),
  1565. target: tsp.target.enemy(),
  1566. value: renderValue(skill.value),
  1567. };
  1568. frg.ap(tsp.skill.follow_attack(dict));
  1569. break;
  1570. }
  1571. case SkillKinds.FollowAttackFixed: { //队长技固伤追打
  1572. let damage = skill.value;
  1573. let dict = {
  1574. damage: renderValue(damage, {unit: tsp.unit.point}),
  1575. attr: renderAttrs('fixed'),
  1576. };
  1577. frg.ap(tsp.skill.follow_attack_fixed(dict));
  1578. break;
  1579. }
  1580. case SkillKinds.AutoHeal: { //队长技自动回血
  1581. let dict = {
  1582. icon: createIcon(skill.kind),
  1583. belong_to: tsp.target.self(),
  1584. value: renderValue(skill.value),
  1585. stats: tsp.stats.hp(),
  1586. };
  1587. frg.ap(tsp.skill.auto_heal(dict));
  1588. break;
  1589. }
  1590. case SkillKinds.CTW: { //时间暂停
  1591. let dict = {
  1592. icon: createIcon(skill.kind),
  1593. value: renderValue(skill.value, { unit: tsp.unit.seconds }),
  1594. };
  1595. frg.ap(tsp.skill.ctw(dict));
  1596. break;
  1597. }
  1598. case SkillKinds.Gravity: { //重力
  1599. let dict = {
  1600. icon: createIcon(skill.kind),
  1601. target: tsp.target.enemy(),
  1602. value: renderValue(skill.value, { percent:true }),
  1603. };
  1604. frg.ap(tsp.skill.gravity(dict));
  1605. break;
  1606. }
  1607. case SkillKinds.Resolve: { //根性
  1608. let prob = skill.prob;
  1609. let dict = {
  1610. icon: createIcon(skill.kind),
  1611. stats: renderStat('chp'),
  1612. min: renderValue(skill.min, { percent:true }),
  1613. max: renderValue(skill.max, { percent:true }),
  1614. };
  1615. frg.ap(tsp.skill.resolve(dict));
  1616. break;
  1617. }
  1618. case SkillKinds.DamageEnemy: { //大炮和固伤
  1619. let attr = skill.attr, target = skill.target, damage = skill.damage, times = skill.times;
  1620. if (attr == null) break; //没有属性时,编号为0的空技能
  1621. dict = {
  1622. target: target === 'all' ? tsp.target.enemy_all() : target === 'single' ? tsp.target.enemy_one() : tsp.target.enemy_attr({attr: renderAttrs(target, {affix: true})}),
  1623. damage: renderValue(damage, {unit: tsp.unit.point}),
  1624. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true}),
  1625. };
  1626. if (times)
  1627. {
  1628. dict.times = tsp.skill.damage_enemy_times({
  1629. times: renderValue(v.constant(times), {unit: tsp.unit.times})
  1630. });
  1631. dict.totalDamage = tsp.skill.damage_enemy_count({
  1632. damage: renderValue(v.constant(damage.value * times), {unit: tsp.unit.point})
  1633. });
  1634. }
  1635. frg.ap(tsp.skill.damage_enemy(dict));
  1636. break;
  1637. }
  1638. case SkillKinds.Unbind: { //解封
  1639. let normal = skill.normal, awakenings = skill.awakenings, matches = skill.matches;
  1640. let effects = [];
  1641. if (normal)
  1642. effects.push(tsp.skill.unbind_normal({icon: createIcon("unbind-normal"), turns: normal}));
  1643. if (awakenings)
  1644. effects.push(tsp.skill.unbind_awakenings({icon: createIcon("unbind-awakenings"), turns: awakenings}));
  1645. if (matches)
  1646. effects.push(tsp.skill.unbind_matches({icon: createIcon("unbind-matches"), turns: matches}));
  1647. frg.ap(effects.nodeJoin(tsp.word.comma()));
  1648. break;
  1649. }
  1650. case SkillKinds.BindSkill: {
  1651. dict = {
  1652. icon: createIcon(skill.kind)
  1653. };
  1654. frg.ap(tsp.skill.bind_skill(dict));
  1655. break;
  1656. }
  1657. case SkillKinds.BoardChange: { //洗版
  1658. const attrs = skill.attrs;
  1659. dict = {
  1660. orbs: renderOrbs(attrs),
  1661. };
  1662. frg.ap(tsp.skill.board_change(dict));
  1663. if (!merge_skill)
  1664. {
  1665. let board = new Board(attrs);
  1666. frg.ap(board.toTable());
  1667. }
  1668. break;
  1669. }
  1670. case SkillKinds.SkillBoost: { //溜
  1671. const value = skill.value;
  1672. let dict = {
  1673. icon: createIcon(skill.kind, SkillValue.isLess(skill.value) ? "boost-decr" : "boost-incr"),
  1674. turns: renderValue(value, { unit:tsp.unit.turns, plusSign:true }),
  1675. };
  1676. frg.ap(tsp.skill.skill_boost(dict));
  1677. break;
  1678. }
  1679. case SkillKinds.AddCombo: { //+C
  1680. const value = skill.value;
  1681. let icon = createIcon(skill.kind);
  1682. icon.setAttribute("data-add-combo", value);
  1683. let dict = {
  1684. icon: icon,
  1685. value: value,
  1686. };
  1687. frg.ap(tsp.skill.add_combo(dict));
  1688. break;
  1689. }
  1690. case SkillKinds.FixedTime: { //固定手指
  1691. const value = skill.value;
  1692. let dict = {
  1693. icon: createIcon(skill.kind),
  1694. value: renderValue(value, { unit: tsp.unit.seconds }),
  1695. };
  1696. frg.ap(tsp.skill.fixed_time(dict));
  1697. break;
  1698. }
  1699. case SkillKinds.MinMatchLength: { //最低匹配长度
  1700. const value = skill.value;
  1701. let dict = {
  1702. icon: createIcon(skill.kind),
  1703. unmatchable: value - 1,
  1704. matchable: value,
  1705. };
  1706. frg.ap(tsp.skill.min_match_length(dict));
  1707. break;
  1708. }
  1709. case SkillKinds.DropRefresh: { //刷版
  1710. let dict = {
  1711. icon: createIcon(skill.kind),
  1712. };
  1713. frg.ap(tsp.skill.drop_refresh(dict));
  1714. break;
  1715. }
  1716. case SkillKinds.Drum: { //太鼓达人音效
  1717. frg.ap(tsp.skill.drum());
  1718. break;
  1719. }
  1720. case SkillKinds.AutoPath: { //小龙的萌新技能
  1721. frg.ap(tsp.skill.auto_path());
  1722. break;
  1723. }
  1724. case SkillKinds.Board7x6: { //76版
  1725. let dict = {
  1726. icon: createIcon(skill.kind),
  1727. };
  1728. frg.ap(tsp.skill.board7x6(dict));
  1729. break;
  1730. }
  1731. case SkillKinds.Vampire: { //吸血
  1732. let attr = skill.attr, damage = skill.damage, heal = skill.heal;
  1733. let _dict = {
  1734. target: tsp.target.enemy_one(),
  1735. damage: renderValue(damage),
  1736. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true}),
  1737. };
  1738. dict = {
  1739. icon: createIcon("heal", "hp-incr"),
  1740. damage_enemy: tsp.skill.damage_enemy(_dict),
  1741. heal: renderValue(heal, {percent: true}),
  1742. };
  1743. frg.ap(tsp.skill.vampire(dict));
  1744. break;
  1745. }
  1746. case SkillKinds.CounterAttack: { //反击
  1747. let attr = skill.attr, prob = skill.prob, value = skill.value;
  1748. dict = {
  1749. icon: createIcon(skill.kind),
  1750. target: tsp.target.enemy(),
  1751. chance: prob.value < 1 ? tsp.value.prob({value: renderValue(prob, { percent:true })}) : null,
  1752. value: renderValue(value),
  1753. attr: renderAttrs(attr, {affix: true}),
  1754. };
  1755. frg.ap(tsp.skill.counter_attack(dict));
  1756. break;
  1757. }
  1758. case SkillKinds.ChangeOrbs: { //珠子变换
  1759. let changes = skill.changes;
  1760. let subDocument = [];
  1761. for (const change of changes)
  1762. {
  1763. dict = {
  1764. from: renderOrbs(change.from),
  1765. to: renderOrbs(change.to),
  1766. };
  1767. subDocument.push(tsp.skill.change_orbs(dict));
  1768. }
  1769. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  1770. break;
  1771. }
  1772. case SkillKinds.GenerateOrbs: { //产生珠子
  1773. let orbs = skill.orbs, exclude = skill.exclude, count = skill.count, time = skill.time;
  1774. dict = {
  1775. exclude: exclude?.length ? tsp.word.affix_exclude({cotent: renderOrbs(exclude)}) : void 0,
  1776. orbs: renderOrbs(orbs, {time}),
  1777. value: count,
  1778. };
  1779. frg.ap(tsp.skill.generate_orbs(dict));
  1780. if (!merge_skill)
  1781. {
  1782. let board = new Board();
  1783. board.generateOrbs(orbs, count, exclude);
  1784. frg.ap(board.toTable());
  1785. }
  1786. break;
  1787. }
  1788. case SkillKinds.FixedOrbs: { //固定位置产生珠子
  1789. let generates = skill.generates;
  1790. let slight_pause = tsp.word.slight_pause().textContent;
  1791. let subDocument = [];
  1792. let board = merge_skill ? null : new Board();
  1793. function posSplit(pos, max)
  1794. {
  1795. return {sequence: pos.filter(n=>n<=2).map(n=>n+1), reverse: pos.filter(n=>n>=3).reverse().map(n=>max-n)};
  1796. }
  1797. for (const generate of generates)
  1798. {
  1799. let orb = generate.orbs?.[0], time = generate.time;
  1800. dict = {
  1801. orbs: renderOrbs(orb, {time}),
  1802. };
  1803. if (generate.type == 'shape')
  1804. {
  1805. dict.position = tsp.position.shape();
  1806. if (!merge_skill) board.setShape(generate.positions, orb);
  1807. }else
  1808. {
  1809. let posFrgs = [];
  1810. if (generate.positions.length == 0) continue;
  1811. if (generate.type == 'row')
  1812. {
  1813. const pos = posSplit(generate.positions, 5);
  1814. if (pos.sequence.length) posFrgs.push(tsp.position.top({pos: pos.sequence.join(slight_pause)}));
  1815. if (pos.reverse.length) posFrgs.push(tsp.position.bottom({pos: pos.reverse.join(slight_pause)}));
  1816. if (!merge_skill) board.setRow(generate.positions, orb);
  1817. }else
  1818. {
  1819. const pos = posSplit(generate.positions, 6);
  1820. if (pos.sequence.length) posFrgs.push(tsp.position.left({pos: pos.sequence.join(slight_pause)}));
  1821. if (pos.reverse.length) posFrgs.push(tsp.position.right({pos: pos.reverse.join(slight_pause)}));
  1822. if (!merge_skill) board.setColumn(generate.positions, orb);
  1823. }
  1824. dict.position = posFrgs.nodeJoin(tsp.word.slight_pause());
  1825. }
  1826. subDocument.push(tsp.skill.fixed_orbs(dict));
  1827. }
  1828. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  1829. if (!merge_skill) frg.ap(board.toTable());
  1830. break;
  1831. }
  1832. case SkillKinds.OrbDropIncrease: { //增加天降
  1833. let attrs = skill.attrs, value = skill.value, flag = skill.flag;
  1834. dict = {
  1835. value: value && renderValue(value, {percent: true}) || null,
  1836. chance: value && tsp.value.prob({
  1837. value: renderValue(value, {percent: true})
  1838. }) || null,
  1839. orbs: renderOrbs(attrs, {className: "drop", affix: true}),
  1840. flag: flag && tsp.orbs[flag]({icon: createIcon("orb-" + flag)}) || null,
  1841. };
  1842. frg.ap(flag ? tsp.skill.orb_drop_increase_flag(dict) : tsp.skill.orb_drop_increase(dict));
  1843. break;
  1844. }
  1845. case SkillKinds.VoidEnemyBuff: {
  1846. let buffs = skill.buffs;
  1847. let subDocument = [];
  1848. for (let buff of buffs)
  1849. {
  1850. let dict = {
  1851. icon: createIcon(buff),
  1852. };
  1853. subDocument.push(tsp.skill[buff.replace(/\-/g,'_')](dict));
  1854. }
  1855. let dict = {
  1856. buff: subDocument.nodeJoin(tsp.word.slight_pause()),
  1857. };
  1858. frg.ap(tsp.skill.void_enemy_buff(dict));
  1859. break;
  1860. }
  1861. case SkillKinds.ChangeAttribute: {
  1862. let attr = skill.attr, target = skill.target;
  1863. dict = {
  1864. attrs: renderAttrs(attr, {affix: true}),
  1865. target: target === 'opponent' ? tsp.target.enemy_all() : tsp.target.self(),
  1866. };
  1867. frg.ap(tsp.skill.change_attribute(dict));
  1868. break;
  1869. }
  1870. case SkillKinds.SetOrbState: {
  1871. let orbs = skill.orbs, state = skill.state, arg = skill.arg;
  1872. dict = {
  1873. orbs: renderOrbs(orbs, {className: state, affix: true}),
  1874. icon: createIcon('orb-' + state),
  1875. };
  1876. switch (state)
  1877. {
  1878. case "enhanced":{
  1879. dict.value = renderValue(arg.enhance, {percent: true});
  1880. frg.ap(tsp.skill.set_orb_state_enhanced(dict));
  1881. break;
  1882. }
  1883. case "locked":{
  1884. if (arg.count.value < 42)
  1885. dict.value = renderValue(arg.count, {unit: tsp.unit.orbs});
  1886. frg.ap(tsp.skill.set_orb_state_locked(dict));
  1887. break;
  1888. }
  1889. case "unlocked":{
  1890. frg.ap(tsp.skill.set_orb_state_unlocked(dict));
  1891. break;
  1892. }
  1893. case "bound":{
  1894. frg.ap(tsp.skill.set_orb_state_bound(dict));
  1895. break;
  1896. }
  1897. }
  1898. break;
  1899. }
  1900. case SkillKinds.RateMultiply: {
  1901. let rate = skill.rate, value = skill.value;
  1902. dict = {
  1903. rate: tsp.skill["rate_multiply_" + rate]({icon: createIcon(skill.kind + "-" + rate)}),
  1904. value: renderValue(value),
  1905. };
  1906. frg.ap(tsp.skill.rate_multiply(dict));
  1907. break;
  1908. }
  1909. case SkillKinds.ReduceDamage: {
  1910. let attrs = skill.attrs, percent = skill.percent, condition = skill.condition;
  1911. dict = {
  1912. icon: createIcon(skill.kind),
  1913. attrs: renderAttrs(attrs, {affix: true}),
  1914. value: renderValue(percent, {percent: true}),
  1915. };
  1916. if (condition) dict.condition = renderCondition(condition);
  1917. frg.ap(tsp.skill.reduce_damage(dict));
  1918. break;
  1919. }
  1920. case SkillKinds.PowerUp: {
  1921. let attrs = skill.attrs, types = skill.types, condition = skill.condition, value = skill.value, reduceDamage = skill.reduceDamage, additional = skill.additional;
  1922. dict = {
  1923. icon: createIcon(skill.kind),
  1924. };
  1925. if (condition) dict.condition = renderCondition(condition);
  1926. let targetDict = {}, attrs_types = [];
  1927. if (attrs?.length && !isEqual(attrs, Attributes.all()))
  1928. {
  1929. targetDict.attrs = renderAttrs(attrs || [], {affix: attrs?.filter(attr=> attr !== 5)?.length});
  1930. attrs_types.push(targetDict.attrs);
  1931. }
  1932. if (types?.length)
  1933. {
  1934. targetDict.types = renderTypes(types || [], {affix: true});
  1935. attrs_types.push(targetDict.types);
  1936. }
  1937. if (attrs_types.length)
  1938. {
  1939. targetDict.attrs_types = attrs_types.nodeJoin(tsp.word.slight_pause());
  1940. }
  1941. if (targetDict.attrs || targetDict.types) dict.targets = tsp.skill.power_up_targets(targetDict);
  1942. let subDocument = [];
  1943. if (value){
  1944. /*if (attrs?.includes(5) && value.kind == SkillPowerUpKind.Multiplier)
  1945. { //如果属性有5,则是回复力
  1946. let _value = Object.assign({}, value);
  1947. _value.rcv = value.atk;
  1948. _value.atk = value.rcv;
  1949. value = _value;
  1950. }*/
  1951. if (value.kind == SkillPowerUpKind.Multiplier && Boolean(value.hp || value.atk || value.rcv) == false)
  1952. {
  1953. //不显示 value
  1954. }else
  1955. {
  1956. subDocument.push(renderPowerUp(value));
  1957. }
  1958. }
  1959. if (reduceDamage && reduceDamage.value > 0) {
  1960. subDocument.push(tsp.skill.reduce_damage({
  1961. value: renderValue(reduceDamage, {percent: true}),
  1962. icon: createIcon("reduce-damage"),
  1963. }));
  1964. }
  1965. if (additional?.length) {
  1966. for (let subSkill of additional.filter(Boolean))
  1967. {
  1968. subDocument.push(renderSkill(subSkill, option));
  1969. }
  1970. }
  1971. dict.value = subDocument.filter(Boolean).nodeJoin(tsp.word.comma());
  1972. frg.ap(tsp.skill.power_up(dict));
  1973. break;
  1974. }
  1975. case SkillKinds.Henshin: { //变身
  1976. let id = skill.id;
  1977. const dom = cardN(id);
  1978. dom.monDom.onclick = changeToIdInSkillDetail;
  1979. dict = {
  1980. card: dom,
  1981. }
  1982. frg.ap(tsp.skill.henshin(dict));
  1983. break;
  1984. }
  1985. case SkillKinds.VoidPoison: { //毒无效
  1986. dict = {
  1987. poison: renderOrbs([7,8], {affix: true})
  1988. }
  1989. frg.ap(tsp.skill.void_poison(dict));
  1990. break;
  1991. }
  1992. case SkillKinds.SkillProviso: { //条件限制才能用技能
  1993. let cond = skill.cond;
  1994. dict = {
  1995. condition: renderCondition(cond)
  1996. }
  1997. frg.ap(tsp.skill.skill_proviso(dict));
  1998. break;
  1999. }
  2000. default: {
  2001. console.log("未处理的技能类型",skill.kind, skill);
  2002. frg.ap(skill.kind);
  2003. }
  2004. }
  2005. return frg;
  2006. };
  2007. function renderStat(stat, option) {
  2008. const frg = document.createDocumentFragment();
  2009. if (typeof localTranslating == "undefined") return frg;
  2010. const tspt = localTranslating.skill_parse.stats;
  2011. if (tspt[stat])
  2012. frg.ap(tspt[stat](option));
  2013. else
  2014. {
  2015. console.log("未知状态类型",stat);
  2016. frg.ap(tspt.unknown({ type: stat }));
  2017. }
  2018. return frg;
  2019. }
  2020. function renderAttrs(attrs, option = {}) {
  2021. if (!Array.isArray(attrs))
  2022. attrs = [attrs ?? 0];
  2023. const frg = document.createDocumentFragment();
  2024. if (typeof localTranslating == "undefined") return frg;
  2025. const tsp = localTranslating.skill_parse;
  2026. let contentFrg;
  2027. if (isEqual(attrs, Attributes.all()))
  2028. {
  2029. contentFrg = tsp.attrs.all();
  2030. }
  2031. else
  2032. {
  2033. contentFrg = attrs.map(attr => {
  2034. const icon = document.createElement("icon");
  2035. icon.className = "attr";
  2036. icon.setAttribute("data-attr-icon",attr);
  2037. return tsp.attrs?.[attr]({icon: icon});
  2038. })
  2039. .nodeJoin(tsp.word.slight_pause());
  2040. }
  2041. if (option.affix)
  2042. contentFrg = tsp.word.affix_attr({cotent: contentFrg});
  2043. frg.ap(contentFrg);
  2044. return frg;
  2045. }
  2046. function renderOrbs(attrs, option = {}) {
  2047. if (!Array.isArray(attrs))
  2048. attrs = [attrs ?? 0];
  2049. const frg = document.createDocumentFragment();
  2050. if (typeof localTranslating == "undefined") return frg;
  2051. const tsp = localTranslating.skill_parse;
  2052. let contentFrg;
  2053. if (isEqual(attrs, Attributes.orbs()))
  2054. {
  2055. contentFrg = tsp.orbs.all();
  2056. }
  2057. else if (isEqual(attrs, Attributes.all()))
  2058. {
  2059. contentFrg = renderOrbs('_5color');
  2060. }
  2061. else if (isEqual(attrs, Attributes._6color()))
  2062. {
  2063. contentFrg = tsp.orbs._6color({
  2064. _5color: renderOrbs('_5color'),
  2065. orb_rcv: renderOrbs(5),
  2066. });
  2067. }
  2068. else
  2069. {
  2070. contentFrg = attrs.map(attr => {
  2071. const icon = document.createElement("icon");
  2072. icon.className = "orb";
  2073. if (option.className) icon.className += " " + option.className;
  2074. icon.setAttribute("data-orb-icon",attr);
  2075. let dict = {
  2076. icon: icon,
  2077. }
  2078. if (attr == 'variation') dict.time = renderValue(v.constant(option.time), {unit: tsp.unit.seconds}) ;
  2079. return tsp.orbs?.[attr](dict);
  2080. })
  2081. .nodeJoin(tsp.word.slight_pause());
  2082. }
  2083. if (option.affix)
  2084. contentFrg = tsp.word.affix_orb({cotent: contentFrg});
  2085. if (option.any && attrs.length >= 2)
  2086. contentFrg = tsp.orbs.any({cotent: contentFrg});
  2087. frg.ap(contentFrg);
  2088. return frg;
  2089. }
  2090. function renderTypes(types, option = {}) {
  2091. if (!Array.isArray(types))
  2092. types = [types ?? 0];
  2093. const frg = document.createDocumentFragment();
  2094. if (typeof localTranslating == "undefined") return frg;
  2095. const tsp = localTranslating.skill_parse;
  2096. let contentFrg = types.map(type => {
  2097. const icon = document.createElement("icon");
  2098. icon.className = "type";
  2099. icon.setAttribute("data-type-icon",type);
  2100. return tsp.types?.[type]({icon: icon});
  2101. })
  2102. .nodeJoin(tsp.word.slight_pause());
  2103. if (option.affix)
  2104. contentFrg = tsp.word.affix_type({cotent: contentFrg});
  2105. frg.ap(contentFrg);
  2106. return frg;
  2107. }
  2108. function renderAwakenings(awakenings, option = {}) {
  2109. if (!Array.isArray(awakenings))
  2110. awakenings = [awakenings ?? 0];
  2111. const frg = document.createDocumentFragment();
  2112. if (typeof localTranslating == "undefined") return frg;
  2113. const tsp = localTranslating.skill_parse;
  2114. let contentFrg = awakenings.map(awoken => {
  2115. const icon = document.createElement("icon");
  2116. icon.className = "awoken-icon";
  2117. icon.setAttribute("data-awoken-icon",awoken);
  2118. return tsp.awokens?.[awoken]({icon: icon});
  2119. })
  2120. .nodeJoin(tsp.word.slight_pause());
  2121. if (option.affix)
  2122. contentFrg = tsp.word.affix_awakening({cotent: contentFrg});
  2123. frg.ap(contentFrg);
  2124. return frg;
  2125. }
  2126. function renderCondition(cond) {
  2127. const frg = document.createDocumentFragment();
  2128. const tsp = localTranslating.skill_parse;
  2129. if (cond.hp) {
  2130. let dict = {
  2131. hp: renderStat('chp'),
  2132. min: renderValue(v.percent(cond.hp.min * 100), {percent: true}),
  2133. max: renderValue(v.percent(cond.hp.max * 100), {percent: true}),
  2134. };
  2135. if (cond.hp.min === cond.hp.max)
  2136. frg.ap(tsp.cond.hp_equal(dict));
  2137. else if (cond.hp.min === 0)
  2138. frg.ap(tsp.cond.hp_less_or_equal(dict));
  2139. else if (cond.hp.max === 1)
  2140. frg.ap(tsp.cond.hp_greater_or_equal(dict));
  2141. else
  2142. frg.ap(tsp.cond.hp_belong_to_range(dict));
  2143. } else if (cond.useSkill) {
  2144. frg.ap(tsp.cond.use_skill());
  2145. } else if (cond.multiplayer) {
  2146. frg.ap(tsp.cond.multi_player());
  2147. } else if (cond.remainOrbs) {
  2148. let dict = {
  2149. value: renderValue(v.constant(cond.remainOrbs.count), {unit: tsp.unit.orbs}),
  2150. };
  2151. frg.ap(tsp.cond.remain_orbs(dict));
  2152. } else if (cond.exact) {
  2153. if (cond.exact.type === 'combo') {
  2154. let dict = {value: cond.exact.value};
  2155. frg.ap(tsp.cond.exact_combo(dict));
  2156. } else if (cond.exact.type === 'match-length') {
  2157. let dict = {
  2158. value: renderValue(v.constant(cond.exact.value), {unit: tsp.unit.orbs}),
  2159. orbs: cond.exact.attrs === 'enhanced' ? tsp.cond.exact_match_enhanced() : renderOrbs(cond.exact.attrs, {affix: true})
  2160. };
  2161. frg.ap(tsp.cond.exact_match_length(dict));
  2162. }
  2163. } else if (cond.compo) {
  2164. let dict = {};
  2165. switch (cond.compo.type)
  2166. {
  2167. case 'card':{
  2168. dict.ids = cond.compo.ids.map(mid=>{
  2169. const dom = cardN(mid);
  2170. dom.monDom.onclick = changeToIdInSkillDetail;
  2171. return dom;
  2172. }).nodeJoin();
  2173. frg.ap(tsp.cond.compo_type_card(dict));
  2174. break;
  2175. }
  2176. case 'series':{
  2177. dict.ids = cond.compo.ids.map(cid=>{
  2178. const lnk = document.createElement("a");
  2179. lnk.className ="detail-search monster-collabId";
  2180. lnk.setAttribute("data-collabId",cid);
  2181. lnk.onclick = searchCollab;
  2182. lnk.textContent = (cid == 10001 ? Cards[5435] : Cards.find(card=>card.collabId == cid))?.altName?.[0] ?? `No.${cid}`;
  2183. return lnk;
  2184. }).nodeJoin(tsp.word.slight_pause());
  2185. frg.ap(tsp.cond.compo_type_series(dict));
  2186. break;
  2187. }
  2188. case 'evolution':{
  2189. dict.ids = cond.compo.ids.map(eid=>{
  2190. const lnk = document.createElement("a");
  2191. lnk.className ="detail-search";
  2192. switch (eid)
  2193. {
  2194. case 0:{ //像素进化
  2195. lnk.appendChild(tsp.word.evo_type_pixel());
  2196. lnk.onclick = function(){
  2197. showSearch(Cards.filter(card=>card.evoMaterials.includes(3826)));
  2198. };
  2199. break;
  2200. }
  2201. case 2:{ //转生或超转生
  2202. lnk.appendChild(tsp.word.evo_type_reincarnation());
  2203. lnk.onclick = function(){
  2204. showSearch(Cards.filter(card=>isReincarnated(card)));
  2205. };
  2206. break;
  2207. }
  2208. default:{ //转生或超转生
  2209. return tsp.word.evo_type_unknow();
  2210. }
  2211. }
  2212. return lnk;
  2213. }).nodeJoin(tsp.word.slight_pause());
  2214. frg.ap(tsp.cond.compo_type_evolution(dict));
  2215. break;
  2216. }
  2217. }
  2218. } else if (cond.LShape) {
  2219. let dict = {
  2220. orbs: renderOrbs(cond.LShape.attrs, {affix: true, any: true}),
  2221. };
  2222. frg.ap(tsp.cond.L_shape(dict));
  2223. } else if (cond.heal) {
  2224. let dict = {
  2225. orbs: renderOrbs(5, {affix: true}),
  2226. heal: renderValue(v.constant(cond.heal.min), {unit: tsp.unit.point}),
  2227. stats: renderStat('hp'),
  2228. };
  2229. frg.ap(tsp.cond.heal(dict));
  2230. } else {
  2231. frg.ap(tsp.cond.unknown());
  2232. }
  2233. return frg;
  2234. }
  2235. function renderPowerUp(powerUp) {
  2236. const frg = document.createDocumentFragment();
  2237. const tsp = localTranslating.skill_parse;
  2238. function renderStats(hp, atk, rcv, option = {}) {
  2239. const mul = option.mul ?? true;
  2240. option.percent = !mul;
  2241. const frg = document.createDocumentFragment();
  2242. const operator = mul ? ' ' : '+';
  2243. let list = [['hp', hp], ['atk', atk], ['rcv', rcv]];
  2244. //去除不改变的值
  2245. list = list.filter(([, value]) => value !== (mul ? 1 : 0));
  2246. //&&!(name === 'hp' && value === 0));
  2247. if (list.length === 0) return frg;
  2248. if (list.every(([, value]) => value === list[0][1])) {
  2249. let value = list[0][1];
  2250. //三个值一样
  2251. frg.ap(list.map(([name]) => renderStat(name)).nodeJoin(tsp.word.slight_pause()));
  2252. frg.ap(operator);
  2253. frg.ap(renderValue(v.percent(value * 100), option));
  2254. } else {
  2255. //三个值不一样
  2256. let subDocument = list.map(([name, value]) => {
  2257. let _frg = document.createDocumentFragment();
  2258. _frg.ap(renderStat(name));
  2259. _frg.ap(operator);
  2260. _frg.ap(renderValue(v.percent(value * 100), option));
  2261. return _frg;
  2262. });
  2263. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  2264. }
  2265. return frg;
  2266. }
  2267. switch (powerUp.kind) {
  2268. case SkillPowerUpKind.Multiplier: {
  2269. let hp = powerUp.hp, atk = powerUp.atk, rcv = powerUp.rcv;
  2270. frg.ap(renderStats(hp, atk, rcv));
  2271. break;
  2272. }
  2273. case SkillPowerUpKind.ScaleAttributes: {
  2274. let attrs = powerUp.attrs, min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv;
  2275. let dict = {
  2276. orbs: renderOrbs(attrs, {affix: true}),
  2277. min: min,
  2278. stats: renderStats(1, baseAtk, baseRcv),
  2279. }
  2280. if (max !== min)
  2281. {
  2282. let _dict = {
  2283. max: max,
  2284. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  2285. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  2286. }
  2287. dict.bonus = frg.ap(tsp.power.scale_attributes_bonus(_dict));
  2288. }
  2289. frg.ap(tsp.power.scale_attributes(dict));
  2290. break;
  2291. }
  2292. case SkillPowerUpKind.ScaleCombos: {
  2293. let min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv;
  2294. let dict = {
  2295. min: min,
  2296. stats: renderStats(1, baseAtk, baseRcv),
  2297. }
  2298. if (max !== min)
  2299. {
  2300. let _dict = {
  2301. max: max,
  2302. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  2303. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  2304. }
  2305. dict.bonus = frg.ap(tsp.power.scale_combos_bonus(_dict));
  2306. }
  2307. frg.ap(tsp.power.scale_combos(dict));
  2308. break;
  2309. }
  2310. case SkillPowerUpKind.ScaleMatchAttrs: {
  2311. let matches = powerUp.matches, min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv;
  2312. let dict = {
  2313. matches: matches.map(orbs=>renderOrbs(orbs)).nodeJoin(tsp.word.slight_pause()),
  2314. min: min,
  2315. stats: renderStats(1, baseAtk, baseRcv),
  2316. }
  2317. if (max !== min)
  2318. {
  2319. let _dict = {
  2320. max: max,
  2321. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  2322. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  2323. }
  2324. dict.bonus = frg.ap(tsp.power.scale_match_attrs_bonus(_dict));
  2325. }
  2326. frg.ap(tsp.power.scale_match_attrs(dict));
  2327. break;
  2328. }
  2329. case SkillPowerUpKind.ScaleMatchLength: {
  2330. let attrs = powerUp.attrs, min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv, matchAll = powerUp.matchAll;
  2331. let dict = {
  2332. orbs: renderOrbs(attrs, {affix: true}),
  2333. min: min,
  2334. stats: renderStats(1, baseAtk, baseRcv),
  2335. in_once: matchAll && attrs.length>1 && tsp.word.in_once() || null,
  2336. }
  2337. if (max !== min)
  2338. {
  2339. let _dict = {
  2340. max: max,
  2341. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  2342. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  2343. }
  2344. dict.bonus = frg.ap(tsp.power.scale_match_length_bonus(_dict));
  2345. }
  2346. frg.ap(tsp.power.scale_match_length(dict));
  2347. break;
  2348. }
  2349. case SkillPowerUpKind.ScaleCross: {
  2350. let crosses = powerUp.crosses;
  2351. /*if (crosses.length >= 2 && crosses.every(cross => cross.atk === crosses[0].atk)) {
  2352. //所有值一样
  2353. let cross = crosses[0];
  2354. let dict = {
  2355. orbs: renderOrbs(crosses.map(cross => cross.attr), {affix: true, any: true}),
  2356. stats: renderStats(1, cross.atk, cross.rcv),
  2357. }
  2358. frg.ap(cross.single ? tsp.power.scale_cross_single(dict) : tsp.power.scale_cross(dict));
  2359. } else {*/
  2360. let subDocument = crosses.map(cross=>{
  2361. let dict = {
  2362. orbs: renderOrbs(cross.attr, {affix: true, any: true}),
  2363. stats: renderStats(1, cross.atk, cross.rcv),
  2364. }
  2365. return cross.single ? tsp.power.scale_cross_single(dict) : tsp.power.scale_cross(dict);
  2366. });
  2367. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  2368. //}
  2369. break;
  2370. }
  2371. case SkillPowerUpKind.ScaleStateKindCount: {
  2372. let awakenings = powerUp.awakenings, attrs = powerUp.attrs, types = powerUp.types, value = powerUp.value;
  2373. let dict = {
  2374. stats: renderStats(value.hp, value.atk, value.rcv, {mul: false, percent: true}),
  2375. awakenings: awakenings?.length && renderAwakenings(awakenings, {affix: true}) || null,
  2376. attrs: attrs?.length && renderAttrs(attrs, {affix: true}) || null,
  2377. types: types?.length && renderTypes(types, {affix: true}) || null,
  2378. }
  2379. frg.ap(tsp.power.scale_state_kind_count(dict));
  2380. break;
  2381. }
  2382. default:
  2383. frg.ap(tsp.power.unknown({type: powerUp.kind}));
  2384. }
  2385. return frg;
  2386. }
  2387. function renderValue(_value, option = {}) {
  2388. const frg = document.createDocumentFragment();
  2389. if (typeof localTranslating == "undefined") return frg;
  2390. const tsp = localTranslating.skill_parse
  2391. const tspv = tsp.value;
  2392. const od = option.decimalDigits, os = option.plusSign;
  2393. let dict;
  2394. switch (_value.kind) {
  2395. case SkillValueKind.Percent: {
  2396. dict = {
  2397. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2398. };
  2399. frg.ap(
  2400. option.percent ?
  2401. tspv.mul_percent(dict) :
  2402. tspv.mul_times(dict)
  2403. );
  2404. break;
  2405. }
  2406. case SkillValueKind.Constant: {
  2407. dict = {
  2408. value: _value.value.keepCounts(od,os),
  2409. unit: option.unit ? option.unit() : null,
  2410. };
  2411. frg.ap(tspv.const(dict));
  2412. break;
  2413. }
  2414. case SkillValueKind.ConstantTo: {
  2415. dict = {
  2416. value: _value.value.keepCounts(od,os)
  2417. };
  2418. frg.ap(tspv.const_to(dict));
  2419. break;
  2420. }
  2421. case SkillValueKind.xMaxHP: {
  2422. dict = {
  2423. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2424. stats: renderStat('maxhp'),
  2425. };
  2426. frg.ap(
  2427. option.percent ?
  2428. tspv.mul_of_percent(dict) :
  2429. tspv.mul_of_times(dict)
  2430. );
  2431. break;
  2432. }
  2433. case SkillValueKind.xHP: {
  2434. dict = {
  2435. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2436. stats: renderStat('hp'),
  2437. };
  2438. frg.ap(
  2439. option.percent ?
  2440. tspv.mul_of_percent(dict) :
  2441. tspv.mul_of_times(dict)
  2442. );
  2443. break;
  2444. }
  2445. case SkillValueKind.xCHP: {
  2446. dict = {
  2447. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2448. stats: renderStat('chp'),
  2449. };
  2450. frg.ap(
  2451. option.percent ?
  2452. tspv.mul_of_percent(dict) :
  2453. tspv.mul_of_times(dict)
  2454. );
  2455. break;
  2456. }
  2457. case SkillValueKind.xATK: {
  2458. dict = {
  2459. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2460. stats: renderStat('atk'),
  2461. };
  2462. frg.ap(
  2463. option.percent ?
  2464. tspv.mul_of_percent(dict) :
  2465. tspv.mul_of_times(dict)
  2466. );
  2467. break;
  2468. }
  2469. case SkillValueKind.xRCV: {
  2470. dict = {
  2471. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2472. stats: renderStat('rcv'),
  2473. };
  2474. frg.ap(
  2475. option.percent ?
  2476. tspv.mul_of_percent(dict) :
  2477. tspv.mul_of_times(dict)
  2478. );
  2479. break;
  2480. }
  2481. case SkillValueKind.xTeamHP: {
  2482. let value = _value.value;
  2483. dict = {
  2484. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  2485. stats: renderStat('teamhp'),
  2486. };
  2487. frg.ap(
  2488. option.percent ?
  2489. tspv.mul_of_percent(dict) :
  2490. tspv.mul_of_times(dict)
  2491. );
  2492. break;
  2493. }
  2494. case SkillValueKind.xTeamRCV: {
  2495. dict = {
  2496. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2497. stats: renderStat('teamrcv'),
  2498. };
  2499. frg.ap(
  2500. option.percent ?
  2501. tspv.mul_of_percent(dict) :
  2502. tspv.mul_of_times(dict)
  2503. );
  2504. break;
  2505. }
  2506. case SkillValueKind.xTeamATK: {
  2507. let attrs = _value.attrs, value = _value.value;
  2508. dict = {
  2509. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  2510. stats: renderStat('teamatk', {attrs: renderAttrs(attrs, {affix: true})}),
  2511. };
  2512. frg.ap(
  2513. option.percent ?
  2514. tspv.mul_of_percent(dict) :
  2515. tspv.mul_of_times(dict)
  2516. );
  2517. break;
  2518. }
  2519. case SkillValueKind.HPScale: {
  2520. let min = _value.min, max = _value.max;
  2521. dict = {
  2522. min: tspv.mul_of_times({value: min.keepCounts(od,os), stats:renderStat('atk')}),
  2523. max: tspv.mul_of_times({value: max.keepCounts(od,os), stats:renderStat('atk')}),
  2524. hp: renderStat('hp'),
  2525. };
  2526. frg.ap(tspv.hp_scale(dict));
  2527. break;
  2528. }
  2529. case SkillValueKind.RandomATK: {
  2530. let min = _value.min, max = _value.max;
  2531. dict = {
  2532. min: min.keepCounts(od,os),
  2533. atk: renderStat('atk'),
  2534. };
  2535. if (max != min)
  2536. {
  2537. dict.max = tsp.word.range_hyphen().ap(max.keepCounts(od,os));
  2538. }
  2539. frg.ap(tspv.random_atk(dict));
  2540. break;
  2541. }
  2542. case SkillValueKind.xAwakenings: {
  2543. let value = _value.value, awakenings = _value.awakenings;
  2544. let dict = {
  2545. value: renderValue(value,{percent : true}),
  2546. awakenings: renderAwakenings(awakenings, {affix: true}),
  2547. }
  2548. frg.ap(tsp.value.x_awakenings(dict));
  2549. break;
  2550. }
  2551. default: {
  2552. console.log("未知数值类型",_value.kind, _value);
  2553. frg.ap(tspv.unknown({ type: _value.kind }));
  2554. }
  2555. }
  2556. return frg;
  2557. }

智龙迷城队伍图制作工具