Skip to content

Commit

Permalink
Expense levels
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed May 6, 2024
1 parent 85f06f3 commit 185f0aa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ team graphs https://old.reddit.com/r/BasketballGM/comments/1bsp3ji/monthly_sugge
- DRY with powerRankings code, avgAge too
- getFormattedStat for all of them
- finances
- expense levels
- DRY with leagueFinances, make sure it's using current values for this season
- rounding of large units in axis ticks and tooltip
- getFormattedStat for all of them
- does playoffs dropdown make sense for any of these except stats? not really
Expand Down
8 changes: 8 additions & 0 deletions src/ui/views/TeamGraphs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const addPrefixForStat = (statType: string, stat: string) => {
cash: "Cash",
pop: "Pop",
payrollOrSalaryPaid: "Payroll",
scoutingLevel: "Scouting",
coachingLevel: "Coaching",
healthLevel: "Health",
facilitiesLevel: "Facilities",
};

return overrides[stat] ?? stat;
Expand Down Expand Up @@ -98,6 +102,10 @@ const getStatsWithLabels = (
};

const getStatFromTeam = (t: any, stat: string, statType: string) => {
if (statType === "finances" && stat.endsWith("Level")) {
const key = stat.replace("Level", "");
return t.seasonAttrs.expenseLevels[key];
}
if (
statType == "standings" ||
statType === "powerRankings" ||
Expand Down
26 changes: 19 additions & 7 deletions src/worker/views/teamGraphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ export const getStats = (statTypePlus: string) => {
} else if (statTypePlus === "powerRankings") {
return ["avgAge"];
} else if (statTypePlus === "finances") {
return ["pop", "att", "revenue", "profit", "cash", "payrollOrSalaryPaid"];
return [
"pop",
"att",
"revenue",
"profit",
"cash",
"payrollOrSalaryPaid",
"scoutingLevel",
"coachingLevel",
"healthLevel",
"facilitiesLevel",
];
} else {
const statsTable = getStatsTableByType(statTypePlus);
if (!statsTable) {
Expand Down Expand Up @@ -94,12 +105,13 @@ const getTeamStats = async (

const stats = getStats(statTypePlus);

if (
statTypePlus === "standings" ||
statTypePlus === "powerRankings" ||
statTypePlus === "finances"
) {
seasonAttrs.push(...(stats as any));
if (statTypePlus === "standings" || statTypePlus === "powerRankings") {
seasonAttrs.push(...(stats as any[]));
} else if (statTypePlus === "finances") {
seasonAttrs.push(
...(stats as any[]).filter(stat => !stat.endsWith("Level")),
"expenseLevels",
);
}

const teams = await idb.getCopies.teamsPlus(
Expand Down

0 comments on commit 185f0aa

Please sign in to comment.