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

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