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

智龙迷城队伍图制作工具