Players resources - how to store them

Game development with Board Game Arena Studio
Post Reply
User avatar
Hornir91
Posts: 38
Joined: 15 October 2018, 06:39

Players resources - how to store them

Post by Hornir91 »

Hello.

I am currently developing a game in the studio and have a question.

How do you store players resources in the database?

Should I extend players table and add columns to store quantity of eg. "food" and "gold" tokens and in JS make just a visual representation based on these values or store every resource token in db as a independent record and then just assign playerId to them when player should receive one?
User avatar
RicardoRix
Posts: 2540
Joined: 29 April 2012, 23:43

Re: Players resources - how to store them

Post by RicardoRix »

You could do it that way, if it's just a quantity, but otherwise I would create a new table. Personally speaking, I have a generic data table with player_id for this kind of thing. The framework also has a built-in 'global vars' which could be fudged for this too:
https://en.doc.boardgamearena.com/Main_ ... se_globals

For individual tokens that normally have ids: Usual is either : 1 table per kind of resource, or 1 table for all resources with a 'token_type' field.

However you like though, world is your oyster.
User avatar
Hornir91
Posts: 38
Joined: 15 October 2018, 06:39

Re: Players resources - how to store them

Post by Hornir91 »

Thank you for the answer :).

Actually I will stick with having one big table for tokens used in the game.
User avatar
RicardoRix
Posts: 2540
Joined: 29 April 2012, 23:43

Re: Players resources - how to store them

Post by RicardoRix »

In the 'sharedcode' project there is a file called tokens.php. I believe that's the general idea for that - to have just 1 table for all tokens.
https://github.com/elaskavaia/bga-share ... er/modules
User avatar
LeSteffen
Posts: 75
Joined: 13 July 2020, 15:32

Re: Players resources - how to store them

Post by LeSteffen »

Here's what I do:
1. For game-wide values (e.g. turn number) I use the BGA framework's setGameStateValue()
2. For simple player-related variables I extend the player table
3. Everything else needs it's own DB table

:-)
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Players resources - how to store them

Post by Tisaac »

Hornir91 wrote: 14 January 2024, 13:49 Hello.

I am currently developing a game in the studio and have a question.

How do you store players resources in the database?

Should I extend players table and add columns to store quantity of eg. "food" and "gold" tokens and in JS make just a visual representation based on these values or store every resource token in db as a independent record and then just assign playerId to them when player should receive one?
Both approach are perfectly valid and i have used both in my games. The main criterion for me to decide is whether these tokens might be displayed somewhere outside of these reserves. If it's just some kind of "money", then sure you can put them in player db. But if like agricola, meeples Can be placed on your player board, on next action space, on cards, etc, then it's much easier to just store them in a "token" db (i use my own augmented version or deck for that)
Post Reply

Return to “Developers”