Skip to content

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

Merged
dumbmatter merged 3 commits into
masterfrom
unknown repository
Jul 21, 2020
Merged

Added player rating changes for player profile (basketball and football)#280
dumbmatter merged 3 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jul 19, 2020

Copy link
Copy Markdown

No description provided.

@dumbmatter

Copy link
Copy Markdown
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?

@dumbmatter dumbmatter left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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.)

<div className="col-lg-8">
<h2>Overall: {ratings[r].ovr}</h2>
<h2>
Overall:&nbsp;

Copy link
Copy Markdown
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.

1 participant