14Plumes / Hexode

MIT License
0 stars 2 forks source link

Better separation between games and boards #14

Open Soreine opened 8 years ago

Soreine commented 8 years ago

I suggest to refactor a bit the API so we don't always serve the Board object along with games.

Endpoint Returns
List all ongoing games [Game]
Create a new game Game
Delete a game -
Join a game Game + Board
Create and join new game Game + Board
Invade an available tile Game + Board
Get a specific game's state Game + Board
KtorZ commented 8 years ago

What about getting rid of the game for join, invade and state ? Maybe split the last endpoint in two -> get a specific game's state | get a specific board's state which is basically just get a game, and get a board. This mean that we have a complete separation between game and board whereas, in the first place, they were tightly coupled because there is no point of considering a game without a board and a board without a game. There is a 1:1 relation between them and that's why I don't really the point of separating them.

However, if we do, then we have to do the separation completely and cleanly such that there are endpoints to manipulate a game, and endpoints to manipulate a given board but no endpoint to manipulate both of them.

Soreine commented 8 years ago

Join: it is useful to know who has joined the game after joining it, because that's a point where we would like to have a true snapshot of the game state (so who is in, and what the board looks like).

Invade: yes let's just return the board.

Get game and get board separation: yes. And the reason we do separate them is because they are two different entities. The game is a kind of meta-object, dealing with users and passwords and are listed in the lobby. The board is a representation of a game state, unaware of usernames etc. just dealing with the rules of the game and players with no identity other than "player 1" and "player 2". Another reason if because of visibility issues. We want to be able to list ongoing games or query the metadata of a particular game without giving access to the board etc.