From aa859e9dd797e7f7bc9056568e50e685c54f5126 Mon Sep 17 00:00:00 2001 From: Jeremy Scheff Date: Tue, 28 Feb 2023 01:39:22 -0500 Subject: [PATCH] Start adding height/weight multiplier settings --- TODO | 3 +++ src/common/defaultGameAttributes.ts | 2 ++ src/common/types.ts | 2 ++ src/worker/core/league/createStream.ts | 11 +---------- src/worker/core/player/genWeight.ts | 2 ++ src/worker/core/player/generate.ts | 9 ++++----- src/worker/views/newLeague.ts | 2 ++ src/worker/views/settings.ts | 4 ++++ tools/lib/generateJSONSchema.mjs | 6 ++++++ 9 files changed, 26 insertions(+), 15 deletions(-) diff --git a/TODO b/TODO index 9c6e06f8ef..8bd43c861c 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/src/common/defaultGameAttributes.ts b/src/common/defaultGameAttributes.ts index f0f1c9bb57..31555906ed 100644 --- a/src/common/defaultGameAttributes.ts +++ b/src/common/defaultGameAttributes.ts @@ -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, diff --git a/src/common/types.ts b/src/common/types.ts index da5da88bf9..464f8b1a5e 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -486,6 +486,7 @@ export type GameAttributesLeague = { godMode: boolean; godModeInPast: boolean; gracePeriodEnd: number; + heightFactor: number; hideDisabledTeams: boolean; hofFactor: number; homeCourtAdvantage: number; @@ -577,6 +578,7 @@ export type GameAttributesLeague = { tragicDeaths?: TragicDeaths; userTid: number; userTids: number[]; + weightFactor: number; threePointers: boolean; threePointTendencyFactor: number; diff --git a/src/worker/core/league/createStream.ts b/src/worker/core/league/createStream.ts index 8ff5d8d31c..6f401c566b 100644 --- a/src/worker/core/league/createStream.ts +++ b/src/worker/core/league/createStream.ts @@ -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 = [ { diff --git a/src/worker/core/player/genWeight.ts b/src/worker/core/player/genWeight.ts index 24f07ce7c6..f54d4c2516 100644 --- a/src/worker/core/player/genWeight.ts +++ b/src/worker/core/player/genWeight.ts @@ -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); diff --git a/src/worker/core/player/generate.ts b/src/worker/core/player/generate.ts index 438ac02293..dc7ce50162 100644 --- a/src/worker/core/player/generate.ts +++ b/src/worker/core/player/generate.ts @@ -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: [], @@ -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: { diff --git a/src/worker/views/newLeague.ts b/src/worker/views/newLeague.ts index 792e4368fe..54dcb5030d 100644 --- a/src/worker/views/newLeague.ts +++ b/src/worker/views/newLeague.ts @@ -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: diff --git a/src/worker/views/settings.ts b/src/worker/views/settings.ts index 446558609f..c966c99f60 100644 --- a/src/worker/views/settings.ts +++ b/src/worker/views/settings.ts @@ -146,6 +146,8 @@ const keys = [ "contactFactor", "softCapTradeSalaryMatch", "gender", + "heightFactor", + "weightFactor", ] as const; export type Settings = Pick< @@ -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", diff --git a/tools/lib/generateJSONSchema.mjs b/tools/lib/generateJSONSchema.mjs index 38c236c332..4cfa6b45ab 100644 --- a/tools/lib/generateJSONSchema.mjs +++ b/tools/lib/generateJSONSchema.mjs @@ -816,6 +816,9 @@ const generateJSONSchema = (sport /*: string*/) => { gracePeriodEnd: { type: "integer", }, + heightFactor: { + type: "number", + }, hideDisabledTeams: { type: "boolean", }, @@ -1160,6 +1163,9 @@ const generateJSONSchema = (sport /*: string*/) => { }, minItems: 1, }, + weightFactor: { + type: "number", + }, threePointers: { type: "boolean", },