killer-queen-stats / kqstats

Get real time statistics from your Killer Queen cabinets!
Other
25 stars 10 forks source link

Support tournament mode events #44

Open cscorley opened 6 years ago

cscorley commented 6 years ago

There are several events that are not yet handled. I will work on gathering more data on what the structure of these events look like. They are currently used to communicate with the cab in tournament mode.

Many of these can be requested from the cabinet by sending a "get" request: ![k[get],v[goldonleft]]!, but some are responses to more complicated messages sent.


"restarttourney" ![k[restarttourney],v[r,testatest,test,1,1,1,test1,test2]]!

This is sent back whenever a request to restart the tournament is sent to the cab (![k[restarttourney],v[]]!). Values look to be what's needed in order to send the cab a 'start tournament' message, structure follows: {"format":"r","name":"testatest","location":"test","teams":["test1","test2"],"bestOf":"1,1,1","swissround":1,"warmup":"60"}


"bracket" ![k[bracket],v[{"tournament_name":"testatest","tournament_location":"test","format":"r","concluded":false,"stream_url":"","brackets":[{"bracket_type":"r","rounds":[{"round_num":0,"sets":[{"id":1,"best_of":1,"on_machine_name":"","start_time":"","teams":[{"name":"test1","score":0},{"name":"test2","score":0}],"victory_types":[],"match_data_id":[]}]}]}],"standings":[{"name":"test1","point":0,"win":0,"loss":0},{"name":"test2","point":0,"win":0,"loss":0}]}]]!

This is the good one. This is the entire tournament bracket state. Seems useful for building a kiosk mode


"loginevent" ![k[loginevent],v[1]]!

Returns whenever a socket has attempted to log in to the tournament mode (after sending ![k[adminlogin],v[tournament_mode_password_here]]!). The bit indicates success.


"tstart" ![k[tstart],v[{"start":"True","format":"r","tournamentname":"testatest","message":"Can not connect to Database, bracket will only be locally saved."}]]! This indicates that a tournament has started, but mostly seems like something that's used to display error messaging after starting a tournament.


"tournamentstatus" ![k[tournamentstatus],v[0,1]]!

Returns whether the tournament is currently active and if its concluded. The first bit is whether the tournament has started, the second bit is whether it has concluded (and subsequently needs to be restarted?)


"machinenames"

Haven't seen this one in the wild, but JS parsing code of structure is just raw JSON. I'd expect something like this ![k[machinenames],v[["cab1","cab2"]]]!

(This is unlike the CSV format playernames uses)


"goldonleft"

This is primarily in the OBS template and only seems to trigger after a "get". Haven't seen this one in the wild, but JS parsing code of structure is just raw JSON. I'd expect something like this ![k[goldonleft],v[True]]!

I think you can figure this one out :-)


"currentmatch"

Haven't seen this one in the wild, but JS parsing code of structure is just raw JSON. This seems to be an object with the following fields: "bestOf", "score1", "score2", "team1", "team2", "next1", and "next2"

bestOf is team maximum for round, score is current scores, team is playing teams, next is teams on deck.


"teamsms" Haven't seen this one in the wild, but JS parsing code of structure is just raw JSON. This looks like it was implemented to support texting players during BB2? You can access modifying this by browsing to http://kq.local/ondeck.html while in a tournament. I can get real data on this if it seems useful.


"dl" Haven't seen this one in the wild. This looks to represent some integer value. Perhaps the cab sends it when overloaded. I'd expect something like this ![k[dl],v[20]]!

cscorley commented 6 years ago

Some more information about what messages cab be sent to the cab:

On connect, it may need some validation. The tournament mode starts with this message:

SEND ![k[connect],v[{"name":"1","isGameMachine":false}]]! RECV ![k[connected],v[9]]!

The value in the response seems to vary.


Login verifies over plain-text (lol)

SEND ![k[adminlogin],v[beegame]]! RECV ![k[loginevent],v[1]]!

![k[loginevent],v[1]]! value is 1 if a tournament has started and we have something to display, 0 otherwise if no tournament is started


It will then ping status every 5 seconds (this is likely not needed): SEND ![k[im alive],v[1]]!


Getting current tournament status

SEND ![k[get],v[tournamentstatus]]! RECV ![k[tournamentstatus],v[0,1]]!


Starts a round robin

SEND ![k[tstart],v[{"format":"r","name":"testatest","location":"test","teams":["test1","test2"],"bestOf":"1,1,1","swissround":1,"warmup":"60"}]]! RECV ![k[bracket],v[{"tournament_name":"testatest","tournament_location":"test","format":"r","concluded":false,"stream_url":"","brackets":[{"bracket_type":"r","rounds":[{"round_num":0,"sets":[{"id":1,"best_of":1,"on_machine_name":"","start_time":"","teams":[{"name":"test1","score":0},{"name":"test2","score":0}],"victory_types":[],"match_data_id":[]}]}]}],"standings":[{"name":"test1","point":0,"win":0,"loss":0},{"name":"test2","point":0,"win":0,"loss":0}]}]]!

and also a start status:

RECV ![k[tstart],v[{"start":"True","format":"r","tournamentname":"testatest","message":"Can not connect to Database, bracket will only be locally saved."}]]!

Different formats:

{r:"round robin", w:"swiss", d:"double elimination", s:"single elimination", m:"manual"};

SEND ![k[tstart],v[{"format":"m","name":"manualtesting","location":"","teams":["team 1","team 2","team 3"],"bestOf":"1,1,1","swissround":2,"warmup":"60"}]]!

"swissround":2 seems to be determined by either the number of swiss rounds in swiss, or the number of teams - 1 in other modes. Not sure if this has any real use outside of swiss...


This ends tournament

SEND ![k[restarttourney],v[]]! RECV ![k[restarttourney],v[r,testatest,test,1,1,1,test1,test2]]!


Disconnect messages are sent as well:

SEND ![k[Disconnect],v[]]!