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

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

智龙迷城队伍图制作工具