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

智龙迷城队伍图制作工具