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

Trade filter #358

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions public/css/dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ $text-muted: $gray-400;
color: $primary;
}

.check-item-default {
color: $gray-600;
background: $gray-200;
}
.check-item-checked {
background: $primary;
color: $black;
border-color: $primary;
}

.text-danger {
color: lighten($red, 10) !important;
}
Expand Down
18 changes: 18 additions & 0 deletions public/css/light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,24 @@ tr.table-warning:hover > td {
color: $gray-700 !important;
}

.toggle-item-default {
color: $gray-600;
background: $gray-200;
padding: 3px 7px;
border-radius: 50px;
font-size: 12px;
border-width: 1px;
cursor: pointer;
width: 40px;
display: inline-block;
margin: 0 5px 0 0;
}
.toggle-item-checked {
@extend .toggle-item-default;
background: $primary;
color: $white;
border-color: $primary;
}
.navbar-border {
border-bottom: 1px solid $gray-200;
}
Expand Down
11 changes: 10 additions & 1 deletion src/common/constants.basketball.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CompositeWeights, Conf, Div } from "./types";
import type { CompositeWeights, Conf, Div, Skill } from "./types";
import type { RatingKey } from "./types.basketball";

const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
Copy link
Member

Choose a reason for hiding this comment

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

Very recently a "V" "Volume scorer" label was added to "scoring", looks like it got lost in a merge.

Copy link
Author

Choose a reason for hiding this comment

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

I also just realized I seem to have caught you guys as hockey is being added. I'll go ahead and make sure those are included as well

Expand All @@ -10,6 +10,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1.5, 1, 1, 1, 0.5, 0.5, 0.5, 0.5],
skill: {
label: "V",
description: "Volume Scorer",
cutoff: 0.61,
},
},
Expand All @@ -18,6 +19,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1],
skill: {
label: "B",
description: "Ball Handler",
cutoff: 0.68,
},
},
Expand All @@ -26,6 +28,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [0.4, 1, 0.5],
skill: {
label: "Ps",
description: "Passer",
cutoff: 0.63,
},
},
Expand All @@ -42,6 +45,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 0.6, 0.2, 1, 0.4],
skill: {
label: "Po",
description: "Post Scorer",
cutoff: 0.61,
},
},
Expand All @@ -54,6 +58,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [0.1, 1],
skill: {
label: "3",
description: "Three Point Shooter",
cutoff: 0.59,
},
},
Expand All @@ -65,6 +70,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [2, 0.1, 0.1, 2, 0.5, 0.5],
skill: {
label: "R",
description: "Rebounder",
cutoff: 0.61,
},
},
Expand Down Expand Up @@ -93,6 +99,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [2.5, 1, 0.5, 0.5, 2],
skill: {
label: "Di",
description: "Interior Defender",
cutoff: 0.57,
},
},
Expand All @@ -101,6 +108,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [0.5, 0.5, 2, 0.5, 1],
skill: {
label: "Dp",
description: "Perimeter Defender",
cutoff: 0.61,
},
},
Expand All @@ -113,6 +121,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1, 1, 0.75],
skill: {
label: "A",
description: "Athlete",
cutoff: 0.63,
},
},
Expand Down
11 changes: 11 additions & 0 deletions src/common/constants.football.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,47 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 0.2],
skill: {
label: "Pa",
description: "Accurate Passer",
},
},
passingDeep: {
ratings: ["thp", "tha", "hgt"],
weights: [1, 0.1, 0.2],
skill: {
label: "Pd",
description: "Deep Passer",
},
},
passingVision: {
ratings: ["thv", "hgt"],
weights: [1, 0.5],
skill: {
label: "Ps",
description: "Smart Passer",
},
},
athleticism: {
ratings: ["stre", "spd", "hgt"],
weights: [1, 1, 0.2],
skill: {
label: "A",
description: "Athletic",
},
},
rushing: {
ratings: ["stre", "spd", "elu"],
weights: [0.5, 1, 1],
skill: {
label: "X",
description: "Explosive Runner",
},
},
catching: {
ratings: ["hgt", "hnd"],
weights: [0.2, 1],
skill: {
label: "H",
description: "Hands",
},
},
gettingOpen: {
Expand All @@ -53,34 +59,39 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [0.5, 1, 0.2, 1],
skill: {
label: "Bp",
description: "Pass Blocker",
},
},
runBlocking: {
ratings: ["hgt", "stre", "spd", "rbk"],
weights: [0.5, 1, 0.4, 1],
skill: {
label: "Br",
description: "Run Blocker",
},
},
passRushing: {
ratings: ["hgt", "stre", "spd", "prs", "tck"],
weights: [1, 1, 0.5, 1, 0.25],
skill: {
label: "PR",
description: "Pass Rusher",
},
},
runStopping: {
ratings: ["hgt", "stre", "spd", "rns", "tck"],
weights: [0.5, 1, 0.5, 1, 1],
skill: {
label: "RS",
description: "Run Stopper",
},
},
passCoverage: {
ratings: ["hgt", "spd", "pcv", "tck"],
weights: [0.1, 1, 1, 0.25],
skill: {
label: "L",
description: "Lockdown Coverage",
},
},
tackling: {
Expand Down
5 changes: 5 additions & 0 deletions src/common/constants.hockey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1, 1, 1, 0.25, 0.1],
skill: {
label: "Pm",
description: "Playmaker",
cutoff: 0.65,
},
},
Expand All @@ -15,6 +16,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1, 1, 0.25, 0.1],
skill: {
label: "Pw",
description: "Power",
cutoff: 0.65,
},
},
Expand All @@ -23,6 +25,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1, 1, 0.25, 0.25, 0.1],
skill: {
label: "G",
description: "Grinder",
cutoff: 0.65,
},
},
Expand All @@ -31,6 +34,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1, 0.25, 0.1],
skill: {
label: "E",
description: "Enforcer",
cutoff: 0.65,
},
},
Expand All @@ -39,6 +43,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
weights: [1, 1, 0.25],
skill: {
label: "S",
description: "Sniper",
cutoff: 0.65,
},
},
Expand Down
20 changes: 19 additions & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import * as constantsBasketball from "./constants.basketball";
import * as constantsFootball from "./constants.football";
import * as constantsHockey from "./constants.hockey";

import type { CompositeWeights, Phase, DraftType, MoodTrait } from "./types";
import type {
CompositeWeights,
Phase,
DraftType,
MoodTrait,
CompositeWeight,
} from "./types";

const ACCOUNT_API_URL =
process.env.NODE_ENV === "development"
Expand Down Expand Up @@ -142,6 +148,17 @@ const POSITIONS = bySport<any[]>({
hockey: constantsHockey.POSITIONS,
});

const SKILLS: { [key: string]: string } = Object.values(
bySport<CompositeWeights>({
basketball: constantsBasketball.COMPOSITE_WEIGHTS,
football: constantsFootball.COMPOSITE_WEIGHTS,
hockey: constantsHockey.COMPOSITE_WEIGHTS,
}),
).reduce((skills: { [key: string]: string }, item: CompositeWeight) => {
if (item.skill) skills[item.skill.label] = item.skill.description;
return skills;
}, {});

const TEAM_STATS_TABLES: {
[key: string]: {
name: string;
Expand Down Expand Up @@ -285,5 +302,6 @@ export {
SUBREDDIT_NAME,
TEAM_STATS_TABLES,
TIME_BETWEEN_GAMES,
SKILLS,
TWITTER_HANDLE,
};
20 changes: 12 additions & 8 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,19 @@ export type AllStars = {
};
};

export type CompositeWeight<RatingKey = string> = {
ratings: (RatingKey | number)[];
weights?: number[] | undefined;
skill?:
| {
label: string;
cutoff?: number | undefined;
description: string;
}
| undefined;
};
export type CompositeWeights<RatingKey = string> = {
[key: string]: {
ratings: (RatingKey | number)[];
weights?: number[];
skill?: {
label: string;
cutoff?: number;
};
};
[key: string]: CompositeWeight<RatingKey>;
};

// Not exact because https://github.com/facebook/flow/issues/2386 - same thing elsewhere
Expand Down
40 changes: 4 additions & 36 deletions src/ui/components/SkillsBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
import PropTypes from "prop-types";
import { bySport } from "../../common";
import { SKILLS } from "../../common/constants";

const tooltips = bySport({
basketball: {
"3": "Three Point Shooter",
S: "Scorer",
A: "Athlete",
B: "Ball Handler",
Di: "Interior Defender",
Dp: "Perimeter Defender",
Po: "Post Scorer",
Ps: "Passer",
R: "Rebounder",
V: "Volume Scorer",
},
football: {
Pa: "Accurate Passer",
Pd: "Deep Passer",
Ps: "Smart Passer",
A: "Athletic",
X: "Explosive Runner",
H: "Hands",
Bp: "Pass Blocker",
Br: "Run Blocker",
PR: "Pass Rusher",
RS: "Run Stopper",
L: "Lockdown Coverage",
},
hockey: {
Pm: "Playmaker",
Pw: "Power",
G: "Grinder",
E: "Enforcer",
S: "Sniper",
},
});
const tooltips = SKILLS;
Copy link
Member

Choose a reason for hiding this comment

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

Glad to see this gone :) for the same reason I wrote above, this old code of mine was bad because it required the list of skills here to remain in sync with the list of skills in COMPOSITE_WEIGHTS, so it was just asking for a bug to appear..

console.log(tooltips);

const SkillsBlock = ({
className,
Expand All @@ -56,7 +24,7 @@ const SkillsBlock = ({
title={
// https://github.com/microsoft/TypeScript/issues/21732
// @ts-ignore
tooltips.hasOwnProperty(skill) ? tooltips[skill] : null
tooltips.hasOwnProperty(skill) ? tooltips[skill] : undefined
}
>
{skill}
Expand Down
Loading