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 60 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
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
4 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
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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646
  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. prob: function (percent) { return { prob: 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, prob) {
  363. return { kind: SkillKinds.Resolve, min: min, max: 1, prob: prob };
  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: v.constant(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, prob) { return resolve(v.percent(min), v.percent(prob)); },
  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 value = skill.value;
  885. let dict = {
  886. icon: createIcon("status-time", SkillValue.isLess(value) ? "time-decr" : "time-incr"),
  887. value: renderValue(value, { unit:tsp.unit.seconds, plusSign: value.kind != SkillValueKind.Percent, percent: SkillValue.isLess(value) }),
  888. };
  889. frg.ap(tsp.skill.time_extend(dict));
  890. break;
  891. }
  892. case SkillKinds.FollowAttack: { //队长技追打
  893. let dict = {
  894. //icon: createIcon("follow_attack"),
  895. belong_to: tsp.target.self(),
  896. target: tsp.target.enemy(),
  897. value: renderValue(skill.value),
  898. };
  899. frg.ap(tsp.skill.follow_attack(dict));
  900. break;
  901. }
  902. case SkillKinds.AutoHeal: { //队长技自动回血
  903. let dict = {
  904. icon: createIcon("auto-heal"),
  905. belong_to: tsp.target.self(),
  906. value: renderValue(skill.value),
  907. stats: tsp.stats.hp(),
  908. };
  909. frg.ap(tsp.skill.auto_heal(dict));
  910. break;
  911. }
  912. case SkillKinds.CTW: { //时间暂停
  913. let dict = {
  914. icon: createIcon("ctw"),
  915. value: renderValue(skill.value, { unit: tsp.unit.seconds }),
  916. };
  917. frg.ap(tsp.skill.ctw(dict));
  918. break;
  919. }
  920. case SkillKinds.Gravity: { //重力
  921. let dict = {
  922. icon: createIcon("gravity"),
  923. target: tsp.target.enemy(),
  924. value: renderValue(skill.value, { percent:true }),
  925. };
  926. frg.ap(tsp.skill.gravity(dict));
  927. break;
  928. }
  929. case SkillKinds.Resolve: { //根性
  930. let prob = skill.prob;
  931. let dict = {
  932. icon: createIcon("resolve"),
  933. stats: renderStat('hp'),
  934. value: renderValue(skill.min, { percent:true }),
  935. prob: prob.value < 1 ? tsp.value.prob({value: renderValue(prob, { percent:true })}) : null,
  936. };
  937. frg.ap(tsp.skill.resolve(dict));
  938. break;
  939. }
  940. case SkillKinds.DamageEnemy: { //大炮和固伤
  941. let attr = skill.attr, target = skill.target, damage = skill.damage;
  942. if (attr == null) break; //没有属性时,编号为0的空技能
  943. dict = {
  944. target: target === 'all' ? tsp.target.enemy_all() : target === 'single' ? tsp.target.enemy_one() : tsp.target.enemy_attr({attr: renderAttrs(target)}),
  945. damage: renderValue(damage, {unit: tsp.unit.point}),
  946. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true})
  947. };
  948. frg.ap(tsp.skill.damage_enemy(dict));
  949. break;
  950. }
  951. case SkillKinds.Unbind: { //解封
  952. let normal = skill.normal, awakenings = skill.awakenings, matches = skill.matches;
  953. let effects = [];
  954. if (normal)
  955. effects.push(tsp.skill.unbind_normal({icon: createIcon("unbind-normal"), value: normal}));
  956. if (awakenings)
  957. effects.push(tsp.skill.unbind_awakenings({icon: createIcon("unbind-awakenings"), value: awakenings}));
  958. if (matches)
  959. effects.push(tsp.skill.unbind_matches({icon: createIcon("unbind-matches"), value: matches}));
  960. frg.ap(effects.nodeJoin(tsp.word.comma()));
  961. break;
  962. }
  963. case SkillKinds.BoardChange: { //洗版
  964. const attrs = skill.attrs;
  965. dict = {
  966. attrs: renderOrbs(attrs),
  967. };
  968. frg.ap(tsp.skill.board_change(dict));
  969. break;
  970. }
  971. case SkillKinds.SkillBoost: { //溜
  972. const value = skill.value;
  973. let dict = {
  974. icon: createIcon("skill-boost", SkillValue.isLess(skill.value) ? "boost-decr" : "boost-incr"),
  975. turns: renderValue(value, { unit:tsp.unit.turns, plusSign:true }),
  976. };
  977. frg.ap(tsp.skill.skill_boost(dict));
  978. break;
  979. }
  980. case SkillKinds.AddCombo: { //+C
  981. const value = skill.value;
  982. let icon = createIcon("add-combo");
  983. icon.setAttribute("data-add-combo", value);
  984. let dict = {
  985. icon: icon,
  986. value: value,
  987. };
  988. frg.ap(tsp.skill.add_combo(dict));
  989. break;
  990. }
  991. case SkillKinds.FixedTime: { //固定手指
  992. const value = skill.value;
  993. let dict = {
  994. icon: createIcon(skill.kind),
  995. value: renderValue(value, { unit: tsp.unit.seconds }),
  996. };
  997. frg.ap(tsp.skill.fixed_time(dict));
  998. break;
  999. }
  1000. case SkillKinds.MinMatchLength: { //最低匹配长度
  1001. const value = skill.value;
  1002. let dict = {
  1003. icon: createIcon(skill.kind),
  1004. value: value,
  1005. };
  1006. frg.ap(tsp.skill.min_match_length(dict));
  1007. break;
  1008. }
  1009. case SkillKinds.DropRefresh: {
  1010. let dict = {
  1011. icon: createIcon(skill.kind),
  1012. };
  1013. frg.ap(tsp.skill.drop_refresh(dict));
  1014. break;
  1015. }
  1016. case SkillKinds.Drum: {
  1017. let dict = {
  1018. icon: createIcon(skill.kind),
  1019. };
  1020. frg.ap(tsp.skill.drum(dict));
  1021. break;
  1022. }
  1023. case SkillKinds.Board7x6: {
  1024. let dict = {
  1025. icon: createIcon(skill.kind),
  1026. };
  1027. frg.ap(tsp.skill.board7x6(dict));
  1028. break;
  1029. }
  1030. case SkillKinds.Vampire: { //吸血
  1031. let attr = skill.attr, damage = skill.damage, heal = skill.heal;
  1032. dict = {
  1033. icon: createIcon("heal", "hp-incr"),
  1034. target: tsp.target.enemy_one(),
  1035. damage: renderValue(damage),
  1036. attr: renderAttrs(attr, {affix: (attr === 'self' || attr === 'fixed') ? false : true}),
  1037. heal: renderValue(heal, {percent: true}),
  1038. };
  1039. frg.ap(tsp.skill.vampire(dict));
  1040. break;
  1041. }
  1042. case SkillKinds.CounterAttack: {
  1043. let attr = skill.attr, prob = skill.prob, value = skill.value;
  1044. dict = {
  1045. icon: createIcon("counter-attack"),
  1046. target: tsp.target.enemy(),
  1047. prob: prob.value < 1 ? tsp.value.prob({value: renderValue(prob, { percent:true })}) : null,
  1048. value: renderValue(value),
  1049. attr: renderAttrs(attr),
  1050. };
  1051. frg.ap(tsp.skill.counter_attack(dict));
  1052. break;
  1053. }
  1054. /*
  1055. case SkillKinds.ChangeOrbs: {
  1056. const { changes } = skill as Skill.ChangeOrbs;
  1057. return (
  1058. <span className="CardSkill-skill">
  1059. <AssetBox className="CardSkill-icon-box" title="Change orbs">
  1060. <Asset assetId="status-all-attrs" className="CardSkill-icon" />
  1061. <Asset assetId="overlay-heal" className="CardSkill-icon" />
  1062. </AssetBox>
  1063. <span className="CardSkill-item-list">
  1064. {changes.map((change, i) => {
  1065. switch (change.kind) {
  1066. case 'from':
  1067. return (
  1068. <span key={i}>
  1069. {renderOrbs(change.from)} &rArr; {renderOrbs(change.to)}
  1070. </span>
  1071. );
  1072. case 'gen':
  1073. return (
  1074. <span key={i}>
  1075. {renderOrbs(change.exclude).map((orb, j) => (
  1076. <AssetBox className="CardSkill-icon-box" key={j}>
  1077. {orb}
  1078. <Asset assetId="overlay-cross" className="CardSkill-icon" />
  1079. </AssetBox>
  1080. ))} &rArr; {renderOrbs(change.to)} &times; {change.count}
  1081. </span>
  1082. );
  1083. case 'fixed':
  1084. return (change.positions.length > 0 &&
  1085. <span key={i}>
  1086. {change.type === 'col' ? 'column' : 'row'}&nbsp;
  1087. {change.positions.map(p => p + 1).join(', ')}
  1088. &nbsp;&rArr; {renderOrbs(change.to)}
  1089. </span>
  1090. );
  1091. }
  1092. })}
  1093. </span>
  1094. </span>
  1095. );
  1096. }
  1097. case SkillKinds.Unbind: {
  1098. const { normal, awakenings } = skill as Skill.Unbind;
  1099. return (
  1100. <span className="CardSkill-skill CardSkill-item-list">
  1101. {!!normal && <span>
  1102. <Asset assetId="skill-unbind" className="CardSkill-icon" />
  1103. {normal} turns
  1104. </span>}
  1105. {!!awakenings && <span>
  1106. <AssetBox className="CardSkill-icon-box">
  1107. <Asset assetId="status-bind-awakenings" className="CardSkill-icon" />
  1108. <Asset assetId="overlay-heal" className="CardSkill-icon" />
  1109. </AssetBox>
  1110. {awakenings} turns
  1111. </span>}
  1112. </span>
  1113. );
  1114. }
  1115. case SkillKinds.OrbDropIncrease: {
  1116. const { attrs, value } = skill as Skill.OrbDropIncrease;
  1117. let attrElems: React.ReactNode[];
  1118. if (attrs === 'enhanced')
  1119. attrElems = [<Asset assetId="status-orb-enhanced" className="CardSkill-icon" key="enhanced" />];
  1120. else
  1121. attrElems = renderOrbs(attrs);
  1122. attrElems = attrElems.map((elem, i) => (
  1123. <AssetBox className="CardSkill-icon-box" key={i}>
  1124. {elem}
  1125. <Asset assetId="overlay-drop" className="CardSkill-icon" />
  1126. </AssetBox>
  1127. ));
  1128. return (
  1129. <span className="CardSkill-skill">
  1130. {attrElems}
  1131. {renderValue(value)}
  1132. </span>
  1133. );
  1134. }
  1135. case SkillKinds.VoidEnemyBuff: {
  1136. const { buffs } = skill as Skill.VoidEnemyBuff;
  1137. return (
  1138. <span className="CardSkill-skill">{
  1139. buffs.map(buff => {
  1140. switch (buff) {
  1141. case 'attr-absorb': return (
  1142. <AssetBox className="CardSkill-icon-box" key={buff}>
  1143. <Asset assetId="status-all-attrs" className="CardSkill-icon" />
  1144. <Asset assetId="overlay-heal" className="CardSkill-icon" />
  1145. <Asset assetId="overlay-cross" className="CardSkill-icon" style={{ opacity: 0.75 }} />
  1146. </AssetBox>
  1147. );
  1148. case 'damage-absorb': return (
  1149. <AssetBox className="CardSkill-icon-box" key={buff}>
  1150. <Asset assetId="status-damage-absorb" className="CardSkill-icon" />
  1151. <Asset assetId="overlay-cross" className="CardSkill-icon" style={{ opacity: 0.75 }} />
  1152. </AssetBox>
  1153. );
  1154. }
  1155. })
  1156. } </span>
  1157. );
  1158. }
  1159. case SkillKinds.ChangeAttribute: {
  1160. const { attr, target } = skill as Skill.ChangeAttribute;
  1161. return (
  1162. <span className="CardSkill-skill">
  1163. {target === 'self' && 'Self'}
  1164. {target === 'opponent' && 'enemy'}
  1165. &nbsp;&rArr; {renderAttrs(attr)}
  1166. </span>
  1167. );
  1168. }
  1169. case SkillKinds.SetOrbState: {
  1170. const { orbs, state } = skill as Skill.SetOrbState;
  1171. let orbElems: React.ReactNode[];
  1172. if (!orbs) {
  1173. orbElems = [<Asset assetId="orb-blind" className="CardSkill-icon" key="all" />];
  1174. } else {
  1175. orbElems = renderOrbs(orbs);
  1176. }
  1177. return (
  1178. <span className="CardSkill-skill">
  1179. {(state === 'enhanced' || state === 'locked') && orbElems}
  1180. {state === 'unlocked' && orbElems.map((elem, i) => (
  1181. <AssetBox className="CardSkill-icon-box" key={i}>
  1182. {elem}
  1183. <Asset assetId="orb-locked" className="CardSkill-icon" />
  1184. </AssetBox>
  1185. ))}
  1186. &rArr;
  1187. {state === 'enhanced' && orbElems.map((elem, i) => (
  1188. <AssetBox className="CardSkill-icon-box" key={i}>
  1189. {elem}
  1190. <Asset assetId="orb-enhanced" className="CardSkill-icon" />
  1191. </AssetBox>
  1192. ))}
  1193. {state === 'locked' && orbElems.map((elem, i) => (
  1194. <AssetBox className="CardSkill-icon-box" key={i}>
  1195. {elem}
  1196. <Asset assetId="orb-locked" className="CardSkill-icon" />
  1197. </AssetBox>
  1198. ))}
  1199. {state === 'unlocked' && orbElems}
  1200. </span>
  1201. );
  1202. }
  1203. case SkillKinds.RateMultiply: {
  1204. const { rate, value } = skill as Skill.RateMultiply;
  1205. return (
  1206. <span className="CardSkill-skill">
  1207. {rate === 'drop' && 'drop rate'}
  1208. {rate === 'coin' && 'coins'}
  1209. {rate === 'exp' && 'EXP'}
  1210. &nbsp;&times;&nbsp;
  1211. {renderValue(value)}
  1212. </span>
  1213. );
  1214. }
  1215. case SkillKinds.ReduceDamage: {
  1216. const { attrs, percent, condition } = skill as Skill.ReduceDamage;
  1217. return (
  1218. <span className="CardSkill-skill">
  1219. {!!condition && <>{renderCondition(condition)} &rArr; </>}
  1220. <Asset assetId="status-def" className="CardSkill-icon" />
  1221. {(Array.isArray(attrs) && !isEqual(attrs, Attributes.all())) && renderAttrs(attrs)}
  1222. {renderValue(percent)}
  1223. </span>
  1224. );
  1225. }
  1226. case SkillKinds.PowerUp: {
  1227. const { attrs, types, condition, value, reduceDamage } = skill as Skill.PowerUp;
  1228. const targets: React.ReactNode[] = [];
  1229. if (attrs && !isEqual(attrs, Attributes.all())) targets.push(...renderAttrs(attrs || []));
  1230. if (types) targets.push(...renderTypes(types || []));
  1231. return (
  1232. <span className="CardSkill-skill">
  1233. {condition && <>{renderCondition(condition)} &rArr; </>}
  1234. {targets.length > 0 && <>{targets}</>}
  1235. {!!value && renderPowerUp(value)}
  1236. {!!reduceDamage && <>
  1237. <Asset assetId="status-def" className="CardSkill-icon" />
  1238. {renderValue(reduceDamage)}
  1239. </>}
  1240. </span>
  1241. );
  1242. }
  1243. */
  1244. default: {
  1245. console.log("未处理的技能类型",skill.kind, skill);
  1246. frg.ap(skill.kind);
  1247. }
  1248. }
  1249. return frg;
  1250. };
  1251. function renderStat(stat, option) {
  1252. const frg = document.createDocumentFragment();
  1253. if (typeof localTranslating == "undefined") return frg;
  1254. const tspt = localTranslating.skill_parse.stats;
  1255. if (tspt[stat])
  1256. frg.ap(tspt[stat](option));
  1257. else
  1258. {
  1259. console.log("未知状态类型",stat);
  1260. frg.ap(tspt.unknown({ type: stat }));
  1261. }
  1262. return frg;
  1263. }
  1264. function renderAttrs(attrs, option = {}) {
  1265. if (!Array.isArray(attrs))
  1266. attrs = [attrs || 0];
  1267. const frg = document.createDocumentFragment();
  1268. if (typeof localTranslating == "undefined") return frg;
  1269. const tsp = localTranslating.skill_parse;
  1270. const contentFrg = attrs.map(attr => {
  1271. const icon = document.createElement("icon");
  1272. icon.className = "attr";
  1273. icon.setAttribute("data-attr-icon",attr);
  1274. return tsp.attrs[attr]({icon: icon});
  1275. })
  1276. .nodeJoin(tsp.word.slight_pause());
  1277. frg.ap(option.affix ? tsp.word.affix_attr({cotent: contentFrg}) : contentFrg);
  1278. return frg;
  1279. }
  1280. function renderOrbs(attrs, option = {}) {
  1281. if (!Array.isArray(attrs))
  1282. attrs = [attrs || 0];
  1283. const frg = document.createDocumentFragment();
  1284. if (typeof localTranslating == "undefined") return frg;
  1285. const tsp = localTranslating.skill_parse;
  1286. const contentFrg = attrs.map(attr => {
  1287. const icon = document.createElement("icon");
  1288. icon.className = "orb";
  1289. icon.setAttribute("data-orb-icon",attr);
  1290. return tsp.orbs[attr]({icon: icon});
  1291. })
  1292. .nodeJoin(tsp.word.slight_pause());
  1293. frg.ap(option.affix ? tsp.word.affix_attr({cotent: contentFrg}) : contentFrg);
  1294. return frg;
  1295. }
  1296. /*
  1297. function renderOrbs(attrs: Attributes | Attributes[]) {
  1298. if (!Array.isArray(attrs))
  1299. attrs = [attrs];
  1300. return attrs.map(attr => <Asset assetId={`orb-${attr}`} key={attr} className="CardSkill-icon" />);
  1301. }
  1302. function renderTypes(types: Types | Types[]) {
  1303. if (!Array.isArray(types))
  1304. types = [types];
  1305. return types.map(type => <Asset assetId={`type-${type}`} key={type} className="CardSkill-icon" />);
  1306. }
  1307. function renderCondition(cond: SkillCondition) {
  1308. if (cond.hp) {
  1309. if (cond.hp.min === cond.hp.max)
  1310. return <>{renderStat('hp')} = {formatNumber(cond.hp.min * 100)}%</>;
  1311. else if (cond.hp.min === 0)
  1312. return <>{renderStat('hp')} &le; {formatNumber(cond.hp.max * 100)}%</>;
  1313. else if (cond.hp.max === 1)
  1314. return <>{renderStat('hp')} &ge; {formatNumber(cond.hp.min * 100)}%</>;
  1315. else
  1316. return <>{renderStat('hp')} &in; [{formatNumber(cond.hp.min * 100)}%, {formatNumber(cond.hp.max * 100)}%]</>;
  1317. } else if (cond.useSkill) {
  1318. return <>use skill</>;
  1319. } else if (cond.multiplayer) {
  1320. return <>in multiplayer</>;
  1321. } else if (cond.remainOrbs) {
  1322. return <>&le; {cond.remainOrbs.count} orbs remain</>;
  1323. } else if (cond.exact) {
  1324. if (cond.exact.type === 'combo') {
  1325. return <>= {cond.exact.value} combos</>;
  1326. } else if (cond.exact.type === 'match-length') {
  1327. return <>= {cond.exact.value} {cond.exact.attrs === 'enhanced' ? 'Enhanced' : renderAttrs(cond.exact.attrs)} orbs</>;
  1328. }
  1329. } else if (cond.compo) {
  1330. return <>{cond.compo.type} [{cond.compo.ids.join()}] in team</>;
  1331. }
  1332. return <>[ unknown condition ]</>;
  1333. }
  1334. function renderPowerUp(powerUp: SkillPowerUp) {
  1335. function renderStats(hp: number, atk: number, rcv: number, mul = true) {
  1336. const operator = mul ? <>&times;</> : <>+</>;
  1337. let list: Array<['hp' | 'atk' | 'rcv', number]> = [['hp', hp], ['atk', atk], ['rcv', rcv]];
  1338. list = list.filter(([, value]) => value !== (mul ? 1 : 0));
  1339. if (list.length === 0) return null;
  1340. if (list.every(([, value]) => value === list[0][1])) {
  1341. return <>
  1342. {list.map(([name], i) => <React.Fragment key={name}>{i !== 0 && ', '}{renderStat(name)}</React.Fragment>)}
  1343. &nbsp;{operator} {formatNumber(list[0][1])}
  1344. </>;
  1345. } else {
  1346. return <>
  1347. {list.map(([name, value], i) => (
  1348. <React.Fragment key={name}>
  1349. {i !== 0 ? '; ' : ''}
  1350. {renderStat(name)}
  1351. &nbsp;{operator} {formatNumber(value)}
  1352. </React.Fragment>
  1353. ))}
  1354. </>;
  1355. }
  1356. }
  1357. switch (powerUp.kind) {
  1358. case SkillPowerUpKind.Multiplier: {
  1359. const { hp, atk, rcv } = powerUp as SkillPowerUp.Mul;
  1360. return renderStats(hp, atk, rcv);
  1361. }
  1362. case SkillPowerUpKind.ScaleAttributes: {
  1363. const { attrs, min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.ScaleAttrs;
  1364. return <>
  1365. &ge; {min} of [{renderAttrs(attrs)}] &rArr; {renderStats(1, baseAtk, baseRcv)}
  1366. {max !== min && <> for each &le; {max} attributes: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1367. </>;
  1368. }
  1369. case SkillPowerUpKind.ScaleCombos: {
  1370. const { min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.Scale;
  1371. return <>
  1372. &ge; {min} combos &rArr; {renderStats(1, baseAtk, baseRcv)}
  1373. {max !== min && <> for each &le; {max} combos: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1374. </>;
  1375. }
  1376. case SkillPowerUpKind.ScaleMatchAttrs: {
  1377. const { matches, min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.ScaleMultiAttrs;
  1378. return <>
  1379. &ge; {min} matches of [{matches.map((attrs, i) =>
  1380. <React.Fragment key={i}>{i !== 0 && ', '}{renderAttrs(attrs)}</React.Fragment>
  1381. )}] &rArr; {renderStats(1, baseAtk, baseRcv)}
  1382. {max !== min && <> for each &le; {max} matches: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1383. </>;
  1384. }
  1385. case SkillPowerUpKind.ScaleMatchLength: {
  1386. const { attrs, min, max, baseAtk, baseRcv, bonusAtk, bonusRcv } = powerUp as SkillPowerUp.ScaleAttrs;
  1387. return <>
  1388. &ge; {min} &times; {renderAttrs(attrs)} &rArr; {renderStats(1, baseAtk, baseRcv)}
  1389. {max !== min && <> for each &le; {max} orbs: {renderStats(0, bonusAtk, bonusRcv, false)}</>}
  1390. </>;
  1391. }
  1392. case SkillPowerUpKind.ScaleCross: {
  1393. const { crosses } = powerUp as SkillPowerUp.ScaleCross;
  1394. return crosses.map(({ single, attr, mul }, i) => <React.Fragment key={i}>
  1395. {i !== 0 && ', '}
  1396. {mul !== 1 && <>{renderStat('atk')} &times; {formatNumber(mul)} </>}
  1397. {single ? 'when' : 'for each'} cross of {renderAttrs(attr)}
  1398. </React.Fragment>);
  1399. }
  1400. case SkillPowerUpKind.ScaleAwakenings: {
  1401. const { awakenings, value } = powerUp as SkillPowerUp.ScaleAwakenings;
  1402. return <>
  1403. {renderStat('atk')} &times; {formatNumber(value - 1)} for each {awakenings.map(id =>
  1404. <Asset assetId={`awakening-${id}`} className="CardSkill-icon" key={id} />
  1405. )}
  1406. </>;
  1407. }
  1408. default:
  1409. return <>[ unknown power up ]</>;
  1410. }
  1411. }
  1412. */
  1413. function renderValue(_value, option = {}) {
  1414. const frg = document.createDocumentFragment();
  1415. if (typeof localTranslating == "undefined") return frg;
  1416. const tsp = localTranslating.skill_parse
  1417. const tspv = tsp.value;
  1418. const od = option.decimalDigits, os = option.plusSign;
  1419. let dict;
  1420. switch (_value.kind) {
  1421. case SkillValueKind.Percent: {
  1422. dict = {
  1423. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1424. };
  1425. frg.ap(
  1426. option.percent ?
  1427. tspv.mul_percent(dict) :
  1428. tspv.mul_times(dict)
  1429. );
  1430. break;
  1431. }
  1432. case SkillValueKind.Constant: {
  1433. dict = {
  1434. value: _value.value.keepCounts(od,os),
  1435. unit: option.unit ? option.unit() : undefined,
  1436. };
  1437. frg.ap(tspv.const(dict));
  1438. break;
  1439. }
  1440. case SkillValueKind.ConstantTo: {
  1441. dict = {
  1442. value: _value.value.keepCounts(od,os)
  1443. };
  1444. frg.ap(tspv.const_to(dict));
  1445. break;
  1446. }
  1447. case SkillValueKind.xMaxHP: {
  1448. dict = {
  1449. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1450. stats: renderStat('maxhp'),
  1451. };
  1452. frg.ap(
  1453. option.percent ?
  1454. tspv.mul_of_percent(dict) :
  1455. tspv.mul_of_times(dict)
  1456. );
  1457. break;
  1458. }
  1459. case SkillValueKind.xHP: {
  1460. dict = {
  1461. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1462. stats: renderStat('hp'),
  1463. };
  1464. frg.ap(
  1465. option.percent ?
  1466. tspv.mul_of_percent(dict) :
  1467. tspv.mul_of_times(dict)
  1468. );
  1469. break;
  1470. }
  1471. case SkillValueKind.xATK: {
  1472. dict = {
  1473. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1474. stats: renderStat('atk'),
  1475. };
  1476. frg.ap(
  1477. option.percent ?
  1478. tspv.mul_of_percent(dict) :
  1479. tspv.mul_of_times(dict)
  1480. );
  1481. break;
  1482. }
  1483. case SkillValueKind.xRCV: {
  1484. dict = {
  1485. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1486. stats: renderStat('rcv'),
  1487. };
  1488. frg.ap(
  1489. option.percent ?
  1490. tspv.mul_of_percent(dict) :
  1491. tspv.mul_of_times(dict)
  1492. );
  1493. break;
  1494. }
  1495. case SkillValueKind.xTeamHP: {
  1496. let value = _value.value;
  1497. dict = {
  1498. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  1499. stats: renderStat('teamhp'),
  1500. };
  1501. frg.ap(
  1502. option.percent ?
  1503. tspv.mul_of_percent(dict) :
  1504. tspv.mul_of_times(dict)
  1505. );
  1506. break;
  1507. }
  1508. case SkillValueKind.xTeamRCV: {
  1509. dict = {
  1510. value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
  1511. stats: renderStat('teamrcv'),
  1512. };
  1513. frg.ap(
  1514. option.percent ?
  1515. tspv.mul_of_percent(dict) :
  1516. tspv.mul_of_times(dict)
  1517. );
  1518. break;
  1519. }
  1520. case SkillValueKind.xTeamATK: {
  1521. let attrs = _value.attrs, value = _value.value;
  1522. dict = {
  1523. value: option.percent ? (value * 100).keepCounts(od,os) : value.keepCounts(od,os),
  1524. stats: renderStat('teamatk', {attrs: renderAttrs(attrs, {affix: true})}),
  1525. };
  1526. frg.ap(
  1527. option.percent ?
  1528. tspv.mul_of_percent(dict) :
  1529. tspv.mul_of_times(dict)
  1530. );
  1531. break;
  1532. }
  1533. case SkillValueKind.HPScale: {
  1534. let min = _value.min, max = _value.max;
  1535. dict = {
  1536. min: tspv.mul_of_times({value: min.keepCounts(od,os), stats:renderStat('atk')}),
  1537. max: tspv.mul_of_times({value: max.keepCounts(od,os), stats:renderStat('atk')}),
  1538. hp: renderStat('hp'),
  1539. };
  1540. frg.ap(tspv.hp_scale(dict));
  1541. break;
  1542. }
  1543. case SkillValueKind.RandomATK: {
  1544. let min = _value.min, max = _value.max;
  1545. dict = {
  1546. min: min.keepCounts(od,os),
  1547. atk: renderStat('atk'),
  1548. };
  1549. if (max != min)
  1550. {
  1551. dict.max = tsp.word.range_hyphen().ap(max.keepCounts(od,os));
  1552. }
  1553. frg.ap(tspv.random_atk(dict));
  1554. break;
  1555. }
  1556. /*
  1557. case SkillValueKind.RandomATK: {
  1558. const { min, max } = _value as SkillValue.Scale;
  1559. if (min === max) {
  1560. return <span>{formatNumber(min)} &times; {renderStat('atk')}</span>;
  1561. } else {
  1562. return <span>(random &times; {formatNumber(min)} &hArr; {formatNumber(max)}) &times; {renderStat('atk')}</span>;
  1563. }
  1564. }
  1565. case SkillValueKind.xAwakenings: {
  1566. const { value, awakenings } = _value as SkillValue.WithAwakenings;
  1567. return <span>{formatNumber(value * 100)}% &times; each of {awakenings.map(id =>
  1568. <Asset assetId={`awakening-${id}`} className="CardSkill-icon" key={id} />
  1569. )}</span>;
  1570. }
  1571. */
  1572. default: {
  1573. console.log("未知数值类型",_value.kind, _value);
  1574. frg.ap(tspv.unknown({ type: _value.kind }));
  1575. }
  1576. }
  1577. return frg;
  1578. }

智龙迷城队伍图制作工具