Skip to content

Commit

Permalink
Slightly more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 20, 2024
1 parent a4373b0 commit 8e754ce
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/worker/core/player/genRatings.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const typeFactors: Record<
},
};

const athleticismRatings = new Set(["stre", "spd", "jmp", "endu", "dnk"]);
const shootingRatings = new Set(["ft", "fg", "tp"]);
const skillRatings = new Set(["oiq", "diq", "drb", "pss", "reb"]); // ins purposely left out

const genRatings = (
season: number,
scoutingLevel: number,
Expand Down Expand Up @@ -112,19 +116,16 @@ const genRatings = (
const factorShooting = helpers.bound(random.realGauss(1, 0.2), 0.2, 1.2);
const factorSkill = helpers.bound(random.realGauss(1, 0.2), 0.2, 1.2);
const factorIns = helpers.bound(random.realGauss(1, 0.2), 0.2, 1.2);
const athleticismRatings = ["stre", "spd", "jmp", "endu", "dnk"];
const shootingRatings = ["ft", "fg", "tp"];
const skillRatings = ["oiq", "diq", "drb", "pss", "reb"]; // ins purposely left out

for (const key of helpers.keys(rawRatings)) {
const typeFactor = typeFactors[type]?.[key] ?? 1;
const typeFactor = typeFactors[type][key] ?? 1;
let factor = factorIns;

if (athleticismRatings.includes(key)) {
if (athleticismRatings.has(key)) {
factor = factorAthleticism;
} else if (shootingRatings.includes(key)) {
} else if (shootingRatings.has(key)) {
factor = factorShooting;
} else if (skillRatings.includes(key)) {
} else if (skillRatings.has(key)) {
factor = factorSkill;
}

Expand Down

0 comments on commit 8e754ce

Please sign in to comment.