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

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

智龙迷城队伍图制作工具