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

script-skill-parser.js 102 kB

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

智龙迷城队伍图制作工具