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

report_winner function doesn't work inside a group stage #10

Open
3rdCore opened this issue Aug 11, 2021 · 8 comments
Open

report_winner function doesn't work inside a group stage #10

3rdCore opened this issue Aug 11, 2021 · 8 comments
Assignees

Comments

@3rdCore
Copy link

3rdCore commented Aug 11, 2021

report_winner function seems not to work correctly while being used for matches inside a group stage. The associated group_player_ids for a player inside a group is not understanted by the function report_winner(..). This function expects a player with the id attribute equals to group_player_ids but get a player with his original id (outsite group stage) and crash.

example, with 2 objects player and match :

In [68]: player
Out[68]: <challonge.participant.Participant at 0x23866bb9c40>

In [69]: player.id
Out[69]: 152547829
In [70]: player.group_player_ids
Out[70]: [17666281] 

In [72]: match.player1_id
Out[72]: 17666281

await match.report_winner(player,score)

Error call : `APIException: ({'errors': ['Winner ID must be one of the player/participant IDs']}, 422, 'Unprocessable Entity', 'tournaments/10145851/matches/247328813', [('match[scores_csv]', '1-0'), ('match[winner_id]', '152547845')])
@fp12
Copy link
Owner

fp12 commented Aug 16, 2021

Thanks for reporting the issue!
I need to test more for group stages it seems...
I'll look into it!

@fp12 fp12 self-assigned this Aug 16, 2021
@fp12
Copy link
Owner

fp12 commented Aug 16, 2021

@3rdCore did you create the group stage via API/achallonge?
If so, could you share the code? Thanks!

@3rdCore
Copy link
Author

3rdCore commented Aug 16, 2021

I created the tournament using the web interface and I then call the tournament using its token.
Every thing was then done using the Challonge API. This is my main function :

  my_user = await challonge.get_user(my_username, my_api_key)
  my_tournament_id = 'ycpl6a79'
  my_tournament = await my_user.get_tournament(my_tournament_id)
  print(my_tournament.name, my_tournament.full_challonge_url)
  #if not (my_tournament.state =='pending'): 
  #    print("tournament reseted")
  #    await my_tournament.reset()
  #print("Beginning of the tournament !")
  await my_tournament.start()
  matches = await my_tournament.get_matches()
  players = await my_tournament.get_participants()
  player_index = {players[i].id:i for i in range(0,len(players))}

  for match in matches:
          player1 = await my_tournament.get_participant(match.player1_id)
          player2 = await my_tournament.get_participant(match.player2_id)
          #print("players id : ", player1.id, " ", player2.id)
          #player1.id = player1.  [0]
          #player2.id = player2.group_player_ids[0]
          #print("players id : ", player1, " ", player2.id)
          winner, score = get_winner_and_score(player1, player2)
          await match.report_winner(winner,score)

@fp12
Copy link
Owner

fp12 commented Aug 17, 2021

ok, so with my_tournament_id = 'ycpl6a79', I'm assuming you set up the (group) tournament on the website and you are then updating the results through the API, right?

@3rdCore
Copy link
Author

3rdCore commented Aug 17, 2021

That's right. I set up the tournament ( number of player, tournament tree.. ) online, does it come from this ?

First of all, the function start() doesn't start the group phase so we have to manually start the group phase on the website ( with the button ) otherwise the tournament is stuck in an in-between phase where the user can't modify anything.

Should I try to totally setup a tournament through the API ?

Have you understand the difference between .id an. .group_player_id ?

Thanks for your help.

@3rdCore
Copy link
Author

3rdCore commented Sep 2, 2021

do you guys figured out what could be the problem ?

@fp12
Copy link
Owner

fp12 commented Sep 3, 2021

No, sorry, I haven't looked into it yet.
And since we can't do groups from the API, it makes testing a bit harder/longer...

@3rdCore
Copy link
Author

3rdCore commented Sep 20, 2021

I've managed to update the scores using the function report_tie(). This function makes it possible to give un-tie scores and therefore undirectly declare a winner (it would appear as a tie on the web interface, but will still rank players in order of their score.)

This is obviously not a solution but could help someone else stuck in the same situation as me.

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

2 participants