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

智龙迷城队伍图制作工具