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

Refactor commanders list to include abilities #115

Merged
merged 2 commits into from
Nov 21, 2021

Conversation

R4md4c
Copy link
Contributor

@R4md4c R4md4c commented Nov 20, 2021

Hello,

This PR addresses the requirements in issue #73, by displaying the abilities in the commanders list screen in a horizontal fashion.

Also, I've managed to sort the abilities according to the command points, that sorting though will be applied to any screen that uses getCommanderData and getCommanderByRaces functions.

I'm not really experienced with web development, since I come from a mobile development background (native Android), so there might be better ways to do things that I've specified, let me know please in case there were any.

Testing:

  • I've added tests for getCommanderData and getCommanderByRaces functions.

Screenshot:
image

Copy link
Member

@petrvecera petrvecera left a comment

Choose a reason for hiding this comment

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

This is awesome. I don't see any issues. I've added just few comments for you. But I don't think we need to change anything this is great.

}

type CommanderAbility = {
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I am so lazy with adding types but in the end it's really great to have them.

return {
...commander,
abilities: commander.abilities.sort((a, b) => {
return +a.commandPoints < +b.commandPoints ? -1 : 1;
Copy link
Member

Choose a reason for hiding this comment

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

Lol this is pretty cool trick to convert string to number! I didn't know that. Nice

Btw this compare doesn't return 0 if the elements are the same - which means it's gonna swap them in that case. I am not sure if that's a problem or not - technically not | just from the user perspective.

Also if you are comparing the numbers I think you can do just :

function compareNumbers(a, b) {
  return a - b;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip, yeah, you are right, if both command points are the same they'll be swapped. I guess better to compare between the names then in case command points are equal.

commanderDescription: string;
};

const CommanderAbilitiesComponent = (props: CommanderAbilityProps) => {
Copy link
Member

Choose a reason for hiding this comment

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

Just a tip how you can nicely define a props with React functional components and typescript https://www.pluralsight.com/guides/defining-props-in-react-function-component-with-typescript

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will take that into account next time, thanks!

@petrvecera petrvecera merged commit 111c3d3 into cohstats:master Nov 21, 2021
@petrvecera
Copy link
Member

Great work thank you!

@R4md4c R4md4c deleted the commander-list-refactor branch November 22, 2021 10:47
@R4md4c
Copy link
Contributor Author

R4md4c commented Nov 22, 2021

@petrvecera I'm wondering if you're interested to develop a discord bot using the data that's gathered by coh2ladders? I believe it would make an interesting project, no? 🤔

@petrvecera
Copy link
Member

@R4md4c if you are interested in doing it, pleas try to create a new issue https://github.com/petrvecera/coh2ladders/issues where we could discuss this - the features etc. I personally don't have much extra time - so I don't think I would be contributing much into the bot source code. But I could help with providing and exposing the data from site.

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