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

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

智龙迷城队伍图制作工具