Skip to content

Commit

Permalink
Upcoming Free Agents should not show other team free agents as loyal …
Browse files Browse the repository at this point in the history
…to your team during the re-signing phase
  • Loading branch information
dumbmatter committed Dec 12, 2024
1 parent dbd3325 commit 412b7e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
there is "loyalty to current team" in projected mood toward your team in upcoming FA page https://discord.com/channels/290013534023057409/290015591216054273/1315482039918526584

make player graphs remember selections https://old.reddit.com/r/BasketballGM/comments/1gplx7g/could_you_make_the_player_graphs_remember_what/
- other pages?

Expand Down
14 changes: 11 additions & 3 deletions src/worker/core/player/moodComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { facilitiesEffectMood } from "../../../common/budgetLevels";
import type { MoodComponents, Player } from "../../../common/types";
import { idb } from "../../db";
import { g, helpers, local } from "../../util";
import { getNegotiationPids } from "../../views/negotiationList";

const getMinFractionDiff = async (pid: number, tid: number) => {
if (!isSport("basketball")) {
Expand Down Expand Up @@ -259,11 +260,18 @@ const moodComponents = async (
const numSeasonsWithTeam = p.stats.filter(row => row.tid === tid).length;
components.loyalty = numSeasonsWithTeam / 8;

let wantsToReSign = p.tid === tid;
if (
p.tid === tid ||
(p.tid === PLAYER.FREE_AGENT && phase === PHASE.RESIGN_PLAYERS)
!wantsToReSign &&
p.tid === PLAYER.FREE_AGENT &&
phase === PHASE.RESIGN_PLAYERS
) {
// Wants to re-sign
// Is this a free agent that a user team can re-sign? If so, apply bonus only for that team.
const negotiationPids = await getNegotiationPids(tid);
wantsToReSign = negotiationPids.has(p.pid);
}

if (wantsToReSign) {
components.loyalty += isSport("football") ? 5 : 2;
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/worker/views/negotiationList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@ import { g } from "../util";
import addFirstNameShort from "../util/addFirstNameShort";
import { addMood, freeAgentStats } from "./freeAgents";

export const getNegotiationPids = async (tid: number) => {
const negotiations = await idb.cache.negotiations.getAll();

// Need to check tid for Multi Team Mode, might have other team's negotiations going on
return new Set(
negotiations
.filter(negotiation => negotiation.tid === tid)
.map(negotiation => negotiation.pid),
);
};

const updateNegotiationList = async () => {
const stats = ["yearsWithTeam", ...freeAgentStats];

const userTid = g.get("userTid");

let negotiations = await idb.cache.negotiations.getAll();
const negotiationPids = await getNegotiationPids(userTid);

// For Multi Team Mode, might have other team's negotiations going on
negotiations = negotiations.filter(
negotiation => negotiation.tid === userTid,
);
const negotiationPids = negotiations.map(negotiation => negotiation.pid);
const userPlayersAll = await idb.cache.players.indexGetAll(
"playersByTid",
userTid,
);
const playersAll = await addMood(
(
await idb.cache.players.indexGetAll("playersByTid", PLAYER.FREE_AGENT)
).filter(p => negotiationPids.includes(p.pid)),
).filter(p => negotiationPids.has(p.pid)),
);

const players = addFirstNameShort(
Expand Down

0 comments on commit 412b7e9

Please sign in to comment.