utils = {
function isRelic(obj) {
return obj?.itemName.toLowerCase().includes("relic");
}
function groupBy(list, func, groupValueNotKey = true) {
const result = {};
for (const [k, v] of list.entries()) {
let index = func(v, k);
if (!Array.isArray(result[index])) {
result[index] = [];
}
result[index].push(groupValueNotKey ? v : k);
}
return result;
}
function getAverageRotationChance(gamemode){
if(gamemode === 'Disruption') return (a,b,c)=>c
if(gamemode.toLowerCase().includes('caches')) return (a,b,c)=>(a+b+c)/3
if(gamemode.toLowerCase().includes('sabotage')) return (a,b,c)=>(a+b+c)/3
if(['Rescue', 'Spy', 'Rush'].some(it=> it === gamemode)) return (a,b,c)=>(a+b+c)/3
return (a,b,c)=>(a+a+b+c)/4
}
function getAverageRotationChanceFactor(gamemode, rotation){
if(gamemode === 'Disruption') {
if (rotation !== 'C'){
return 0
} else {
return 1
}
}
if(gamemode.toLowerCase().includes('caches')) return 1/3
if(['Rescue', 'Spy', 'Rush'].some(it=> it === gamemode)) return 1/3
if (rotation === 'A'){
return 0.5
} else {
return 0.25
}
}
return {
isRelic,
groupBy,
getAverageRotationChance,
getAverageRotationChanceFactor,
};
}