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

智龙迷城队伍图制作工具