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

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

智龙迷城队伍图制作工具