Page 1 of 2

Not having success having tournaments removed from the lobby at a specific time using API

Posted: Tue Feb 06, 2024 7:43 pm
by TJ-Cookier
Hi Kent,
My goal is to use automation and the API to have ring games, SNGs, and featured tourneys all appear in the lobby at certain times and then be removed from the lobby at later times. I have it working successfully for ring games (both add and remove). But with tourneys, they appear as specified but do not go away at the specified time. I'm using the following command, which I *think* is correct from what I've read, but I'm clearly doing something wrong.

r = requests.post('http://127.0.0.1:80/api', data={'Command': 'TournamentsOffline','Password': '*********','JSON': 'Yes','Name': 'Example SNG'})

Any idea what I'm doing wrong?

Also, let's imagine this scenario. I have a SNG (in this case called "Example SNG") offered in the lobby and it launches and people are playing. While they are playing, I send the command above to remove that SNG from the lobby. I assume what should happen is the currently running instance of it will keep running, but users will no longer see a registering version of that SNG in the lobby. Do I have that right? Thx!

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Tue Feb 06, 2024 7:55 pm
by Kent Briggs
TJ-Cookier wrote: Tue Feb 06, 2024 7:43 pm r = requests.post('http://127.0.0.1:80/api', data={'Command': 'TournamentsOffline','Password': '*********','JSON': 'Yes','Name': 'Example SNG'})

Any idea what I'm doing wrong?
Every API command returns a Result parameter set to either "Ok" or "Error". You need to check for that and if it returns "Error" then check for the returned Error parameter and see what it says (record it somewhere you can check).
Also, let's imagine this scenario. I have a SNG (in this case called "Example SNG") offered in the lobby and it launches and people are playing. While they are playing, I send the command above to remove that SNG from the lobby. I assume what should happen is the currently running instance of it will keep running, but users will no longer see a registering version of that SNG in the lobby. Do I have that right? Thx!
Yes, the default behavior is to let the tournament finish out first. Unless you sent the optional Now parameter to "Yes", which will cancel it immediately and spread out the prizepool.

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 1:13 pm
by TJ-Cookier
OK, I did that, here's what it returned:

{"Result":"Error","Error":"Tournament is not currently playing"}

I agree that it's not currently playing, but that's not what I was trying to do (cancel a tourney in progress). I'm trying to make it so after a specified time, the tournament will disappear as a choice from the lobby so that no new tournaments can be started. Is there a way to do that?

*edit* it appears to me that this command is expected to be used when a tournament is actually running. It will both stop the tournament and take it offline. But what I want is for tourneys that are not yet running (like a bunch of SNGs that may or may not have anyone registered yet) to be able to be taken offline so they can't be started.

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 1:39 pm
by Kent Briggs
Looks like a bug. I'll check into it.

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 1:51 pm
by Kent Briggs
Nevermind, not a bug. You just have to include the Now = Yes parameter. Needs a better error message, though.

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 2:31 pm
by TJ-Cookier
Before I try this with people playing live, I'd just like verification of something. First, this is really intended for SNGs.

I have my SNGs structured so that when one instance of a specific SNG starts, another instance of it will appear in the lobby so that people can start registering for it if they want to. So technically, there can be more than one SNG that has the same name (one that's playing and one that's registering).

So, if I pass the STOP NOW parameter, will it behave differently for the two SNGs that share the name? Here's what I hope it will do:
For the already running version - it keeps running and plays to the end
For the version that is not yet running but is shown as registering in the lobby - it disappears. If people had registered for it, their entries are refunded when it is removed.

Is that how it will work?

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 3:07 pm
by TJ-Cookier
Learned a couple things.

First, I thought that SNGs worked the way I described where there can be more than one instance of the same tourney at the same time (one registering, one or more playing). But, I was wrong. It looks like when one is playing, there's not another one offered in the lobby until the first one completes.

If I use the NOW parameter then:
If the SNG is running, it ends immediately and no new version of it is shown in the lobby.
If the SNG is not running, then it is removed from the lobby.

If I don't use the NOW parameter then:
If the SNG is running, it'll play to completion and no new version of it is shown in the lobby.
If the SNG is not running, I get an error message.

I'd suggest the very last case should behave differently. Rather than an error message, how about it removes it from the lobby?

Otherwise, I think I'm going to have to query the state of every tourney and have different commands based on that query. And it still may not work right if a SNG launches at precisely the wrong time (between my query of its state and the follow on command)

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 3:18 pm
by Kent Briggs
Tournaments and SnGs are recycled so there is never more than one of them with the same name. But they do allow people to register for the next start while it is currently playing. Stopping the current one with Now = Yes does spread the prizepool and unregister everyone else in the waiting list. However, while testing this with Now = No (or just manually taking it offline after game) it is NOT refunding those waiting list players when the current game ends. So that's a huge bug I'll be fixing real soon. :oops:

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 3:27 pm
by Kent Briggs
TJ-Cookier wrote: Wed Feb 07, 2024 3:07 pm I'd suggest the very last case should behave differently.
The Now parameter mimics what you can do manually from the Action button in the admin console. Now = No in the API is the same as selecting Take offline (after game) in the admin console. So if you do that for a game that is not currently running it returns that error because "after game" does not apply.

If you want to take running games offline after they complete and all other games offline immediately then I'd suggest starting with Now = No and check for error. If you get the error, call again with Now = Yes. They you're safe not to kill any active games. Perhaps I could think up a third value for Now that would do both in one call?

Re: Not having success having tournaments removed from the lobby at a specific time using API

Posted: Wed Feb 07, 2024 4:25 pm
by Kent Briggs
Kent Briggs wrote: Wed Feb 07, 2024 3:27 pm Perhaps I could think up a third value for Now that would do both in one call?
Actually I think I'm just going to change the behavior of the command so that non-running tourneys are taken offline regardless of whether it's a now or later situation. Both the manual command and in the API. This would make it consistent with closing ring games since "closing after hand" still works on idle tables.