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

智龙迷城队伍图制作工具