Closed Spheroman closed 5 months ago
Here's how this is going to work.
First, the player accesses the pairingpage.php. It checks the session variable for a pairing id. if there is a pairing id, then load that pairing from the database and check if it's completed. If it isn't completed, then show the user the pairing, and on complete send a post request to itself with the ID of the winner along with the pairing ID so it can cross check with the session variable.
When it recieves a post request, it will call the pairing->setwinner, and if it is valid, it will call the calculate function in the pairing class to update the rating for the pairings. It will then update itself in the database, and go to create a new pairing.
If the pairing is missing or the pairing ID is marked complete, or if either of the values in the post request are invalid, then it should generate a new pairing, add it to the database, and then show the user the pairing so it can be completed.
When it generates a pairing, it will create a pairing, and add it to the pairings database even though it is unfilled. This way we can prevent pairing scumming by refreshing the page by keeping the pairing id in the session variable and loading it from the database. Another option is to save the pairing object itself in the session variable.
This is where we show a pairing. Basically have the two options with large buttons to choose between them. Store this pairing in a session variable.
Then send a post request to another page that will submit it to the database and redirect to pairingpage.php, similar to add.php and whatnot. It should only need to send the winner and the pairing id, as the pairing class should handle everything else.
Also have a counter in the session variable, and we should probably have an option for minimum or maximum number of loops or something. When its looped n times, redirect to the ranking page.