Skip to content

Commit

Permalink
Add contract to Compare Players
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Dec 10, 2024
1 parent 61985c5 commit 9ff8463
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
5 changes: 2 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
have the players’ contracts on the Compare Players screen https://old.reddit.com/r/BasketballGM/comments/1ggtvkv/monthly_suggestions_thread/luz5409/
make player graphs remember selections https://old.reddit.com/r/BasketballGM/comments/1gplx7g/could_you_make_the_player_graphs_remember_what/
- other pages?

FBGM - declines penalty when it would have given untimed down in 4th quarter with a chance to win https://discord.com/channels/290013534023057409/290015591216054273/1313017959035179008

Expand Down Expand Up @@ -303,8 +304,6 @@ compare players http://www.reddit.com/r/BasketballGM/comments/1saclf/suggestion_
- needs to know pid/playoffs/season for each row, could put in metadata
- replace existing links, such as award races
- could implement as "compare highlighted players", would also need a "clear highlight", idk
- for current players, show contract and team, if current year or career is selected? https://old.reddit.com/r/BasketballGM/comments/1bdi7eg/version_202403130000_new_compare_players_feature/kun5sce/?context=3
- handle free agent contracts

jersey numbers by position and frequency
- football - classic numbers more popular
Expand Down
43 changes: 43 additions & 0 deletions src/ui/views/ComparePlayers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { groupByUnique } from "../../../common/utils";
import PlayersForm from "./PlayersForm";
import CollapseArrow from "../../components/CollapseArrow";
import { lowerIsBetter } from "../../../common/lowerIsBetter";
import { Contract, ContractAmount } from "../../components/contract";

type PlayerInfo = View<"comparePlayers">["players"][number];
type PlayerInfoAndLegend =
Expand Down Expand Up @@ -211,6 +212,7 @@ const useManualSticky = (element: HTMLElement | null, top: number) => {

const ComparePlayers = ({
challengeNoRatings,
currentSeason,
initialAvailablePlayers,
players,
ratings,
Expand Down Expand Up @@ -292,6 +294,41 @@ const ComparePlayers = ({
/>
);

const contractValues = playersToValues(playersAndLegend, (p, i) => {
const season = playersAndLegend[i].season;

if (
p.tid === PLAYER.UNDRAFTED ||
(typeof season === "number" && season <= p.draft.year) ||
(season === "career" && p.salariesTotal === 0)
) {
return null;
}

if (season === "career") {
return <ContractAmount p={p} override={p.salariesTotal} />;
}

if (season !== currentSeason) {
return <ContractAmount p={p} />;
}

if (p.tid === PLAYER.FREE_AGENT) {
return (
<>
<Contract p={p} /> (FA)
</>
);
}

return <Contract p={p} />;
});

// Only show contract if there is a non-null value for some player
const showContracts = contractValues.some(
value => value !== null && value !== "legend",
);

return (
<>
{playersForm}
Expand Down Expand Up @@ -378,6 +415,12 @@ const ComparePlayers = ({
sortType="draftPick"
sortAsc
/>
{showContracts ? (
<InfoRow
col={getCols(["Contract"])[0]}
values={contractValues}
/>
) : null}
</>
) : null}
{challengeNoRatings &&
Expand Down
4 changes: 4 additions & 0 deletions src/worker/views/comparePlayers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ const updateComparePlayers = async (
"tid",
"experience",
"awards",
"contract",
"salaries",
"salariesTotal",
],
ratings: ["season", "pos", "ovr", "pot", ...RATINGS],
stats: allStats,
Expand Down Expand Up @@ -429,6 +432,7 @@ const updateComparePlayers = async (

return {
challengeNoRatings: g.get("challengeNoRatings"),
currentSeason: g.get("season"),
initialAvailablePlayers,
players,
ratings,
Expand Down

0 comments on commit 9ff8463

Please sign in to comment.