Page 1 of 1

php Deck: createCards and location_arg

Posted: 05 January 2021, 21:50
by RicardoRix
Using the php deck component, when trying to initialise the location_arg with a large number, like the player_id, it corrupts the number, I was getting values between 50 and 70.

I initialise the type_arg with the same number as that is fine.

Code: Select all

		
$actionCards = [];
foreach( $players as $player_id => $player )
{
	for( $value=100; $value<=103; $value++ )   
        {
		$actionCards[] = array( 'type' => $value, 'type_arg' => $player_id, 'location_arg' => $player_id, 'nbr' => 1);
	}	
}		
 $this->cards->createCards( $actionCards, 'action_hand' );			
If afterwards I do this:

Code: Select all

		self::DbQuery( "UPDATE card SET card_location_arg=card_type_arg WHERE card_location='action_hand'");	
then the card_location_arg is now OK.

Re: php Deck: createCards and location_arg

Posted: 06 January 2021, 06:58
by Loreroth
I'm not sure that you can set the location_arg through the array, the documentation only provides for setting it through the create cards method.

Code: Select all

createCards( $cards, $location='deck', $location_arg=null )
https://en.doc.boardgamearena.com/Deck# ... _component

Re: php Deck: createCards and location_arg

Posted: 06 January 2021, 10:07
by RicardoRix
yes, you are right, Thanks.

I have used the argument in create cards instead and that works fine.

I got slightly hung-up on this statement:
Note: createCards is optimized to create a lot of cards at once. Do not use it to create cards one by one.