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

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

智龙迷城队伍图制作工具