-
Notifications
You must be signed in to change notification settings - Fork 42
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
deck: completed function to create and shuffle a UNO card deck. #30
Conversation
25181d0
to
31b341a
Compare
Can you edit the commit message to occupy less width per line? |
31b341a
to
2e30543
Compare
I have shortened the commit message. |
Great work! |
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.
Posted some minor comments.
Overall, this seems promising and can be merged once the comments are addressed and tests are added.
PS. the commit message is perfect. Kudos for that!
backend/uno-game-engine/deck.ts
Outdated
const deck = []; | ||
const specialValues: Array<SpecialCardNames> = ['skip', 'reverse', 'draw2']; | ||
const wildCardValue: Array<SpecialCardNames> = ['colchange', 'draw4']; | ||
const deck: Array<UNOCard> = []; |
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.
Seems like this variable is useless.
You can go ahead and remove it.
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 would also make the eslint-backend check pass.
backend/uno-game-engine/deck.ts
Outdated
@@ -1,5 +1,5 @@ | |||
const colors: Array<CardColor> = ['red', 'yellow', 'green', 'blue']; | |||
const values = [ | |||
const numValues: Array<CardNumbers> = [ |
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.
Make CardNumbers singular.
backend/uno-game-engine/deck.ts
Outdated
]; | ||
const specialCards = ['wild', 'draw4']; | ||
const deck = []; | ||
const specialValues: Array<SpecialCardNames> = ['skip', 'reverse', 'draw2']; |
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.
Here too, types should be singular, unless they are an array
backend/uno-game-engine/deck.ts
Outdated
const specialCards = ['wild', 'draw4']; | ||
const deck = []; | ||
const specialValues: Array<SpecialCardNames> = ['skip', 'reverse', 'draw2']; | ||
const wildCardValue: Array<SpecialCardNames> = ['colchange', 'draw4']; |
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.
The variable name should be plural.
1. Added black to CardColor in types.d.ts. 2. Split special and wild cards into specialValues and wildCardValues arrays. 3. For each color in the colors array: - Add two cards for each number (0-9), except one card for '0'. - Add two cards for each special value. - For 'black', add four cards for each wild card value. 4. Added test,in deck.test.ts, to check the correct functioning of getShuffledCardDeck() Fixes: shivansh-bhatnagar18#1
2e30543
to
e5cfedf
Compare
@kuv2707 Please check I have made the desired changes and added a test to validate the created function. |
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.
Looks great!
getShuffledCardDeck, | ||
} from '../uno-game-engine/deck'; | ||
|
||
describe('getShuffledCardDeck', () => { |
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.
Appreciate the thorough testing!
Merged, thanks @sethdivyansh ! |
Description
Fixes: #1
Checklist