Skip to content

Commit

Permalink
Start adding height/weight multiplier settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Feb 28, 2023
1 parent 98c949d commit aa859e9
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 15 deletions.
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
add settings for height/weight multipliers https://discord.com/channels/290013534023057409/290013534023057409/1079901943981420576
- make this multiplicative with current female adjustment (0.92 in generate.ts, 0.75 in genWeight.ts)

make cap space visible above the fold on trade page on mobile https://mail.google.com/mail/u/0/#inbox/FMfcgzGrcXqKVMHkvwNxkzXsrsbWwBKh

jordan not in HoF when starting in 2003 during draft https://discord.com/channels/290013534023057409/290015591216054273/1073981357614706821
Expand Down
2 changes: 2 additions & 0 deletions src/common/defaultGameAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ const defaultGameAttributes: GameAttributesLeagueWithHistory = {
draftPickAutoContractRounds: 1,
dh: "all",
gender: "male",
heightFactor: 1,
weightFactor: 1,

// These will always be overwritten when creating a league, just here for TypeScript
lid: 0,
Expand Down
2 changes: 2 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ export type GameAttributesLeague = {
godMode: boolean;
godModeInPast: boolean;
gracePeriodEnd: number;
heightFactor: number;
hideDisabledTeams: boolean;
hofFactor: number;
homeCourtAdvantage: number;
Expand Down Expand Up @@ -577,6 +578,7 @@ export type GameAttributesLeague = {
tragicDeaths?: TragicDeaths;
userTid: number;
userTids: number[];
weightFactor: number;

threePointers: boolean;
threePointTendencyFactor: number;
Expand Down
11 changes: 1 addition & 10 deletions src/worker/core/league/createStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1475,16 +1475,7 @@ const afterDBStream = async ({
// Gregg Brown from DNBA, RIP. Make one player on Denver have his name, assuming it's a random players league, Denver exists, and there are no custom names.
if (!fileHasPlayers && !g.get("playerBioInfo")) {
let memorials;
if (isSport("basketball")) {
memorials = [
{
region: "Denver",
firstName: "Gregg",
lastName: "Brown",
bornLoc: "Australia",
},
];
} else if (isSport("hockey")) {
if (isSport("hockey")) {
// https://discord.com/channels/@me/896580823057326130
memorials = [
{
Expand Down
2 changes: 2 additions & 0 deletions src/worker/core/player/genWeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const genWeight = (hgt: number, stre?: number, pos?: string) => {
MIN_WEIGHT;
}

weight *= g.get("weightFactor");

if (female) {
// Ratio comes from average USA stats, adjusted a bit down because they still seem to high
return Math.round(0.75 * weight);
Expand Down
9 changes: 4 additions & 5 deletions src/worker/core/player/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ const generate = (

const weight = genWeight(ratings.hgt, (ratings as any).stre);

let genderAdjustedHeightInInches;
let actualHeightInInches = g.get("heightFactor") * heightInInches;
if (g.get("gender") === "female") {
// Ratio comes from average USA stats
genderAdjustedHeightInInches = Math.round(0.92 * heightInInches);
} else {
genderAdjustedHeightInInches = heightInInches;
actualHeightInInches *= 0.92;
}
actualHeightInInches = Math.round(actualHeightInInches);

const p = {
awards: [],
Expand All @@ -74,7 +73,7 @@ const generate = (
face: face.generate(race),
firstName,
gamesUntilTradable: 0,
hgt: genderAdjustedHeightInInches,
hgt: actualHeightInInches,
imgURL: "",
// Custom rosters can define player image URLs to be used rather than vector faces
injury: {
Expand Down
2 changes: 2 additions & 0 deletions src/worker/views/newLeague.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ export const getDefaultSettings = () => {
"softCapTradeSalaryMatch",
),
gender: unwrapGameAttribute(defaultGameAttributes, "gender"),
heightFactor: unwrapGameAttribute(defaultGameAttributes, "heightFactor"),
weightFactor: unwrapGameAttribute(defaultGameAttributes, "weightFactor"),

// This can be undefined, but if the setting is ever displayed to the user, it should default to "rookie"
realDraftRatings:
Expand Down
4 changes: 4 additions & 0 deletions src/worker/views/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ const keys = [
"contactFactor",
"softCapTradeSalaryMatch",
"gender",
"heightFactor",
"weightFactor",
] as const;

export type Settings = Pick<
Expand Down Expand Up @@ -321,6 +323,8 @@ const updateSettings = async (inputs: unknown, updateEvents: UpdateEvents) => {
contactFactor: g.get("contactFactor"),
softCapTradeSalaryMatch: g.get("softCapTradeSalaryMatch"),
gender: g.get("gender"),
heightFactor: g.get("heightFactor"),
weightFactor: g.get("weightFactor"),

// Might as well be undefined, because it will never be saved from this form, only the new league form
realDraftRatings: g.get("realDraftRatings") ?? "rookie",
Expand Down
6 changes: 6 additions & 0 deletions tools/lib/generateJSONSchema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ const generateJSONSchema = (sport /*: string*/) => {
gracePeriodEnd: {
type: "integer",
},
heightFactor: {
type: "number",
},
hideDisabledTeams: {
type: "boolean",
},
Expand Down Expand Up @@ -1160,6 +1163,9 @@ const generateJSONSchema = (sport /*: string*/) => {
},
minItems: 1,
},
weightFactor: {
type: "number",
},
threePointers: {
type: "boolean",
},
Expand Down

0 comments on commit aa859e9

Please sign in to comment.