Page 1 of 1

[SOLVED] Stock or Zone ?

Posted: 17 September 2014, 19:38
by Woodruff
Hi everybody !

I am trying to find the good the best solution to display a stack of cards, with the following design:
-Each card vertically overlaps on the card at its bottom (at a given X% percentage), so they compose splayed-up stack.
-I would like to have the possibility to dynamically remove either the top card, or the bottom one.

I found that the stock component would ideally fullfil my purpose, since it enables to manipulates card ids, which are known. However, I did not manage to control how the cards overlaps (I did not find the way to "force" cards not to display horizontally, even with the setOverlap method, and the vertical overlap is only effective on every two cards).

With the Zone component I woud be able to fix this, but then I lose the id system which is very convenient, and I have to deal with the CSS-sprite myself, which can lead to a CSS-code pretty ugly :?.

From your experience, which component would you use for this ? (or maybe something else, that I would have certainly missed :roll:)

Tcheby

Re: Stock or Zone ?

Posted: 17 September 2014, 21:48
by daikinee
Hi,

Try to use the stock component with:

mystock.setOverlap(0.1, mypercent);
mystock.item_margin = 0;

Re: Stock or Zone ?

Posted: 24 September 2014, 13:11
by sourisdudesert
Hi,

You're right, Stock does not support verticality at now.

For example on Spyrium, I used Zone instead.

Did you manage to do solve your problem?

Cheers,

[SOLVED] Stock or Zone ?

Posted: 02 October 2014, 17:57
by Woodruff
daikinee wrote:Hi,

Try to use the stock component with:

mystock.setOverlap(0.1, mypercent);
mystock.item_margin = 0;
Thanks, I already did. I thought that setOverlap would have solved my problem. But depending on the zoom and the overlapping percentage, the cards behave strangely, sometimes they place themselves in column (and only two cards are visible...), other times in row, in an anarchic way... The 0.1 for horizontallity did not get the things improved that much, except that the cards remain in column which is good, but still only two cards are visible (this seems to be the normal behavior, according to the documentation).
Hi,

You're right, Stock does not support verticality at now.

For example on Spyrium, I used Zone instead.

Did you manage to do solve your problem?

Cheers,
OK, so if I want to use Zone, I have to make the sprites myself, is that right? Or is it reliable to slide the cards from a existing stock (using the removeFromStock method with parameter to) and so conserve the model?
How would you manage card selection, then?

Cheers !

Tcheby

[SOLVED] Stock or Zone ?

Posted: 14 June 2017, 21:52
by Woodruff
Hi everybody!

By the time I progressed a lot in my game. I've finally gone for "Zone" and totally abandonned "Stock". "Zone" is more flexible to use, but it requires more code. Here the extra work you have to do if you want to go for it:
  • Set up the selection system, using dojo.connect click events. Usually you will use it on EnteringState method. But if you want to disconnect these events as well you have to use this.connect and this.disconnect because there is no disconnect equivalent for dojo.connect.
  • Set up the shape of the stock: horizontally, vertically, with or without overlap. For consistency I used the 'custom' pattern for all and define the x and y coordinates manually for all case (see the doc about Zone for more details: http://en.doc.boardgamearena.com/Zone#Custom_mode)
  • Set up your own "weight" system if you want to insert the card on last, first or in any X position. For this I've gone the hard way managing that on both server side with a dedicated column in the database, and on client side. When inserting or removing a card of your zone, you have to update the weight of other cards consistently.
Thats sounds a lot but when it's done properly, you can then focus on higher logic of your code :)

Good luck :D

Tchebychev