Page 1 of 1
[SOLVED] Deck component and card_id
Posted: 04 April 2021, 02:32
by Badguizmo
Hello.
It is me again

.
Do we have a documentation on how "$this->cards->createCards" generates the card Id's ?
I am wondering because it does not seems to be related with the 'index" of the array of cards.
For example :
Code: Select all
// Create cards
$cards = array();
index = 1;
foreach( $this->colors as $color_id => $color ) // spade, heart, diamond, club
{
for( $value=2; $value<=14; $value++ ) // 2, 3, 4, ... K, A
{
$cards[] = array( 'type' => $color_id, 'type_arg' => $value, 'nbr' => 1);
index++;
}
}
$this->cards->createCards( $cards, 'deck' );
The card with the ID "1" will not necessarily the one with index "1".
I hope my question is clear.
NB : I am asking because I eventually need it for Riftforce as multiple cards have the same value (type_arg)
Re: Deck component and card_id
Posted: 04 April 2021, 09:04
by tchobello
hi
not sure why you need an index...
what do you wanna do once cards are created ?
Re: Deck component and card_id
Posted: 04 April 2021, 10:28
by Tisaac
Badguizmo wrote: ↑04 April 2021, 02:32
Hello.
It is me again

.
Do we have a documentation on how "$this->cards->createCards" generates the card Id's ?
I am wondering because it does not seems to be related with the 'index" of the array of cards.
For example :
Code: Select all
// Create cards
$cards = array();
index = 1;
foreach( $this->colors as $color_id => $color ) // spade, heart, diamond, club
{
for( $value=2; $value<=14; $value++ ) // 2, 3, 4, ... K, A
{
$cards[] = array( 'type' => $color_id, 'type_arg' => $value, 'nbr' => 1);
index++;
}
}
$this->cards->createCards( $cards, 'deck' );
The card with the ID "1" will not necessarily the one with index "1".
I hope my question is clear.
NB : I am asking because I eventually need it for Riftforce as multiple cards have the same value (type_arg)
It's a mess, never understood what the is the order logic with createCards. In Santorini we finally end up with adding the card ourself to the DB to be able to have control on the id.
Re: Deck component and card_id
Posted: 04 April 2021, 13:20
by tchobello
Tisaac wrote: ↑04 April 2021, 10:28
It's a mess, never understood what the is the order logic with createCards. In Santorini we finally end up with adding the card ourself to the DB to be able to have control on the id.
I think there is some shuffle done on creation in order to avoid some kind of cheating afterwards, based on card ids...
Re: Deck component and card_id
Posted: 04 April 2021, 13:57
by Tisaac
Oh ! That would make sense in this case !
Re: Deck component and card_id
Posted: 04 April 2021, 16:18
by Benoit314
Just consider you won't know the ID of the cards you create and don't implement your game logic based on this.
The difficulty with the doc is that there is only an example with a standard deck of cards. It is easy to adapt it to a game like UNO in which cards also have colours and numbers. Sometimes it is not the case.
You can use type and type_arg to know what the card is. In my game I have 50 different kind of cards, some are unique, other have up to 8 copies in the deck. I just defined an item ID for each kind of card and store the value in type.
When a player plays a card, I just load the correct card class based on type and execute the code.
I don't really know your game, there seems to be 1 deck per Guild. You could store the Guild ID in type and the card kind in type_arg or the other way around, or even don't store the Guild ID at all and have the info in your card class. It really depends on what you want to do with it.
Also, if you have a lot of different decks of cards that never interact with each other, they all can be in the same deck, but with different locations.
Re: Deck component and card_id
Posted: 04 April 2021, 22:38
by Badguizmo
Thank you all for your answers.
I think at first I will test with manual database insertion.
Maybe later I will check another way to do it
