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

智龙迷城队伍图制作工具