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

Added player rating changes for player profile (basketball and football) #280

Merged
merged 3 commits into from Jul 21, 2020
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jul 19, 2020

No description provided.

@dumbmatter
Copy link
Member

This is cool, but I was thinking... do it for all the ratings! Not just ovr and pot. Or do you think that would look too busy?

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, this looks almost perfect!


const RatingsOverview = ({ ratings }: { ratings: PlayerRatings[] }) => {
const r = ratings.length - 1;
const lastSeason: PlayerRatings[] =
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be cleaner if you did something like:

let lastSeason: PlayerRatings = ratings[r];
// Search backwards to find the last entry from last season, in the case where there are multiple rows due to injuries
for (let i = ratings.length - 1; i--; i >= 0) {
    if (ratings[i].season === ratings[r].season - 1) {
        lastSeason = ratings[i];
        break;
    }
}

and then you can get rid of all the Math.max calls below.

Copy link
Member

Choose a reason for hiding this comment

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

(Also the Math.max calls are not even what we want, we'd want Math.min because ratings can currently only go down within a season, and we want to compare with the last ratings from last season. However my suggested change is more future proof, in case eventually there is some way for ratings to increase.)


return (
<>
<div className="d-none d-lg-flex row">
<div className="col-lg-8">
<h2>Overall: {ratings[r].ovr}</h2>
<h2>
Overall:&nbsp;
Copy link
Member

Choose a reason for hiding this comment

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

Unless there's a good reason for &nbsp; it shouldn't be used. You could use either {" "} or move the <RatingWithChange up to this line, like Overall: <RatingWithChange. Actually doesn't matter which you pick, I think Prettier will ultimately decide between them :)

@dumbmatter dumbmatter merged commit 3fa3b82 into zengm-games:master Jul 21, 2020
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