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

script-skill-parser.js 114 kB

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

智龙迷城队伍图制作工具