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

Adding cards to pile only works with repeated cards #134

Open
romosken opened this issue Feb 9, 2024 · 0 comments
Open

Adding cards to pile only works with repeated cards #134

romosken opened this issue Feb 9, 2024 · 0 comments

Comments

@romosken
Copy link

romosken commented Feb 9, 2024

When I try to add drawn cards from the deck to one pile, it only stores when I pass repeated cards, in any other ocasion, it does not add to the pile!

Here is my code:

  jogadores = ['Rodrigo']
  baralho = requests.get(
      "https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=2").json()
  id_baralho = baralho['deck_id']
  
  for jogador in jogadores:
    response_cartas = requests.get(f"https://deckofcardsapi.com/api/deck/{id_baralho}/draw/?count=11").json()
    cartas = [carta['code'] for carta in response_cartas['cards']]
    cartas_juntas = ','.join(cartas)
    url =f"https://deckofcardsapi.com/api/deck/{id_baralho}/pile/{jogador}/add/"
    response_pilha = requests.post(url, data={"cards": cartas_juntas}).json()
    print(response_pilha)
  
  pilha_rodrigo = requests.get(f"https://deckofcardsapi.com/api/deck/{id_baralho}/pile/{'Rodrigo'}/list/").json()
  print(pilha_rodrigo)`

I basically create a deck, draw eleven cards, get each one's code, and add to a new pile, in this case named Rodrigo.

Here is my debug session, where it only added the 6C cards:
image

Already tried adding with the GET route, same issue.

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

1 participant