Custom Stock overlap

Game development with Board Game Arena Studio
Post Reply
User avatar
Marcuda
Posts: 25
Joined: 21 September 2015, 00:36

Custom Stock overlap

Post by Marcuda »

Hello,

In my game Saint Petersburg I have a Stock component for each player's tableau where cards are played. By the end of the game there can be quite a few cards there and I would like to overlap duplicates (i.e. same weight) to save space. From what I can tell there is no way to do this with Stock. Horizontal overlap is all or nothing.

I gather this can be done with Zone (haven't looked too closely), but Stock feels like the right component here. It does exactly what I want in all other cases so I don't want to re-implement those features for Zone.

Is there any way to have more control on or define a custom overlap for Stock?
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Custom Stock overlap

Post by RicardoRix »

Stock has onItemCreate for customisation.
User avatar
Marcuda
Posts: 25
Joined: 21 September 2015, 00:36

Re: Custom Stock overlap

Post by Marcuda »

Sorry but I don't follow. I've used onItemCreate to add decorations or change the content, but not the position. I want to modify how the Stock positions any duplicate items, and consequently all subsequent items. I'm not sure how onItemCreate would keep track of all that.

I'm thinking I might need to override the updateDisplay method with something like

Code: Select all

// inside this.items loop, after computing left value
if (this.is_duplicate(item)) {
    dups++;
}
left -= dups * item.width * this.dup_overlap/100
That would only work with a single row. It would probably be more like the existing logic for horizontal_overlap, but looking at the minified code I haven't worked it all out yet. Actually, is the raw source for ly_studio.js and other BGA framework code available anywhere?
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Custom Stock overlap

Post by RicardoRix »

You can instead add a div into the stock item with whatever you like:

setupMinorContainer : function(card_div, card_type_id, card_id)
{

dojo.place(this.format_block('jstpl_minorContainer', {
"token_id" : 'company' + card_id,
"company_num" : 'company' + card_type_id,
}), card_div);
},
User avatar
tsaunat
Posts: 30
Joined: 28 April 2020, 05:10

Re: Custom Stock overlap

Post by tsaunat »

For the game butterfly I wanted right to left horizontal overlap and stock does left to right so I overrode the stock updateDisplay to do it when I gave a negative horizontal overlap.

updateDisplay is the function that does the majority of the work in managing the display within stock. You can look at butterfly for how I do it. One note I pulled the updateDisplay function from the minimized published version so the variables have been obscured.

edit: I had left to right twice.
Post Reply

Return to “Developers”