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

智龙迷城队伍图制作工具