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

Sometimes card shuffle doesnt work #119

Open
przemo9696 opened this issue Jul 29, 2022 · 4 comments
Open

Sometimes card shuffle doesnt work #119

przemo9696 opened this issue Jul 29, 2022 · 4 comments

Comments

@przemo9696
Copy link

przemo9696 commented Jul 29, 2022

I'm using 3 requests in my app to play Blackjack.

  1. I'm fetching deck with fetch('https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1');
  2. Drawing some cards with fetch('https://deckofcardsapi.com/api/deck/${deck?.deck_id}/draw/?count=${count}')
  3. After game shuffling them with fetch('https://deckofcardsapi.com/api/deck/${deck?.deck_id}/shuffle/?deck_count=1');

And sometimes it gives me back deck when cards are in order from ace of spades, 2 of spades, 3 of spades ... etc.

@crobertsbmw
Copy link
Owner

Sorry, I'm not able to reproduce this.
If you create a deck like you are doing in step 1. And then re-using the same deck, like what you're doing in step 3, then the same deck will be re-used. You end up keeping the same deck_id, and the drawn cards are shuffled into the remaining cards in the deck. There aren't any new decks opened in this scenario.
If you can post steps to reproduce, or maybe maybe post a link to your code or something?

@przemo9696
Copy link
Author

przemo9696 commented Aug 1, 2022

Yes, It is like You said, I am using the same deck. I wanted to work the same deck all the time (reshuffle after game instead of taking new deck), according to docs - "Don't throw away a deck when all you want to do is shuffle.". Do You think, that I should go for new deck every game?

Here's link yo my repo (Not proud of it, but still learining).
https://github.com/przemo9696/blackjack

@crobertsbmw
Copy link
Owner

It sounds like something is weird is going on and you are already getting an new deck. Once a deck is shuffled, it isn't ever "un-shuffled", so if you're getting a deck that is in numerical order, then you're getting a new deck. Could the browser or something be caching responses somehow (try using POST instead of GET if you aren't already). Are you sure that the data is being handled properly?

fecresgam added a commit to fecresgam/karate-deckofcards that referenced this issue Feb 10, 2024
Executed 5 times x 10 shuffle each time.
But its working properly
@fecresgam
Copy link

Hi,

I've also try to replicate this issue. Everything is working properly, @przemo9696
Each run try 10 reshuffle and I have executed it +6 times and never failed.

If you want to execute it just clone my repo
https://github.com/fecresgam/karate-deckofcards

and execute
mvn clean test -Dkarate.options="--tags @issue119".

I suggest to close this issue since nobody seems to be able to replicate it, @crobertsbmw .

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

No branches or pull requests

3 participants