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

script-skill-parser.js 84 kB

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

智龙迷城队伍图制作工具