-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
There was a problem hiding this 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 = { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
Great work thank you! |
@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? 🤔 |
@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. |
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
andgetCommanderByRaces
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:
getCommanderData
andgetCommanderByRaces
functions.Screenshot: