-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples in docs + api change: add_participants
- Loading branch information
Showing
6 changed files
with
88 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.. currentmodule:: challonge | ||
.. module:: challonge | ||
|
||
|
||
Examples | ||
======== | ||
|
||
|
||
Simple list of tournaments | ||
-------------------------- | ||
|
||
Let's fetch and print all names and url of the organizer's tournaments | ||
|
||
.. literalinclude:: ../examples/listing.py | ||
|
||
|
||
Simple creation of a tournament | ||
------------------------------- | ||
|
||
.. literalinclude:: ../examples/create.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import challonge | ||
import asyncio | ||
|
||
my_username = 'challonge_username' | ||
my_api_key = 'challonge_api_key' | ||
|
||
|
||
async def main(loop): | ||
my_user = challonge.get_user(my_username, my_api_key) | ||
new_tournament = await my_user.create_tournament(name='my super tournament', | ||
url='super-tournament-url') | ||
|
||
john = await new_tournament.add_participant('john') | ||
bob = await new_tournament.add_participant('bob') | ||
steve = await new_tournament.add_participant('steve') | ||
franck = await new_tournament.add_participant('franck') | ||
# or simply new_tournament.add_participants('john', 'bob', 'steve', 'franck') | ||
|
||
await new_tournament.start() | ||
|
||
matches = await new_tournament.get_matches() | ||
|
||
# match 1: john (p1) Vs bob (p2) | ||
await matches[0].report_winner(john, '2-0,1-2,2-1') | ||
# match 2: steve (p1) Vs franck (p2) | ||
await matches[1].report_winner(franck, '2-0,1-2,0-2') | ||
|
||
# finals: john (p1) Vs franck (p2) | ||
await matches[2].report_winner(franck, '2-1,0-2,1-2') | ||
|
||
await new_tournament.finalize() | ||
|
||
|
||
if __name__ == '__main__': | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(main(loop)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import challonge | ||
import asyncio | ||
|
||
my_username = 'challonge_username' | ||
my_api_key = 'challonge_api_key' | ||
|
||
|
||
async def main(loop): | ||
my_user = challonge.get_user(my_username, my_api_key) | ||
my_tournaments = await my_user.get_tournaments() | ||
for t in my_tournaments: | ||
print(t.name, t.full_challonge_url) | ||
|
||
|
||
if __name__ == '__main__': | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(main(loop)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters