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

智龙迷城队伍图制作工具