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

5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
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
4 years ago
4 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
5 years ago
4 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
4 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
4 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
4 years ago
5 years ago
4 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
5 years ago
5 years ago
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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249
  1. //带标签的模板字符串
  2. function tp(strings, ...keys) {
  3. return (function(...values) {
  4. let dict = values[values.length - 1] || {};
  5. let fragment = document.createDocumentFragment();
  6. fragment.appendChild(document.createTextNode(strings[0]));
  7. //let result = [strings[0]];
  8. keys.forEach(function(key, i, arr) {
  9. let value = Number.isInteger(key) ? values[key] : dict[key];
  10. if (value == undefined)
  11. {
  12. //console.debug("模板字符串中 %s 未找到输入数据",key);
  13. }else
  14. {
  15. if (!(value instanceof Node))
  16. {
  17. value = document.createTextNode(value);
  18. }
  19. try{
  20. fragment.appendChild(arr.lastIndexOf(key) == i ? value : value.cloneNode(true));
  21. }catch(e)
  22. {
  23. console.log(value, e);
  24. console.log(keys, values);
  25. }
  26. }
  27. fragment.appendChild(document.createTextNode(strings[i + 1]));
  28. });
  29. return fragment;
  30. });
  31. }
  32. const Attributes = {
  33. /*0: "Fire",
  34. 1: "Water",
  35. 2: "Wood",
  36. 3: "Light",
  37. 4: "Dark",
  38. 5: "Heart",
  39. 6: "Jammer",
  40. 7: "Poison",
  41. 8: "MPoison",
  42. 9: "Bomb",*/
  43. Fire: 0,
  44. Water: 1,
  45. Wood: 2,
  46. Light: 3,
  47. Dark: 4,
  48. Heart: 5,
  49. Jammer: 6,
  50. Poison: 7,
  51. MPoison: 8,
  52. Bomb: 9,
  53. }
  54. for (let name in Attributes)
  55. {
  56. Attributes[Attributes[name]] = name;
  57. }
  58. Attributes.all = function () {
  59. return [
  60. this.Fire,
  61. this.Water,
  62. this.Wood,
  63. this.Light,
  64. this.Dark
  65. ];
  66. }
  67. Attributes._6color = function () {
  68. return [
  69. this.Fire,
  70. this.Water,
  71. this.Wood,
  72. this.Light,
  73. this.Dark,
  74. this.Heart
  75. ];
  76. }
  77. Attributes.orbs = function () {
  78. return [
  79. this.Fire,
  80. this.Water,
  81. this.Wood,
  82. this.Light,
  83. this.Dark,
  84. this.Heart,
  85. this.Jammer,
  86. this.Poison,
  87. this.MPoison,
  88. this.Bomb,
  89. ];
  90. }
  91. //代码来自于 https://www.jianshu.com/p/3644833bca33
  92. function isEqual(obj1,obj2) {
  93. //判断是否是对象或数组
  94. function isObject(obj) {
  95. return typeof obj === 'object' && obj !== null;
  96. }
  97. // 两个数据有任何一个不是对象或数组
  98. if (!isObject(obj1) || !isObject(obj2)) {
  99. // 值类型(注意:参与equal的一般不会是函数)
  100. return obj1 === obj2;
  101. }
  102. // 如果传的两个参数都是同一个对象或数组
  103. if (obj1 === obj2) {
  104. return true;
  105. }
  106. // 两个都是对象或数组,而且不相等
  107. // 1.先比较obj1和obj2的key的个数,是否一样
  108. const obj1Keys = Object.keys(obj1);
  109. const obj2Keys = Object.keys(obj2);
  110. if (obj1Keys.length !== obj2Keys.length) {
  111. return false;
  112. }
  113. // 如果key的个数相等,就是第二步
  114. // 2.以obj1为基准,和obj2依次递归比较
  115. for (let key in obj1) {
  116. // 比较当前key的value --- 递归
  117. const res = isEqual(obj1[key], obj2[key]);
  118. if (!res) {
  119. return false;
  120. }
  121. }
  122. // 3.全相等
  123. return true
  124. }
  125. class Board
  126. {
  127. #rowCount = 6;
  128. #columnCount = 7;
  129. #data = [];
  130. constructor(def = null)
  131. {
  132. for (let ri=0;ri<this.#rowCount;ri++)
  133. {
  134. this.#data.push(new Array(this.#columnCount).fill(Array.isArray(def) ? null : def));
  135. }
  136. if (Array.isArray(def))
  137. {
  138. this.randomFill(def);
  139. }
  140. }
  141. //填充序列
  142. sequenceFill(sequence, exclude)
  143. {
  144. if (!Array.isArray(exclude) && exclude != null)
  145. exclude = [exclude];
  146. const o = sequence.entries();
  147. //65版部分
  148. for (let ri=0;ri<this.#data.length;ri++)
  149. {
  150. if (ri == 2) ri++;
  151. const row = this.#data[ri];
  152. for (let ci=0;ci<row.length;ci++)
  153. {
  154. if (ci == 3) ci++;
  155. //从数组中随机取出一个
  156. if (exclude && exclude.includes([row[ci]])) continue;
  157. row[ci] = o.next().value?.[1] ?? row[ci];
  158. }
  159. }
  160. //填充剩下的部分
  161. for (let ri=0;ri<this.#data.length;ri++)
  162. {
  163. if (ri == 2) ri++;
  164. const row = this.#data[ri];
  165. if (exclude && exclude.includes([row[3]])) continue;
  166. row[3] = o.next().value?.[1] ?? row[3] ;
  167. }
  168. const row = this.#data[2];
  169. for (let ci=0;ci<row.length;ci++)
  170. {
  171. if (exclude && exclude.includes([row[ci]])) continue;
  172. row[ci] = o.next().value?.[1] ?? row[ci] ;
  173. }
  174. }
  175. //将有序数组转为随机的数组
  176. sequenceToRandom(valueArray)
  177. {
  178. const randomData = [];
  179. //将65版之后的的提出来
  180. let secondaryData = valueArray.splice((this.#rowCount - 1) * (this.#columnCount - 1));
  181. while(valueArray.length > 0)
  182. {
  183. randomData.push(valueArray.randomShift());
  184. }
  185. while(secondaryData.length > 0)
  186. {
  187. randomData.push(secondaryData.randomShift());
  188. }
  189. return randomData;
  190. }
  191. //洗版的填充
  192. randomFill(attrs)
  193. {
  194. let valueArray = new Uint8Array(this.#rowCount * this.#columnCount);
  195. crypto.getRandomValues(valueArray); //获取符合密码学要求的安全的随机值
  196. valueArray = Array.from(valueArray.map(x => attrs[x % attrs.length])); //用所有宝珠随机填充
  197. //之后用每种颜色填充前3个
  198. attrs.forEach((attr,idx)=>{
  199. valueArray.fill(attr, idx * 3, (idx + 1) * 3);
  200. });
  201. //将上方数据重新乱序排列
  202. const randomData = this.sequenceToRandom(valueArray);
  203. this.sequenceFill(randomData);
  204. }
  205. //生成珠子的填充
  206. generateOrbs(attrs, count, exclude)
  207. {
  208. let space = this.#rowCount * this.#columnCount;
  209. if (exclude?.length > 0)
  210. {
  211. space -= this.#data.flat().filter(o=>exclude.includes(o)).length;
  212. }
  213. let valueArray = new Array(space);
  214. attrs.forEach((attr,idx)=>{
  215. valueArray.fill(attr, idx * count, (idx + 1) * count);
  216. });
  217. //将上方数据重新乱序排列
  218. const randomData = this.sequenceToRandom(valueArray);
  219. this.sequenceFill(randomData, exclude);
  220. }
  221. //设定横行
  222. setRow(rows, attr = 0)
  223. {
  224. for (let row of rows)
  225. {
  226. if (row >= 2) row++;
  227. const rowData = this.#data[row];
  228. for (let ri=0;ri<rowData.length;ri++)
  229. {
  230. rowData[ri] = attr;
  231. }
  232. }
  233. }
  234. //设定竖列
  235. setColumn(cols, attr = 0)
  236. {
  237. for (let col of cols)
  238. {
  239. if (col >= 3) col++;
  240. for (let row of this.#data)
  241. {
  242. row[col] = attr;
  243. }
  244. }
  245. }
  246. //设定形状
  247. setShape(matrix, attr = 0)
  248. {
  249. function fillRow(rowData, inputRow, attr)
  250. {
  251. for (let col of inputRow)
  252. {
  253. if (col == 3) rowData[col] = attr;
  254. if (col >= 3) col++;
  255. rowData[col] = attr;
  256. }
  257. }
  258. for (let ri=0;ri<matrix.length;ri++)
  259. {
  260. if (ri == 2)
  261. {
  262. fillRow(this.#data[ri], matrix[ri], attr);
  263. }
  264. fillRow(this.#data[ri >= 2 ? ri+1 : ri], matrix[ri], attr);
  265. }
  266. }
  267. //面板叠加
  268. overlayBoard(board)
  269. {
  270. for (let ri=0;ri<board.length;ri++)
  271. {
  272. const rowNew = board[ri];
  273. const rowOld = this.#data[ri];
  274. for (let ci=0;ci<rowNew.length;ci++)
  275. {
  276. rowOld[ci] = rowNew[ci] ?? rowOld[ci];
  277. }
  278. }
  279. }
  280. //导出数组
  281. valueOf()
  282. {
  283. return this.#data;
  284. }
  285. //输出表格
  286. toTable()
  287. {
  288. const table = document.createElement("table");
  289. table.className = "board";
  290. this.#data.forEach((rowData, ri, rArr) => {
  291. const row = table.insertRow();
  292. if (ri == 2 && rArr.length > 5) row.classList.add("board-row4");
  293. rowData.forEach((orbType, ci, cArr) => {
  294. const cell = row.insertCell();
  295. const orb = cell.appendChild(document.createElement('icon'));
  296. orb.className = "orb";
  297. if (orbType != null) orb.setAttribute("data-orb-icon", orbType);
  298. if (ci == 3 && cArr.length > 6) cell.classList.add("board-cell5");
  299. });
  300. });
  301. if (this.#data.length > 5)
  302. {
  303. table.onclick = function() {
  304. this.classList.toggle("board-76");
  305. };
  306. }
  307. return table;
  308. }
  309. }
  310. const SkillValue = {
  311. isLess: function (value) {
  312. if (value.kind === SkillValueKind.Percent) return value.value < 1;
  313. if (value.kind === SkillValueKind.Constant) return value.value < 0;
  314. return false;
  315. }
  316. };
  317. const SkillValueKind = {
  318. Percent: 'mul',
  319. Constant: 'const',
  320. ConstantTo: 'const-to',
  321. xMaxHP: 'mul-maxhp',
  322. xHP: 'mul-hp',
  323. xATK: 'mul-atk',
  324. xRCV: 'mul-rcv',
  325. RandomATK: 'random-atk',
  326. HPScale: 'hp-scale',
  327. xTeamHP: 'mul-team-hp',
  328. xTeamATK: 'mul-team-atk',
  329. xTeamRCV: 'mul-team-rcv',
  330. xAwakenings: 'mul-awakenings',
  331. };
  332. const SkillPowerUpKind = {
  333. Multiplier: 'mul',
  334. ScaleAttributes: 'scale-attrs',
  335. ScaleCombos: 'scale-combos',
  336. ScaleMatchLength: 'scale-match-len',
  337. ScaleMatchAttrs: 'scale-match-attrs',
  338. ScaleCross: 'scale-cross',
  339. ScaleStateKindCount: 'scale-state-kind-count',
  340. };
  341. const SkillKinds = {
  342. Unknown: "unknown",
  343. ActiveTurns: "active-turns",
  344. DamageEnemy: "damage-enemy",
  345. Vampire: "vampire",
  346. ReduceDamage: "reduce-damage",
  347. SelfHarm: "self-harm",
  348. Heal: "heal",
  349. AutoHealBuff: "auto-heal-buff",
  350. ChangeOrbs: "change-orbs",
  351. GenerateOrbs: "generate-orbs",
  352. FixedOrbs: "fixed-orbs",
  353. PowerUp: "power-up",
  354. CounterAttack: "counter-attack",
  355. SetOrbState: "set-orb-state",
  356. RateMultiply: "rate-mul",
  357. OrbDropIncrease: "orb-drop-incr",
  358. Resolve: "resolve",
  359. Delay: "delay",
  360. DefenseBreak: "def-break",
  361. MassAttack: "mass-attack",
  362. BoardChange: "board-change",
  363. Unbind: "unbind",
  364. RandomSkills: "random-skills",
  365. ChangeAttribute: "change-attr",
  366. SkillBoost: "skill-boost",
  367. AddCombo: "add-combo",
  368. VoidEnemyBuff: "void-enemy-buff",
  369. Poison: "poison",
  370. CTW: "ctw",
  371. Gravity: "gravity",
  372. FollowAttack: "follow-attack",
  373. AutoHeal: "auto-heal",
  374. TimeExtend: "time-extend",
  375. DropRefresh: "drop-refresh",
  376. LeaderChange: "leader-change",
  377. MinMatchLength: "min-match-len",
  378. FixedTime: "fixed-time",
  379. Drum: "drum",
  380. AutoPath: "auto-path",
  381. Board7x6: "7x6-board",
  382. NoSkyfall: "no-skyfall",
  383. Henshin: "henshin",
  384. VoidPoison: "void-poison",
  385. }
  386. function skillParser(skillId)
  387. {
  388. function merge(skills)
  389. {
  390. //解封部分的合并
  391. let unbinds = skills.filter(skill=>skill.kind == SkillKinds.Unbind);
  392. if (unbinds.length>1)
  393. { //把后面的全都合并到第一个
  394. unbinds.reduce((pre,cur)=>{
  395. pre.normal = pre.normal || cur.normal;
  396. pre.awakenings = pre.awakenings || cur.awakenings;
  397. pre.matches = pre.matches || cur.matches;
  398. return pre
  399. });
  400. unbinds.shift(); //从筛选中去除第一个
  401. unbinds.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  402. }
  403. let fixedDamages = skills.filter(skill=>skill.kind == SkillKinds.DamageEnemy && skill.attr === 'fixed').filter((skill,idx,arr)=>skill.id==arr[0].id);
  404. if (fixedDamages.length>1)
  405. { //把后面的全都合并到第一个
  406. fixedDamages[0].times = fixedDamages.length;
  407. fixedDamages.shift(); //从筛选中去除第一个
  408. fixedDamages.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  409. }
  410. let scaleCross = skills.filter(skill=>skill.kind == SkillKinds.PowerUp && skill.value.kind == SkillPowerUpKind.ScaleCross).filter((skill,idx,arr)=>{
  411. let atk = arr[0].value.crosses[0].atk;
  412. return skill.value.crosses.every(cross=>cross.atk == atk);
  413. });
  414. if (scaleCross.length>1)
  415. { //把后面的全都合并到第一个
  416. scaleCross.reduce((pre,cur)=>{
  417. pre.value.crosses = pre.value.crosses.concat(cur.value.crosses);
  418. return pre
  419. });
  420. scaleCross.shift(); //从筛选中去除第一个
  421. scaleCross.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  422. }
  423. }
  424. const skill = Skills[skillId];
  425. if (!skill) return [];
  426. if (!parsers[skill.type]) {
  427. return [{ kind: SkillKinds.Unknown }];
  428. }
  429. //此处用apply将这个parser传递到后面解析函数的this里,用于递归解析
  430. const result = parsers[skill.type].apply({ parser: skillParser }, skill.params);
  431. const skills = (Array.isArray(result) ? result : [result])
  432. .filter(s => Boolean(s))
  433. .map(s => ({ id: skillId, type: skill.type, params: skill.params, ...s }));
  434. //merge(skills);
  435. return skills;
  436. }
  437. //返回flag里值为true的数组,如[1,4,7]
  438. function flags(num){
  439. /*
  440. return Array.from(new Array(32),(i,n)=>n).filter(n => num & (1 << n)); //性能太差
  441. return new Array(32).fill(null).map((i,n)=>n).filter(n => num & (1 << n)); //性能比上者好,但还是不够快
  442. */
  443. const arr = [];
  444. for (let i = 0; i<32;i++)
  445. {
  446. if (num & (1<<i))
  447. {
  448. arr.push(i);
  449. }
  450. }
  451. return arr;
  452. }
  453. const v = {
  454. percent: function(value) {
  455. return { kind: SkillValueKind.Percent, value: (value / 100) ?? 1 };
  456. },
  457. constant: function(value) {
  458. return { kind: SkillValueKind.Constant, value: value ?? 0 };
  459. },
  460. constantTo: function(value) {
  461. return { kind: SkillValueKind.ConstantTo, value: value ?? 1 };
  462. },
  463. xMaxHP: function(value) {
  464. return { kind: SkillValueKind.xMaxHP, value: (value / 100) ?? 1 };
  465. },
  466. xHP: function(value) {
  467. return { kind: SkillValueKind.xHP, value: (value / 100) ?? 1 };
  468. },
  469. xATK: function(value) {
  470. return { kind: SkillValueKind.xATK, value: (value / 100) ?? 1 };
  471. },
  472. xRCV: function(value) {
  473. return { kind: SkillValueKind.xRCV, value: (value / 100) ?? 1 };
  474. },
  475. randomATK: function(min, max) {
  476. return { kind: SkillValueKind.RandomATK, min: (min / 100) ?? 1, max: (max / 100) ?? 1, scale: 1 };
  477. },
  478. hpScale: function(min, max, scale) {
  479. return { kind: SkillValueKind.HPScale, min: (min / 100) ?? 1, max: (max / 100) ?? 1, scale: (scale / 100) ?? 1 };
  480. },
  481. xTeamHP: function(value) {
  482. return { kind: SkillValueKind.xTeamHP, value: (value / 100) ?? 1 };
  483. },
  484. xTeamATK: function(attrs, value) {
  485. return { kind: SkillValueKind.xTeamATK, attrs: attrs, value: (value / 100) ?? 1 };
  486. },
  487. xTeamRCV: function(value) {
  488. return { kind: SkillValueKind.xTeamRCV, value: (value / 100) ?? 1 };
  489. },
  490. percentAwakenings: function(awakenings, value) {
  491. return { kind: SkillValueKind.xAwakenings, awakenings: awakenings, value: value };
  492. },
  493. };
  494. const c = {
  495. hp: function (min, max) {
  496. return { hp: { min: min / 100, max: max / 100 } };
  497. },
  498. exact: function (type, value, attrs) {
  499. if (attrs === void 0) { attrs = Attributes.all(); }
  500. return { exact: { type: type, value: value, attrs: attrs } };
  501. },
  502. compo: function (type, ids) {
  503. return { compo: { type: type, ids: ids } };
  504. },
  505. remainOrbs: function (count) { return { remainOrbs: { count: count } }; },
  506. useSkill: function () { return { useSkill: true }; },
  507. multiplayer: function () { return { multiplayer: true }; },
  508. prob: function (percent) { return { prob: percent }; },
  509. LShape: function (attrs) { return { LShape: { attrs: attrs } }; },
  510. heal: function (heal) { return { heal: { heal: heal } }; },
  511. }
  512. const p = {
  513. mul: function (values) {
  514. if (Array.isArray(values)) {
  515. return {
  516. kind: SkillPowerUpKind.Multiplier,
  517. hp: 1,
  518. atk: values[0] / 100,
  519. rcv: values[1] / 100
  520. };
  521. }
  522. else {
  523. return {
  524. kind: SkillPowerUpKind.Multiplier,
  525. hp: (values.hp ?? 100) / 100,
  526. atk: (values.atk ?? 100) / 100,
  527. rcv: (values.rcv ?? 100) / 100
  528. };
  529. }
  530. },
  531. stats: function (value) {
  532. let statTypes = Array.from(arguments).slice(1);
  533. return [
  534. statTypes.indexOf(1) >= 0 ? value : 100,
  535. statTypes.indexOf(2) >= 0 ? value : 100
  536. ];
  537. },
  538. scale: function (min, max, baseMul, bonusMul) {
  539. return {
  540. min: min,
  541. max: max ?? min,
  542. baseAtk: (baseMul[0] / 100) ?? 1,
  543. baseRcv: (baseMul[1] / 100) ?? 1,
  544. bonusAtk: (bonusMul[0] / 100) ?? 0,
  545. bonusRcv: (bonusMul[1] / 100) ?? 0
  546. };
  547. },
  548. scaleAttrs: function (attrs, min, max, baseMul, bonusMul) {
  549. return { kind: SkillPowerUpKind.ScaleAttributes, attrs: attrs ,...this.scale(min, max, baseMul, bonusMul) };
  550. },
  551. scaleCombos: function (min, max, baseMul, bonusMul) {
  552. return { kind: SkillPowerUpKind.ScaleCombos ,...this.scale(min, max, baseMul, bonusMul) };
  553. },
  554. scaleMatchLength: function (attrs, min, max, baseMul, bonusMul, matchAll = false) {
  555. return { kind: SkillPowerUpKind.ScaleMatchLength, attrs: attrs, matchAll: matchAll ,...this.scale(min, max, baseMul, bonusMul) };
  556. },
  557. scaleMatchAttrs: function (matches, min, max, baseMul, bonusMul) {
  558. return { kind: SkillPowerUpKind.ScaleMatchAttrs, matches: matches ,...this.scale(min, max, baseMul, bonusMul) };
  559. },
  560. scaleCross: function (crosses) {
  561. return { kind: SkillPowerUpKind.ScaleCross, crosses: crosses.map(cross => ({ ...cross, atk: (cross.atk / 100) ?? 1, rcv: (cross.rcv / 100) ?? 1 })) };
  562. },
  563. scaleStateKindCount: function (awakenings, attrs, types, value) {
  564. return { kind: SkillPowerUpKind.ScaleStateKindCount, awakenings: awakenings, attrs: attrs, types: types, value: value };
  565. },
  566. }
  567. function activeTurns(turns, skill) {
  568. return skill ? { kind: SkillKinds.ActiveTurns, turns: turns, skill: skill } : null;
  569. }
  570. function damageEnemy(target, attr, damage) {
  571. return { kind: SkillKinds.DamageEnemy, target: target, attr: attr, damage: damage };
  572. }
  573. function vampire(attr, damageValue, healValue) {
  574. return { kind: SkillKinds.Vampire, attr: attr, damage: damageValue, heal: healValue };
  575. }
  576. function reduceDamage(attrs, percent, condition) {
  577. return { kind: SkillKinds.ReduceDamage, attrs: attrs, percent: percent, condition: condition };
  578. }
  579. function selfHarm(value) {
  580. return { kind: SkillKinds.SelfHarm, value: value };
  581. }
  582. function heal(value) {
  583. return { kind: SkillKinds.Heal, value: value };
  584. }
  585. function autoHealBuff(value) {
  586. return { kind: SkillKinds.AutoHealBuff, value: value };
  587. }
  588. function fromTo(from, to) {
  589. return { from: from, to: to };
  590. }
  591. function changeOrbs() {
  592. return { kind: SkillKinds.ChangeOrbs, changes: Array.from(arguments) };
  593. }
  594. function generateOrbs(orbs, exclude, count) {
  595. return { kind: SkillKinds.GenerateOrbs, orbs: orbs, exclude: exclude, count: count };
  596. }
  597. function fixedOrbs() {
  598. return { kind: SkillKinds.FixedOrbs, generates: Array.from(arguments) };
  599. }
  600. function powerUp(attrs, types, value, condition, reduceDamageValue, additional) {
  601. if (value.kind === SkillPowerUpKind.Multiplier) {
  602. let hp = value.hp, atk = value.atk, rcv = value.rcv;
  603. if (hp === 1 && atk === 1 && rcv === 1 && !reduceDamage)
  604. return null;
  605. }
  606. return { kind: SkillKinds.PowerUp, attrs: attrs, types: types, condition: condition, value: value, reduceDamage: reduceDamageValue, additional: additional};
  607. }
  608. function counterAttack(attr, prob, value) {
  609. return { kind: SkillKinds.CounterAttack, attr: attr, prob: prob, value: value };
  610. }
  611. function setOrbState(orbs, state, arg) {
  612. return { kind: SkillKinds.SetOrbState, orbs: orbs, state: state, arg: arg};
  613. }
  614. function rateMultiply(value, rate) {
  615. return { kind: SkillKinds.RateMultiply, value: value, rate: rate };
  616. }
  617. function orbDropIncrease(value, attrs, flag) {
  618. return { kind: SkillKinds.OrbDropIncrease, value: value, attrs: attrs, flag: flag };
  619. }
  620. function resolve(min, prob) {
  621. return { kind: SkillKinds.Resolve, min: min, max: 1, prob: prob };
  622. }
  623. function unbind(normal, awakenings, matches) {
  624. return { kind: SkillKinds.Unbind, normal: normal, awakenings: awakenings , matches: matches};
  625. }
  626. function boardChange(attrs) {
  627. return { kind: SkillKinds.BoardChange, attrs: attrs };
  628. }
  629. function randomSkills(skills) {
  630. return { kind: SkillKinds.RandomSkills, skills: skills };
  631. }
  632. function changeAttr(target, attr) {
  633. return { kind: SkillKinds.ChangeAttribute, target: target, attr: attr ?? 0 };
  634. }
  635. function gravity(value) {
  636. return { kind: SkillKinds.Gravity, value: value };
  637. }
  638. function voidEnemyBuff(buffs) {
  639. return { kind: SkillKinds.VoidEnemyBuff, buffs: buffs };
  640. }
  641. function skillBoost(value) { return { kind: SkillKinds.SkillBoost, value: value }; }
  642. function minMatch(value) { return { kind: SkillKinds.MinMatchLength, value: value }; }
  643. function fixedTime(value) { return { kind: SkillKinds.FixedTime, value: v.constant(value) }; }
  644. function addCombo(value) { return { kind: SkillKinds.AddCombo, value: value }; }
  645. function defBreak(value) { return { kind: SkillKinds.DefenseBreak, value: value }; }
  646. function poison(value) { return { kind: SkillKinds.Poison, value: value }; }
  647. function CTW(value) { return { kind: SkillKinds.CTW, value: value }; }
  648. function followAttack(value) { return { kind: SkillKinds.FollowAttack, value: value }; }
  649. function autoHeal(value) { return { kind: SkillKinds.AutoHeal, value: value }; }
  650. function timeExtend(value) { return { kind: SkillKinds.TimeExtend, value: value }; }
  651. function delay() { return { kind: SkillKinds.Delay }; }
  652. function massAttack() { return { kind: SkillKinds.MassAttack }; }
  653. function dropRefresh() { return { kind: SkillKinds.DropRefresh }; }
  654. function drum() { return { kind: SkillKinds.Drum }; }
  655. function autoPath() { return { kind: SkillKinds.AutoPath }; }
  656. function leaderChange(type = 0) { return { kind: SkillKinds.LeaderChange, type: type }; }
  657. function board7x6() { return { kind: SkillKinds.Board7x6 }; }
  658. function noSkyfall() { return { kind: SkillKinds.NoSkyfall }; }
  659. function henshin(id) { return { kind: SkillKinds.Henshin, id: id }; }
  660. function voidPoison() { return { kind: SkillKinds.VoidPoison }; }
  661. const parsers = {
  662. parser: (() => []), //这个用来解决代码提示的报错问题,不起实际作用
  663. [0](attr, mul) { return damageEnemy('all', attr, v.xATK(mul)); },
  664. [1](attr, value) { return damageEnemy('all', attr, v.constant(value)); },
  665. [2](mul, _) { return damageEnemy('single', 'self', v.xATK(mul)); },
  666. [3](turns, percent) { return activeTurns(turns, reduceDamage('all', v.percent(percent))); },
  667. [4](mul) { return poison(v.xATK(mul)); },
  668. [5](time) { return CTW(v.constant(time)); },
  669. [6](percent) { return gravity(v.xHP(percent)); },
  670. [7](mul) { return heal(v.xRCV(mul)); },
  671. [8](value) { return heal(v.constant(value)); },
  672. [9](from, to) { return changeOrbs(fromTo([from ?? 0], [to ?? 0])); },
  673. [10]() { return dropRefresh(); },
  674. [11](attr, mul) { return powerUp([attr], null, p.mul({ atk: mul })); },
  675. [12](mul) { return followAttack(v.xATK(mul)); },
  676. [13](mul) { return autoHeal(v.xRCV(mul)); },
  677. [14](min, prob) { return resolve(v.percent(min), v.percent(prob)); },
  678. [15](time) { return timeExtend(v.constant(time / 100)); },
  679. [16](percent) { return reduceDamage('all', v.percent(percent)); },
  680. [17](attr, percent) { return reduceDamage([attr], v.percent(percent)); },
  681. [18](turns) { return activeTurns(turns, delay()); },
  682. [19](turns, percent) { return activeTurns(turns, defBreak(v.percent(percent))); },
  683. [20](from1, to1, from2, to2) {
  684. if ((to1 ?? 0) == (to2 ?? 0))
  685. return changeOrbs(fromTo([from1 ?? 0, from2 ?? 0], [to1 ?? 0]));
  686. else
  687. return changeOrbs(
  688. fromTo([from1 ?? 0], [to1 ?? 0]),
  689. fromTo([from2 ?? 0], [to2 ?? 0])
  690. );
  691. },
  692. [21](turns, attr, percent) { return activeTurns(turns, reduceDamage([attr], v.percent(percent))); },
  693. [22](type, mul) { return powerUp(null, [type], p.mul({ atk: mul })); },
  694. [23](type, mul) { return powerUp(null, [type], p.mul({ hp: mul })); },
  695. [24](type, mul) { return powerUp(null, [type], p.mul({ rcv: mul })); },
  696. [26](mul) { return powerUp(null, null, p.mul({ atk: mul })); },
  697. [28](attr, mul) { return powerUp([attr], null, p.mul({ atk: mul, rcv: mul })); },
  698. [29](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, atk: mul, rcv: mul })); },
  699. [30](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ hp: mul })); },
  700. [31](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ atk: mul })); },
  701. [33]() { return drum(); },
  702. [35](mul, percent) { return vampire('self', v.xATK(mul), v.percent(percent)); },
  703. [36](attr1, attr2, percent) { return reduceDamage([attr1, attr2], v.percent(percent)); },
  704. [37](attr, mul) { return damageEnemy('single', attr, v.xATK(mul)); },
  705. [38](max, _, percent) { return reduceDamage('all', v.percent(percent), max === 100 ? c.hp(max, max) : c.hp(0, max)); },
  706. [39](percent, stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  707. [40](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ atk: mul })); },
  708. [41](prob, mul, attr) { return counterAttack(attr ?? 0, v.percent(prob), v.percent(mul)); },
  709. [42](targetAttr, dmgAttr, value) { return damageEnemy(targetAttr, dmgAttr, v.constant(value)); },
  710. [43](min, max, percent) { return reduceDamage('all', v.percent(percent), c.hp(min, max)); },
  711. [44](percent, stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  712. [45](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, atk: mul })); },
  713. [46](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul })); },
  714. [48](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul })); },
  715. [49](attr, mul) { return powerUp([attr], null, p.mul({ rcv: mul })); },
  716. [50](turns, attr, mul) { return activeTurns(turns, powerUp([attr], null, p.mul({ atk: mul }))); },
  717. [51](turns) { return activeTurns(turns, massAttack()); },
  718. [52](attr, mul) { return setOrbState([attr], 'enhanced', {enhance: v.percent(mul)}); },
  719. [53](mul) { return rateMultiply(v.percent(mul), 'drop'); },
  720. [54](mul) { return rateMultiply(v.percent(mul), 'coin'); },
  721. [55](value) { return damageEnemy('single', 'fixed', v.constant(value)); },
  722. [56](value) { return damageEnemy('all', 'fixed', v.constant(value)); },
  723. [58](attr, min, max) { return damageEnemy('all', attr, v.randomATK(min, max)); },
  724. [59](attr, min, max) { return damageEnemy('single', attr, v.randomATK(min, max)); },
  725. [60](turns, mul, attr) { return activeTurns(turns, counterAttack(attr, v.percent(100), v.percent(mul))); },
  726. [61](attrs, min, base, bonus, incr) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min + (incr ?? 0), [base, 100], [bonus, 0])); },
  727. [62](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, atk: mul })); },
  728. [63](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, rcv: mul })); },
  729. [64](type, mul) { return powerUp(null, [type], p.mul({ atk: mul, rcv: mul })); },
  730. [65](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, atk: mul, rcv: mul })); },
  731. [66](combo, mul) { return powerUp(null, null, p.scaleCombos(combo, combo, [mul, 100], [0, 0])); },
  732. [67](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, rcv: mul })); },
  733. [69](attr, type, mul) { return powerUp([attr], [type], p.mul({ atk: mul })); },
  734. [71](...attrs) { return boardChange(attrs.filter(attr => attr >= 0)); },
  735. [73](attr, type, mul) { return powerUp([attr], [type], p.mul({ hp: mul, atk: mul })); },
  736. [75](attr, type, mul) { return powerUp([attr], [type], p.mul({ atk: mul, rcv: mul })); },
  737. [76](attr, type, mul) { return powerUp([attr], [type], p.mul({ hp: mul, atk: mul, rcv: mul })); },
  738. [77](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ hp: mul, atk: mul })); },
  739. [79](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ atk: mul, rcv: mul })); },
  740. [84](attr, min, max, percent) {
  741. return [
  742. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  743. damageEnemy('single', attr, v.randomATK(min, max))
  744. ];
  745. },
  746. [85](attr, min, max, percent) {
  747. return [
  748. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  749. damageEnemy('all', attr, v.randomATK(min, max))
  750. ];
  751. },
  752. [86](attr, value, _, percent) {
  753. return [
  754. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  755. damageEnemy('single', attr, v.constant(value))
  756. ];
  757. },
  758. [87](attr, value, _, percent) {
  759. return [
  760. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  761. damageEnemy('all', attr, v.constant(value))
  762. ];
  763. },
  764. [88](turns, type, mul) { return activeTurns(turns, powerUp(null, [type], p.mul({ atk: mul }))); },
  765. [90](turns, attr1, attr2, mul) { return activeTurns(turns, powerUp([attr1, attr2], null, p.mul({ atk: mul }))); },
  766. [91](attr1, attr2, mul) { return setOrbState([attr1, attr2], 'enhanced', {enhance: v.percent(mul)}); },
  767. [92](turns, type1, type2, mul) { return activeTurns(turns, powerUp(null, [type1, type2], p.mul({ atk: mul }))); },
  768. [93]() { return leaderChange(); },
  769. [94](percent, attr, stats1, stats2, mul) { return powerUp([attr], null, p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  770. [95](percent, type, stats1, stats2, mul) { return powerUp(null, [type], p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  771. [96](percent, attr, stats1, stats2, mul) { return powerUp([attr], null, p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  772. [97](percent, type, stats1, stats2, mul) { return powerUp(null, [type], p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  773. [98](min, base, bonus, max) { return powerUp(null, null, p.scaleCombos(min, max, [base, 100], [bonus, 0])); },
  774. [100](stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.useSkill()); },
  775. [101](combo, mul) { return powerUp(null, null, p.mul({ atk: mul }), c.exact('combo', combo)); },
  776. [103](combo, stats1, stats2, mul) { return powerUp(null, null, p.scaleCombos(combo, combo, p.stats(mul, stats1, stats2), [0, 0])); },
  777. [104](combo, attrs, stats1, stats2, mul) { return powerUp(flags(attrs), null, p.scaleCombos(combo, combo, p.stats(mul, stats1, stats2), [0, 0])); },
  778. [105](rcv, atk) { return powerUp(null, null, p.mul({ rcv, atk })); },
  779. [106](hp, atk) { return powerUp(null, null, p.mul({ hp, atk })); },
  780. [107](hp) { return powerUp(null, null, p.mul({ hp })); },
  781. [108](hp, type, atk) { return [powerUp(null, null, p.mul({ hp })), powerUp(null, [type], p.mul({ atk }))]; },
  782. [109](attrs, len, mul) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul, 100], [0, 0])); },
  783. [110](single, attr, min, max, scale) { return damageEnemy(single ? 'single' : 'all', attr, v.hpScale(min, max, scale)); },
  784. [111](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul, atk: mul })); },
  785. [114](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul, atk: mul, rcv: mul })); },
  786. [115](attr, mul, percent) { return vampire(attr, v.xATK(mul), v.percent(percent)); },
  787. [116](...ids) { return ids.flatMap(id => this.parser(id)); },
  788. [117](bind, rcv, constant, hp, awokenBind) {
  789. return [
  790. rcv ? heal(v.xRCV(rcv)) : hp ? heal(v.xMaxHP(hp)) : constant ? heal(v.constant(constant)) : null,
  791. (bind || awokenBind) ? unbind(bind ?? 0, awokenBind ?? 0) : null,
  792. ].filter(Boolean);
  793. },
  794. [118](...ids) { return randomSkills(ids.map(id => this.parser(id))); },
  795. [119](attrs, min, base, bonus, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [base, 100], [bonus, 0])); },
  796. [121](attrs, types, hp, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })); },
  797. [122](percent, attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(0, percent)); },
  798. [123](percent, attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(percent, 100)); },
  799. [124](attrs1, attrs2, attrs3, attrs4, attrs5, min, mul, bonus) {
  800. const attrs = [attrs1, attrs2, attrs3, attrs4, attrs5].filter(Boolean);
  801. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, bonus ? attrs.length : min, [mul, 100], [bonus, 0]));
  802. },
  803. [125](mon1, mon2, mon3, mon4, mon5, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp, atk, rcv }), c.compo('card', [mon1, mon2, mon3, mon4, mon5].filter(Boolean))); },
  804. [126](attrs, turns, turns2, percent) { return activeTurns(turns === turns2 ? turns : [turns, turns2], orbDropIncrease(v.percent(percent), flags(attrs))); },
  805. [127](cols1, attrs1, cols2, attrs2) {
  806. return fixedOrbs(
  807. { orbs: flags(attrs1), type: 'col', positions: flags(cols1) },
  808. { orbs: flags(attrs2), type: 'col', positions: flags(cols2) }
  809. );
  810. },
  811. [128](rows1, attrs1, rows2, attrs2) {
  812. return fixedOrbs(
  813. { orbs: flags(attrs1), type: 'row', positions: flags(rows1) },
  814. { orbs: flags(attrs2), type: 'row', positions: flags(rows2) }
  815. );
  816. },
  817. [129](attrs, types, hp, atk, rcv, rAttrs, rPercent) {
  818. return [
  819. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  820. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent)) || null
  821. ];
  822. },
  823. [130](percent, attrs, types, atk, rcv, rAttrs, rPercent) {
  824. return [
  825. (atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(0, percent)) || null,
  826. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent), c.hp(0, percent)) || null
  827. ];
  828. },
  829. [131](percent, attrs, types, atk, rcv, rAttrs, rPercent) {
  830. return [
  831. powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(percent, 100)),
  832. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent), c.hp(percent, 100)) || null
  833. ];
  834. },
  835. [132](turns, time, percent) { return activeTurns(turns, timeExtend(time ? v.constant(time / 10) : v.percent(percent))); },
  836. [133](attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.useSkill()); },
  837. [136](attrs1, hp1, atk1, rcv1, attrs2, hp2, atk2, rcv2) {
  838. return [
  839. powerUp(flags(attrs1), null, p.mul({ hp: hp1, atk: atk1, rcv: rcv1 })),
  840. powerUp(flags(attrs2), null, p.mul({ hp: hp2, atk: atk2, rcv: rcv2 })),
  841. ];
  842. },
  843. [137](types1, hp1, atk1, rcv1, types2, hp2, atk2, rcv2) {
  844. return [
  845. powerUp(null, flags(types1), p.mul({ hp: hp1, atk: atk1, rcv: rcv1 })),
  846. powerUp(null, flags(types2), p.mul({ hp: hp2, atk: atk2, rcv: rcv2 })),
  847. ];
  848. },
  849. [138](...ids) { return ids.flatMap(id => this.parser(id)); },
  850. [139](attrs, types, percent1, less1, mul1, percent2, less2, mul2) {
  851. return [
  852. powerUp(flags(attrs), flags(types), p.mul({ atk: mul1 }), less1 ? c.hp(0, percent1) : c.hp(percent1, 100)),
  853. powerUp(flags(attrs), flags(types), p.mul({ atk: mul2 }), less1 ?
  854. (less2 ? c.hp(percent1, percent2) : c.hp(percent2, 100)) :
  855. (less2 ? c.hp(0, percent2) : c.hp(percent2, percent1))
  856. ),
  857. ];
  858. },
  859. [140](attrs, mul) { return setOrbState(flags(attrs), 'enhanced', {enhance: v.percent(mul)}); },
  860. [141](count, to, exclude) { return generateOrbs(flags(to), flags(exclude), count); },
  861. [142](turns, attr) { return activeTurns(turns, changeAttr('self', attr)); },
  862. [143](mul, dmgAttr) { return damageEnemy('all', dmgAttr ?? 0, v.xTeamHP(mul)); },
  863. [144](teamAttrs, mul, single, dmgAttr) { return damageEnemy(single ? 'single' : 'all', dmgAttr, v.xTeamATK(flags(teamAttrs), mul)); },
  864. [145](mul) { return heal(v.xTeamRCV(mul)); },
  865. [146](turns) { return skillBoost(v.constant(turns)); },
  866. [148](percent) { return rateMultiply(v.percent(percent), 'exp'); },
  867. [149](mul) { return powerUp(null, null, p.mul({ rcv: mul }), c.exact('match-length', 4, [Attributes.Heart])); },
  868. [150](_, mul) { return powerUp(null, null, p.mul({ atk: mul }), c.exact('match-length', 5, 'enhanced')); },
  869. [151](mul1, mul2, percent) {
  870. return [
  871. powerUp(null, null, p.scaleCross([{ single: true, attr: Attributes.Heart, atk: mul1, rcv: mul2 }]), undefined, v.percent(percent)),
  872. ];
  873. },
  874. [152](attrs, count) { return setOrbState(flags(attrs), 'locked', {count: v.constant(count)}); },
  875. [153](attr) { return changeAttr('opponent', attr); },
  876. [154](from, to) { return changeOrbs(fromTo(flags(from), flags(to))); },
  877. [155](attrs, types, hp, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv }), c.multiplayer()); },
  878. [156](turns, awoken1, awoken2, awoken3, type, mul) {
  879. if (type == 1)
  880. {
  881. return heal(v.percentAwakenings([awoken1, awoken2, awoken3].filter(Boolean), v.xRCV(mul)));
  882. }else
  883. {
  884. return activeTurns(turns, type === 2 ?
  885. powerUp(null, null, p.scaleStateKindCount([awoken1, awoken2, awoken3].filter(Boolean), null, null, p.mul({atk: mul - 100, hp:0, rcv:0}))) :
  886. reduceDamage('all', v.percentAwakenings([awoken1, awoken2, awoken3].filter(Boolean), v.percent(mul)))
  887. );
  888. }
  889. },
  890. [157](attr1, mul1, attr2, mul2, attr3, mul3) {
  891. return powerUp(null, null, p.scaleCross([
  892. { single: false, attr: attr1, atk: mul1 },
  893. { single: false, attr: attr2, atk: mul2 },
  894. { single: false, attr: attr3, atk: mul3 }
  895. ].filter(cross => cross.atk)));
  896. },
  897. [158](len, attrs, types, atk, hp, rcv) {
  898. return [
  899. minMatch(len),
  900. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv }))
  901. ];
  902. },
  903. [159](attrs, min, base, bonus, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [base, 100], [bonus, 0])); },
  904. [160](turns, combo) { return activeTurns(turns, addCombo(combo)); },
  905. [161](percent) { return gravity(v.xMaxHP(percent)); },
  906. [162]() { return board7x6(); },
  907. [163](attrs, types, hp, atk, rcv, rAttrs, rPercent) {
  908. return [
  909. noSkyfall(),
  910. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  911. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent)) || null,
  912. ].filter(Boolean);
  913. },
  914. [164](attrs1, attrs2, attrs3, attrs4, min, atk, rcv, bonus) {
  915. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  916. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, attrs.length, [atk, rcv], [bonus, bonus]));
  917. },
  918. [165](attrs, min, baseAtk, baseRcv, bonusAtk, bonusRcv, incr) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min + (incr ?? 0), [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  919. [166](min, baseAtk, baseRcv, bonusAtk, bonusRcv, max) { return powerUp(null, null, p.scaleCombos(min, max, [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  920. [167](attrs, min, baseAtk, baseRcv, bonusAtk, bonusRcv, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  921. [168](turns, awoken1, awoken2, awoken3, awoken4, awoken5, awoken6, mul) {
  922. return activeTurns(turns,
  923. powerUp(null, null, p.scaleStateKindCount([awoken1, awoken2, awoken3, awoken4, awoken5, awoken6].filter(Boolean), null, null, p.mul({atk: mul, hp:0, rcv:0})))
  924. );
  925. },
  926. [169](combo, mul, percent) { return powerUp(null, null, p.scaleCombos(combo, combo, [mul, 100], [0, 0]), undefined, v.percent(percent)); },
  927. [170](attrs, min, mul, percent) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min, [mul, 100], [0, 0]), undefined, v.percent(percent)); },
  928. [171](attrs1, attrs2, attrs3, attrs4, min, mul, percent) {
  929. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  930. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, min, [mul, 0], [0, 0]), undefined, v.percent(percent));
  931. },
  932. [172]() { return setOrbState(null, 'unlocked'); },
  933. [173](turns, attrAbsorb, comboAbsorb, damageAbsorb) {
  934. return activeTurns(turns, voidEnemyBuff(
  935. [
  936. attrAbsorb && 'attr-absorb',
  937. comboAbsorb && 'combo-absorb',
  938. damageAbsorb && 'damage-absorb'
  939. ].filter((buff) => typeof buff === 'string')
  940. ));
  941. },
  942. [175](series1, series2, series3, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp, atk, rcv }), c.compo('series', [series1, series2, series3].filter(Boolean))); },
  943. [176](row1, row2, row3, row4, row5, attrs) {
  944. return fixedOrbs(
  945. { orbs: [attrs ?? 0], type: 'shape', positions: [row1, row2, row3, row4, row5].map(row=>flags(row)) }
  946. );
  947. },
  948. [177](attrs, types, hp, atk, rcv, remains, mul) {
  949. return [
  950. noSkyfall(),
  951. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })) || null,
  952. mul && powerUp(null, null, p.mul({ atk: mul }), c.remainOrbs(remains)) || null
  953. ].filter(Boolean);
  954. },
  955. [178](time, attrs, types, hp, atk, rcv, attrs2, percent) {
  956. return [
  957. fixedTime(time),
  958. (hp || atk || rcv) && powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  959. percent && reduceDamage(flags(attrs2), v.percent(percent)) || null,
  960. ].filter(Boolean);
  961. },
  962. [179](turns, value, percent, bind, awokenBind) {
  963. return [
  964. (bind || awokenBind) ? unbind(bind ?? 0, awokenBind ?? 0) : null,
  965. activeTurns(turns, autoHealBuff(value ? v.constant(value) : v.xMaxHP(percent)))
  966. ].filter(Boolean);
  967. },
  968. [180](turns, percent) { return activeTurns(turns, orbDropIncrease(v.percent(percent), [], 'enhanced')); },
  969. [182](attrs, len, mul, percent) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul, 100], [0, 0]), undefined, v.percent(percent)); },
  970. [183](attrs, types, percent1, atk1, reduce, percent2, atk2, rcv2) {
  971. return [
  972. powerUp(flags(attrs), flags(types), p.mul({ atk: atk1 }), c.hp(percent1, 100), v.percent(reduce)),
  973. (atk2 || rcv2) && powerUp(flags(attrs), flags(types), p.mul({ atk: atk2, rcv: rcv2 }), c.hp(0, percent2 || percent1)) || null
  974. ];
  975. },
  976. [184](turns) { return activeTurns(turns, noSkyfall()); },
  977. [185](time, attrs, types, hp, atk, rcv) {
  978. return [
  979. timeExtend(v.constant(time / 100)),
  980. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  981. ];
  982. },
  983. [186](attrs, types, hp, atk, rcv) {
  984. return [
  985. board7x6(),
  986. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  987. ];
  988. },
  989. [188](value) {
  990. return damageEnemy('single', 'fixed', v.constant(value));
  991. },
  992. [189]() {
  993. return [
  994. setOrbState(null, 'unlocked'),
  995. boardChange([0,1,2,3]),
  996. autoPath(),
  997. ];
  998. },
  999. [191](turns) {
  1000. return activeTurns(turns, voidEnemyBuff(['damage-void']));
  1001. },
  1002. [192](attrs, len, mul, combo) {
  1003. return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul, 100], [0, 0], true), null, null, [addCombo(combo)]);
  1004. },
  1005. [193](attrs, atk, rcv, percent) {
  1006. return powerUp(null, null, p.mul([atk, rcv]), c.LShape(flags(attrs)), v.percent(percent));
  1007. },
  1008. [194](attrs, min, mul, combo) {
  1009. return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min, [mul, 0], [0, 0]), null, null, [addCombo(combo)]);
  1010. },
  1011. [195](percent) {
  1012. return selfHarm(percent ? v.xHP(percent) : v.constantTo(1));
  1013. },
  1014. [196](matches) {
  1015. return unbind(0,0,matches);
  1016. },
  1017. [197]() {
  1018. return voidPoison();
  1019. },
  1020. [198](heal, atk, percent, awokenBind) {
  1021. return powerUp(null, null, p.mul([atk, 0]), c.heal(heal), v.percent(percent), [unbind(0, awokenBind ?? 0)]);
  1022. },
  1023. [202](id) {
  1024. return henshin(id);
  1025. },
  1026. [203](evotype, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp, atk, rcv }), c.compo('evolution', [evotype])); },
  1027. [205](attrs, turns) { return activeTurns(turns, orbDropIncrease(null, flags(attrs), 'locked')); },
  1028. [215](turns, attrs) { return activeTurns(turns, setOrbState(flags(attrs), 'bound')); },
  1029. [218](turns) { return skillBoost(v.constant(-turns)); },
  1030. [224](turns, attr) { return activeTurns(turns, changeAttr('opponent', attr)); },
  1031. [226](turns, percent) { return activeTurns(turns, orbDropIncrease(v.percent(percent), [], 'nail')); },
  1032. [227]() { return leaderChange(1); },
  1033. [228](turns, attrs, types, atk, rcv) {
  1034. return activeTurns(turns,
  1035. powerUp(null, null, p.scaleStateKindCount(null, flags(attrs), flags(types), p.mul({atk: atk, rcv: rcv, hp:0})))
  1036. );
  1037. },
  1038. [229](attrs, types, hp, atk, rcv) {
  1039. return powerUp(null, null, p.scaleStateKindCount(null, flags(attrs), flags(types), p.mul({hp: hp, atk: atk, rcv: rcv})));
  1040. },
  1041. };
  1042. //将内容添加到代码片段
  1043. DocumentFragment.prototype.ap = function(arg)
  1044. {
  1045. if (Array.isArray(arg)) //数组,递归自身
  1046. {
  1047. arg.forEach(element=>this.ap(element));
  1048. }
  1049. else if (arg instanceof Node) //属于Node的直接添加
  1050. {
  1051. this.appendChild(arg);
  1052. }
  1053. else //其他内容的转换为文字添加
  1054. {
  1055. this.appendChild(document.createTextNode(arg));
  1056. }
  1057. return this;
  1058. }
  1059. //将数组和分隔符添加到一个代码片段,类似join
  1060. Array.prototype.nodeJoin = function(separator)
  1061. {
  1062. const frg = document.createDocumentFragment();
  1063. this.forEach((item, idx, arr)=>{
  1064. frg.ap(item);
  1065. if (idx < (arr.length - 1) && separator != null)
  1066. frg.ap(separator instanceof Node ? separator.cloneNode(true) : separator);
  1067. });
  1068. return frg;
  1069. }
  1070. //按住Ctrl点击技能在控制台输出技能的对象
  1071. function showParsedSkill(event) {
  1072. if (event.ctrlKey) {
  1073. console.log(this.skill);
  1074. }
  1075. }
  1076. function renderSkillEntry(skills)
  1077. {
  1078. const ul = document.createElement("ul");
  1079. ul.className = "card-skill-list";
  1080. skills.forEach(skill=>{
  1081. const li = ul.appendChild(document.createElement("li"));
  1082. li.className = skill.kind;
  1083. li.appendChild(renderSkill(skill));
  1084. li.skill = skill;
  1085. li.addEventListener("click", showParsedSkill);
  1086. });
  1087. /*
  1088. let boardChange = skills.filter(skill=>
  1089. skill.kind == SkillKinds.BoardChange ||
  1090. skill.kind == SkillKinds.GenerateOrbs ||
  1091. skill.kind == SkillKinds.FixedOrbs
  1092. );
  1093. if (boardChange.length > 0)
  1094. {
  1095. const board = new Board();
  1096. for (let skill of boardChange)
  1097. {
  1098. switch (skill.kind)
  1099. {
  1100. case SkillKinds.BoardChange: { //洗版
  1101. const attrs = skill.attrs;
  1102. board.randomFill(attrs);
  1103. break;
  1104. }
  1105. case SkillKinds.GenerateOrbs: { //产生珠子
  1106. let orbs = skill.orbs, exclude = skill.exclude, count = skill.count;
  1107. board.generateOrbs(orbs, count, exclude);
  1108. break;
  1109. }
  1110. case SkillKinds.FixedOrbs: { //固定位置产生珠子
  1111. let generates = skill.generates;
  1112. for (const generate of generates)
  1113. {
  1114. let orb = generate.orbs?.[0];
  1115. if (generate.type == 'shape') {
  1116. board.setShape(generate.positions, orb);
  1117. } else {
  1118. if (generate.type == 'row')
  1119. board.setRow(generate.positions, orb);
  1120. else
  1121. board.setColumn(generate.positions, orb);
  1122. }
  1123. }
  1124. break;
  1125. }
  1126. }
  1127. }
  1128. const li = ul.appendChild(document.createElement("li"));
  1129. li.appendChild(board.toTable());
  1130. li.className = "merge-board";
  1131. }
  1132. */
  1133. return ul;
  1134. }
  1135. function renderSkill(skill, option = {})
  1136. {
  1137. const frg = document.createDocumentFragment();
  1138. if (typeof localTranslating == "undefined") return frg;
  1139. const tsp = localTranslating.skill_parse;
  1140. function createIcon(iconType, className){
  1141. const idoc = document.createElement("icon");
  1142. idoc.className = `icon-skill${className ? ` ${className}` : ''}`;
  1143. idoc.setAttribute("data-icon-type", iconType);
  1144. return idoc;
  1145. }
  1146. if (Array.isArray(skill))
  1147. {
  1148. frg.ap(skill.map(_skill=>renderSkill(_skill)));
  1149. return frg;
  1150. }
  1151. switch (skill.kind) {
  1152. case SkillKinds.Unknown: {
  1153. let dict = {
  1154. type: skill.kind
  1155. };
  1156. frg.ap(tsp.skill.unknown(dict));
  1157. break;
  1158. }
  1159. case SkillKinds.ActiveTurns: { //有回合的行动
  1160. let turns = skill.turns, actionSkill = skill.skill;
  1161. let dict = {
  1162. turns: Array.isArray(turns) ? turns.join(tsp.word.range_hyphen().textContent) : turns,
  1163. actionSkill: renderSkill(actionSkill),
  1164. };
  1165. frg.ap(tsp.skill.active_turns(dict));
  1166. break;
  1167. }
  1168. case SkillKinds.RandomSkills: { //随机技能
  1169. let skills = skill.skills;
  1170. const ul = document.createElement("ul");
  1171. ul.className = "random-active-skill";
  1172. skills.forEach(subSkills=>{
  1173. const li = ul.appendChild(document.createElement("li"));
  1174. li.appendChild(renderSkillEntry(subSkills));
  1175. });
  1176. let dict = {
  1177. skills: ul,
  1178. };
  1179. frg.ap(tsp.skill.random_skills(dict));
  1180. break;
  1181. }
  1182. case SkillKinds.Delay: { //威吓
  1183. let dict = {
  1184. icon: createIcon(skill.kind),
  1185. };
  1186. frg.ap(tsp.skill.delay(dict));
  1187. break;
  1188. }
  1189. case SkillKinds.MassAttack: { //全体攻击
  1190. let dict = {
  1191. icon: createIcon(skill.kind),
  1192. };
  1193. frg.ap(tsp.skill.mass_attack(dict));
  1194. break;
  1195. }
  1196. case SkillKinds.LeaderChange: { //切换队长
  1197. let type = skill.type;
  1198. let dict = {
  1199. icon: createIcon(skill.kind),
  1200. target: type ? tsp.target.team_last() : tsp.target.self(),
  1201. };
  1202. frg.ap(tsp.skill.leader_change(dict));
  1203. break;
  1204. }
  1205. case SkillKinds.NoSkyfall: { //无天降
  1206. let dict = {
  1207. icon: createIcon(skill.kind),
  1208. };
  1209. frg.ap(tsp.skill.no_skyfall(dict));
  1210. break;
  1211. }
  1212. case SkillKinds.SelfHarm: { //主动自残
  1213. let value = skill.value;
  1214. let dict = {
  1215. icon: createIcon("heal", "hp-decr"),
  1216. value: renderValue(value, {percent: true}),
  1217. stats: tsp.stats.hp(),
  1218. };
  1219. frg.ap(tsp.skill.self_harm(dict));
  1220. break;
  1221. }
  1222. case SkillKinds.Heal: { //主动回血buff
  1223. let value = skill.value;
  1224. let dict = {
  1225. icon: createIcon("heal", "hp-incr"),
  1226. //icon: createIcon("auto-heal"),
  1227. value: renderValue(value, {unit: tsp.unit.point, percent: value.kind == SkillValueKind.xRCV ? false : true}),
  1228. stats: tsp.stats.hp(),
  1229. };
  1230. frg.ap(tsp.skill.heal(dict));
  1231. break;
  1232. }
  1233. case SkillKinds.AutoHealBuff: { //自动回血buff
  1234. let dict = {
  1235. icon: createIcon("auto-heal"),
  1236. value: renderValue(skill.value, {unit: tsp.unit.point, percent: true}),
  1237. stats: tsp.stats.hp(),
  1238. };
  1239. frg.ap(tsp.skill.auto_heal_buff(dict));
  1240. break;
  1241. }
  1242. case SkillKinds.DefenseBreak: { //破防
  1243. let dict = {
  1244. icon: createIcon(skill.kind),
  1245. value: renderValue(skill.value, {percent: true}),
  1246. };
  1247. frg.ap(tsp.skill.defense_break(dict));
  1248. break;
  1249. }
  1250. case SkillKinds.Poison: { //毒
  1251. let dict = {
  1252. icon: createIcon(skill.kind),
  1253. belong_to: tsp.target.self(),
  1254. target: tsp.target.enemy(),
  1255. stats: tsp.stats.hp(),
  1256. value: renderValue(skill.value),
  1257. };
  1258. frg.ap(tsp.skill.poison(dict));
  1259. break;
  1260. }
  1261. case SkillKinds.TimeExtend: { //时间变化buff
  1262. let value = skill.value;
  1263. let dict = {
  1264. icon: createIcon("status-time", SkillValue.isLess(value) ? "time-decr" : "time-incr"),
  1265. value: renderValue(value, { unit:tsp.unit.seconds, plusSign: value.kind != SkillValueKind.Percent, percent: SkillValue.isLess(value) }),
  1266. };
  1267. frg.ap(tsp.skill.time_extend(dict));
  1268. break;
  1269. }
  1270. case SkillKinds.FollowAttack: { //队长技追打
  1271. let dict = {
  1272. //icon: createIcon("follow_attack"),
  1273. belong_to: tsp.target.self(),
  1274. target: tsp.target.enemy(),
  1275. value: renderValue(skill.value),
  1276. };
  1277. frg.ap(tsp.skill.follow_attack(dict));
  1278. break;
  1279. }
  1280. case SkillKinds.AutoHeal: { //队长技自动回血
  1281. let dict = {
  1282. icon: createIcon(skill.kind),
  1283. belong_to: tsp.target.self(),
  1284. value: renderValue(skill.value),
  1285. stats: tsp.stats.hp(),
  1286. };
  1287. frg.ap(tsp.skill.auto_heal(dict));
  1288. break;
  1289. }
  1290. case SkillKinds.CTW: { //时间暂停
  1291. let dict = {
  1292. icon: createIcon(skill.kind),
  1293. value: renderValue(skill.value, { unit: tsp.unit.seconds }),
  1294. };
  1295. frg.ap(tsp.skill.ctw(dict));
  1296. break;
  1297. }
  1298. case SkillKinds.Gravity: { //重力
  1299. let dict = {
  1300. icon: createIcon(skill.kind),
  1301. target: tsp.target.enemy(),
  1302. value: renderValue(skill.value, { percent:true }),
  1303. };
  1304. frg.ap(tsp.skill.gravity(dict));
  1305. break;
  1306. }
  1307. case SkillKinds.Resolve: { //根性
  1308. let prob = skill.prob;
  1309. let dict = {
  1310. icon: createIcon(skill.kind),
  1311. stats: renderStat('chp'),
  1312. value: renderValue(skill.min, { percent:true }),
  1313. prob: prob.value < 1 ? tsp.value.prob({value: renderValue(prob, { percent:true })}) : null,
  1314. };
  1315. frg.ap(tsp.skill.resolve(dict));
  1316. break;
  1317. }
  1318. case SkillKinds.DamageEnemy: { //大炮和固伤
  1319. let attr = skill.attr, target = skill.target, damage = skill.damage;
  1320. if (attr == null) break; //没有属性时,编号为0的空技能
  1321. dict = {
  1322. target: target === 'all' ? tsp.target.enemy_all() : target === 'single' ? tsp.target.enemy_one() : tsp.target.enemy_attr({attr: renderAttrs(target, {affix: true})}),
  1323. damage: renderValue(damage, {unit: tsp.unit.point}),
  1324. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true})
  1325. };
  1326. frg.ap(tsp.skill.damage_enemy(dict));
  1327. break;
  1328. }
  1329. case SkillKinds.Unbind: { //解封
  1330. let normal = skill.normal, awakenings = skill.awakenings, matches = skill.matches;
  1331. let effects = [];
  1332. if (normal)
  1333. effects.push(tsp.skill.unbind_normal({icon: createIcon("unbind-normal"), turns: normal}));
  1334. if (awakenings)
  1335. effects.push(tsp.skill.unbind_awakenings({icon: createIcon("unbind-awakenings"), turns: awakenings}));
  1336. if (matches)
  1337. effects.push(tsp.skill.unbind_matches({icon: createIcon("unbind-matches"), turns: matches}));
  1338. frg.ap(effects.nodeJoin(tsp.word.comma()));
  1339. break;
  1340. }
  1341. case SkillKinds.BoardChange: { //洗版
  1342. const attrs = skill.attrs;
  1343. dict = {
  1344. orbs: renderOrbs(attrs),
  1345. };
  1346. let board = new Board(attrs);
  1347. frg.ap(tsp.skill.board_change(dict));
  1348. frg.ap(board.toTable());
  1349. break;
  1350. }
  1351. case SkillKinds.SkillBoost: { //溜
  1352. const value = skill.value;
  1353. let dict = {
  1354. icon: createIcon(skill.kind, SkillValue.isLess(skill.value) ? "boost-decr" : "boost-incr"),
  1355. turns: renderValue(value, { unit:tsp.unit.turns, plusSign:true }),
  1356. };
  1357. frg.ap(tsp.skill.skill_boost(dict));
  1358. break;
  1359. }
  1360. case SkillKinds.AddCombo: { //+C
  1361. const value = skill.value;
  1362. let icon = createIcon(skill.kind);
  1363. icon.setAttribute("data-add-combo", value);
  1364. let dict = {
  1365. icon: icon,
  1366. value: value,
  1367. };
  1368. frg.ap(tsp.skill.add_combo(dict));
  1369. break;
  1370. }
  1371. case SkillKinds.FixedTime: { //固定手指
  1372. const value = skill.value;
  1373. let dict = {
  1374. icon: createIcon(skill.kind),
  1375. value: renderValue(value, { unit: tsp.unit.seconds }),
  1376. };
  1377. frg.ap(tsp.skill.fixed_time(dict));
  1378. break;
  1379. }
  1380. case SkillKinds.MinMatchLength: { //最低匹配长度
  1381. const value = skill.value;
  1382. let dict = {
  1383. icon: createIcon(skill.kind),
  1384. value: value,
  1385. };
  1386. frg.ap(tsp.skill.min_match_length(dict));
  1387. break;
  1388. }
  1389. case SkillKinds.DropRefresh: { //刷版
  1390. let dict = {
  1391. icon: createIcon(skill.kind),
  1392. };
  1393. frg.ap(tsp.skill.drop_refresh(dict));
  1394. break;
  1395. }
  1396. case SkillKinds.Drum: { //太鼓达人音效
  1397. frg.ap(tsp.skill.drum());
  1398. break;
  1399. }
  1400. case SkillKinds.AutoPath: { //小龙的萌新技能
  1401. frg.ap(tsp.skill.auto_path());
  1402. break;
  1403. }
  1404. case SkillKinds.Board7x6: { //76版
  1405. let dict = {
  1406. icon: createIcon(skill.kind),
  1407. };
  1408. frg.ap(tsp.skill.board7x6(dict));
  1409. break;
  1410. }
  1411. case SkillKinds.Vampire: { //吸血
  1412. let attr = skill.attr, damage = skill.damage, heal = skill.heal;
  1413. dict = {
  1414. icon: createIcon("heal", "hp-incr"),
  1415. target: tsp.target.enemy_one(),
  1416. damage: renderValue(damage),
  1417. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true}),
  1418. heal: renderValue(heal, {percent: true}),
  1419. };
  1420. frg.ap(tsp.skill.vampire(dict));
  1421. break;
  1422. }
  1423. case SkillKinds.CounterAttack: { //反击
  1424. let attr = skill.attr, prob = skill.prob, value = skill.value;
  1425. dict = {
  1426. icon: createIcon(skill.kind),
  1427. target: tsp.target.enemy(),
  1428. prob: prob.value < 1 ? tsp.value.prob({value: renderValue(prob, { percent:true })}) : null,
  1429. value: renderValue(value),
  1430. attr: renderAttrs(attr, {affix: true}),
  1431. };
  1432. frg.ap(tsp.skill.counter_attack(dict));
  1433. break;
  1434. }
  1435. case SkillKinds.ChangeOrbs: { //珠子变换
  1436. let changes = skill.changes;
  1437. let subDocument = [];
  1438. for (const change of changes)
  1439. {
  1440. dict = {
  1441. from: renderOrbs(change.from),
  1442. to: renderOrbs(change.to),
  1443. };
  1444. subDocument.push(tsp.skill.change_orbs(dict));
  1445. }
  1446. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  1447. break;
  1448. }
  1449. case SkillKinds.GenerateOrbs: { //产生珠子
  1450. let orbs = skill.orbs, exclude = skill.exclude, count = skill.count;
  1451. dict = {
  1452. exclude: exclude.length ? tsp.word.affix_exclude({cotent: renderOrbs(exclude)}) : void 0,
  1453. orbs: renderOrbs(orbs),
  1454. value: count,
  1455. };
  1456. let board = new Board();
  1457. board.generateOrbs(orbs, count, exclude);
  1458. frg.ap(tsp.skill.generate_orbs(dict));
  1459. frg.ap(board.toTable());
  1460. break;
  1461. }
  1462. case SkillKinds.FixedOrbs: { //固定位置产生珠子
  1463. let generates = skill.generates;
  1464. let slight_pause = tsp.word.slight_pause().textContent;
  1465. let subDocument = [];
  1466. //let board = new Array(5).fill(null).map(i=>new Array(6).fill(null));
  1467. let board = new Board();
  1468. function posSplit(pos, max)
  1469. {
  1470. return {sequence: pos.filter(n=>n<=2).map(n=>n+1), reverse: pos.filter(n=>n>=3).reverse().map(n=>max-n)};
  1471. }
  1472. for (const generate of generates)
  1473. {
  1474. let orb = generate.orbs?.[0];
  1475. dict = {
  1476. orbs: renderOrbs(orb),
  1477. };
  1478. if (generate.type == 'shape')
  1479. {
  1480. dict.position = tsp.position.shape();
  1481. board.setShape(generate.positions, orb);
  1482. }else
  1483. {
  1484. let posFrgs = [];
  1485. if (generate.positions.length == 0) continue;
  1486. if (generate.type == 'row')
  1487. {
  1488. const pos = posSplit(generate.positions, 5);
  1489. if (pos.sequence.length) posFrgs.push(tsp.position.top({pos: pos.sequence.join(slight_pause)}));
  1490. if (pos.reverse.length) posFrgs.push(tsp.position.bottom({pos: pos.reverse.join(slight_pause)}));
  1491. board.setRow(generate.positions, orb);
  1492. }else
  1493. {
  1494. const pos = posSplit(generate.positions, 6);
  1495. if (pos.sequence.length) posFrgs.push(tsp.position.left({pos: pos.sequence.join(slight_pause)}));
  1496. if (pos.reverse.length) posFrgs.push(tsp.position.right({pos: pos.reverse.join(slight_pause)}));
  1497. board.setColumn(generate.positions, orb);
  1498. }
  1499. dict.position = posFrgs.nodeJoin(tsp.word.slight_pause());
  1500. }
  1501. subDocument.push(tsp.skill.fixed_orbs(dict));
  1502. }
  1503. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  1504. frg.ap(board.toTable());
  1505. break;
  1506. }
  1507. case SkillKinds.OrbDropIncrease: { //增加天降
  1508. let attrs = skill.attrs, value = skill.value, flag = skill.flag;
  1509. dict = {
  1510. value: value && renderValue(value, {percent: true}) || null,
  1511. orbs: renderOrbs(attrs, {className: "drop", affix: true}),
  1512. flag: flag && tsp.orbs[flag]({icon: createIcon("orb-" + flag)}) || null,
  1513. };
  1514. frg.ap(flag ? tsp.skill.orb_drop_increase_flag(dict) : tsp.skill.orb_drop_increase(dict));
  1515. break;
  1516. }
  1517. case SkillKinds.VoidEnemyBuff: {
  1518. let buffs = skill.buffs;
  1519. let subDocument = [];
  1520. for (let buff of buffs)
  1521. {
  1522. let dict = {
  1523. icon: createIcon(buff),
  1524. };
  1525. subDocument.push(tsp.skill[buff.replace(/\-/g,'_')](dict));
  1526. }
  1527. let dict = {
  1528. buff: subDocument.nodeJoin(tsp.word.slight_pause()),
  1529. };
  1530. frg.ap(tsp.skill.void_enemy_buff(dict));
  1531. break;
  1532. }
  1533. case SkillKinds.ChangeAttribute: {
  1534. let attrs = skill.attrs, target = skill.target;
  1535. dict = {
  1536. attrs: renderAttrs(attrs, {affix: true}),
  1537. target: target === 'opponent' ? tsp.target.enemy_all() : tsp.target.self(),
  1538. };
  1539. frg.ap(tsp.skill.change_attribute(dict));
  1540. break;
  1541. }
  1542. case SkillKinds.SetOrbState: {
  1543. let orbs = skill.orbs, state = skill.state, arg = skill.arg;
  1544. dict = {
  1545. orbs: renderOrbs(orbs, {className: state, affix: true}),
  1546. };
  1547. switch (state)
  1548. {
  1549. case "enhanced":{
  1550. dict.value = renderValue(arg.enhance, {percent: true});
  1551. frg.ap(tsp.skill.set_orb_state_enhanced(dict));
  1552. break;
  1553. }
  1554. case "locked":{
  1555. if (arg.count.value < 42)
  1556. dict.value = renderValue(arg.count, {unit: tsp.unit.unit});
  1557. frg.ap(tsp.skill.set_orb_state_locked(dict));
  1558. break;
  1559. }
  1560. case "unlocked":{
  1561. dict.icon = createIcon('orb-unlocked'),
  1562. frg.ap(tsp.skill.set_orb_state_unlocked(dict));
  1563. break;
  1564. }
  1565. case "bound":{
  1566. frg.ap(tsp.skill.set_orb_state_bound(dict));
  1567. break;
  1568. }
  1569. }
  1570. break;
  1571. }
  1572. case SkillKinds.RateMultiply: {
  1573. let rate = skill.rate, value = skill.value;
  1574. dict = {
  1575. rate: tsp.skill["rate_multiply_" + rate]({icon: createIcon(skill.kind + "-" + rate)}),
  1576. value: renderValue(value),
  1577. };
  1578. frg.ap(tsp.skill.rate_multiply(dict));
  1579. break;
  1580. }
  1581. case SkillKinds.ReduceDamage: {
  1582. let attrs = skill.attrs, percent = skill.percent, condition = skill.condition;
  1583. dict = {
  1584. icon: createIcon(skill.kind),
  1585. attrs: renderAttrs(attrs, {affix: true}),
  1586. value: renderValue(percent, {percent: true}),
  1587. };
  1588. if (condition) dict.condition = renderCondition(condition);
  1589. frg.ap(tsp.skill.reduce_damage(dict));
  1590. break;
  1591. }
  1592. case SkillKinds.PowerUp: {
  1593. let attrs = skill.attrs, types = skill.types, condition = skill.condition, value = skill.value, reduceDamage = skill.reduceDamage, additional = skill.additional;
  1594. let targets = [];
  1595. if (attrs?.filter(attr=> attr !== 5)?.length && !isEqual(attrs, Attributes.all())) targets.push(renderAttrs(attrs || [], {affix: true}));
  1596. if (types?.length) targets.push(renderTypes(types || [], {affix: true}));
  1597. dict = {
  1598. icon: createIcon(skill.kind),
  1599. };
  1600. if (condition) dict.condition = renderCondition(condition);
  1601. if (targets.length > 0) dict.targets = targets.nodeJoin(tsp.word.slight_pause());
  1602. let subDocument = [];
  1603. if (value){
  1604. if (attrs?.includes(5) && value.kind == SkillPowerUpKind.Multiplier)
  1605. { //如果属性有5,则是回复力
  1606. let _value = Object.assign({}, value);
  1607. _value.rcv = value.atk;
  1608. _value.atk = value.rcv;
  1609. value = _value;
  1610. }
  1611. if (value.kind == SkillPowerUpKind.Multiplier && Boolean(value.hp || value.atk || value.rcv) == false)
  1612. {
  1613. //不显示 value
  1614. }else
  1615. {
  1616. subDocument.push(renderPowerUp(value));
  1617. }
  1618. }
  1619. if (reduceDamage) {
  1620. subDocument.push(tsp.skill.reduce_damage({
  1621. value: renderValue(reduceDamage, {percent: true}),
  1622. icon: createIcon("reduce-damage"),
  1623. }));
  1624. }
  1625. if (additional?.length) {
  1626. for (let subSkill of additional)
  1627. {
  1628. subDocument.push(renderSkill(subSkill, option));
  1629. }
  1630. }
  1631. dict.value = subDocument.filter(Boolean).nodeJoin(tsp.word.comma());
  1632. frg.ap(tsp.skill.power_up(dict));
  1633. break;
  1634. }
  1635. case SkillKinds.Henshin: { //变身
  1636. let id = skill.id;
  1637. const dom = cardN(id);
  1638. dom.monDom.onclick = changeToIdInSkillDetail;
  1639. dict = {
  1640. card: dom,
  1641. }
  1642. frg.ap(tsp.skill.henshin(dict));
  1643. break;
  1644. }
  1645. case SkillKinds.VoidPoison: { //毒无效
  1646. dict = {
  1647. poison: renderOrbs([7,8], {affix: true})
  1648. }
  1649. frg.ap(tsp.skill.void_poison(dict));
  1650. break;
  1651. }
  1652. default: {
  1653. console.log("未处理的技能类型",skill.kind, skill);
  1654. frg.ap(skill.kind);
  1655. }
  1656. }
  1657. return frg;
  1658. };
  1659. function renderStat(stat, option) {
  1660. const frg = document.createDocumentFragment();
  1661. if (typeof localTranslating == "undefined") return frg;
  1662. const tspt = localTranslating.skill_parse.stats;
  1663. if (tspt[stat])
  1664. frg.ap(tspt[stat](option));
  1665. else
  1666. {
  1667. console.log("未知状态类型",stat);
  1668. frg.ap(tspt.unknown({ type: stat }));
  1669. }
  1670. return frg;
  1671. }
  1672. function renderAttrs(attrs, option = {}) {
  1673. if (!Array.isArray(attrs))
  1674. attrs = [attrs ?? 0];
  1675. const frg = document.createDocumentFragment();
  1676. if (typeof localTranslating == "undefined") return frg;
  1677. const tsp = localTranslating.skill_parse;
  1678. let contentFrg;
  1679. if (isEqual(attrs, Attributes.all()))
  1680. {
  1681. contentFrg = tsp.attrs.all();
  1682. }
  1683. else
  1684. {
  1685. contentFrg = attrs.map(attr => {
  1686. const icon = document.createElement("icon");
  1687. icon.className = "attr";
  1688. icon.setAttribute("data-attr-icon",attr);
  1689. return tsp.attrs[attr]({icon: icon});
  1690. })
  1691. .nodeJoin(tsp.word.slight_pause());
  1692. }
  1693. if (option.affix)
  1694. contentFrg = tsp.word.affix_attr({cotent: contentFrg});
  1695. frg.ap(contentFrg);
  1696. return frg;
  1697. }
  1698. function renderOrbs(attrs, option = {}) {
  1699. if (!Array.isArray(attrs))
  1700. attrs = [attrs ?? 0];
  1701. const frg = document.createDocumentFragment();
  1702. if (typeof localTranslating == "undefined") return frg;
  1703. const tsp = localTranslating.skill_parse;
  1704. let contentFrg;
  1705. if (isEqual(attrs, Attributes.orbs()))
  1706. {
  1707. contentFrg = tsp.orbs.all();
  1708. }
  1709. else if (isEqual(attrs, Attributes.all()))
  1710. {
  1711. contentFrg = renderOrbs('_5color');
  1712. }
  1713. else if (isEqual(attrs, Attributes._6color()))
  1714. {
  1715. contentFrg = tsp.orbs._6color({
  1716. _5color: renderOrbs('_5color'),
  1717. orb_rcv: renderOrbs(5),
  1718. });
  1719. }
  1720. else
  1721. {
  1722. contentFrg = attrs.map(attr => {
  1723. const icon = document.createElement("icon");
  1724. icon.className = "orb";
  1725. if (option.className) icon.className += " " + option.className;
  1726. icon.setAttribute("data-orb-icon",attr);
  1727. return tsp.orbs[attr]({icon: icon});
  1728. })
  1729. .nodeJoin(tsp.word.slight_pause());
  1730. }
  1731. if (option.affix)
  1732. contentFrg = tsp.word.affix_orb({cotent: contentFrg});
  1733. if (option.any)
  1734. contentFrg = tsp.orbs.any({cotent: contentFrg});
  1735. frg.ap(contentFrg);
  1736. return frg;
  1737. }
  1738. function renderTypes(types, option = {}) {
  1739. if (!Array.isArray(types))
  1740. types = [types ?? 0];
  1741. const frg = document.createDocumentFragment();
  1742. if (typeof localTranslating == "undefined") return frg;
  1743. const tsp = localTranslating.skill_parse;
  1744. const contentFrg = types.map(type => {
  1745. const icon = document.createElement("icon");
  1746. icon.className = "type";
  1747. icon.setAttribute("data-type-icon",type);
  1748. return tsp.types[type]({icon: icon});
  1749. })
  1750. .nodeJoin(tsp.word.slight_pause());
  1751. frg.ap(option.affix ? tsp.word.affix_type({cotent: contentFrg}) : contentFrg);
  1752. return frg;
  1753. }
  1754. function renderAwakenings(awakenings, option = {}) {
  1755. if (!Array.isArray(awakenings))
  1756. awakenings = [awakenings ?? 0];
  1757. const frg = document.createDocumentFragment();
  1758. if (typeof localTranslating == "undefined") return frg;
  1759. const tsp = localTranslating.skill_parse;
  1760. const contentFrg = awakenings.map(awoken => {
  1761. const icon = document.createElement("icon");
  1762. icon.className = "awoken-icon";
  1763. icon.setAttribute("data-awoken-icon",awoken);
  1764. return icon;
  1765. })
  1766. .nodeJoin(tsp.word.slight_pause());
  1767. frg.ap(option.affix ? tsp.word.affix_awakening({cotent: contentFrg}) : contentFrg);
  1768. return frg;
  1769. }
  1770. function renderCondition(cond) {
  1771. const frg = document.createDocumentFragment();
  1772. const tsp = localTranslating.skill_parse;
  1773. if (cond.hp) {
  1774. let dict = {
  1775. hp: renderStat('chp'),
  1776. min: renderValue(v.percent(cond.hp.min * 100), {percent: true}),
  1777. max: renderValue(v.percent(cond.hp.max * 100), {percent: true}),
  1778. };
  1779. if (cond.hp.min === cond.hp.max)
  1780. frg.ap(tsp.cond.hp_equal(dict));
  1781. else if (cond.hp.min === 0)
  1782. frg.ap(tsp.cond.hp_less_or_equal(dict));
  1783. else if (cond.hp.max === 1)
  1784. frg.ap(tsp.cond.hp_greater_or_equal(dict));
  1785. else
  1786. frg.ap(tsp.cond.hp_belong_to_range(dict));
  1787. } else if (cond.useSkill) {
  1788. frg.ap(tsp.cond.use_skill());
  1789. } else if (cond.multiplayer) {
  1790. frg.ap(tsp.cond.multi_player());
  1791. } else if (cond.remainOrbs) {
  1792. let dict = {
  1793. value: renderValue(v.constant(cond.remainOrbs.count), {unit: tsp.unit.unit}),
  1794. };
  1795. frg.ap(tsp.cond.remain_orbs(dict));
  1796. } else if (cond.exact) {
  1797. if (cond.exact.type === 'combo') {
  1798. let dict = {value: cond.exact.value};
  1799. frg.ap(tsp.cond.exact_combo(dict));
  1800. } else if (cond.exact.type === 'match-length') {
  1801. let dict = {
  1802. value: renderValue(v.constant(cond.exact.value), {unit: tsp.unit.unit}),
  1803. orbs: cond.exact.attrs === 'enhanced' ? tsp.cond.exact_match_enhanced() : renderOrbs(cond.exact.attrs, {affix: true})
  1804. };
  1805. frg.ap(tsp.cond.exact_match_length(dict));
  1806. }
  1807. } else if (cond.compo) {
  1808. let dict = {};
  1809. switch (cond.compo.type)
  1810. {
  1811. case 'card':{
  1812. dict.ids = cond.compo.ids.map(mid=>{
  1813. const dom = cardN(mid);
  1814. dom.monDom.onclick = changeToIdInSkillDetail;
  1815. return dom;
  1816. }).nodeJoin();
  1817. frg.ap(tsp.cond.compo_type_card(dict));
  1818. break;
  1819. }
  1820. case 'series':{
  1821. dict.ids = cond.compo.ids.map(cid=>{
  1822. const lnk = document.createElement("a");
  1823. lnk.className ="detail-search monster-collabId";
  1824. lnk.setAttribute("data-collabId",cid);
  1825. lnk.onclick = searchCollab;
  1826. lnk.textContent = cid;
  1827. return lnk;
  1828. }).nodeJoin(tsp.word.slight_pause());
  1829. frg.ap(tsp.cond.compo_type_series(dict));
  1830. break;
  1831. }
  1832. case 'evolution':{
  1833. dict.ids = cond.compo.ids.join();
  1834. frg.ap(tsp.cond.compo_type_evolution(dict));
  1835. break;
  1836. }
  1837. }
  1838. } else if (cond.LShape) {
  1839. let dict = {
  1840. orbs: renderOrbs(cond.LShape.attrs, {affix: true}),
  1841. };
  1842. frg.ap(tsp.cond.L_shape(dict));
  1843. } else {
  1844. frg.ap(tsp.cond.unknown());
  1845. }
  1846. return frg;
  1847. }
  1848. function renderPowerUp(powerUp) {
  1849. const frg = document.createDocumentFragment();
  1850. const tsp = localTranslating.skill_parse;
  1851. function renderStats(hp, atk, rcv, option = {}) {
  1852. const mul = option.mul ?? true;
  1853. option.percent = !mul;
  1854. const frg = document.createDocumentFragment();
  1855. const operator = mul ? '' : '+';
  1856. let list = [['hp', hp], ['atk', atk], ['rcv', rcv]];
  1857. //去除不改变的值
  1858. list = list.filter(([, value]) => value !== (mul ? 1 : 0) && value !== 0);
  1859. //&&!(name === 'hp' && value === 0));
  1860. if (list.length === 0) return frg;
  1861. if (list.every(([, value]) => value === list[0][1])) {
  1862. let value = list[0][1];
  1863. //三个值一样
  1864. frg.ap(list.map(([name]) => renderStat(name)).nodeJoin(tsp.word.slight_pause()));
  1865. frg.ap(operator);
  1866. frg.ap(renderValue(v.percent(value * 100), option));
  1867. } else {
  1868. //三个值不一样
  1869. let subDocument = list.map(([name, value]) => {
  1870. let _frg = document.createDocumentFragment();
  1871. _frg.ap(renderStat(name));
  1872. _frg.ap(operator);
  1873. _frg.ap(renderValue(v.percent(value * 100), option));
  1874. return _frg;
  1875. });
  1876. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  1877. }
  1878. return frg;
  1879. }
  1880. switch (powerUp.kind) {
  1881. case SkillPowerUpKind.Multiplier: {
  1882. let hp = powerUp.hp, atk = powerUp.atk, rcv = powerUp.rcv;
  1883. frg.ap(renderStats(hp, atk, rcv));
  1884. break;
  1885. }
  1886. case SkillPowerUpKind.ScaleAttributes: {
  1887. let attrs = powerUp.attrs, min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv;
  1888. let dict = {
  1889. orbs: renderOrbs(attrs, {affix: true}),
  1890. min: min,
  1891. stats: renderStats(1, baseAtk, baseRcv),
  1892. }
  1893. if (max !== min)
  1894. {
  1895. let _dict = {
  1896. max: max,
  1897. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  1898. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  1899. }
  1900. dict.bonus = frg.ap(tsp.power.scale_attributes_bonus(_dict));
  1901. }
  1902. frg.ap(tsp.power.scale_attributes(dict));
  1903. break;
  1904. }
  1905. case SkillPowerUpKind.ScaleCombos: {
  1906. let min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv;
  1907. let dict = {
  1908. min: min,
  1909. stats: renderStats(1, baseAtk, baseRcv),
  1910. }
  1911. if (max !== min)
  1912. {
  1913. let _dict = {
  1914. max: max,
  1915. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  1916. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  1917. }
  1918. dict.bonus = frg.ap(tsp.power.scale_combos_bonus(_dict));
  1919. }
  1920. frg.ap(tsp.power.scale_combos(dict));
  1921. break;
  1922. }
  1923. case SkillPowerUpKind.ScaleMatchAttrs: {
  1924. let matches = powerUp.matches, min = powerUp.min, max = powerUp.max, baseAtk = powerUp.baseAtk, baseRcv = powerUp.baseRcv, bonusAtk = powerUp.bonusAtk, bonusRcv = powerUp.bonusRcv;
  1925. let dict = {
  1926. matches: matches.map(orbs=>renderOrbs(orbs)).nodeJoin(tsp.word.slight_pause()),
  1927. min: min,
  1928. stats: renderStats(1, baseAtk, baseRcv),
  1929. }
  1930. if (max !== min)
  1931. {
  1932. let _dict = {
  1933. max: max,
  1934. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  1935. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  1936. }
  1937. dict.bonus = frg.ap(tsp.power.scale_match_attrs_bonus(_dict));
  1938. }
  1939. frg.ap(tsp.power.scale_match_attrs(dict));
  1940. break;
  1941. }
  1942. case SkillPowerUpKind.ScaleMatchLength: {
  1943. 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;
  1944. let dict = {
  1945. orbs: renderOrbs(attrs, {affix: true}),
  1946. min: min,
  1947. stats: renderStats(1, baseAtk, baseRcv),
  1948. in_once: matchAll && tsp.word.in_once() || null,
  1949. }
  1950. if (max !== min)
  1951. {
  1952. let _dict = {
  1953. max: max,
  1954. bonus: renderStats(0, bonusAtk, bonusRcv, {mul: false}),
  1955. stats_max: renderStats(1, baseAtk + bonusAtk * (max-min), baseRcv + bonusRcv * (max-min)),
  1956. }
  1957. dict.bonus = frg.ap(tsp.power.scale_match_length_bonus(_dict));
  1958. }
  1959. frg.ap(tsp.power.scale_match_length(dict));
  1960. break;
  1961. }
  1962. case SkillPowerUpKind.ScaleCross: {
  1963. let crosses = powerUp.crosses;
  1964. if (crosses.length >= 2 && crosses.every(cross => cross.atk === crosses[0].atk)) {
  1965. //所有值一样
  1966. let cross = crosses[0];
  1967. let dict = {
  1968. orbs: renderOrbs(crosses.map(cross => cross.attr), {affix: true, any: true}),
  1969. stats: renderStats(1, cross.atk, cross.rcv),
  1970. }
  1971. frg.ap(cross.single ? tsp.power.scale_cross_single(dict) : tsp.power.scale_cross(dict));
  1972. } else {
  1973. let subDocument = crosses.map(cross=>{
  1974. let dict = {
  1975. orbs: renderOrbs(cross.attr, {affix: true, any: true}),
  1976. stats: renderStats(1, cross.atk, cross.rcv),
  1977. }
  1978. return cross.single ? tsp.power.scale_cross_single(dict) : tsp.power.scale_cross(dict);
  1979. });
  1980. frg.ap(subDocument.nodeJoin(tsp.word.comma()));
  1981. }
  1982. break;
  1983. }
  1984. case SkillPowerUpKind.ScaleStateKindCount: {
  1985. let awakenings = powerUp.awakenings, attrs = powerUp.attrs, types = powerUp.types, value = powerUp.value;
  1986. let dict = {
  1987. stats: renderStats(value.hp, value.atk, value.rcv, {mul: false, percent: true}),
  1988. awakenings: awakenings?.length && renderAwakenings(awakenings, {affix: true}) || null,
  1989. attrs: attrs?.length && renderAttrs(attrs, {affix: true}) || null,
  1990. types: types?.length && renderTypes(types, {affix: true}) || null,
  1991. }
  1992. frg.ap(tsp.power.scale_state_kind_count(dict));
  1993. break;
  1994. }
  1995. default:
  1996. frg.ap(tsp.power.unknown({type: powerUp.kind}));
  1997. }
  1998. return frg;
  1999. }
  2000. function renderValue(_value, option = {}) {
  2001. const frg = document.createDocumentFragment();
  2002. if (typeof localTranslating == "undefined") return frg;
  2003. const tsp = localTranslating.skill_parse
  2004. const tspv = tsp.value;
  2005. const od = option.decimalDigits, os = option.plusSign;
  2006. let dict;
  2007. switch (_value.kind) {
  2008. case SkillValueKind.Percent: {
  2009. dict = {
  2010. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2011. };
  2012. frg.ap(
  2013. option.percent ?
  2014. tspv.mul_percent(dict) :
  2015. tspv.mul_times(dict)
  2016. );
  2017. break;
  2018. }
  2019. case SkillValueKind.Constant: {
  2020. dict = {
  2021. value: _value.value.keepCounts(od,os),
  2022. unit: option.unit ? option.unit() : undefined,
  2023. };
  2024. frg.ap(tspv.const(dict));
  2025. break;
  2026. }
  2027. case SkillValueKind.ConstantTo: {
  2028. dict = {
  2029. value: _value.value.keepCounts(od,os)
  2030. };
  2031. frg.ap(tspv.const_to(dict));
  2032. break;
  2033. }
  2034. case SkillValueKind.xMaxHP: {
  2035. dict = {
  2036. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2037. stats: renderStat('maxhp'),
  2038. };
  2039. frg.ap(
  2040. option.percent ?
  2041. tspv.mul_of_percent(dict) :
  2042. tspv.mul_of_times(dict)
  2043. );
  2044. break;
  2045. }
  2046. case SkillValueKind.xHP: {
  2047. dict = {
  2048. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2049. stats: renderStat('hp'),
  2050. };
  2051. frg.ap(
  2052. option.percent ?
  2053. tspv.mul_of_percent(dict) :
  2054. tspv.mul_of_times(dict)
  2055. );
  2056. break;
  2057. }
  2058. case SkillValueKind.xATK: {
  2059. dict = {
  2060. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2061. stats: renderStat('atk'),
  2062. };
  2063. frg.ap(
  2064. option.percent ?
  2065. tspv.mul_of_percent(dict) :
  2066. tspv.mul_of_times(dict)
  2067. );
  2068. break;
  2069. }
  2070. case SkillValueKind.xRCV: {
  2071. dict = {
  2072. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2073. stats: renderStat('rcv'),
  2074. };
  2075. frg.ap(
  2076. option.percent ?
  2077. tspv.mul_of_percent(dict) :
  2078. tspv.mul_of_times(dict)
  2079. );
  2080. break;
  2081. }
  2082. case SkillValueKind.xTeamHP: {
  2083. let value = _value.value;
  2084. dict = {
  2085. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  2086. stats: renderStat('teamhp'),
  2087. };
  2088. frg.ap(
  2089. option.percent ?
  2090. tspv.mul_of_percent(dict) :
  2091. tspv.mul_of_times(dict)
  2092. );
  2093. break;
  2094. }
  2095. case SkillValueKind.xTeamRCV: {
  2096. dict = {
  2097. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  2098. stats: renderStat('teamrcv'),
  2099. };
  2100. frg.ap(
  2101. option.percent ?
  2102. tspv.mul_of_percent(dict) :
  2103. tspv.mul_of_times(dict)
  2104. );
  2105. break;
  2106. }
  2107. case SkillValueKind.xTeamATK: {
  2108. let attrs = _value.attrs, value = _value.value;
  2109. dict = {
  2110. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  2111. stats: renderStat('teamatk', {attrs: renderAttrs(attrs, {affix: true})}),
  2112. };
  2113. frg.ap(
  2114. option.percent ?
  2115. tspv.mul_of_percent(dict) :
  2116. tspv.mul_of_times(dict)
  2117. );
  2118. break;
  2119. }
  2120. case SkillValueKind.HPScale: {
  2121. let min = _value.min, max = _value.max;
  2122. dict = {
  2123. min: tspv.mul_of_times({value: min.keepCounts(od,os), stats:renderStat('atk')}),
  2124. max: tspv.mul_of_times({value: max.keepCounts(od,os), stats:renderStat('atk')}),
  2125. hp: renderStat('hp'),
  2126. };
  2127. frg.ap(tspv.hp_scale(dict));
  2128. break;
  2129. }
  2130. case SkillValueKind.RandomATK: {
  2131. let min = _value.min, max = _value.max;
  2132. dict = {
  2133. min: min.keepCounts(od,os),
  2134. atk: renderStat('atk'),
  2135. };
  2136. if (max != min)
  2137. {
  2138. dict.max = tsp.word.range_hyphen().ap(max.keepCounts(od,os));
  2139. }
  2140. frg.ap(tspv.random_atk(dict));
  2141. break;
  2142. }
  2143. case SkillValueKind.xAwakenings: {
  2144. let value = _value.value, awakenings = _value.awakenings;
  2145. let dict = {
  2146. value: renderValue(value,{percent : true}),
  2147. awakenings: renderAwakenings(awakenings, {affix: true}),
  2148. }
  2149. frg.ap(tsp.value.x_awakenings(dict));
  2150. break;
  2151. }
  2152. /*
  2153. case SkillValueKind.xAwakenings: {
  2154. const { value, awakenings } = _value as SkillValue.WithAwakenings;
  2155. return <span>{formatNumber(value * 100)}% &times; each of {awakenings.map(id =>
  2156. <Asset assetId={`awakening-${id}`} className="CardSkill-icon" key={id} />
  2157. )}</span>;
  2158. }
  2159. */
  2160. default: {
  2161. console.log("未知数值类型",_value.kind, _value);
  2162. frg.ap(tspv.unknown({ type: _value.kind }));
  2163. }
  2164. }
  2165. return frg;
  2166. }

智龙迷城队伍图制作工具