This will represent each round of the game. Feel free to create 2 branches/PRs if you need, 1 for table, and 1 for model.
Table
game_id FK
player_id FK
round_type - string enum
position - int
scores - jsonb
Unique validation for (game_id, player_id, round_type), which means that in a game, a player can play a type of round just once (e.g. You can only choose King of Hearts just once)
The game_id will be the game where this round was played
The player_id will be the player that chooses this round
The round_type will be a string value from a pre-defined enum
The scores will hold all the scores of the playing players. E.g. { marius: -100, robert: -300 } for queens, or { marius: 0, robert: -400 } for king of hearts
Model
Validate the uniqueness of (game_id, player_id, round_type)
Define the round_type enum, as
Feel free to change the enum with the desired values (e.g. you can remove levate/whist/totale/renta, and add totale_minus, totale_plus, rentz_minue, rentz_plus)
This will represent each round of the game. Feel free to create 2 branches/PRs if you need, 1 for table, and 1 for model.
Table
Unique validation for (game_id, player_id, round_type), which means that in a game, a player can play a type of round just once (e.g. You can only choose King of Hearts just once)
The game_id will be the game where this round was played The player_id will be the player that chooses this round The round_type will be a string value from a pre-defined enum The scores will hold all the scores of the playing players. E.g.
{ marius: -100, robert: -300 }
for queens, or{ marius: 0, robert: -400 }
for king of heartsModel
:constant
type is the easiest - it will always be that score:per_player
type means the total score should bescore * players.count * 2
-50 * 3 * 2
=>-300
50 * 4 * 2
=>400
:predefined
will be the trickiest, as we need to define it specifically1200 (800/400/0)
, while for 4 players you might want a different value