25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

165 lines
4.1 KiB

  1. define([
  2. '../config/prefixes',
  3. '../config/suffixes'
  4. ], function (
  5. prefixes,
  6. suffixes
  7. ) {
  8. return {
  9. generators: [
  10. 'basic', ['basic'],
  11. ['gPrefix', 'gSuffix'],
  12. ['gPrefix', 'gSuffix'],
  13. ['gPrefix', 'gSuffix']
  14. ],
  15. prefixes: {
  16. vit: 'Healthy',
  17. regenHp: 'Regenerating',
  18. manaMax: `Caster's`,
  19. regenMana: 'Tapping',
  20. str: 'Brutal',
  21. int: 'Wise',
  22. dex: 'Agile',
  23. addArmor: 'Plated',
  24. addCritChance: 'Precise',
  25. addCritMultiplier: 'Piercing',
  26. magicFind: `Seeker's`,
  27. sprintChance: `Traveler's`,
  28. dmgPercent: 'Powerful',
  29. allAttributes: 'Hybrid',
  30. elementArcanePercent: 'Volatile',
  31. elementFrostPercent: 'Frigid',
  32. elementFirePercent: 'Burning',
  33. elementHolyPercent: 'Righteous',
  34. elementPhysicalPercent: `Brawler's`,
  35. elementPoisonPercent: 'Bubbling',
  36. elementArcaneResist: 'Protective',
  37. elementFrostResist: 'Protective',
  38. elementFireResist: 'Protective',
  39. elementHolyResist: 'Protective',
  40. elementPhysicalResist: `Protective`,
  41. elementPoisonResist: 'Protective',
  42. elementAllResist: 'Protective',
  43. xpIncrease: `Scholar's`,
  44. lvlRequire: 'Elementary'
  45. },
  46. suffixes: {
  47. vit: 'Health',
  48. regenHp: 'Regeneration',
  49. manaMax: 'Mana',
  50. regenMana: 'Orbs',
  51. str: 'the Titan',
  52. int: 'Angels',
  53. dex: 'the Assassin',
  54. addArmor: 'the Fortress',
  55. addCritChance: 'Pain',
  56. addCritMultiplier: 'Ferocity',
  57. magicFind: 'Luck',
  58. sprintChance: 'Haste',
  59. dmgPercent: 'Power',
  60. allAttributes: 'Divergence',
  61. elementArcanePercent: 'the Magi',
  62. elementFrostPercent: 'Winter',
  63. elementFirePercent: 'the Inferno',
  64. elementHolyPercent: 'the Gods',
  65. elementPhysicalPercent: 'Combat',
  66. elementPoisonPercent: 'Poison',
  67. elementArcaneResist: 'Arcane Resistance',
  68. elementFrostResist: 'Frost Resistance',
  69. elementFireResist: 'Fire Resistance',
  70. elementHolyResist: 'Holy Resistance',
  71. elementPhysicalResist: `Physical Resistance`,
  72. elementPoisonResist: 'Poison Resistance',
  73. elementAllResist: 'Arcane Resistance',
  74. xpIncrease: 'Experience',
  75. lvlRequire: 'Ease'
  76. },
  77. generate: function(item, blueprint) {
  78. if (blueprint.name) {
  79. item.name = blueprint.name;
  80. return;
  81. } else if (blueprint.noName) {
  82. item.name = item.type;
  83. return;
  84. }
  85. var gen = this.generators[item.quality];
  86. if (!(gen instanceof Array))
  87. gen = [gen];
  88. gen.forEach(g => this.types[g].call(this, item, blueprint));
  89. },
  90. types: {
  91. basic: function (item, blueprint) {
  92. item.name = item.type;
  93. },
  94. prefix: function (item, blueprint) {
  95. var maxStat = '';
  96. var maxValue = 0;
  97. for (var s in item.stats) {
  98. if ((item.stats[s] > maxValue) && (this.prefixes[s])) {
  99. maxValue = item.stats[s];
  100. maxStat = s;
  101. }
  102. }
  103. item.name = this.prefixes[maxStat] + ' ' + item.name;
  104. },
  105. suffix: function (item, blueprint) {
  106. var stats = [];
  107. for (var s in item.stats) {
  108. if (this.suffixes[s])
  109. stats.push({
  110. stat: s,
  111. value: item.stats[s]
  112. });
  113. }
  114. stats.sort((a, b) => b.value - a.value);
  115. var useIndex = 1;
  116. if (useIndex >= stats.length)
  117. useIndex = 0;
  118. item.name = item.name + ' of ' + this.suffixes[stats[useIndex].stat];
  119. },
  120. gPrefix: function (item, blueprint) {
  121. var list = prefixes.generic.concat(prefixes.slots[item.slot] || []);
  122. if (item.stats.armor)
  123. list = list.concat(prefixes.armor);
  124. else if (item.slot == 'twoHanded')
  125. list = list.concat(prefixes.weapons);
  126. var pick = list[~~(Math.random() * list.length)];
  127. item.name = pick[0].toUpperCase() + pick.substr(1);
  128. if (item.name.indexOf('%') > -1) {
  129. var replacer = (Math.random() < 0.5) ? `'s` : '';
  130. item.name = item.name.split('%').join(replacer);
  131. }
  132. },
  133. gSuffix: function (item, blueprint) {
  134. var list = null;
  135. if (item.slot == 'tool') {
  136. list = suffixes.slots.tool;
  137. } else {
  138. list = suffixes.generic.concat(suffixes.slots[item.slot] || []);
  139. if (item.stats.armor)
  140. list = list.concat(suffixes.armor);
  141. else if (item.slot == 'twoHanded')
  142. list = list.concat(suffixes.weapons);
  143. }
  144. var pick = list[~~(Math.random() * list.length)];
  145. item.name += ' ' + pick[0].toUpperCase() + pick.substr(1);
  146. }
  147. }
  148. };
  149. });