Troupe battle
Troupe battle is an async multiplayer game which is made within unity, created with C#. The server makes use of PHP with a MySQL database
How does Troupe battle work?
The video below shows the process of an account being made, once an account is made it will show up within the database which allows the database to identify which account is yours which also allows you to log into the account automatically. Each account has a unique token to allow the database to identify which data is your account.
I also gave an example within the video showing how the process is with buying items within the database, the example shown below is buying a woodcutter with 10 gold and 5 iron, once we have bought the woodcutter the database will be updated to show that we now own one woodcutter and have 15 iron remaining in our inventory. The token used within the game gives us permission to do these actions.
PHP code snippets
The script below can create an account which allows you to create and log into your account, for the script to work it takes the individuals email, username and password to make the account. The script will then put the email, username and password into the database. If the email already exists the script will relay it back to the player to let them know that they need to use a different email to make an account.
When logging into the account the script will take the email and look at the password you have given the database to compare the details of the account with the details on the database, this will allow the player to sign into the account as long as the password is the same as the password the database holds, this then creates a unique token for the account.
This is the PHP code for making an account and logging in. Below you can see the C# code for this PHP code.
C# code snippets
This script works the same as the first script however, it talks to the first script to tell that script to work a certain way, the script allows information to pass through to the first script to create an account and to allow players to sign into their account to access the game.