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

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

智龙迷城队伍图制作工具