heroesHelper.js 764 B

12345678910111213141516171819202122232425262728
  1. export const initHeroesFromJson = function(allHeroesJson) {
  2. let abilitiesMap = new Map();
  3. allHeroesJson.abilities.forEach(ability => {
  4. abilitiesMap.set(ability.abilityName, {
  5. name: ability.abilityName,
  6. hook: ability.abilityHook,
  7. isOptionnal: ability.optionnal,
  8. desc: ability['abilityDesc-FR']
  9. });
  10. });
  11. let heroesSet = new Set();
  12. allHeroesJson.heroes.forEach(hero => {
  13. let i = 0;
  14. while (i < hero.nbInDeck) {
  15. heroesSet.add({
  16. name: hero.name,
  17. cost: hero.cost,
  18. power: hero.power,
  19. faction: hero.faction,
  20. ability: abilitiesMap.get(hero.ability),
  21. isDraftable: hero.draftMode,
  22. popularity: hero.popularity
  23. });
  24. i++;
  25. }
  26. });
  27. return heroesSet;
  28. };