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

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

智龙迷城队伍图制作工具