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

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