You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
586 B

  1. define([
  2. '../config/slots'
  3. ], function(
  4. configSlots
  5. ) {
  6. var chances = [];
  7. for (var c in configSlots.chance) {
  8. var rolls = configSlots.chance[c];
  9. for (var i = 0; i < rolls; i++) {
  10. chances.push(c);
  11. }
  12. }
  13. var generator = {
  14. generate: function(item, blueprint) {
  15. if (blueprint.slot)
  16. item.slot = blueprint.slot;
  17. else
  18. item.slot = chances[~~(Math.random() * chances.length)];
  19. if (!blueprint.statMult)
  20. blueprint.statMult = {};
  21. if (!blueprint.statMult.armor)
  22. blueprint.statMult.armor = configSlots.armorMult[item.slot];
  23. }
  24. };
  25. return generator;
  26. });