diff --git a/src/common/defaultGameAttributes.ts b/src/common/defaultGameAttributes.ts index d329cbec38..1badf9da40 100644 --- a/src/common/defaultGameAttributes.ts +++ b/src/common/defaultGameAttributes.ts @@ -64,6 +64,7 @@ const defaultGameAttributes: GameAttributesLeagueWithHistory = { numGames: 82, // per season numGamesDiv: 16, numGamesConf: 36, + tradeMatchingPercentage: 125, otherTeamsWantToHire: false, numPeriods: 4, // per game quarterLength: 12, // [minutes] diff --git a/src/common/types.ts b/src/common/types.ts index afdcc11ad1..c0cf1c5f49 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -507,6 +507,7 @@ export type GameAttributesLeague = { numGames: number; numGamesDiv: number | null; numGamesConf: number | null; + tradeMatchingPercentage: number; numGamesPlayoffSeries: number[]; numPeriods: number; numPlayersDunk: number; @@ -554,6 +555,7 @@ export type GameAttributesLeague = { stopOnInjury: boolean; stopOnInjuryGames: number; tiebreakers: (keyof typeof TIEBREAKERS)[]; + teamInfoCache: { abbrev: string; region: string; @@ -1212,8 +1214,6 @@ export type Local = { autoPlayUntil?: { season: number; phase: number; - - // Time in milliseconds of the start of auto play start: number; }; autoSave: boolean; @@ -1714,5 +1714,3 @@ export type HeadToHead = { > >; }; - -export type GetCopyType = "noCopyCache"; diff --git a/src/ui/views/Settings/settings.tsx b/src/ui/views/Settings/settings.tsx index 8b4adb7c19..f2cc69834c 100644 --- a/src/ui/views/Settings/settings.tsx +++ b/src/ui/views/Settings/settings.tsx @@ -994,6 +994,7 @@ export const settings: {

), + validator: value => { if (value > 1) { throw new Error("Value cannot be greater than 1"); @@ -1003,6 +1004,24 @@ export const settings: { } }, }, + { + category: "Schedule", + key: "tradeMatchingPercentage", + name: "Trade Matching Percentage", + godModeRequired: "existingLeagueOnly", + type: "int", + descriptionLong: ( + <> +

+ Set this to whatever value you want for the trades to match + contract-wise. In real life, the percentage is 125%, but this allows + you to modify this. +

+ +

Set this to 0 to turn off the rule

+ + ), + }, { category: "Playoffs", key: "playoffsByConf", diff --git a/src/worker/core/trade/summary.ts b/src/worker/core/trade/summary.ts index 2c3ef43233..76faa37b45 100644 --- a/src/worker/core/trade/summary.ts +++ b/src/worker/core/trade/summary.ts @@ -2,6 +2,8 @@ import { team } from ".."; import { idb } from "../../db"; import { g, helpers } from "../../util"; import type { TradeSummary, TradeTeams } from "../../../common/types"; +import { league } from "src/worker/core"; +league.loadGameAttributes(); /** * Create a summary of the trade, for eventual display to the user. @@ -101,9 +103,13 @@ const summary = async (teams: TradeTeams): Promise => { } }), ); + if (g.get("tradeMatchingPercentage") === 0) { + return s; + } const softCapCondition = !g.get("hardCap") && - ((ratios[0] > 125 && overCap[0]) || (ratios[1] > 125 && overCap[1])); + ((ratios[0] > g.get("tradeMatchingPercentage") && overCap[0]) || + (ratios[1] > g.get("tradeMatchingPercentage") && overCap[1])); const overCapAndIncreasing = (i: 0 | 1) => overCap[i] && s.teams[i].payrollAfterTrade > s.teams[i].payrollBeforeTrade; @@ -113,8 +119,14 @@ const summary = async (teams: TradeTeams): Promise => { if (softCapCondition) { // Which team is at fault?; - const j = ratios[0] > 125 ? 0 : 1; - s.warning = `The ${s.teams[j].name} are over the salary cap, so the players it receives must have a combined salary of less than 125% of the salaries of the players it trades away. Currently, that value is ${ratios[j]}%.`; + const j = ratios[0] > g.get("tradeMatchingPercentage") ? 0 : 1; + s.warning = `The ${ + s.teams[j].name + } are over the salary cap, so the players it receives must have a combined salary of less than ${g.get( + "tradeMatchingPercentage", + )}% of the salaries of the players it trades away. Currently, that value is ${ + ratios[j] + }%.`; } else if (hardCapCondition) { const j = overCapAndIncreasing(0) ? 0 : 1; const amountIncrease = diff --git a/src/worker/views/settings.ts b/src/worker/views/settings.ts index a1c615bd31..0b1a3b44ef 100644 --- a/src/worker/views/settings.ts +++ b/src/worker/views/settings.ts @@ -81,6 +81,7 @@ const keys = [ "stopOnInjury", "stopOnInjuryGames", "aiJerseyRetirement", + "tradeMatchingPercentage", "numPeriods", "tiebreakers", "pointsFormula", @@ -143,6 +144,7 @@ const updateSettings = async (inputs: unknown, updateEvents: UpdateEvents) => { minContractLength: g.get("minContractLength"), maxContractLength: g.get("maxContractLength"), aiTradesFactor: g.get("aiTradesFactor"), + tradeMatchingPercentage: g.get("tradeMatchingPercentage"), injuryRate: g.get("injuryRate"), homeCourtAdvantage: g.get("homeCourtAdvantage"), rookieContractLengths: g.get("rookieContractLengths"),