-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to modify or remove the 125% trade rule #403
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)[]; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for a new line here. |
||
teamInfoCache: { | ||
abbrev: string; | ||
region: string; | ||
|
@@ -1211,8 +1213,6 @@ export type Local = { | |
autoPlayUntil?: { | ||
season: number; | ||
phase: number; | ||
|
||
// Time in milliseconds of the start of auto play | ||
Comment on lines
-1215
to
-1216
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this back. |
||
start: number; | ||
}; | ||
autoSave: boolean; | ||
|
@@ -1713,5 +1713,3 @@ export type HeadToHead = { | |
> | ||
>; | ||
}; | ||
|
||
export type GetCopyType = "noCopyCache"; | ||
Comment on lines
-1717
to
-1718
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this back. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -994,6 +994,7 @@ export const settings: { | |
</p> | ||
</> | ||
), | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for a new line here. |
||
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch this to |
||
descriptionLong: ( | ||
<> | ||
<p> | ||
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. | ||
</p> | ||
|
||
<p>Set this to 0 to turn off the rule</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the text to:
|
||
</> | ||
), | ||
}, | ||
{ | ||
category: "Playoffs", | ||
key: "playoffsByConf", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete these lines, they are not necessary and will cause errors in some situations. |
||
|
||
/** | ||
* Create a summary of the trade, for eventual display to the user. | ||
|
@@ -101,9 +103,13 @@ const summary = async (teams: TradeTeams): Promise<TradeSummary> => { | |
} | ||
}), | ||
); | ||
if (g.get("tradeMatchingPercentage") === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it was changed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you return here, then the |
||
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<TradeSummary> => { | |
|
||
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 = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this down so it's in alphabetical order.