Day3 - server
I decided to write the server in flask, as it is a pretty common small framework people use. I sort of wanted to use hug, since my api should be only json and I don't need any templating or html, but I wanted something that could come with authentication that would be really easy to copy and paste or quickstart. I found the answer in flask faster than the answer for hug, which is less common. I chose flask-security which has most of the pieces, and away we went.
There is now an api with the following commands:
- You can register a new account
- You can create a game - you are randomly assigned to either player 1 or player 2
- The /home route gives you some user state, including a list of games you are a player in
- You can join a game - you are slotted into the unassigned player, and there is verification that the game is open
- You can ask for the current state of a game - this gives you all of the game state, in the same format the client understands. There is verification that you are actually a player in that specific game
- You can play a card - there is verification that it is currently your turn. The state of the game is appropriately transformed according to the game model I wrote yesterday, and as a shortcut for testing, the game model is asked to end the current player's turn.
Through api commands, you can play the game, just like you would in the client. Everything is persisted to a database, so asyncronous play is absolutely feasible. Cool! The next step is to hook up the client - I just have to figure out how to get the kivy networking to authenticate with the server, and save any session cookies that need to be kept around.
Oh... the most important thing to do now is design the game. I can do a paper prototype and take it to the board game design group on wednesday. If I finish the client on thursday, that gives me about 2 days to implement whatever game I designed into my functioning game model.