In order to stop our engineers from doing stupid things and "accidentally" DDOSing the museum's database, we have updated the base code the teachers provided to us to make it "Stupid-Proof".
Firstly, to coincide with the coding conventions in our group, we have adjusted all the arguments the game receives from the player to be accessible via properties instead of getter methods.
Then, since the Arguments are simply data received from the player, we have changed them to be a simpe C# class.
Furthermore, we have added an Initialized property to the Arguments to let our engineers know whether there is a connection to the museum's database or not.
![](https://i.gyazo.com/d4aa598a89e55d538e44fe03626603a8.png)
Next, we created an exposed method that starts a request as a coroutine in order to take control of how many times the coroutine is started. This way, users of the API are unable to start millions of requests to the database, crashing it.
Moreover, we have added an optional System.Action parameter that allows the engineers to take specific actions after the request is processed. In our case, we are using it to proceed to the next level once the score has been uploaded.
![](https://i.gyazo.com/8695f1857d44800a39c0b1fc97dd687d.png)
This framework allows us to take the players score and upload it to the museum's database. However, the problem is that there is no way currently to get the score from the server. In other words, this renders this entire system useless and makes us unable to create a high score system, unless we store the high scores locally on the computer where the game is run.
No comments:
Post a Comment