[SOLVED] Deck component and card_id

Game development with Board Game Arena Studio
Post Reply
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

[SOLVED] Deck component and card_id

Post 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)
Last edited by Badguizmo on 04 April 2021, 22:38, edited 1 time in total.
Official BGA developper newb :oops:
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: Deck component and card_id

Post by tchobello »

hi

not sure why you need an index...

what do you wanna do once cards are created ?
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: Deck component and card_id

Post 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.
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: Deck component and card_id

Post 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...
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: Deck component and card_id

Post by Tisaac »

Oh ! That would make sense in this case !
User avatar
Benoit314
Posts: 82
Joined: 02 April 2020, 22:12

Re: Deck component and card_id

Post 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.
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Deck component and card_id

Post 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 ;)
Official BGA developper newb :oops:
Post Reply

Return to “Developers”