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

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

智龙迷城队伍图制作工具