Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

GeniusASTG
Copy link

@GeniusASTG GeniusASTG commented Dec 18, 2021

  1. I added a setting, named Trade Matching Percentage, whose value is an integer. By default, it is 125%(I got that to work)
  2. Set it to 0 and the rule is removed

Screenshot 2021-12-18 at 3 37 35 PM

(Screenshot rule set as 300)

Screenshot 2021-12-18 at 3 53 37 PM

(Screenshot rule set to 0)

@dumbmatter

@GeniusASTG GeniusASTG changed the title Ability to modify or remove the 125% trade Ability to modify or remove the 125% trade rule Dec 18, 2021
Copy link
Member

@dumbmatter dumbmatter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

If you want to take this PR all the way, then address all the comments I left and push to your branch again. It's all little stuff, but let me know if you need help. Also if you don't want to do all this extra stuff, just tell me and I will do it.

Also, there are a couple other places you need to add tradeMatchingPercentage:

  • In gameAttributes in tools/lib/generateJSONSchema.mjs, next to all the other settings (keep this one in alphabetical order)
  • In defaultSettings in src/worker/views/newLeague.ts, next to all the other settings (this is already not in alphabetical order, so just add it below fantasyPoints)

key: "tradeMatchingPercentage",
name: "Trade Matching Percentage",
godModeRequired: "existingLeagueOnly",
type: "int",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch this to intOrNull so that blank is disabled, rather than 0. I think that's a little more straightforward.

@@ -101,9 +103,13 @@ const summary = async (teams: TradeTeams): Promise<TradeSummary> => {
}
}),
);
if (g.get("tradeMatchingPercentage") === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it was changed to intOrNull, this should compare against null now.

@@ -101,9 +103,13 @@ const summary = async (teams: TradeTeams): Promise<TradeSummary> => {
}
}),
);
if (g.get("tradeMatchingPercentage") === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you return here, then the hardCapCondition code below never runs. To fix that, add && !g.get("hardCap") to this condition.

you to modify this.
</p>

<p>Set this to 0 to turn off the rule</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the text to:

<p>If you have the Hard Cap setting disabled, teams can make trades that increase their payroll beyond the salary cap. To limit the amount they can exceed the salary cap in a trade, their total incoming contracts must be less than X% of their outgoing contracts. By default this value is 125%.</p>
<p>Leave blank to disable this rule and allow any trades over the cap.</p>

Comment on lines +5 to +6
import { league } from "src/worker/core";
league.loadGameAttributes();
Copy link
Member

Choose a reason for hiding this comment

The 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.

Comment on lines -1214 to -1216

// Time in milliseconds of the start of auto play
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this back.

Comment on lines -1716 to -1718

export type GetCopyType = "noCopyCache";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this back.

@@ -507,6 +507,7 @@ export type GameAttributesLeague = {
numGames: number;
numGamesDiv: number | null;
numGamesConf: number | null;
tradeMatchingPercentage: number;
Copy link
Member

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.

@@ -554,6 +555,7 @@ export type GameAttributesLeague = {
stopOnInjury: boolean;
stopOnInjuryGames: number;
tiebreakers: (keyof typeof TIEBREAKERS)[];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a new line here.

@@ -994,6 +994,7 @@ export const settings: {
</p>
</>
),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a new line here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants