I want to build an iPhone game, which is real-time and turn-based, with a back-end implemented in Rails.
The game flow is like the following:
Player A and Player B will queue for a match. Then the server will match these 2 players into a match which is turn-based.
When the match starts, Player A waits while Player B is entering his action, and Player B waits while Player A entering his action.
The game ends after 5 or 6 turns.
What I am planning is that to use "Devise" for user authentication, and a RESTful API. The iOS game client will keep sending request to the server and ask if the opponent has finish his/her moves or not.
Is this approach correct for this kind of application? As this is the first time I use Rails to build an app, I am not sure which approach should be used. And there are far too many libraries or tools to choose from.
And if I use a RESTful API, how can I send request like
Any good suggestions?
I can't speak to the game-design aspects of the question, but as far as a RESTful API, you could try something like:
GET /available-opponents?ratingMin=XX&ratingMax=YY
POST /actions
{
"userId": "bob",
"gameId": 231,
"actionType": "StingLikeABee",
...
}
The only verb in your URI should be the HTTP verb: GET, POST, PUT, DELETE, etc.