Page 1 of 1

Best way to initialize complex card at game start?

Posted: 14 March 2024, 20:30
by damlepetitpasblond
Hello, I am trying to develop a game here, and I have a question about the way to initialize the card of a complex deck.

What I mean by complex is each card is different and have data associated with it that cannot be initialized like the tutorial of heart (which is 2 for loop).

What is the best way to enter the data for each card (name, value, color, etc.)? I thought about creating every cards in the sql file and getting all the cards in the php with a sql request to form the deck, but I am not sure if this is the best solution.

What is you thought about this?

Re: Best way to initialize complex card at game start?

Posted: 14 March 2024, 21:01
by vurtan
Hi,
I would put the static information as array in the material.inc.php. There you can reference each card with an number/id.

In the xxx.game.php during setupNewGame you have two options:
- go over each entry from that array and use the Deck component with createCards to create each time a single card
- create your sql statement manually and insert the data directly in the table the Deck component uses

Only the dynamic information which changes during the game (location of card, status, health, etc.) should be in the database.
If you cannot fit the dynamic information in the base columns of the Deck component, extend the table with custom ones (and then you must use the 2nd option from the list above).