Not able to moveCards during setupNewGame

Game development with Board Game Arena Studio
Post Reply
User avatar
panyakali
Posts: 15
Joined: 11 May 2020, 15:59

Not able to moveCards during setupNewGame

Post by panyakali »

Hi All,

First post here, and still trying to find my way around the BGA framework. I am building a game which has multiple sub-decks, each dealt from a common reserve of cards. Currently, I am able to create the common deck of cards, but when I try using moveCards, nothing happens in the game, and the database looks as if I had never run (successfully) the moveCards functions. Any idea what may be going wrong? Here is a snippet of the code from setupNewGame in my game.php file:

Code: Select all

        // Initialize an empty array for adding all cards to
        $cards = array ();
        $playercount = count($players);

        // First, the cards that have a variable count based on the number of players
        // ...these are: 'type_args' of 0 (starting side of Founders), 1 (flipped side of Founders), 59 (Town Square)
        $values = array(0, 1, 59);  
        foreach ($values as $value) { 
            $type = $this->card_types[$value]["type"];
            $nbr = $playercount;
            $cards [] = array ('type' => $type,'type_arg' => $value,'nbr' => $nbr );
        } 

        // Then, the cards that always have a set position during setup
        // These are: 'type' values of 'basic_villager' and 'road_setup'
        for ($value = 2; $value <= 10; $value ++) {
            $type = $this->card_types[$value]["type"];
            $nbr = $this->card_types[$value]["count"];
            $cards [] = array ('type' => $type,'type_arg' => $value,'nbr' => $nbr );
        }
        
...       

        // Make the deck from all defined cards
        $this->cards->createCards( $cards, 'deck' );

        // Split the cards into special decks for all the different kinds of cards needed for setup
        $starting_founders = $this->cards->getCardsOfType( 'founders', 0 );
        $specific_ids = array ();
        foreach ($starting_founders as $specific_card) { 
            $specific_id = $specific_card['id'];
            $specific_ids [] = $specific_id; 
        }
        $this->cards->moveCards( $specific_ids, 'sideA_founders');
...and, yes, I made sure to also include this in __construct for the same file, game.php:

Code: Select all

		// declare your Deck component in your PHP code in your class constructor
		// define a cards object of type deck for our NavComp cards
        $this->cards = self::getNew( "module.common.deck" );
		// initialize the deck and associate it with table in DB
        $this->cards->init( "cards" ); // "cards" is the name of the table associated with the villager deck
...and, by far the most confusing part- although the code doesn't appear to run properly in the setupNewGame portion of the code, when I define essentially the same code in the utilities section of game.php and run it via the chat window debugging on a live studio game, it *does* actually do what it's supposed to do, and it moves the specified cards to the proper location:

Code: Select all

    function util_moveCardsByType( $type, $type_arg ) {
        $return_array = $this->cards->getCardsOfType( $type, $type_arg );
        // $json_to_print = json_encode($return_array);
        $specific_ids = array ();
        foreach ($return_array as $specific_card) { 
            $specific_id = $specific_card['id'];
            $specific_ids [] = $specific_id;
        }
        // $json_to_print = array_keys();
        self::debug(json_encode($specific_ids));

        $this->cards->moveCards($specific_ids, 'founders');

        return 0;
    }
Thanks,
Collin
User avatar
Brainchild
Posts: 71
Joined: 31 January 2014, 19:42

Re: Not able to moveCards during setupNewGame

Post by Brainchild »

Just based on the code snippets you posted, this line stands out as suspicious:

Code: Select all

        $starting_founders = $this->cards->getCardsOfType( 'founders', 0 );
Will you share your material.inc.php?
User avatar
panyakali
Posts: 15
Joined: 11 May 2020, 15:59

Re: Not able to moveCards during setupNewGame

Post by panyakali »

Thanks for the reply! Here's the user-defined contents of material.inc.php:

Code: Select all

// This array stores the suit names of each value present in the "suit" field of card_types
// 0 = Grains, 1 = Solitary, 2 = Hay, 3 = Ore, 4 = Wood, 5 = Grapes, 6 = Special, 7 = Leather, 8 = Wool
$this->suits = array(
	0 => array( 'name' => clienttranslate('grains'),
                'nametr' => self::_('grains') ),
    1 => array( 'name' => clienttranslate('solitary'),
                'nametr' => self::_('solitary') ),
    2 => array( 'name' => clienttranslate('hay'),
                'nametr' => self::_('hay') ),
    3 => array( 'name' => clienttranslate('ore'),
                'nametr' => self::_('ore') ),
    4 => array( 'name' => clienttranslate('wood'),
				'nametr' => self::_('wood') ),
	5 => array( 'name' => clienttranslate('grapes'),
				'nametr' => self::_('grapes') ),
	6 => array( 'name' => clienttranslate('special'),
				'nametr' => self::_('special') ),
	7 => array( 'name' => clienttranslate('leather'),
				'nametr' => self::_('leather') ),
	8 => array( 'name' => clienttranslate('wool'),
                'nametr' => self::_('wool') ),
);


// This array stores all of the static card information for each unique card face (there are usually two actual cards of each unique card face)
// "type" - The group of cards into which this card is logically grouped, for the purposes of gameplay; linked to the db field `card_type`
//          VALUES: "founders", "basic_villager", "road_setup", "always_in_deck", "special", "in_deck_for_four_plus"
// "count" - The number of actual cards of this card face that should be in the deck; this also denotes the number of unique card_id's that will be made in the db on setup
//           VALUES: 5 (for max player count) Founders, 10 of each basic villager type, 1 of each road setup card (and another 1 in the deck), and 2 of every other card
// "name" - The name of this unique card face; clienttranslate is used to allow for multilingual compatibility
// "suit" - The type of symbol at the top center of each card (and usually on the back side of the card as well)
//          VALUES: 0 = Grains, 1 = Solitary, 2 = Hay, 3 = Ore, 4 = Wood, 5 = Grapes, 6 = Special, 7 = Leather, 8 = Wool
// "suit_symbols" - The number of suit symbols showing on the top of the card; usually just 1, but sometimes 2
// "chain_predecessor" - The card_type array index (and also db `card_type_arg` value) of the card on top of which this card must be played
//                       NOTE: If a villager must be placed on the Founders card, it is allowed to be preceded by 0 (face-up Founders) OR 1 (flipped Founders)
//                             Also, any villager that is not a 1st level card may be placed on the Monk card (47) in addition to its usual predecessor
// "unlocked_by" - The card_type array index (and also db `card_type_arg` value) of the card that must be paid 2 money when this card is played
// "food_symbols" - The number of food (card drafting) symbols that this card provides while it is the top card in a chain
// "builder_symbols" - The number of builder (card playing) symbols that this card provides while it is the top card in a chain
// "gold_value" - The amount of money that this card provides in the 1st & 2nd market phases while it is the top card in a chain
// "silver_value" - The amount of money that this card provides in the 2nd market phases, conditional on "silver_criteria"
// "silver_criteria" - The multiplier on "silver_value", usually multiplies that number by the number of a certain kind of symbol
// "special_action" - The special ability for each of the "Special" suit cards
$this->card_types = array(
     0 => array( "type" => "founders", 
                 "count" => 5, 
                 "name" => clienttranslate("Founders"), 
                 "suit" => 0,
             	 "suit_symbols" => 1,
             	 "chain_predecessor" => NULL,
             	 "unlocked_by" => NULL,
             	 "food_symbols" => 0,
             	 "builder_symbols" => 0,
             	 "gold_value" => 2,
             	 "silver_value" => 0,
             	 "silver_criteria" => NULL,
             	 "special_action" => NULL
             	 ),
     1 => array( "type" => "founders", 
                 "count" => 5, 
                 "name" => clienttranslate("Founders"), 
                 "suit" => 0,
             	 "suit_symbols" => 1,
             	 "chain_predecessor" => NULL,
             	 "unlocked_by" => NULL,
             	 "food_symbols" => 1,
             	 "builder_symbols" => 0,
             	 "gold_value" => 0,
             	 "silver_value" => 0,
             	 "silver_criteria" => NULL,
             	 "special_action" => NULL
				  ),
	 2 => array( "type" => "basic_villager", 
				 "count" => 10, 
				 "name" => clienttranslate("Hayer"), 
				 "suit" => 2,
				 "suit_symbols" => 1,
			     "chain_predecessor" => NULL,
				 "unlocked_by" => NULL,
				 "food_symbols" => 0,
				 "builder_symbols" => 0,
				 "gold_value" => 0,
				 "silver_value" => 0,
				 "silver_criteria" => NULL,
				 "special_action" => NULL
				 ),
     3 => array( "type" => "basic_villager", 
                 "count" => 10, 
                 "name" => clienttranslate("Miner"), 
                 "suit" => 3,
             	 "suit_symbols" => 1,
             	 "chain_predecessor" => NULL,
             	 "unlocked_by" => NULL,
             	 "food_symbols" => 0,
             	 "builder_symbols" => 0,
             	 "gold_value" => 0,
             	 "silver_value" => 0,
             	 "silver_criteria" => NULL,
             	 "special_action" => NULL
				  ),
	 4 => array( "type" => "basic_villager", 
				 "count" => 10, 
				 "name" => clienttranslate("Lumberjack"), 
				 "suit" => 4,
				 "suit_symbols" => 1,
				 "chain_predecessor" => NULL,
				 "unlocked_by" => NULL,
				 "food_symbols" => 0,
				 "builder_symbols" => 0,
				 "gold_value" => 0,
				 "silver_value" => 0, 
				 "silver_criteria" => NULL,
				 "special_action" => NULL
				 ),
     5 => array( "type" => "road_setup", 
                 "count" => 1, 
                 "name" => clienttranslate("Harvester"), 
                 "suit" => 1,
             	 "suit_symbols" => 1,
             	 "chain_predecessor" => NULL,
             	 "unlocked_by" => NULL,
             	 "food_symbols" => 1,
             	 "builder_symbols" => 0,
             	 "gold_value" => 0,
             	 "silver_value" => 0,
             	 "silver_criteria" => NULL,
             	 "special_action" => NULL
				  ),
     6 => array( "type" => "road_setup", 
			     "count" => 1, 
			     "name" => clienttranslate("Thatcher"), 
			     "suit" => 2,
			     "suit_symbols" => 1,
			     "chain_predecessor" => array(2, 47),
			     "unlocked_by" => NULL,
			     "food_symbols" => 0,
			     "builder_symbols" => 1,
		         "gold_value" => 2,
			     "silver_value" => 0,
			     "silver_criteria" => NULL,
		         "special_action" => NULL
				 ),
	 7 => array( "type" => "road_setup", 
				 "count" => 1, 
			     "name" => clienttranslate("Blacksmith"), 
			     "suit" => 3,
			     "suit_symbols" => 1,
			     "chain_predecessor" => array(3, 47),
				 "unlocked_by" => NULL,
				 "food_symbols" => 0,
				 "builder_symbols" => 0,
				 "gold_value" => 2,
				 "silver_value" => 0,
				 "silver_criteria" => NULL,
				 "special_action" => NULL
				 ),
	 8 => array( "type" => "road_setup", 
                 "count" => 1, 
                 "name" => clienttranslate("Carpenter"), 
                 "suit" => 4,
             	 "suit_symbols" => 1,
             	 "chain_predecessor" => array(4, 47),
             	 "unlocked_by" => NULL,
             	 "food_symbols" => 0,
             	 "builder_symbols" => 1,
             	 "gold_value" => 0,
             	 "silver_value" => 0,
             	 "silver_criteria" => NULL,
             	 "special_action" => NULL
				  ),
     9 => array( "type" => "road_setup", 
			     "count" => 1, 
			     "name" => clienttranslate("Cooper"), 
			     "suit" => 4,
			     "suit_symbols" => 1,
			     "chain_predecessor" => array(4, 47),
			     "unlocked_by" => 7,
			     "food_symbols" => 0,
			     "builder_symbols" => 0,
		         "gold_value" => 4,
			     "silver_value" => 0,
			     "silver_criteria" => NULL,
		         "special_action" => NULL
				 ),
	 10 => array( "type" => "road_setup", 
		 		  "count" => 1, 
		 	      "name" => clienttranslate("Poulterer"), 
			      "suit" => 0,
			      "suit_symbols" => 1,
			      "chain_predecessor" => array(0, 1, 47),
				  "unlocked_by" => 8,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 3,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				 ),
     11 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Beekeeper"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => 8,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 4,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
			      ),
     12 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Fisher"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => 35,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 3,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 13 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Wattler"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 1,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 14 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Chandler"), 
				  "suit" => 1,
				  "suit_symbols" => 2,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 3,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
			      ),
     15 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Hunter"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 16 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Grocer"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => 5,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 3,
				  "silver_criteria" => "per Food symbol",
				  "special_action" => NULL
				  ),
	 17 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Freemason"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => 40,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 3,
				  "silver_criteria" => "per Builder symbol",
				  "special_action" => NULL
				  ),
	 18 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Priest"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => 14,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 3,
				  "silver_criteria" => "per 2 solitary symbols",
				  "special_action" => NULL
				  ),
	 19 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Plower"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 2,
				  "silver_criteria" => "per grain symbol",
				  "special_action" => NULL
				  ),
	 20 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Scribe"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 1,
				  "silver_criteria" => "per card in hand",
				  "special_action" => NULL
				  ),
	 21 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Agent"), 
				  "suit" => 1,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 1,
				  "silver_criteria" => "per coin on your single (highest) unlocking villager",
				  "special_action" => NULL
				  ),
	 22 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Milk Maid"), 
				  "suit" => 2,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(24, 47),
				  "unlocked_by" => 9,
				  "food_symbols" => 2,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 23 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Bed Builder"), 
				  "suit" => 2,
				  "suit_symbols" => 2,
				  "chain_predecessor" => array(2, 47),
				  "unlocked_by" => 8,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 4,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 24 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Grazier"), 
				  "suit" => 2,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(2, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
			      ),
     25 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Fromager"), 
				  "suit" => 2,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(22, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 15,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 26 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Peddler"), 
				  "suit" => 2,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(2, 47),
				  "unlocked_by" => 8,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 3,
				  "silver_criteria" => "per 2 gold symbols",
				  "special_action" => NULL
				  ),
	 27 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Ore Muler"), 
				  "suit" => 2,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(2, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 3,
				  "silver_criteria" => "per 2 ore symbols",
				  "special_action" => NULL
				  ),
	 28 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Horse Trader"), 
				  "suit" => 2,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(2, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 3,
				  "silver_criteria" => "per 2 hay symbols",
				  "special_action" => NULL
				  ),
	 29 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Glass Blower"), 
				  "suit" => 3,
				  "suit_symbols" => 2,
				  "chain_predecessor" => array(3, 47),
				  "unlocked_by" => 7,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 4,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 30 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Spelunker"), 
				  "suit" => 3,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(32, 47),
				  "unlocked_by" => 14,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 10,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 31 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Jeweler"), 
				  "suit" => 3,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(30, 47),
				  "unlocked_by" => 7,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 20,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 32 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Seeker"), 
				  "suit" => 3,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(3, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
			      ),
     33 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Mason"), 
				  "suit" => 3,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(3, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 1,
				  "gold_value" => 2,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 34 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Locksmith"), 
				  "suit" => 3,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(3, 47),
				  "unlocked_by" => 7,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 2,
				  "silver_criteria" => "per padlock symbol",
				  "special_action" => NULL
				  ),
	 35 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Shipwright"), 
				  "suit" => 4,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(4, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 1,
				  "gold_value" => 2,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 36 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Wheeler"), 
				  "suit" => 4,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(4, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 3,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 37 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Cartwright"), 
				  "suit" => 4,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(36, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 9,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
			      ),
     38 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Log Rafter"), 
				  "suit" => 4,
				  "suit_symbols" => 2,
				  "chain_predecessor" => array(4, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 1,
				  "silver_criteria" => "per wood symbol",
				  "special_action" => NULL
				  ),
	 39 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Wood Carver"), 
				  "suit" => 4,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(4, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 1,
				  "silver_criteria" => "per gold value printed and showing on wood villagers",
				  "special_action" => NULL
				  ),
	 40 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Brewer"), 
				  "suit" => 0,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(0, 1, 47),
				  "unlocked_by" => 9,
				  "food_symbols" => 1,
				  "builder_symbols" => 1,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 41 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Swinehero"), 
				  "suit" => 0,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(0, 1, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 2,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 42 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Truffler"), 
				  "suit" => 0,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(41, 47),
				  "unlocked_by" => 15,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 8,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 43 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Graper"), 
				  "suit" => 5,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 44 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Vintner"), 
				  "suit" => 5,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(43, 47),
				  "unlocked_by" => 9,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 5,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 45 => array( "type" => "always_in_deck", 
				  "count" => 2, 
				  "name" => clienttranslate("Wine Trader"), 
				  "suit" => 5,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(44, 47),
				  "unlocked_by" => 29,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 14,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
     46 => array( "type" => "special", 
				  "count" => 2, 
				  "name" => clienttranslate("Apprentice"), 
				  "suit" => 6,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "Replace any non-top villager in any village with Apprentice; place replaced villager in your village"
				  ),
	 47 => array( "type" => "special", 
				  "count" => 2, 
				  "name" => clienttranslate("Monk"), 
				  "suit" => 6,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "Use the monk in the place of any villager in a production chain, but don't replace, use when building"
				  ),
	 48 => array( "type" => "special", 
				  "count" => 2, 
				  "name" => clienttranslate("Smuggler"), 
				  "suit" => 6,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => 35,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "DISCARD ON USE; Immediately take from the bank half of the (highest) gold value printed on one of your villagers"
				  ),
	 49 => array( "type" => "special", 
				  "count" => 2, 
				  "name" => clienttranslate("Tinner"), 
				  "suit" => 6,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "DISCARD ON USE; Unlock any villagers that you play this turn for free (unless they are unlocked by your own villager)"
				  ),
	 50 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Tanner"), 
				  "suit" => 7,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 2,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 51 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Saddler"), 
				  "suit" => 7,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(50, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 5,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 52 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Cobbler"), 
				  "suit" => 7,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(50, 47),
				  "unlocked_by" => 7,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 6,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 53 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Shepherd"), 
				  "suit" => 8,
				  "suit_symbols" => 1,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 1,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 54 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Spinner"), 
				  "suit" => 8,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(53, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 4,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 55 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Weaver"), 
				  "suit" => 8,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(54, 47),
				  "unlocked_by" => 8,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 12,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				  ),
	 56 => array( "type" => "in_deck_for_four_plus", 
				  "count" => 2, 
				  "name" => clienttranslate("Tailor"), 
				  "suit" => 8,
				  "suit_symbols" => 1,
				  "chain_predecessor" => array(55, 47),
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 24,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => NULL
				 ),
	 57 => array( "type" => "markets", 
				  "count" => 1, 
				  "name" => clienttranslate("First Market"), 
				  "suit" => 6,
				  "suit_symbols" => 0,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 24,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "Gain gold for all visible gold values and coins on cards (but the coins remain on cards)"
				 ),
	 58 => array( "type" => "markets", 
				  "count" => 1, 
	 			  "name" => clienttranslate("Second Market"), 
				  "suit" => 6,
				  "suit_symbols" => 0,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "Gain gold for all visible gold and silver values and coins on cards"
				 ),
	 59 => array( "type" => "helper_cards", 
				  "count" => 5, 
				  "name" => clienttranslate("Village Square"), 
				  "suit" => 6,
				  "suit_symbols" => 0,
				  "chain_predecessor" => NULL,
				  "unlocked_by" => NULL,
				  "food_symbols" => 0,
				  "builder_symbols" => 0,
				  "gold_value" => 0,
				  "silver_value" => 0,
				  "silver_criteria" => NULL,
				  "special_action" => "Place drafted cards here"
				  )
);
Hope that helps!
User avatar
panyakali
Posts: 15
Joined: 11 May 2020, 15:59

Re: Not able to moveCards during setupNewGame

Post by panyakali »

OK, so... allow me to preface this with: I was building the game in question on top of the hearts tutorial that I had just used to learn the basics of the BGA framework. If you know where this is going, then you've probably read a whole bunch of first-time BGA card game developer posts.

The issue, as I finally discovered, was not that my cards were never being put into the right locations. In hearts (the game that I Mona Lisa'd here), thirteen cards are dealt to each of four players every hand, which means that you need to collect all of the cards into 'deck' at the start of each round. I hadn't yet gotten around to messing with the game states, and the first logical 'robot' or 'game' state that is completed, directly after setup, is `stNewHand`... and who can guess what the first method is that's called by `stNewHand`? That's right, it takes all of the cards from wherever else they might be in the game and puts them all into 'deck' so that the correct number of cards can be dealt to everyone:

Code: Select all

        // Take back all cards (from any location => null) to deck
        $this->cards->moveAllCardsInLocation(null, "deck");
Commenting out this line of code magically makes all of the cards appear in the proper locations defined at setup- so that's the most basic fix here (Although, I will of course be making proper game states and state machine soon].

I am a moron, and I'm sorry for wasting anyone's time who looked at this thread, sincerely tried to help, and was puzzled. I think it may be helpful to keep this thread up anyway, just in case another first-time card game BGA developer happens to run into the same boneheaded issue here that I did...
Post Reply

Return to “Developers”