Evolution Deck: Creating the stock

Game development with Board Game Arena Studio
Post Reply
User avatar
phranklon
Posts: 11
Joined: 06 April 2020, 19:26

Evolution Deck: Creating the stock

Post by phranklon »

Hello all again,

I'm sorry for posting this again, but I wanted to ask my question in a simpler way. I saw that my first post got a lot of views, but no responses. I figured my question was too vague, so I'm trying again a different, more specific way.

I have made a single jpg with all the games cards on it. It has 17 rows (each row being a trait - eg. carnivore, cooperation, hard shell). The "carnivore" trait has 17 cards and it is on my first row. The rest of the traits only have 7 cards each and they are on subsequent rows. Needless to say, I have a LOT of white space, so when I create my stock, and follow that i have 17 items per row (only for the sake of my carnivore row), the rest of my rows still get made with 7 legit cards and 10 blank cards each. :shock:

From what I see, I have 3 options... My question is, which seems easier (or even possible)?

1. Continue with this creation of my stock and figure out a way to delete all my blanks so they are not used AND not messing with the statistics of gameplay.

2. Create two different jpg files (my carnivores + all my other traits) and make separate stocks with each that can be combined as one deck later.

3. Make a single jpeg with a "clean" grid of cards (3 x 43) and loose the functionality of my rows and columns being used to determine which trait or value a card is.

Thanks,
Phranklon
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: Evolution Deck: Creating the stock

Post by tchobello »

Hello,
There are 129 cards in Evolution but they are not all different.
In your graphic file, you only need 1 instance of each card.

In Camouflage, you have 6 cards but only 3 different ones : one Camouflage 2, four Camouflage 3 and one Camouflage 4.

More over, on each card, the number on bottom right has same shape (a green quarter) on all 129 cards.
You could only use 18 cards (2 for carnivors) and add the bottom right number as another sprite over it.
But it might make things a little more difficult...
User avatar
Benoit314
Posts: 82
Joined: 02 April 2020, 22:12

Re: Evolution Deck: Creating the stock

Post by Benoit314 »

I tried to answer to your post this morning but didn't find it... ;)

I would tend to use the solution suggested by tchobello. I would do some photoshop to remove the numbers in the corner and insert it with css or add a sprite with the number for each value.
It would reduce a lot the size of the card image.

Concerning the Hearts tutorial, since your deck isn't a "normal" card deck, don't follow the rows/suite logic. I see 2 options
  • Take the values from your deck definition in material.inc.php to create the cards.In your deck definition, include the position of each card on your image.
  • Do a loop with the number of cards on the image
The first is more suitable if there is gaps (ex: cards cover) you want to skip. In your case a simple loop should be fine.

Check on this page, there are a few examples of games with cards: http://en.doc.boardgamearena.com/BGA_Code_Sharing
(Assyria, Nile, etc)
User avatar
phranklon
Posts: 11
Joined: 06 April 2020, 19:26

Re: Evolution Deck: Creating the stock

Post by phranklon »

Thanks for the link. I didn't realize that was available.

Also, thank you for the idea about only making one image per unique instance of a card. That brought it down from 129 cards to 99 at least.

I did make a grid and I spaced them out with only their values of food numbers that existed. It worked pretty well. They all snapped, and I went back to make sure they were the same amount of pixels apart so I wouldn't have drift for the further down cards.

Please check out my code below let me know what else I need to add to make this work or if my dream is impossible. I am just starting out and I haven't a clue if any of this will stick, so it won't hurt my feelings if it's all wrong.

This is the code I have in .js (I switched the word 'color' for 'trait' since that's what the game calls them.

Code: Select all

// TODO: Set up your game interface here, according to "gamedatas"
            // Player hand
    this.playerHand = new ebg.stock(); // new stock object for hand
    this.playerHand.create( this, $('myhand'), this.cardwidth, this.cardheight );
    this.playerHand.image_items_per_row = 13; // 13 images on first row

//Create cards types
    for(var trait = 1; trait <= 17; trait++){
      for(var value = -3; value <= 9; value++){
        //build card type id
        var card_type_id = this.getCardUniqueId(trait, value);
        this.playerHand.addItemType(card_type_id, card_type_id, g_gamethemeurl+"img/cards.jpg", card_type_id)
  }
}
This is the code I have in the inc.php EDIT: my materials.inc.php

Code: Select all

 $this->traits = array(
     1 => array( 'name' => clienttranslate('ambush'),
                 'nametr' => self::_('ambush') ),
     2 => array( 'name' => clienttranslate('burrowing'),
                 'nametr' => self::_('burrowing') ),
     3 => array( 'name' => clienttranslate('carnivore'),
                 'nametr' => self::_('carnivore') ),
     4 => array( 'name' => clienttranslate('climbing'),
                 'nametr' => self::_('climbing') ),
     5 => array( 'name' => clienttranslate('cooperation'),
                  'nametr' => self::_('cooperation') ),
     6 => array( 'name' => clienttranslate('defensive_herding'),
           'nametr' => self::_('defensive_herding') ),
     7 => array( 'name' => clienttranslate('fat_tissue'),
                 'nametr' => self::_('fat_tissue') ),
     8 => array( 'name' => clienttranslate('fertile'),
                 'nametr' => self::_('fertile') ),
     9 => array( 'name' => clienttranslate('foraging'),
                 'nametr' => self::_('foraging') ),
     10 => array( 'name' => clienttranslate('hard_shell'),
                 'nametr' => self::_('hard_shell') ),
     11 => array( 'name' => clienttranslate('horns'),
                 'nametr' => self::_('horns') ),
     12 => array( 'name' => clienttranslate('intelligence'),
                  'nametr' => self::_('intelligence') ),
    13 => array( 'name' => clienttranslate('long_neck'),
                 'nametr' => self::_('long_neck') ),
    14 => array( 'name' => clienttranslate('pack_hunting'),
                 'nametr' => self::_('pack_hunting') ),
    15=> array( 'name' => clienttranslate('scavenging'),
                 'nametr' => self::_('scavenging') ),
    16 => array( 'name' => clienttranslate('symbiosis'),
                 'nametr' => self::_('symbiosis') ),
    17  => array( 'name' => clienttranslate('warning_call'),
                 'nametr' => self::_('warning_call') )
 );

 $this->values_label = array(
     -3 => '-3 Food',
     -2 => '-2 Food',
     -1 => '-1 Food',
     0 => '0 Food'
     1 => '1 Food',
     2 => '2 Food',
     3 => '3 Food'
     4 => '0 Food',
     5 => '1 Food',
     6 => '2 Food',
     7 => '3 Food',
     8 => '4 Food',
     9 => '9 Food'

 );

The values that exist are from -3 to 9, but not on all traits. I have written code below to make the deck based on their value below:

Code: Select all

	$this->cards = self::getNew( "module.common.deck" );
				        $this->cards->init( "card" );

							//Create cards
							$cards = array(
								//All cards with -3 food
        array( 'type' => 1, 'type_arg' => -3, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => -3, 'nbr' => 1 ),
				//All cards with -2 food
				array( 'type' => 1, 'type_arg' => -2, 'nbr' => 1 ),
				array( 'type' => 12, 'type_arg' => -2, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => -2, 'nbr' => 1 ),
				//All cards with -1 food
				array( 'type' => 1, 'type_arg' => -1, 'nbr' => 1 ),
				array( 'type' => 7, 'type_arg' => -1, 'nbr' => 1 ),
				array( 'type' => 12, 'type_arg' => -1, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => -1, 'nbr' => 1 ),
				//All cards with 0 food
				array( 'type' => 1, 'type_arg' => 0, 'nbr' => 1 ),
				array( 'type' => 3, 'type_arg' => 0, 'nbr' => 2 ),
				array( 'type' => 5, 'type_arg' => 0, 'nbr' => 1 ),
				array( 'type' => 7, 'type_arg' => 0, 'nbr' => 1 ),
				array( 'type' => 12, 'type_arg' => 0, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => 0, 'nbr' => 1 ),
				//All cards with 1 food
				array( 'type' => 1, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 2, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 3, 'type_arg' => 1, 'nbr' => 2 ),
				array( 'type' => 4, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 10, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 11, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 16, 'type_arg' => 1, 'nbr' => 1 ),
				array( 'type' => 17, 'type_arg' => 1, 'nbr' => 1 ),			
				//All cards with 2 food
				array( 'type' => 1, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 2, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 3, 'type_arg' => 2, 'nbr' => 3 ),
				array( 'type' => 4, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 6, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 8, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 9, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 10, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 11, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 15, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 16, 'type_arg' => 2, 'nbr' => 1 ),
				array( 'type' => 17, 'type_arg' => 2, 'nbr' => 1 ),
				//All cards with 3 food
				array( 'type' => 1, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 2, 'type_arg' => 3, 'nbr' => 2 ),
				array( 'type' => 3, 'type_arg' => 3, 'nbr' => 3 ),
				array( 'type' => 4, 'type_arg' => 3, 'nbr' => 2 ),
				array( 'type' => 5, 'type_arg' => 3, 'nbr' => 2 ),
				array( 'type' => 6, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 7, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 8, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 9, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 10, 'type_arg' => 3, 'nbr' => 2 ),
				array( 'type' => 11, 'type_arg' => 3, 'nbr' => 2 ),
				array( 'type' => 13, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 14, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 15, 'type_arg' => 3, 'nbr' => 1 ),
				array( 'type' => 16, 'type_arg' => 3, 'nbr' => 2 ),
				array( 'type' => 17, 'type_arg' => 3, 'nbr' => 2 ),
				//All cards with 4 food
				array( 'type' => 2, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 3, 'type_arg' => 4, 'nbr' => 3 ),
				array( 'type' => 4, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 5, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 6, 'type_arg' => 4, 'nbr' => 1 ),
				array( 'type' => 7, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 8, 'type_arg' => 4, 'nbr' => 1 ),
				array( 'type' => 9, 'type_arg' => 4, 'nbr' => 1 ),
				array( 'type' => 10, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 11, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 12, 'type_arg' => 4, 'nbr' => 1 ),
				array( 'type' => 13, 'type_arg' => 4, 'nbr' => 1 ),
				array( 'type' => 15, 'type_arg' => 4, 'nbr' => 1 ),
				array( 'type' => 16, 'type_arg' => 4, 'nbr' => 2 ),
				array( 'type' => 17, 'type_arg' => 4, 'nbr' => 2 ),
				//All cards with 5 food
				array( 'type' => 2, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 3, 'type_arg' => 5, 'nbr' => 2 ),
				array( 'type' => 4, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 5, 'type_arg' => 5, 'nbr' => 2 ),
				array( 'type' => 6, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 7, 'type_arg' => 5, 'nbr' => 2 ),
				array( 'type' => 8, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 9, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 10, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 11, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 12, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 13, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 15, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 16, 'type_arg' => 5, 'nbr' => 1 ),
				array( 'type' => 17, 'type_arg' => 5, 'nbr' => 1 ),
				//All cards with 6 food
				array( 'type' => 3, 'type_arg' => 6, 'nbr' => 2 ),
				array( 'type' => 6, 'type_arg' => 6, 'nbr' => 1 ),
				array( 'type' => 8, 'type_arg' => 6, 'nbr' => 2 ),
				array( 'type' => 9, 'type_arg' => 6, 'nbr' => 2 ),
				array( 'type' => 12, 'type_arg' => 6, 'nbr' => 1 ),
				array( 'type' => 13, 'type_arg' => 6, 'nbr' => 1 ),
				array( 'type' => 15, 'type_arg' => 6, 'nbr' => 2 ),
				//All cards with 7 food
				array( 'type' => 6, 'type_arg' => 7, 'nbr' => 1 ),
				array( 'type' => 8, 'type_arg' => 7, 'nbr' => 1 ),
				array( 'type' => 9, 'type_arg' => 7, 'nbr' => 1 ),
				array( 'type' => 12, 'type_arg' => 7, 'nbr' => 1 ),
				array( 'type' => 13, 'type_arg' => 7, 'nbr' => 1 ),
				array( 'type' => 15, 'type_arg' => 7, 'nbr' => 1 ),
				//All cards with 8 food
				array( 'type' => 6, 'type_arg' => 8, 'nbr' => 1 ),
				array( 'type' => 13, 'type_arg' => 8, 'nbr' => 1 ),
				//All cards with 9 food
				array( 'type' => 13, 'type_arg' => 9, 'nbr' => 1 ),
        
	}
Last edited by phranklon on 16 April 2020, 18:19, edited 1 time in total.
User avatar
phranklon
Posts: 11
Joined: 06 April 2020, 19:26

Re: Evolution Deck: Creating the stock

Post by phranklon »

...and in my utility methods in .js file is

Code: Select all

getCardUniqueId : function(trait, value) {
                   return (trait - 1) * 13 + (value + 3);
               },
User avatar
apollo1001
Posts: 191
Joined: 21 July 2015, 10:41

Re: Evolution Deck: Creating the stock

Post by apollo1001 »

It looks like you have roughly the right code fragments in place. Quickest way to test is to drop a 'myHand' div into your .tpl file and then add some (dummy) items to it in your .js game setup to see whether it works.

In terms of feedback on your card initialisation, I would have probably put the card details in your materials.inc.php:

Code: Select all

$this->cards_data = array (
	1 => array('type' => 5,
			'food' => 2,
			'trait' => 4,
			...
		),
	2 => ...	
);
so you can then just set up a loop in your game.php to run through these to create the cards in the table. If you need more specific help then do let me know (i'm in between projects atm).
User avatar
apollo1001
Posts: 191
Joined: 21 July 2015, 10:41

Re: Evolution Deck: Creating the stock

Post by apollo1001 »

P.S. On your labels you will need to use a clienttranslate('Food') or these will not be translated correctly from '1 Food'.
User avatar
phranklon
Posts: 11
Joined: 06 April 2020, 19:26

Re: Evolution Deck: Creating the stock

Post by phranklon »

Thanks, apollo.

I added translation after seeing the error in the tester. I also found a few missing commas and semicolons and added them.

I have a test hand that I use to see if it is displaying. It seems to work pretty well.

I don't fully understand your suggestion on how to redo my materials.inc.php file. That is where I have my "$this->traits = array(...." code. should I replace this with your suggestion or add to it?
Post Reply

Return to “Developers”