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

Change to allow for setting of tiebreaker rules through API #2

Merged
merged 12 commits into from Jun 25, 2017

Conversation

margotphoenix
Copy link

After finally updating my fork of pychallonge to the latest most-official version, I think this change should be implemented in the official version. In challonge/api.py, I believe that line 157 should read:

params.append(("%s[%s][]" % (prefix, k), val))

When I originally wrote this section of code in June of 2015 (see this commit), the goal of it was to allow for tiebreaker rules (and the order of tiebreaker rules) for round-robin tournaments to be set via the API. To my knowledge, the attribute "tie_breaks" is the only attribute in the API where the value is a list. I have tested out my version of the code, and it does allow for the setting of tiebreaker rules. I have not tested out ZEDGR's code specifically, but I did attempt a more direct method of updating the API using ZEDGR's version of line 157 and I got an error. I would suggest attempting to run the following lines of code and seeing what happens:

import challonge
t = challonge.tournaments.create("Test RR", "hut5wr9w", tournament_type="round robin", ranked_by="match wins", tie_breaks=["match wins vs tied","points difference","points scored"])

My current commit also contains a bulk_add unit test, which ZEDGR's doesn't, but that's less important.

@ZEDGR ZEDGR merged commit ed5f20b into ZEDGR:master Jun 25, 2017
@ZEDGR
Copy link
Owner

ZEDGR commented Jun 25, 2017

Thank you for your PR!

The bulk test was not added because I already have add_bulk on setUp function.

So the problem was how the parameters passed to API ?

@margotphoenix
Copy link
Author

Yeah, I think that whenever the json needs to be passed an array—which I believe might only be participant objects (in bulk_add) and tie_breaks in the tournament object—you need to put empty brackets "[]" after the name part, then pass the values in the array in order. In the example I had, it should pass [...,("tournament[tie_breaks][]","match wins vs tied"),("tournament[tie_breaks][]","points difference"),("tournament[tie_breaks][]","points scored"),...].

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.

None yet

2 participants