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 102 kB

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

智龙迷城队伍图制作工具