1 |
- {"version":3,"sources":["../../src/client-server-shared/heroesHelper.js"],"names":["shuffle","a","i","length","j","Math","floor","random","initHeroesFromJson","allHeroesJson","abilitiesMap","Map","abilities","forEach","ability","set","abilityName","name","hook","abilityHook","isOptionnal","optionnal","desc","heroesSet","Set","heroes","hero","nbInDeck","add","cost","power","faction","get","isDraftable","draftMode","popularity","getRandomHeroesByFaction","allHeroes","factionArray","filter","getDraftSets","heroesDraftable","shuffledHeroes","draftSets","slice"],"mappings":";;;;;;;AAAA,SAASA,OAAT,CAAiBC,CAAjB,EAAoB;AAClB,OAAK,IAAIC,CAAC,GAAGD,CAAC,CAACE,MAAF,GAAW,CAAxB,EAA2BD,CAAC,GAAG,CAA/B,EAAkCA,CAAC,EAAnC,EAAuC;AACrC,QAAME,CAAC,GAAGC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,MAAiBL,CAAC,GAAG,CAArB,CAAX,CAAV;AADqC,eAEtB,CAACD,CAAC,CAACG,CAAD,CAAF,EAAOH,CAAC,CAACC,CAAD,CAAR,CAFsB;AAEpCD,IAAAA,CAAC,CAACC,CAAD,CAFmC;AAE9BD,IAAAA,CAAC,CAACG,CAAD,CAF6B;AAGtC;;AACD,SAAOH,CAAP;AACD;;AAEM,IAAMO,kBAAkB,GAAG,SAArBA,kBAAqB,CAASC,aAAT,EAAwB;AACxD,MAAIC,YAAY,GAAG,IAAIC,GAAJ,EAAnB;AACAF,EAAAA,aAAa,CAACG,SAAd,CAAwBC,OAAxB,CAAgC,UAAAC,OAAO,EAAI;AACzCJ,IAAAA,YAAY,CAACK,GAAb,CAAiBD,OAAO,CAACE,WAAzB,EAAsC;AACpCC,MAAAA,IAAI,EAAEH,OAAO,CAACE,WADsB;AAEpCE,MAAAA,IAAI,EAAEJ,OAAO,CAACK,WAFsB;AAGpCC,MAAAA,WAAW,EAAEN,OAAO,CAACO,SAHe;AAIpCC,MAAAA,IAAI,EAAER,OAAO,CAAC,gBAAD;AAJuB,KAAtC;AAM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AIE,SAAS,GAAG,CAACD,cAAc,CAACE,KAAf,CAAqB,CAArB,EAAwB,EAAxB,CAAD,EAA8BF,cAAc,CAACE,KAAf,CAAqB,EAArB,EAAyB,EAAzB,CAA9B,CAAhB;AACA,SAAOD,SAAP;AACD,CAVM","sourcesContent":["function shuffle(a) {\r\n for (let i = a.length - 1; i > 0; i--) {\r\n const j = Math.floor(Math.random() * (i + 1));\r\n [a[i], a[j]] = [a[j], a[i]];\r\n }\r\n return a;\r\n}\r\n\r\nexport const initHeroesFromJson = function(allHeroesJson) {\r\n let abilitiesMap = new Map();\r\n allHeroesJson.abilities.forEach(ability => {\r\n abilitiesMap.set(ability.abilityName, {\r\n name: ability.abilityName,\r\n hook: ability.abilityHook,\r\n isOptionnal: ability.optionnal,\r\n desc: ability['abilityDesc-FR']\r\n });\r\n });\r\n let heroesSet = new Set();\r\n allHeroesJson.heroes.forEach(hero => {\r\n let i = 0;\r\n while (i < hero.nbInDeck) {\r\n heroesSet.add({\r\n name: hero.name,\r\n cost: hero.cost,\r\n power: hero.power,\r\n faction: hero.faction,\r\n ability: abilitiesMap.get(hero.ability),\r\n isDraftable: hero.draftMode,\r\n popularity: hero.popularity\r\n });\r\n i++;\r\n }\r\n });\r\n return heroesSet;\r\n};\r\nexport const getRandomHeroesByFaction = function(allHeroes, faction) {\r\n let factionArray = allHeroes.filter(hero => {\r\n return hero.faction === faction;\r\n });\r\n return shuffle(factionArray);\r\n};\r\nexport const getDraftSets = function(allHeroes) {\r\n let heroesDraftable = allHeroes.filter(hero => {\r\n return hero.isDraftable === true;\r\n });\r\n\r\n let shuffledHeroes = shuffle(heroesDraftable);\r\n\r\n // Return two sets of 12 heroes for draft mode\r\n let draftSets = [shuffledHeroes.slice(0, 11), shuffledHeroes.slice(12, 23)];\r\n return draftSets;\r\n};\r\n"],"file":"heroesHelper.js"}
|