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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641
  1. //带标签的模板字符串
  2. function tp(strings, ...keys) {
  3. return (function(...values) {
  4. let dict = values[values.length - 1] || {};
  5. let fragment = document.createDocumentFragment();
  6. fragment.appendChild(document.createTextNode(strings[0]));
  7. //let result = [strings[0]];
  8. keys.forEach(function(key, i, arr) {
  9. let value = Number.isInteger(key) ? values[key] : dict[key];
  10. if (value == undefined)
  11. {
  12. console.log("模板字符串中 %s 未找到输入数据",key);
  13. }else
  14. {
  15. if (!(value instanceof Node))
  16. {
  17. value = document.createTextNode(value);
  18. }
  19. try{
  20. fragment.appendChild(arr.lastIndexOf(key) == i ? value : value.cloneNode(true));
  21. }catch(e)
  22. {
  23. console.log(value, e);
  24. console.log(keys, values);
  25. }
  26. }
  27. fragment.appendChild(document.createTextNode(strings[i + 1]));
  28. });
  29. return fragment;
  30. });
  31. }
  32. const Attributes = {
  33. /*0: "Fire",
  34. 1: "Water",
  35. 2: "Wood",
  36. 3: "Light",
  37. 4: "Dark",
  38. 5: "Heart",
  39. 6: "Jammer",
  40. 7: "Poison",
  41. 8: "MPoison",
  42. 9: "Bomb",*/
  43. Fire: 0,
  44. Water: 1,
  45. Wood: 2,
  46. Light: 3,
  47. Dark: 4,
  48. Heart: 5,
  49. Jammer: 6,
  50. Poison: 7,
  51. MPoison: 8,
  52. Bomb: 9,
  53. }
  54. for (let name in Attributes)
  55. {
  56. Attributes[Attributes[name]] = name;
  57. }
  58. Attributes.all = function () {
  59. return [
  60. this.Fire,
  61. this.Water,
  62. this.Wood,
  63. this.Light,
  64. this.Dark
  65. ];
  66. }
  67. Attributes.orbs = function () {
  68. return [
  69. this.Fire,
  70. this.Water,
  71. this.Wood,
  72. this.Light,
  73. this.Dark,
  74. this.Heart,
  75. this.Jammer,
  76. this.Poison,
  77. this.MPoison,
  78. this.Bomb,
  79. ];
  80. }
  81. const SkillValue = {
  82. isLess: function (value) {
  83. if (value.kind === SkillValueKind.Percent) return value.value < 1;
  84. if (value.kind === SkillValueKind.Constant) return value.value < 0;
  85. return false;
  86. }
  87. };
  88. const SkillValueKind = {
  89. Percent: 'mul',
  90. Constant: 'const',
  91. ConstantTo: 'const-to',
  92. xMaxHP: 'mul-maxhp',
  93. xHP: 'mul-hp',
  94. xATK: 'mul-atk',
  95. xRCV: 'mul-rcv',
  96. RandomATK: 'random-atk',
  97. HPScale: 'hp-scale',
  98. xTeamHP: 'mul-team-hp',
  99. xTeamATK: 'mul-team-atk',
  100. xTeamRCV: 'mul-team-rcv',
  101. xAwakenings: 'mul-awakenings',
  102. };
  103. const SkillPowerUpKind = {
  104. Multiplier: 'mul',
  105. ScaleAttributes: 'scale-attrs',
  106. ScaleCombos: 'scale-combos',
  107. ScaleMatchLength: 'scale-match-len',
  108. ScaleMatchAttrs: 'scale-match-attrs',
  109. ScaleCross: 'scale-cross',
  110. ScaleAwakenings: 'scale-awakenings',
  111. };
  112. const SkillKinds = {
  113. Unknown: "unknown",
  114. ActiveTurns: "active-turns",
  115. DamageEnemy: "damage-enemy",
  116. Vampire: "vampire",
  117. ReduceDamage: "reduce-damage",
  118. SelfHarm: "self-harm",
  119. Heal: "heal",
  120. AutoHealBuff: "auto-heal-buff",
  121. ChangeOrbs: "change-orbs",
  122. PowerUp: "power-up",
  123. CounterAttack: "counter-attack",
  124. SetOrbState: "set-orb-state",
  125. RateMultiply: "rate-mul",
  126. OrbDropIncrease: "orb-drop-incr",
  127. Resolve: "resolve",
  128. Delay: "delay",
  129. DefenseBreak: "def-break",
  130. MassAttack: "mass-attack",
  131. BoardChange: "board-change",
  132. Unbind: "unbind",
  133. RandomSkills: "random-skills",
  134. ChangeAttribute: "change-attr",
  135. SkillBoost: "skill-boost",
  136. AddCombo: "add-combo",
  137. VoidEnemyBuff: "void-enemy-buff",
  138. Poison: "poison",
  139. CTW: "ctw",
  140. Gravity: "gravity",
  141. FollowAttack: "follow-attack",
  142. AutoHeal: "auto-heal",
  143. TimeExtend: "time-extend",
  144. DropRefresh: "drop-refresh",
  145. LeaderChange: "leader-change",
  146. MinMatchLength: "min-match-len",
  147. FixedTime: "fixed-time",
  148. Drum: "drum",
  149. Board7x6: "7x6-board",
  150. NoSkyfall: "no-skyfall",
  151. }
  152. function skillParser(skillId)
  153. {
  154. /*function merge(skills)
  155. {
  156. //解封部分的合并
  157. let unbinds = skills.filter(skill=>skill.kind == SkillKinds.Unbind);
  158. if (unbinds.length>1)
  159. { //把后面的全都合并到第一个
  160. unbinds.reduce((pre,cur)=>{
  161. pre.normal = pre.normal || cur.normal;
  162. pre.awakenings = pre.awakenings || cur.awakenings;
  163. pre.matches = pre.matches || cur.matches;
  164. return pre
  165. });
  166. unbinds.shift(); //去除第一个
  167. unbinds.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  168. }
  169. let fixedDamages = skills.filter(skill=>skill.kind == SkillKinds.DamageEnemy && skill.attr === 'fixed').filter((skill,idx,arr)=>skill.id==arr[0].id);
  170. if (fixedDamages.length>1)
  171. { //把后面的全都合并到第一个
  172. fixedDamages[0].times = 5;
  173. fixedDamages.shift(); //去除第一个
  174. fixedDamages.forEach(skill=>skills.splice(skills.indexOf(skill),1)); //去掉所有后面的
  175. }
  176. }*/
  177. const skill = Skills[skillId];
  178. if (!skill) return [];
  179. if (!parsers[skill.type]) {
  180. return [{ kind: SkillKinds.Unknown }];
  181. }
  182. //此处用apply将这个parser传递到后面解析函数的this里,用于递归解析
  183. const result = parsers[skill.type].apply({ parser: skillParser }, skill.params);
  184. const skills = (Array.isArray(result) ? result : [result])
  185. .filter(s => Boolean(s))
  186. .map(s => ({ id: skillId, type: skill.type, params: skill.params, ...s }));
  187. //merge(skills);
  188. return skills;
  189. }
  190. //返回flag里值为true的数组,如[1,4,7]
  191. function flags(num){
  192. /*
  193. return Array.from(new Array(32),(i,n)=>n).filter(n => num & (1 << n)); //性能太差
  194. return new Array(32).fill(null).map((i,n)=>n).filter(n => num & (1 << n)); //性能比上者好,但还是不够快
  195. */
  196. const arr = [];
  197. for (let i = 0; i<32;i++)
  198. {
  199. if (num & (1<<i))
  200. {
  201. arr.push(i);
  202. }
  203. }
  204. return arr;
  205. }
  206. const v = {
  207. percent: function(value) {
  208. return { kind: SkillValueKind.Percent, value: (value / 100) || 1 };
  209. },
  210. constant: function(value) {
  211. return { kind: SkillValueKind.Constant, value: value || 0 };
  212. },
  213. constantTo: function(value) {
  214. return { kind: SkillValueKind.ConstantTo, value: value || 1 };
  215. },
  216. xMaxHP: function(value) {
  217. return { kind: SkillValueKind.xMaxHP, value: (value / 100) || 1 };
  218. },
  219. xHP: function(value) {
  220. return { kind: SkillValueKind.xHP, value: (value / 100) || 1 };
  221. },
  222. xATK: function(value) {
  223. return { kind: SkillValueKind.xATK, value: (value / 100) || 1 };
  224. },
  225. xRCV: function(value) {
  226. return { kind: SkillValueKind.xRCV, value: (value / 100) || 1 };
  227. },
  228. randomATK: function(min, max) {
  229. return { kind: SkillValueKind.RandomATK, min: (min / 100) || 1, max: (max / 100) || 1, scale: 1 };
  230. },
  231. hpScale: function(min, max, scale) {
  232. return { kind: SkillValueKind.HPScale, min: (min / 100) || 1, max: (max / 100) || 1, scale: (scale / 100) || 1 };
  233. },
  234. xTeamHP: function(value) {
  235. return { kind: SkillValueKind.xTeamHP, value: (value / 100) || 1 };
  236. },
  237. xTeamATK: function(attrs, value) {
  238. return { kind: SkillValueKind.xTeamATK, attrs: attrs, value: (value / 100) || 1 };
  239. },
  240. xTeamRCV: function(value) {
  241. return { kind: SkillValueKind.xTeamRCV, value: (value / 100) || 1 };
  242. },
  243. percentAwakenings: function(awakenings, value) {
  244. return { kind: SkillValueKind.xAwakenings, awakenings: awakenings, value: value / 100 };
  245. },
  246. };
  247. const c = {
  248. hp: function (min, max) {
  249. return { hp: { min: min / 100, max: max / 100 } };
  250. },
  251. exact: function (type, value, attrs) {
  252. if (attrs === void 0) { attrs = Attributes.all(); }
  253. return { exact: { type: type, value: value, attrs: attrs } };
  254. },
  255. compo: function (type, ids) {
  256. return { compo: { type: type, ids: ids } };
  257. },
  258. remainOrbs: function (count) { return { remainOrbs: { count: count } }; },
  259. useSkill: function () { return { useSkill: true }; },
  260. multiplayer: function () { return { multiplayer: true }; },
  261. probability: function (percent) { return { probability: percent }; },
  262. }
  263. const p = {
  264. mul: function (values) {
  265. if (Array.isArray(values)) {
  266. return {
  267. kind: SkillPowerUpKind.Multiplier,
  268. hp: 1,
  269. atk: values[0] / 100,
  270. rcv: values[1] / 100
  271. };
  272. }
  273. else {
  274. return {
  275. kind: SkillPowerUpKind.Multiplier,
  276. hp: (values.hp || 100) / 100,
  277. atk: (values.atk || 100) / 100,
  278. rcv: (values.rcv || 100) / 100
  279. };
  280. }
  281. },
  282. stats: function (value) {
  283. let statTypes = Array.from(arguments).slice(1);
  284. return [
  285. statTypes.indexOf(1) >= 0 ? value : 100,
  286. statTypes.indexOf(2) >= 0 ? value : 100
  287. ];
  288. },
  289. scale: function (min, max, baseMul, bonusMul) {
  290. return {
  291. min: min,
  292. max: max || min,
  293. baseAtk: (baseMul[0] / 100) || 1,
  294. baseRcv: (baseMul[1] / 100) || 1,
  295. bonusAtk: (bonusMul[0] / 100) || 0,
  296. bonusRcv: (bonusMul[1] / 100) || 0
  297. };
  298. },
  299. scaleAttrs: function (attrs, min, max, baseMul, bonusMul) {
  300. return { kind: SkillPowerUpKind.ScaleAttributes, attrs: attrs ,...this.scale(min, max, baseMul, bonusMul) };
  301. },
  302. scaleCombos: function (min, max, baseMul, bonusMul) {
  303. return { kind: SkillPowerUpKind.ScaleCombos ,...this.scale(min, max, baseMul, bonusMul) };
  304. },
  305. scaleMatchLength: function (attrs, min, max, baseMul, bonusMul) {
  306. return { kind: SkillPowerUpKind.ScaleMatchLength, attrs: attrs ,...this.scale(min, max, baseMul, bonusMul) };
  307. },
  308. scaleMatchAttrs: function (matches, min, max, baseMul, bonusMul) {
  309. return { kind: SkillPowerUpKind.ScaleMatchAttrs, matches: matches ,...this.scale(min, max, baseMul, bonusMul) };
  310. },
  311. scaleCross: function (crosses) {
  312. return { kind: SkillPowerUpKind.ScaleCross, crosses: crosses.map(cross => ({ ...cross, mul: (cross.mul / 100) || 1 })) };
  313. },
  314. scaleAwakenings: function (awakenings, value) {
  315. return { kind: SkillPowerUpKind.ScaleAwakenings, awakenings: awakenings, value: value / 100 };
  316. },
  317. }
  318. function activeTurns(turns, skill) {
  319. return skill ? { kind: SkillKinds.ActiveTurns, turns: turns, skill: skill } : null;
  320. }
  321. function damageEnemy(target, attr, damage) {
  322. return { kind: SkillKinds.DamageEnemy, target: target, attr: attr, damage: damage };
  323. }
  324. function vampire(attr, damageValue, healValue) {
  325. return { kind: SkillKinds.Vampire, attr: attr, damage: damageValue, heal: healValue };
  326. }
  327. function reduceDamage(attrs, percent, condition) {
  328. return { kind: SkillKinds.ReduceDamage, attrs: attrs, percent: percent, condition: condition };
  329. }
  330. function selfHarm(value) {
  331. return { kind: SkillKinds.SelfHarm, value: value };
  332. }
  333. function heal(value) {
  334. return { kind: SkillKinds.Heal, value: value };
  335. }
  336. function autoHealBuff(value) {
  337. return { kind: SkillKinds.AutoHealBuff, value: value };
  338. }
  339. function changeOrbs() {
  340. return { kind: SkillKinds.ChangeOrbs, changes: Array.from(arguments) };
  341. }
  342. function powerUp(attrs, types, value, condition, reduceDamageValue) {
  343. if (value.kind === SkillPowerUpKind.Multiplier) {
  344. let hp = value.hp, atk = value.atk, rcv = value.rcv;
  345. if (hp === 1 && atk === 1 && rcv === 1 && !reduceDamage)
  346. return null;
  347. }
  348. return { kind: SkillKinds.PowerUp, attrs: attrs, types: types, condition: condition, value: value, reduceDamage: reduceDamageValue };
  349. }
  350. function counterAttack(attr, prob, value) {
  351. return { kind: SkillKinds.CounterAttack, attr: attr, prob: prob, value: value };
  352. }
  353. function setOrbState(orbs, state) {
  354. return { kind: SkillKinds.SetOrbState, orbs: orbs, state: state };
  355. }
  356. function rateMultiply(value, rate) {
  357. return { kind: SkillKinds.RateMultiply, value: value, rate: rate };
  358. }
  359. function orbDropIncrease(value, attrs) {
  360. return { kind: SkillKinds.OrbDropIncrease, value: value, attrs: attrs };
  361. }
  362. function resolve(min, condition) {
  363. return { kind: SkillKinds.Resolve, min: min, max: 1, condition: condition };
  364. }
  365. function unbind(normal, awakenings, matches) {
  366. return { kind: SkillKinds.Unbind, normal: normal, awakenings: awakenings , matches: matches};
  367. }
  368. function boardChange(attrs) {
  369. return { kind: SkillKinds.BoardChange, attrs: attrs };
  370. }
  371. function randomSkills(skills) {
  372. return { kind: SkillKinds.RandomSkills, skills: skills };
  373. }
  374. function changeAttr(target, attr) {
  375. return { kind: SkillKinds.ChangeAttribute, target: target, attr: attr || 0 };
  376. }
  377. function gravity(value) {
  378. return { kind: SkillKinds.Gravity, value: value };
  379. }
  380. function voidEnemyBuff(buffs) {
  381. return { kind: SkillKinds.VoidEnemyBuff, buffs: buffs };
  382. }
  383. function skillBoost(value) { return { kind: SkillKinds.SkillBoost, value: value }; }
  384. function minMatch(value) { return { kind: SkillKinds.MinMatchLength, value: value }; }
  385. function fixedTime(value) { return { kind: SkillKinds.FixedTime, value: value }; }
  386. function addCombo(value) { return { kind: SkillKinds.AddCombo, value: value }; }
  387. function defBreak(value) { return { kind: SkillKinds.DefenseBreak, value: value }; }
  388. function poison(value) { return { kind: SkillKinds.Poison, value: value }; }
  389. function CTW(value) { return { kind: SkillKinds.CTW, value: value }; }
  390. function followAttack(value) { return { kind: SkillKinds.FollowAttack, value: value }; }
  391. function autoHeal(value) { return { kind: SkillKinds.AutoHeal, value: value }; }
  392. function timeExtend(value) { return { kind: SkillKinds.TimeExtend, value: value }; }
  393. function delay() { return { kind: SkillKinds.Delay }; }
  394. function massAttack() { return { kind: SkillKinds.MassAttack }; }
  395. function dropRefresh() { return { kind: SkillKinds.DropRefresh }; }
  396. function drum() { return { kind: SkillKinds.Drum }; }
  397. function leaderChange() { return { kind: SkillKinds.LeaderChange }; }
  398. function board7x6() { return { kind: SkillKinds.Board7x6 }; }
  399. function noSkyfall() { return { kind: SkillKinds.NoSkyfall }; }
  400. const parsers = {
  401. parser: (() => []), //这个用来解决代码提示的报错问题,不起实际作用
  402. [0](attr, mul) { return damageEnemy('all', attr, v.xATK(mul)); },
  403. [1](attr, value) { return damageEnemy('all', attr, v.constant(value)); },
  404. [2](mul) { return damageEnemy('single', 'self', v.xATK(mul)); },
  405. [3](turns, percent) { return activeTurns(turns, reduceDamage('all', v.percent(percent))); },
  406. [4](mul) { return poison(v.xATK(mul)); },
  407. [5](time) { return CTW(v.constant(time)); },
  408. [6](percent) { return gravity(v.xHP(percent)); },
  409. [7](mul) { return heal(v.xRCV(mul)); },
  410. [8](value) { return heal(v.constant(value)); },
  411. [9](from, to) { return changeOrbs({ kind: 'from', from: [from || 0], to: [to || 0] }); },
  412. [10]() { return dropRefresh(); },
  413. [11](attr, mul) { return powerUp([attr], null, p.mul({ atk: mul })); },
  414. [12](mul) { return followAttack(v.xATK(mul)); },
  415. [13](mul) { return autoHeal(v.xRCV(mul)); },
  416. [14](min, percent) { return resolve(v.percent(min), c.probability(percent)); },
  417. [15](time) { return timeExtend(v.constant(time / 100)); },
  418. [16](percent) { return reduceDamage('all', v.percent(percent)); },
  419. [17](attr, percent) { return reduceDamage([attr], v.percent(percent)); },
  420. [18](turns) { return activeTurns(turns, delay()); },
  421. [19](turns, percent) { return activeTurns(turns, defBreak(v.percent(percent))); },
  422. [20](from1, to1, from2, to2) { return changeOrbs({ kind: 'from', from: [from1 || 0], to: [to1 || 0] }, { kind: 'from', from: [from2 || 0], to: [to2 || 0] }); },
  423. [21](turns, attr, percent) { return activeTurns(turns, reduceDamage([attr], v.percent(percent))); },
  424. [22](type, mul) { return powerUp(null, [type], p.mul({ atk: mul })); },
  425. [23](type, mul) { return powerUp(null, [type], p.mul({ hp: mul })); },
  426. [24](type, mul) { return powerUp(null, [type], p.mul({ rcv: mul })); },
  427. [26](mul) { return powerUp(null, null, p.mul({ atk: mul })); },
  428. [28](attr, mul) { return powerUp([attr], null, p.mul({ atk: mul, rcv: mul })); },
  429. [29](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, atk: mul, rcv: mul })); },
  430. [30](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ hp: mul })); },
  431. [31](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ atk: mul })); },
  432. [33]() { return drum(); },
  433. [35](mul, percent) { return vampire('self', v.xATK(mul), v.percent(percent)); },
  434. [36](attr1, attr2, percent) { return reduceDamage([attr1, attr2], v.percent(percent)); },
  435. [37](attr, mul) { return damageEnemy('single', attr, v.xATK(mul)); },
  436. [38](max, _, percent) { return reduceDamage('all', v.percent(percent), max === 100 ? c.hp(max, max) : c.hp(0, max)); },
  437. [39](percent, stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  438. [40](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ atk: mul })); },
  439. [41](prob, mul, attr) { return counterAttack(attr || 0, v.percent(prob), v.percent(mul)); },
  440. [42](targetAttr, dmgAttr, value) { return damageEnemy(targetAttr, dmgAttr, v.constant(value)); },
  441. [43](min, max, percent) { return reduceDamage('all', v.percent(percent), c.hp(min, max)); },
  442. [44](percent, stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  443. [45](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, atk: mul })); },
  444. [46](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul })); },
  445. [48](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul })); },
  446. [49](attr, mul) { return powerUp([attr], null, p.mul({ rcv: mul })); },
  447. [50](turns, attr, mul) { return activeTurns(turns, powerUp([attr], null, p.mul({ atk: mul }))); },
  448. [51](turns) { return activeTurns(turns, massAttack()); },
  449. [52](attr) { return setOrbState([attr], 'enhanced'); },
  450. [53](mul) { return rateMultiply(v.percent(mul), 'drop'); },
  451. [54](mul) { return rateMultiply(v.percent(mul), 'coin'); },
  452. [55](value) { return damageEnemy('single', 'fixed', v.constant(value)); },
  453. [56](value) { return damageEnemy('all', 'fixed', v.constant(value)); },
  454. [58](attr, min, max) { return damageEnemy('all', attr, v.randomATK(min, max)); },
  455. [59](attr, min, max) { return damageEnemy('single', attr, v.randomATK(min, max)); },
  456. [60](turns, mul, attr) { return activeTurns(turns, counterAttack(attr, v.percent(100), v.percent(mul))); },
  457. [61](attrs, min, base, bonus, incr) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min + (incr || 0), [base, 100], [bonus, 0])); },
  458. [62](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, atk: mul })); },
  459. [63](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, rcv: mul })); },
  460. [64](type, mul) { return powerUp(null, [type], p.mul({ atk: mul, rcv: mul })); },
  461. [65](type, mul) { return powerUp(null, [type], p.mul({ hp: mul, atk: mul, rcv: mul })); },
  462. [66](combo, mul) { return powerUp(null, null, p.scaleCombos(combo, combo, [mul, 100], [0, 0])); },
  463. [67](attr, mul) { return powerUp([attr], null, p.mul({ hp: mul, rcv: mul })); },
  464. [69](attr, type, mul) { return powerUp([attr], [type], p.mul({ atk: mul })); },
  465. [71](...attrs) { return boardChange(attrs.filter(attr => attr >= 0)); },
  466. [73](attr, type, mul) { return powerUp([attr], [type], p.mul({ hp: mul, atk: mul })); },
  467. [75](attr, type, mul) { return powerUp([attr], [type], p.mul({ atk: mul, rcv: mul })); },
  468. [76](attr, type, mul) { return powerUp([attr], [type], p.mul({ hp: mul, atk: mul, rcv: mul })); },
  469. [77](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ hp: mul, atk: mul })); },
  470. [79](type1, type2, mul) { return powerUp(null, [type1, type2], p.mul({ atk: mul, rcv: mul })); },
  471. [84](attr, min, max, percent) {
  472. return [
  473. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  474. damageEnemy('single', attr, v.randomATK(min, max))
  475. ];
  476. },
  477. [85](attr, min, max, percent) {
  478. return [
  479. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  480. damageEnemy('all', attr, v.randomATK(min, max))
  481. ];
  482. },
  483. [86](attr, value, _, percent) {
  484. return [
  485. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  486. damageEnemy('single', attr, v.constant(value))
  487. ];
  488. },
  489. [87](attr, value, _, percent) {
  490. return [
  491. selfHarm(percent ? v.xHP(100 - percent) : v.constantTo(1)),
  492. damageEnemy('all', attr, v.constant(value))
  493. ];
  494. },
  495. [88](turns, type, mul) { return activeTurns(turns, powerUp(null, [type], p.mul({ atk: mul }))); },
  496. [90](turns, attr1, attr2, mul) { return activeTurns(turns, powerUp([attr1, attr2], null, p.mul({ atk: mul }))); },
  497. [91](attr1, attr2) { return setOrbState([attr1, attr2], 'enhanced'); },
  498. [92](turns, type1, type2, mul) { return activeTurns(turns, powerUp(null, [type1, type2], p.mul({ atk: mul }))); },
  499. [93]() { return leaderChange(); },
  500. [94](percent, attr, stats1, stats2, mul) { return powerUp([attr], null, p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  501. [95](percent, type, stats1, stats2, mul) { return powerUp(null, [type], p.mul(p.stats(mul, stats1, stats2)), c.hp(0, percent)); },
  502. [96](percent, attr, stats1, stats2, mul) { return powerUp([attr], null, p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  503. [97](percent, type, stats1, stats2, mul) { return powerUp(null, [type], p.mul(p.stats(mul, stats1, stats2)), c.hp(percent, 100)); },
  504. [98](min, base, bonus, max) { return powerUp(null, null, p.scaleCombos(min, max, [base, 100], [bonus, 0])); },
  505. [100](stats1, stats2, mul) { return powerUp(null, null, p.mul(p.stats(mul, stats1, stats2)), c.useSkill()); },
  506. [101](combo, mul) { return powerUp(null, null, p.mul({ atk: mul }), c.exact('combo', combo)); },
  507. [103](combo, stats1, stats2, mul) { return powerUp(null, null, p.scaleCombos(combo, combo, p.stats(mul, stats1, stats2), [0, 0])); },
  508. [104](combo, attrs, stats1, stats2, mul) { return powerUp(flags(attrs), null, p.scaleCombos(combo, combo, p.stats(mul, stats1, stats2), [0, 0])); },
  509. [105](rcv, atk) { return powerUp(null, null, p.mul({ rcv, atk })); },
  510. [106](hp, atk) { return powerUp(null, null, p.mul({ hp, atk })); },
  511. [107](hp) { return powerUp(null, null, p.mul({ hp })); },
  512. [108](hp, type, atk) { return [powerUp(null, null, p.mul({ hp })), powerUp(null, [type], p.mul({ atk }))]; },
  513. [109](attrs, len, mul) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul, 100], [0, 0])); },
  514. [110](single, attr, min, max, scale) { return damageEnemy(single ? 'single' : 'all', attr, v.hpScale(min, max, scale)); },
  515. [111](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul, atk: mul })); },
  516. [114](attr1, attr2, mul) { return powerUp([attr1, attr2], null, p.mul({ hp: mul, atk: mul, rcv: mul })); },
  517. [115](attr, mul, percent) { return vampire(attr, v.xATK(mul), v.percent(percent)); },
  518. [116](...ids) { return ids.flatMap(id => this.parser(id)); },
  519. [117](bind, rcv, constant, hp, awokenBind) {
  520. return [
  521. rcv ? heal(v.xRCV(rcv)) : hp ? heal(v.xMaxHP(hp)) : constant ? heal(v.constant(constant)) : null,
  522. (bind || awokenBind) ? unbind(bind || 0, awokenBind || 0) : null,
  523. ].filter(Boolean);
  524. },
  525. [118](...ids) { return randomSkills(ids.map(id => this.parser(id))); },
  526. [119](attrs, min, base, bonus, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [base, 100], [bonus, 0])); },
  527. [121](attrs, types, hp, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })); },
  528. [122](percent, attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(0, percent)); },
  529. [123](percent, attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(percent, 100)); },
  530. [124](attrs1, attrs2, attrs3, attrs4, attrs5, min, mul, bonus) {
  531. const attrs = [attrs1, attrs2, attrs3, attrs4, attrs5].filter(Boolean);
  532. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, bonus ? attrs.length : min, [mul, 100], [bonus, 0]));
  533. },
  534. [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))); },
  535. [126](attrs, turns, _, percent) { return activeTurns(turns, orbDropIncrease(v.percent(percent), flags(attrs))); },
  536. [127](cols1, attrs1, cols2, attrs2) {
  537. return changeOrbs(
  538. { kind: 'fixed', to: flags(attrs1), type: 'col', positions: flags(cols1) },
  539. { kind: 'fixed', to: flags(attrs2), type: 'col', positions: flags(cols2) }
  540. );
  541. },
  542. [128](rows1, attrs1, rows2, attrs2) {
  543. return changeOrbs(
  544. { kind: 'fixed', to: flags(attrs1), type: 'row', positions: flags(rows1) },
  545. { kind: 'fixed', to: flags(attrs2), type: 'row', positions: flags(rows2) }
  546. );
  547. },
  548. [129](attrs, types, hp, atk, rcv, rAttrs, rPercent) {
  549. return [
  550. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  551. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent)) || null
  552. ];
  553. },
  554. [130](percent, attrs, types, atk, rcv, rAttrs, rPercent) {
  555. return [
  556. powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(0, percent)),
  557. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent), c.hp(0, percent)) || null
  558. ];
  559. },
  560. [131](percent, attrs, types, atk, rcv, rAttrs, rPercent) {
  561. return [
  562. powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.hp(percent, 100)),
  563. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent), c.hp(percent, 100)) || null
  564. ];
  565. },
  566. [132](turns, time, percent) { return activeTurns(turns, timeExtend(time ? v.constant(time / 10) : v.percent(percent))); },
  567. [133](attrs, types, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ atk, rcv }), c.useSkill()); },
  568. [136](attrs1, hp1, atk1, rcv1, attrs2, hp2, atk2, rcv2) {
  569. return [
  570. powerUp(flags(attrs1), null, p.mul({ hp: hp1, atk: atk1, rcv: rcv1 })),
  571. powerUp(flags(attrs2), null, p.mul({ hp: hp2, atk: atk2, rcv: rcv2 })),
  572. ];
  573. },
  574. [137](types1, hp1, atk1, rcv1, types2, hp2, atk2, rcv2) {
  575. return [
  576. powerUp(null, flags(types1), p.mul({ hp: hp1, atk: atk1, rcv: rcv1 })),
  577. powerUp(null, flags(types2), p.mul({ hp: hp2, atk: atk2, rcv: rcv2 })),
  578. ];
  579. },
  580. [138](...ids) { return ids.flatMap(id => this.parser(id)); },
  581. [139](attrs, types, percent1, less1, mul1, percent2, less2, mul2) {
  582. return [
  583. powerUp(flags(attrs), flags(types), p.mul({ atk: mul1 }), less1 ? c.hp(0, percent1) : c.hp(percent1, 100)),
  584. powerUp(flags(attrs), flags(types), p.mul({ atk: mul2 }), less1 ?
  585. (less2 ? c.hp(percent1, percent2) : c.hp(percent2, 100)) :
  586. (less2 ? c.hp(0, percent2) : c.hp(percent2, percent1))
  587. ),
  588. ];
  589. },
  590. [140](attrs) { return setOrbState(flags(attrs), 'enhanced'); },
  591. [141](count, to, exclude) { return changeOrbs({ kind: 'gen', to: flags(to), exclude: flags(exclude), count }); },
  592. [142](turns, attr) { return activeTurns(turns, changeAttr('self', attr)); },
  593. [143](mul, dmgAttr) { return damageEnemy('all', dmgAttr || 0, v.xTeamHP(mul)); },
  594. [144](teamAttrs, mul, single, dmgAttr) { return damageEnemy(single ? 'single' : 'all', dmgAttr, v.xTeamATK(flags(teamAttrs), mul)); },
  595. [145](mul) { return heal(v.xTeamRCV(mul)); },
  596. [146](turns) { return skillBoost(v.constant(turns)); },
  597. [148](percent) { return rateMultiply(v.percent(percent), 'exp'); },
  598. [149](mul) { return powerUp(null, null, p.mul({ rcv: mul }), c.exact('match-length', 4, [Attributes.Heart])); },
  599. [150](_, mul) { return powerUp(null, null, p.mul({ atk: mul }), c.exact('match-length', 5, 'enhanced')); },
  600. [151](mul, _, percent) {
  601. return [
  602. powerUp(null, null, p.scaleCross([{ single: true, attr: Attributes.Heart, mul }]), undefined, v.percent(percent)),
  603. ];
  604. },
  605. [152](attrs) { return setOrbState(flags(attrs), 'locked'); },
  606. [153](attr) { return changeAttr('opponent', attr); },
  607. [154](from, to) { return changeOrbs({ kind: 'from', to: flags(to), from: flags(from) }); },
  608. [155](attrs, types, hp, atk, rcv) { return powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv }), c.multiplayer()); },
  609. [156](turns, awoken1, awoken2, awoken3, type, mul) {
  610. return activeTurns(turns, type === 2 ?
  611. powerUp(null, null, p.scaleAwakenings([awoken1, awoken2, awoken3].filter(Boolean), mul)) :
  612. reduceDamage('all', v.percentAwakenings([awoken1, awoken2, awoken3].filter(Boolean), mul))
  613. );
  614. },
  615. [157](attr1, mul1, attr2, mul2, attr3, mul3) {
  616. return powerUp(null, null, p.scaleCross([
  617. { single: false, attr: attr1, mul: mul1 },
  618. { single: false, attr: attr2, mul: mul2 },
  619. { single: false, attr: attr3, mul: mul3 }
  620. ].filter(cross => cross.mul)));
  621. },
  622. [158](len, attrs, types, atk, hp, rcv) {
  623. return [
  624. minMatch(len),
  625. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv }))
  626. ];
  627. },
  628. [159](attrs, min, base, bonus, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [base, 100], [bonus, 0])); },
  629. [160](turns, combo) { return activeTurns(turns, addCombo(combo)); },
  630. [161](percent) { return gravity(v.xMaxHP(percent)); },
  631. [162]() { return board7x6(); },
  632. [163](attrs, types, hp, atk, rcv, rAttrs, rPercent) {
  633. return [
  634. noSkyfall(),
  635. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  636. rPercent && reduceDamage(flags(rAttrs), v.percent(rPercent)) || null,
  637. ];
  638. },
  639. [164](attrs1, attrs2, attrs3, attrs4, min, atk, rcv, bonus) {
  640. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  641. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, attrs.length, [atk, rcv], [bonus, bonus]));
  642. },
  643. [165](attrs, min, baseAtk, baseRcv, bonusAtk, bonusRcv, incr) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min + (incr || 0), [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  644. [166](min, baseAtk, baseRcv, bonusAtk, bonusRcv, max) { return powerUp(null, null, p.scaleCombos(min, max, [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  645. [167](attrs, min, baseAtk, baseRcv, bonusAtk, bonusRcv, max) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), min, max, [baseAtk, baseRcv], [bonusAtk, bonusRcv])); },
  646. [169](combo, mul, percent) { return powerUp(null, null, p.scaleCombos(combo, combo, [mul, 100], [0, 0]), undefined, v.percent(percent)); },
  647. [170](attrs, min, mul, percent) { return powerUp(null, null, p.scaleAttrs(flags(attrs), min, min, [mul, 100], [0, 0]), undefined, v.percent(percent)); },
  648. [171](attrs1, attrs2, attrs3, attrs4, min, mul, percent) {
  649. const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean);
  650. return powerUp(null, null, p.scaleMatchAttrs(attrs.map(flags), min, min, [mul, 0], [0, 0]), undefined, v.percent(percent));
  651. },
  652. [172]() { return setOrbState(null, 'unlocked'); },
  653. [173](turns, attrAbsorb, _, damageAbsorb) {
  654. return activeTurns(turns, voidEnemyBuff(
  655. [
  656. attrAbsorb && 'attr-absorb',
  657. damageAbsorb && 'damage-absorb'
  658. ].filter((buff) => typeof buff === 'string')
  659. ));
  660. },
  661. [175](series1, series2, series3, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp, atk, rcv }), c.compo('series', [series1, series2, series3].filter(Boolean))); },
  662. [177](_0, _1, _2, _3, _4, remains, mul) {
  663. return [
  664. noSkyfall(),
  665. powerUp(null, null, p.mul({ atk: mul }), c.remainOrbs(remains))
  666. ];
  667. },
  668. [178](time, attrs, types, hp, atk, rcv) {
  669. return [
  670. fixedTime(time),
  671. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv }))
  672. ];
  673. },
  674. [179](turns, value, percent, bind, awokenBind) {
  675. return [
  676. (bind || awokenBind) ? unbind(bind || 0, awokenBind || 0) : null,
  677. activeTurns(turns, autoHealBuff(value ? v.constant(value) : v.xMaxHP(percent)))
  678. ].filter(Boolean);
  679. },
  680. [180](turns, percent) { return activeTurns(turns, orbDropIncrease(v.percent(percent), 'enhanced')); },
  681. [182](attrs, len, mul, percent) { return powerUp(null, null, p.scaleMatchLength(flags(attrs), len, len, [mul, 100], [0, 0]), undefined, v.percent(percent)); },
  682. [183](attrs, types, percent1, atk1, rcv1, percent2, atk2, rcv2) {
  683. return [
  684. powerUp(flags(attrs), flags(types), p.mul({ atk: atk1, rcv: rcv1 }), c.hp(percent1, 100)),
  685. powerUp(flags(attrs), flags(types), p.mul({ atk: atk2, rcv: rcv2 }), c.hp(0, percent2 || percent1)),
  686. ];
  687. },
  688. [184](turns) { return activeTurns(turns, noSkyfall()); },
  689. [185](time, attrs, types, hp, atk, rcv) {
  690. return [
  691. timeExtend(v.constant(time / 100)),
  692. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  693. ];
  694. },
  695. [186](attrs, types, hp, atk, rcv) {
  696. return [
  697. board7x6(),
  698. powerUp(flags(attrs), flags(types), p.mul({ hp, atk, rcv })),
  699. ];
  700. },
  701. [188](value) {
  702. return damageEnemy('single', 'fixed', v.constant(value));
  703. },
  704. [195](percent) {
  705. return selfHarm(percent ? v.xHP(percent) : v.constantTo(1));
  706. },
  707. [196](matches) {
  708. return unbind(0,0,matches);
  709. },
  710. [218](turns) { return skillBoost(v.constant(-turns)); },
  711. };
  712. //将内容添加到代码片段
  713. DocumentFragment.prototype.ap = function(arg)
  714. {
  715. if (Array.isArray(arg)) //数组,递归自身
  716. {
  717. arg.forEach(element=>this.ap(element));
  718. }
  719. else if (arg instanceof Node) //属于Node的直接添加
  720. {
  721. this.appendChild(arg);
  722. }
  723. else //其他内容的转换为文字添加
  724. {
  725. this.appendChild(document.createTextNode(arg));
  726. }
  727. return this;
  728. }
  729. //将数组和分隔符添加到一个代码片段,类似join
  730. Array.prototype.nodeJoin = function(separator)
  731. {
  732. const frg = document.createDocumentFragment();
  733. this.forEach((item, idx, arr)=>{
  734. frg.ap(item);
  735. if (idx < (arr.length - 1) && separator != null)
  736. frg.ap(separator instanceof Node ? separator.cloneNode(true) : separator);
  737. });
  738. return frg;
  739. }
  740. //按住Ctrl点击技能在控制台输出技能的对象
  741. function showParsedSkill(event) {
  742. if (event.ctrlKey) {
  743. console.log(this.skill);
  744. }
  745. }
  746. function renderSkillEntry(skills)
  747. {
  748. const ul = document.createElement("ul");
  749. ul.className = "card-skill-list";
  750. skills.forEach(skill=>{
  751. const li = ul.appendChild(document.createElement("li"));
  752. li.className = skill.kind;
  753. li.appendChild(renderSkill(skill));
  754. li.skill = skill;
  755. li.addEventListener("click", showParsedSkill);
  756. });
  757. return ul;
  758. }
  759. function renderSkill(skill, option = {})
  760. {
  761. const frg = document.createDocumentFragment();
  762. if (typeof localTranslating == "undefined") return frg;
  763. const tsp = localTranslating.skill_parse;
  764. function createIcon(iconType, className){
  765. const idoc = document.createElement("icon");
  766. idoc.className = `icon-skill${className ? ` ${className}` : ''}`;
  767. idoc.setAttribute("data-icon-type", iconType);
  768. return idoc;
  769. }
  770. if (Array.isArray(skill))
  771. {
  772. frg.ap(skill.map(_skill=>renderSkill(_skill)));
  773. return frg;
  774. }
  775. switch (skill.kind) {
  776. case SkillKinds.Unknown: {
  777. let dict = {
  778. type: skill.kind
  779. };
  780. frg.ap(tsp.skill.unknown(dict));
  781. break;
  782. }
  783. case SkillKinds.ActiveTurns: { //有回合的行动
  784. let turns = skill.turns, actionSkill = skill.skill;
  785. let dict = {
  786. turns: turns,
  787. actionSkill: renderSkill(actionSkill),
  788. };
  789. frg.ap(tsp.skill.active_turns(dict));
  790. break;
  791. }
  792. case SkillKinds.RandomSkills: { //随机技能
  793. let skills = skill.skills;
  794. const ul = document.createElement("ul");
  795. ul.className = "random-active-skill";
  796. skills.forEach(subSkills=>{
  797. const li = ul.appendChild(document.createElement("li"));
  798. li.appendChild(renderSkillEntry(subSkills));
  799. });
  800. let dict = {
  801. skills: ul,
  802. };
  803. frg.ap(tsp.skill.random_skills(dict));
  804. break;
  805. }
  806. case SkillKinds.Delay: { //威吓
  807. let dict = {
  808. icon: createIcon("delay"),
  809. };
  810. frg.ap(tsp.skill.delay(dict));
  811. break;
  812. }
  813. case SkillKinds.MassAttack: { //全体攻击
  814. let dict = {
  815. icon: createIcon("mass-attack"),
  816. };
  817. frg.ap(tsp.skill.mass_attack(dict));
  818. break;
  819. }
  820. case SkillKinds.LeaderChange: { //切换队长
  821. let dict = {
  822. icon: createIcon("leader-change"),
  823. };
  824. frg.ap(tsp.skill.leader_change(dict));
  825. break;
  826. }
  827. case SkillKinds.NoSkyfall: { //无天降
  828. let dict = {
  829. icon: createIcon("no-skyfall"),
  830. };
  831. frg.ap(tsp.skill.no_skyfall(dict));
  832. break;
  833. }
  834. case SkillKinds.SelfHarm: { //主动自残
  835. let value = skill.value;
  836. let dict = {
  837. icon: createIcon("heal", "hp-decr"),
  838. value: renderValue(value, {percent: true}),
  839. stats: tsp.stats.hp(),
  840. };
  841. frg.ap(tsp.skill.self_harm(dict));
  842. break;
  843. }
  844. case SkillKinds.Heal: { //主动回血buff
  845. let value = skill.value;
  846. let dict = {
  847. icon: createIcon("heal", "hp-incr"),
  848. //icon: createIcon("auto-heal"),
  849. value: renderValue(value, {unit: tsp.unit.point, percent: value.kind == SkillValueKind.xRCV ? false : true}),
  850. stats: tsp.stats.hp(),
  851. };
  852. frg.ap(tsp.skill.heal(dict));
  853. break;
  854. }
  855. case SkillKinds.AutoHealBuff: { //自动回血buff
  856. let dict = {
  857. icon: createIcon("auto-heal"),
  858. value: renderValue(skill.value, {unit: tsp.unit.point, percent: true}),
  859. stats: tsp.stats.hp(),
  860. };
  861. frg.ap(tsp.skill.auto_heal_buff(dict));
  862. break;
  863. }
  864. case SkillKinds.DefenseBreak: { //破防
  865. let dict = {
  866. icon: createIcon("defense-break"),
  867. value: renderValue(skill.value, {percent: true}),
  868. };
  869. frg.ap(tsp.skill.defense_break(dict));
  870. break;
  871. }
  872. case SkillKinds.Poison: { //毒
  873. let dict = {
  874. icon: createIcon("poison"),
  875. belong_to: tsp.target.self(),
  876. target: tsp.target.enemy(),
  877. stats: tsp.stats.hp(),
  878. value: renderValue(skill.value),
  879. };
  880. frg.ap(tsp.skill.poison(dict));
  881. break;
  882. }
  883. case SkillKinds.TimeExtend: { //时间变化buff
  884. let dict = {
  885. icon: createIcon("status-time", SkillValue.isLess(skill.value) ? "time-decr" : "time-incr"),
  886. value: renderValue(skill.value, { unit:tsp.unit.seconds, plusSign: skill.value.kind != SkillValueKind.Percent, percent:true }),
  887. };
  888. frg.ap(tsp.skill.time_extend(dict));
  889. break;
  890. }
  891. case SkillKinds.FollowAttack: { //队长技追打
  892. let dict = {
  893. //icon: createIcon("follow_attack"),
  894. belong_to: tsp.target.self(),
  895. target: tsp.target.enemy(),
  896. value: renderValue(skill.value),
  897. };
  898. frg.ap(tsp.skill.follow_attack(dict));
  899. break;
  900. }
  901. case SkillKinds.AutoHeal: { //队长技自动回血
  902. let dict = {
  903. icon: createIcon("auto-heal"),
  904. belong_to: tsp.target.self(),
  905. value: renderValue(skill.value),
  906. stats: tsp.stats.hp(),
  907. };
  908. frg.ap(tsp.skill.auto_heal(dict));
  909. break;
  910. }
  911. case SkillKinds.CTW: { //时间暂停
  912. let dict = {
  913. icon: createIcon("ctw"),
  914. value: renderValue(skill.value, { unit: tsp.unit.seconds }),
  915. };
  916. frg.ap(tsp.skill.ctw(dict));
  917. break;
  918. }
  919. case SkillKinds.Gravity: { //重力
  920. let dict = {
  921. icon: createIcon("gravity"),
  922. target: tsp.target.enemy(),
  923. value: renderValue(skill.value, { percent:true }),
  924. };
  925. frg.ap(tsp.skill.gravity(dict));
  926. break;
  927. }
  928. case SkillKinds.Resolve: { //根性
  929. let prob = skill.condition.probability;
  930. let dict = {
  931. icon: createIcon("resolve"),
  932. stats: renderStat('hp'),
  933. value: renderValue(skill.min, { percent:true }),
  934. probability: prob < 100 ? tsp.skill.probability({value: prob}) : "",
  935. };
  936. frg.ap(tsp.skill.resolve(dict));
  937. break;
  938. }
  939. case SkillKinds.DamageEnemy: { //大炮和固伤
  940. let attr = skill.attr, target = skill.target, damage = skill.damage;
  941. if (attr == null) break; //没有属性时,编号为0的空技能
  942. dict = {
  943. target: target === 'all' ? tsp.target.enemy_all() : target === 'single' ? tsp.target.enemy_one() : tsp.target.enemy_attr({attr: renderAttrs(target)}),
  944. damage: renderValue(damage, {unit: tsp.unit.point}),
  945. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true})
  946. };
  947. frg.ap(tsp.skill.damage_enemy(dict));
  948. break;
  949. }
  950. case SkillKinds.Vampire: {
  951. let attr = skill.attr, damage = skill.damage, heal = skill.heal;
  952. dict = {
  953. icon: createIcon("heal", "hp-incr"),
  954. target: tsp.target.enemy_one(),
  955. damage: renderValue(damage),
  956. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true}),
  957. heal: renderValue(heal, {percent: true}),
  958. };
  959. frg.ap(tsp.skill.vampire(dict));
  960. break;
  961. }
  962. case SkillKinds.Unbind: {
  963. let normal = skill.normal, awakenings = skill.awakenings, matches = skill.matches;
  964. let effects = [];
  965. if (normal)
  966. effects.push(tsp.skill.unbind_normal({icon: createIcon("unbind-normal"), value: normal}));
  967. if (awakenings)
  968. effects.push(tsp.skill.unbind_awakenings({icon: createIcon("unbind-awakenings"), value: awakenings}));
  969. if (matches)
  970. effects.push(tsp.skill.unbind_matches({icon: createIcon("unbind-matches"), value: matches}));
  971. frg.ap(effects.nodeJoin(tsp.word.comma()));
  972. break;
  973. }
  974. case SkillKinds.BoardChange: {
  975. const attrs = skill.attrs;
  976. dict = {
  977. attrs: renderOrbs(attrs),
  978. };
  979. frg.ap(tsp.skill.board_change(dict));
  980. break;
  981. }
  982. case SkillKinds.SkillBoost: {
  983. const value = skill.value;
  984. let dict = {
  985. icon: createIcon("skill-boost", SkillValue.isLess(skill.value) ? "boost-decr" : "boost-incr"),
  986. turns: renderValue(value, { unit:tsp.unit.turns, plusSign:true }),
  987. };
  988. //renderValue(skill.value, { unit:tsp.unit.seconds, plusSign:true, percent:true })
  989. frg.ap(tsp.skill.skill_boost(dict));
  990. break;
  991. }
  992. /*
  993. case SkillKinds.AddCombo: {
  994. const { value } = skill as Skill.WithValue<number>;
  995. return (
  996. <span className="CardSkill-skill">
  997. <Asset assetId={`status-combo-p${value}`} className="CardSkill-icon" title={`Add ${value} combo`} />
  998. </span>
  999. );
  1000. }
  1001. case SkillKinds.FixedTime: {
  1002. const { value } = skill as Skill.WithValue<number>;
  1003. return (
  1004. <span className="CardSkill-skill">
  1005. <AssetBox className="CardSkill-icon-box" title="Fixed movement time">
  1006. <Asset assetId="status-time-incr" className="CardSkill-icon" />
  1007. <Asset assetId="orb-locked" className="CardSkill-icon" />
  1008. </AssetBox>
  1009. {value} seconds
  1010. </span>
  1011. );
  1012. }
  1013. case SkillKinds.MinMatchLength: {
  1014. const { value } = skill as Skill.WithValue<number>;
  1015. return <span className="CardSkill-skill">minimum match length {value}</span>;
  1016. }
  1017. case SkillKinds.DropRefresh: {
  1018. return <span className="CardSkill-skill">drop refresh</span>;
  1019. }
  1020. case SkillKinds.Drum: {
  1021. return <span className="CardSkill-skill">drum sound</span>;
  1022. }
  1023. case SkillKinds.Board7x6: {
  1024. return <span className="CardSkill-skill">7x6 board</span>;
  1025. }
  1026. case SkillKinds.Vampire: {
  1027. const { attr, damage, heal } = skill as Skill.Vampire;
  1028. return (
  1029. <span className="CardSkill-skill">
  1030. <Asset assetId="skill-attack" className="CardSkill-icon" />
  1031. single enemy &rArr; {renderValue(damage)}
  1032. {typeof attr === 'number' && renderAttrs(attr)}
  1033. &nbsp;&rArr;
  1034. <Asset assetId="status-heal" className="CardSkill-icon" />
  1035. {renderValue(heal)} damage
  1036. </span>
  1037. );
  1038. }
  1039. case SkillKinds.CounterAttack: {
  1040. const { attr, prob, value } = skill as Skill.CounterAttack;
  1041. return (
  1042. <span className="CardSkill-skill">
  1043. <Asset assetId="status-counter" className="CardSkill-icon" />
  1044. {renderValue(prob)} &rArr; {renderValue(value)} damage
  1045. {typeof attr === 'number' && renderAttrs(attr)}
  1046. </span>
  1047. );
  1048. }
  1049. case SkillKinds.ChangeOrbs: {
  1050. const { changes } = skill as Skill.ChangeOrbs;
  1051. return (
  1052. <span className="CardSkill-skill">
  1053. <AssetBox className="CardSkill-icon-box" title="Change orbs">
  1054. <Asset assetId="status-all-attrs" className="CardSkill-icon" />
  1055. <Asset assetId="overlay-heal" className="CardSkill-icon" />
  1056. </AssetBox>
  1057. <span className="CardSkill-item-list">
  1058. {changes.map((change, i) => {
  1059. switch (change.kind) {
  1060. case 'from':
  1061. return (
  1062. <span key={i}>
  1063. {renderOrbs(change.from)} &rArr; {renderOrbs(change.to)}
  1064. </span>
  1065. );
  1066. case 'gen':
  1067. return (
  1068. <span key={i}>
  1069. {renderOrbs(change.exclude).map((orb, j) => (
  1070. <AssetBox className="CardSkill-icon-box" key={j}>
  1071. {orb}
  1072. <Asset assetId="overlay-cross" className="CardSkill-icon" />
  1073. </AssetBox>
  1074. ))} &rArr; {renderOrbs(change.to)} &times; {change.count}
  1075. </span>
  1076. );
  1077. case 'fixed':
  1078. return (change.positions.length > 0 &&
  1079. <span key={i}>
  1080. {change.type === 'col' ? 'column' : 'row'}&nbsp;
  1081. {change.positions.map(p => p + 1).join(', ')}
  1082. &nbsp;&rArr; {renderOrbs(change.to)}
  1083. </span>
  1084. );
  1085. }
  1086. })}
  1087. </span>
  1088. </span>
  1089. );
  1090. }
  1091. case SkillKinds.Unbind: {
  1092. const { normal, awakenings } = skill as Skill.Unbind;
  1093. return (
  1094. <span className="CardSkill-skill CardSkill-item-list">
  1095. {!!normal && <span>
  1096. <Asset assetId="skill-unbind" className="CardSkill-icon" />
  1097. {normal} turns
  1098. </span>}
  1099. {!!awakenings && <span>
  1100. <AssetBox className="CardSkill-icon-box">
  1101. <Asset assetId="status-bind-awakenings" className="CardSkill-icon" />
  1102. <Asset assetId="overlay-heal" className="CardSkill-icon" />
  1103. </AssetBox>
  1104. {awakenings} turns
  1105. </span>}
  1106. </span>
  1107. );
  1108. }
  1109. case SkillKinds.OrbDropIncrease: {
  1110. const { attrs, value } = skill as Skill.OrbDropIncrease;
  1111. let attrElems: React.ReactNode[];
  1112. if (attrs === 'enhanced')
  1113. attrElems = [<Asset assetId="status-orb-enhanced" className="CardSkill-icon" key="enhanced" />];
  1114. else
  1115. attrElems = renderOrbs(attrs);
  1116. attrElems = attrElems.map((elem, i) => (
  1117. <AssetBox className="CardSkill-icon-box" key={i}>
  1118. {elem}
  1119. <Asset assetId="overlay-drop" className="CardSkill-icon" />
  1120. </AssetBox>
  1121. ));
  1122. return (
  1123. <span className="CardSkill-skill">
  1124. {attrElems}
  1125. {renderValue(value)}
  1126. </span>
  1127. );
  1128. }
  1129. case SkillKinds.VoidEnemyBuff: {
  1130. const { buffs } = skill as Skill.VoidEnemyBuff;
  1131. return (
  1132. <span className="CardSkill-skill">{
  1133. buffs.map(buff => {
  1134. switch (buff) {
  1135. case 'attr-absorb': return (
  1136. <AssetBox className="CardSkill-icon-box" key={buff}>
  1137. <Asset assetId="status-all-attrs" className="CardSkill-icon" />
  1138. <Asset assetId="overlay-heal" className="CardSkill-icon" />
  1139. <Asset assetId="overlay-cross" className="CardSkill-icon" style={{ opacity: 0.75 }} />
  1140. </AssetBox>
  1141. );
  1142. case 'damage-absorb': return (
  1143. <AssetBox className="CardSkill-icon-box" key={buff}>
  1144. <Asset assetId="status-damage-absorb" className="CardSkill-icon" />
  1145. <Asset assetId="overlay-cross" className="CardSkill-icon" style={{ opacity: 0.75 }} />
  1146. </AssetBox>
  1147. );
  1148. }
  1149. })
  1150. } </span>
  1151. );
  1152. }
  1153. case SkillKinds.ChangeAttribute: {
  1154. const { attr, target } = skill as Skill.ChangeAttribute;
  1155. return (
  1156. <span className="CardSkill-skill">
  1157. {target === 'self' && 'Self'}
  1158. {target === 'opponent' && 'enemy'}
  1159. &nbsp;&rArr; {renderAttrs(attr)}
  1160. </span>
  1161. );
  1162. }
  1163. case SkillKinds.SetOrbState: {
  1164. const { orbs, state } = skill as Skill.SetOrbState;
  1165. let orbElems: React.ReactNode[];
  1166. if (!orbs) {
  1167. orbElems = [<Asset assetId="orb-blind" className="CardSkill-icon" key="all" />];
  1168. } else {
  1169. orbElems = renderOrbs(orbs);
  1170. }
  1171. return (
  1172. <span className="CardSkill-skill">
  1173. {(state === 'enhanced' || state === 'locked') && orbElems}
  1174. {state === 'unlocked' && orbElems.map((elem, i) => (
  1175. <AssetBox className="CardSkill-icon-box" key={i}>
  1176. {elem}
  1177. <Asset assetId="orb-locked" className="CardSkill-icon" />
  1178. </AssetBox>
  1179. ))}
  1180. &rArr;
  1181. {state === 'enhanced' && orbElems.map((elem, i) => (
  1182. <AssetBox className="CardSkill-icon-box" key={i}>
  1183. {elem}
  1184. <Asset assetId="orb-enhanced" className="CardSkill-icon" />
  1185. </AssetBox>
  1186. ))}
  1187. {state === 'locked' && orbElems.map((elem, i) => (
  1188. <AssetBox className="CardSkill-icon-box" key={i}>
  1189. {elem}
  1190. <Asset assetId="orb-locked" className="CardSkill-icon" />
  1191. </AssetBox>
  1192. ))}
  1193. {state === 'unlocked' && orbElems}
  1194. </span>
  1195. );
  1196. }
  1197. case SkillKinds.RateMultiply: {
  1198. const { rate, value } = skill as Skill.RateMultiply;
  1199. return (
  1200. <span className="CardSkill-skill">
  1201. {rate === 'drop' && 'drop rate'}
  1202. {rate === 'coin' && 'coins'}
  1203. {rate === 'exp' && 'EXP'}
  1204. &nbsp;&times;&nbsp;
  1205. {renderValue(value)}
  1206. </span>
  1207. );
  1208. }
  1209. case SkillKinds.ReduceDamage: {
  1210. const { attrs, percent, condition } = skill as Skill.ReduceDamage;
  1211. return (
  1212. <span className="CardSkill-skill">
  1213. {!!condition && <>{renderCondition(condition)} &rArr; </>}
  1214. <Asset assetId="status-def" className="CardSkill-icon" />
  1215. {(Array.isArray(attrs) && !isEqual(attrs, Attributes.all())) && renderAttrs(attrs)}
  1216. {renderValue(percent)}
  1217. </span>
  1218. );
  1219. }
  1220. case SkillKinds.PowerUp: {
  1221. const { attrs, types, condition, value, reduceDamage } = skill as Skill.PowerUp;
  1222. const targets: React.ReactNode[] = [];
  1223. if (attrs && !isEqual(attrs, Attributes.all())) targets.push(...renderAttrs(attrs || []));
  1224. if (types) targets.push(...renderTypes(types || []));
  1225. return (
  1226. <span className="CardSkill-skill">
  1227. {condition && <>{renderCondition(condition)} &rArr; </>}
  1228. {targets.length > 0 && <>{targets}</>}
  1229. {!!value && renderPowerUp(value)}
  1230. {!!reduceDamage && <>
  1231. <Asset assetId="status-def" className="CardSkill-icon" />
  1232. {renderValue(reduceDamage)}
  1233. </>}
  1234. </span>
  1235. );
  1236. }
  1237. */
  1238. default: {
  1239. console.log("未处理的技能类型",skill.kind, skill);
  1240. frg.ap(skill.kind);
  1241. }
  1242. }
  1243. return frg;
  1244. };
  1245. function renderStat(stat, option) {
  1246. const frg = document.createDocumentFragment();
  1247. if (typeof localTranslating == "undefined") return frg;
  1248. const tspt = localTranslating.skill_parse.stats;
  1249. if (tspt[stat])
  1250. frg.ap(tspt[stat](option));
  1251. else
  1252. {
  1253. console.log("未知状态类型",stat);
  1254. frg.ap(tspt.unknown({ type: stat }));
  1255. }
  1256. return frg;
  1257. }
  1258. function renderAttrs(attrs, option = {}) {
  1259. if (!Array.isArray(attrs))
  1260. attrs = [attrs || 0];
  1261. const frg = document.createDocumentFragment();
  1262. if (typeof localTranslating == "undefined") return frg;
  1263. const tsp = localTranslating.skill_parse;
  1264. const contentFrg = attrs.map(attr => {
  1265. const icon = document.createElement("icon");
  1266. icon.className = "attr";
  1267. icon.setAttribute("data-attr-icon",attr);
  1268. return tsp.attrs[attr]({icon: icon});
  1269. })
  1270. .nodeJoin(tsp.word.slight_pause());
  1271. frg.ap(option.affix ? tsp.word.affix_attr({cotent: contentFrg}) : contentFrg);
  1272. return frg;
  1273. }
  1274. function renderOrbs(attrs, option = {}) {
  1275. if (!Array.isArray(attrs))
  1276. attrs = [attrs || 0];
  1277. const frg = document.createDocumentFragment();
  1278. if (typeof localTranslating == "undefined") return frg;
  1279. const tsp = localTranslating.skill_parse;
  1280. const contentFrg = attrs.map(attr => {
  1281. const icon = document.createElement("icon");
  1282. icon.className = "orb";
  1283. icon.setAttribute("data-orb-icon",attr);
  1284. return tsp.orbs[attr]({icon: icon});
  1285. })
  1286. .nodeJoin(tsp.word.slight_pause());
  1287. frg.ap(option.affix ? tsp.word.affix_attr({cotent: contentFrg}) : contentFrg);
  1288. return frg;
  1289. }
  1290. /*
  1291. function renderOrbs(attrs: Attributes | Attributes[]) {
  1292. if (!Array.isArray(attrs))
  1293. attrs = [attrs];
  1294. return attrs.map(attr => <Asset assetId={`orb-${attr}`} key={attr} className="CardSkill-icon" />);
  1295. }
  1296. function renderTypes(types: Types | Types[]) {
  1297. if (!Array.isArray(types))
  1298. types = [types];
  1299. return types.map(type => <Asset assetId={`type-${type}`} key={type} className="CardSkill-icon" />);
  1300. }
  1301. function renderCondition(cond: SkillCondition) {
  1302. if (cond.hp) {
  1303. if (cond.hp.min === cond.hp.max)
  1304. return <>{renderStat('hp')} = {formatNumber(cond.hp.min * 100)}%</>;
  1305. else if (cond.hp.min === 0)
  1306. return <>{renderStat('hp')} &le; {formatNumber(cond.hp.max * 100)}%</>;
  1307. else if (cond.hp.max === 1)
  1308. return <>{renderStat('hp')} &ge; {formatNumber(cond.hp.min * 100)}%</>;
  1309. else
  1310. return <>{renderStat('hp')} &in; [{formatNumber(cond.hp.min * 100)}%, {formatNumber(cond.hp.max * 100)}%]</>;
  1311. } else if (cond.useSkill) {
  1312. return <>use skill</>;
  1313. } else if (cond.multiplayer) {
  1314. return <>in multiplayer</>;
  1315. } else if (cond.remainOrbs) {
  1316. return <>&le; {cond.remainOrbs.count} orbs remain</>;
  1317. } else if (cond.exact) {
  1318. if (cond.exact.type === 'combo') {
  1319. return <>= {cond.exact.value} combos</>;
  1320. } else if (cond.exact.type === 'match-length') {
  1321. return <>= {cond.exact.value} {cond.exact.attrs === 'enhanced' ? 'Enhanced' : renderAttrs(cond.exact.attrs)} orbs</>;
  1322. }
  1323. } else if (cond.compo) {
  1324. return <>{cond.compo.type} [{cond.compo.ids.join()}] in team</>;
  1325. }
  1326. return <>[ unknown condition ]</>;
  1327. }
  1328. function renderPowerUp(powerUp: SkillPowerUp) {
  1329. function renderStats(hp: number, atk: number, rcv: number, mul = true) {
  1330. const operator = mul ? <>&times;</> : <>+</>;
  1331. let list: Array<['hp' | 'atk' | 'rcv', number]> = [['hp', hp], ['atk', atk], ['rcv', rcv]];
  1332. list = list.filter(([, value]) => value !== (mul ? 1 : 0));
  1333. if (list.length === 0) return null;
  1334. if (list.every(([, value]) => value === list[0][1])) {
  1335. return <>
  1336. {list.map(([name], i) => <React.Fragment key={name}>{i !== 0 && ', '}{renderStat(name)}</React.Fragment>)}
  1337. &nbsp;{operator} {formatNumber(list[0][1])}
  1338. </>;
  1339. } else {
  1340. return <>
  1341. {list.map(([name, value], i) => (
  1342. <React.Fragment key={name}>
  1343. {i !== 0 ? '; ' : ''}
  1344. {renderStat(name)}
  1345. &nbsp;{operator} {formatNumber(value)}
  1346. </React.Fragment>
  1347. ))}
  1348. </>;
  1349. }
  1350. }
  1351. switch (powerUp.kind) {
  1352. case SkillPowerUpKind.Multiplier: {
  1353. const { hp, atk, rcv } = powerUp as SkillPowerUp.Mul;
  1354. return renderStats(hp, atk, rcv);
  1355. }
  1356. case SkillPowerUpKind.ScaleAttributes: {
  1357. const { attrs, min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.ScaleAttrs;
  1358. return <>
  1359. &ge; {min} of [{renderAttrs(attrs)}] &rArr; {renderStats(1, baseAtk, baseRcv)}
  1360. {max !== min && <> for each &le; {max} attributes: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1361. </>;
  1362. }
  1363. case SkillPowerUpKind.ScaleCombos: {
  1364. const { min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.Scale;
  1365. return <>
  1366. &ge; {min} combos &rArr; {renderStats(1, baseAtk, baseRcv)}
  1367. {max !== min && <> for each &le; {max} combos: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1368. </>;
  1369. }
  1370. case SkillPowerUpKind.ScaleMatchAttrs: {
  1371. const { matches, min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.ScaleMultiAttrs;
  1372. return <>
  1373. &ge; {min} matches of [{matches.map((attrs, i) =>
  1374. <React.Fragment key={i}>{i !== 0 && ', '}{renderAttrs(attrs)}</React.Fragment>
  1375. )}] &rArr; {renderStats(1, baseAtk, baseRcv)}
  1376. {max !== min && <> for each &le; {max} matches: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1377. </>;
  1378. }
  1379. case SkillPowerUpKind.ScaleMatchLength: {
  1380. const { attrs, min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.ScaleAttrs;
  1381. return <>
  1382. &ge; {min} &times; {renderAttrs(attrs)} &rArr; {renderStats(1, baseAtk, baseRcv)}
  1383. {max !== min && <> for each &le; {max} orbs: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1384. </>;
  1385. }
  1386. case SkillPowerUpKind.ScaleCross: {
  1387. const { crosses } = powerUp as SkillPowerUp.ScaleCross;
  1388. return crosses.map(({ single, attr, mul }, i) => <React.Fragment key={i}>
  1389. {i !== 0 && ', '}
  1390. {mul !== 1 && <>{renderStat('atk')} &times; {formatNumber(mul)} </>}
  1391. {single ? 'when' : 'for each'} cross of {renderAttrs(attr)}
  1392. </React.Fragment>);
  1393. }
  1394. case SkillPowerUpKind.ScaleAwakenings: {
  1395. const { awakenings, value } = powerUp as SkillPowerUp.ScaleAwakenings;
  1396. return <>
  1397. {renderStat('atk')} &times; {formatNumber(value - 1)} for each {awakenings.map(id =>
  1398. <Asset assetId={`awakening-${id}`} className="CardSkill-icon" key={id} />
  1399. )}
  1400. </>;
  1401. }
  1402. default:
  1403. return <>[ unknown power up ]</>;
  1404. }
  1405. }
  1406. */
  1407. function renderValue(_value, option = {}) {
  1408. const frg = document.createDocumentFragment();
  1409. if (typeof localTranslating == "undefined") return frg;
  1410. const tsp = localTranslating.skill_parse
  1411. const tspv = tsp.value;
  1412. const od = option.decimalDigits, os = option.plusSign;
  1413. let dict;
  1414. switch (_value.kind) {
  1415. case SkillValueKind.Percent: {
  1416. dict = {
  1417. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1418. };
  1419. frg.ap(
  1420. option.percent ?
  1421. tspv.mul_percent(dict) :
  1422. tspv.mul_times(dict)
  1423. );
  1424. break;
  1425. }
  1426. case SkillValueKind.Constant: {
  1427. dict = {
  1428. value: _value.value.keepCounts(od,os),
  1429. unit: option.unit ? option.unit() : undefined,
  1430. };
  1431. frg.ap(tspv.const(dict));
  1432. break;
  1433. }
  1434. case SkillValueKind.ConstantTo: {
  1435. dict = {
  1436. value: _value.value.keepCounts(od,os)
  1437. };
  1438. frg.ap(tspv.const_to(dict));
  1439. break;
  1440. }
  1441. case SkillValueKind.xMaxHP: {
  1442. dict = {
  1443. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1444. stats: renderStat('maxhp'),
  1445. };
  1446. frg.ap(
  1447. option.percent ?
  1448. tspv.mul_of_percent(dict) :
  1449. tspv.mul_of_times(dict)
  1450. );
  1451. break;
  1452. }
  1453. case SkillValueKind.xHP: {
  1454. dict = {
  1455. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1456. stats: renderStat('hp'),
  1457. };
  1458. frg.ap(
  1459. option.percent ?
  1460. tspv.mul_of_percent(dict) :
  1461. tspv.mul_of_times(dict)
  1462. );
  1463. break;
  1464. }
  1465. case SkillValueKind.xATK: {
  1466. dict = {
  1467. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1468. stats: renderStat('atk'),
  1469. };
  1470. frg.ap(
  1471. option.percent ?
  1472. tspv.mul_of_percent(dict) :
  1473. tspv.mul_of_times(dict)
  1474. );
  1475. break;
  1476. }
  1477. case SkillValueKind.xRCV: {
  1478. dict = {
  1479. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1480. stats: renderStat('rcv'),
  1481. };
  1482. frg.ap(
  1483. option.percent ?
  1484. tspv.mul_of_percent(dict) :
  1485. tspv.mul_of_times(dict)
  1486. );
  1487. break;
  1488. }
  1489. case SkillValueKind.xTeamHP: {
  1490. let value = _value.value;
  1491. dict = {
  1492. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  1493. stats: renderStat('teamhp'),
  1494. };
  1495. frg.ap(
  1496. option.percent ?
  1497. tspv.mul_of_percent(dict) :
  1498. tspv.mul_of_times(dict)
  1499. );
  1500. break;
  1501. }
  1502. case SkillValueKind.xTeamRCV: {
  1503. dict = {
  1504. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1505. stats: renderStat('teamrcv'),
  1506. };
  1507. frg.ap(
  1508. option.percent ?
  1509. tspv.mul_of_percent(dict) :
  1510. tspv.mul_of_times(dict)
  1511. );
  1512. break;
  1513. }
  1514. case SkillValueKind.xTeamATK: {
  1515. let attrs = _value.attrs, value = _value.value;
  1516. dict = {
  1517. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  1518. stats: renderStat('teamatk', {attrs: renderAttrs(attrs, {affix: true})}),
  1519. };
  1520. frg.ap(
  1521. option.percent ?
  1522. tspv.mul_of_percent(dict) :
  1523. tspv.mul_of_times(dict)
  1524. );
  1525. break;
  1526. }
  1527. case SkillValueKind.HPScale: {
  1528. let min = _value.min, max = _value.max;
  1529. dict = {
  1530. min: tspv.mul_of_times({value: min.keepCounts(od,os), stats:renderStat('atk')}),
  1531. max: tspv.mul_of_times({value: max.keepCounts(od,os), stats:renderStat('atk')}),
  1532. hp: renderStat('hp'),
  1533. };
  1534. frg.ap(tspv.hp_scale(dict));
  1535. break;
  1536. }
  1537. case SkillValueKind.RandomATK: {
  1538. let min = _value.min, max = _value.max;
  1539. dict = {
  1540. min: min.keepCounts(od,os),
  1541. atk: renderStat('atk'),
  1542. };
  1543. if (max != min)
  1544. {
  1545. dict.max = tsp.word.range_hyphen().ap(max.keepCounts(od,os));
  1546. }
  1547. frg.ap(tspv.random_atk(dict));
  1548. break;
  1549. }
  1550. /*
  1551. case SkillValueKind.RandomATK: {
  1552. const { min, max } = _value as SkillValue.Scale;
  1553. if (min === max) {
  1554. return <span>{formatNumber(min)} &times; {renderStat('atk')}</span>;
  1555. } else {
  1556. return <span>(random &times; {formatNumber(min)} &hArr; {formatNumber(max)}) &times; {renderStat('atk')}</span>;
  1557. }
  1558. }
  1559. case SkillValueKind.xAwakenings: {
  1560. const { value, awakenings } = _value as SkillValue.WithAwakenings;
  1561. return <span>{formatNumber(value * 100)}% &times; each of {awakenings.map(id =>
  1562. <Asset assetId={`awakening-${id}`} className="CardSkill-icon" key={id} />
  1563. )}</span>;
  1564. }
  1565. */
  1566. default: {
  1567. console.log("未知数值类型",_value.kind, _value);
  1568. frg.ap(tspv.unknown({ type: _value.kind }));
  1569. }
  1570. }
  1571. return frg;
  1572. }

智龙迷城队伍图制作工具