You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

script-skill-parser.js 119 kB

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

智龙迷城队伍图制作工具