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

Fix issue#1 #27

Conversation

Abhishek-Punhani
Copy link

@Abhishek-Punhani Abhishek-Punhani commented May 31, 2024

backend/deck.js
Fixed the function to initialize the deck according to the requirements and added valid checks to check the composition of deck

Fixes: #1

describe('testing deck.ts', () => {
test('makeCard', () => {
const card = makeCard('number', 'blue', '3');
expect(card.color).toBe('blue');
});
test('getShuffledDeck', () => {
const deck = getShuffledCardDeck();
console.log(deck);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The purpose of tests is not to just console log things. That might have been required during development, but here, you should test whether the card deck correctly creates all the required cards. For example, you should expect there to be 25 cards per color, and 19 of them should be number cards, etc..

Copy link
Author

Choose a reason for hiding this comment

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

Yes i have checked them all like each color cards, special cards , and length of deck to be 108

Copy link
Collaborator

Choose a reason for hiding this comment

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

What I meant was for you to write a test which counts the number of red green etc and assert that they are 25
Then count the no. of wildcards and assert that there are 8, etc.

Writing tests ensures that future changes do not break existing functionality.

The function makeCard is used to make the card objects.
@returns {Array} deck - An array of 108 UNO cards.
*/
export default function getShuffledCardDeck(): Array<UNOCard> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove default from here?

deck.push(makeCard('number', col, val));
if (val === '0') break;
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great job on the algorithm!

Copy link
Collaborator

@kuv2707 kuv2707 left a comment

Choose a reason for hiding this comment

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

Suggested some changes. Focus on improving the tests. Look up jest testing library.

Also the commit title of a preparatory commit doesn't literally have to say so. The commit message should be the same as any other commit, whose format is mentioned in the docs. (just that the Fixes clause is omitted, as that commit doesn't actually fix the issue)

Side note: You can use github's request review feature once you are done with the changes.
Additionally, the PR description can be a bit more descriptive.

@kuv2707
Copy link
Collaborator

kuv2707 commented Jun 2, 2024

@Abhishek-Punhani Since this is a high priority issue, I'll have to go with #30 if the requested changes are not made by today evening.

@Abhishek-Punhani Abhishek-Punhani force-pushed the FixIssue#1 branch 16 times, most recently from 2051ac9 to a3ac3d0 Compare June 2, 2024 10:02
 Added wild color for wild cards like colchange and draw4 cards

 these changes are made in types.d.ts
Abhishek added 2 commits June 2, 2024 15:38
This commit involves one preperatory commit : adding wild color to CardColors

Added deck generation function to initialize the deck according to given constraints

The function generates cards and push them the deck array generating cards of each color and also wild cards

Also have checked the deck composition with jest tests

Fixes :shivansh-bhatnagar18#1
This commit involves one preperatory commit : adding wild color to CardColors

Added deck generation function to initialize the deck according to given constraints

The function generates cards and push them the deck array generating cards of each color and also wild cards

Also have checked the deck composition with jest tests

Fixes :shivansh-bhatnagar18#1
@Abhishek-Punhani Abhishek-Punhani deleted the FixIssue#1 branch June 2, 2024 11:29
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.

Implement the Card array generation logic
2 participants