Page 1 of 1

Let players change card order

Posted: 09 March 2022, 18:20
by emily_nicole
Is it possible to change the stock weight of a card based on card id?? I am trying to let the players reorder their cards and I cannot figure out the best way to go about it.

The first step I was trying to get to work was just to have a player click a card and for that card to move to the front of their hand.

Re: Let players change card order

Posted: 09 March 2022, 19:02
by Victoria_La
emily_nicole wrote: 09 March 2022, 18:20 Is it possible to change the stock weight of a card based on card id?? I am trying to let the players reorder their cards and I cannot figure out the best way to go about it.

The first step I was trying to get to work was just to have a player click a card and for that card to move to the front of their hand.
Yes you can set weight to whaever function you want, the question is on how you store it in database, changing id for purposes of sorting is extreme

Re: Let players change card order

Posted: 09 March 2022, 21:09
by emily_nicole
Is there a simpler solution to letting the players change the order of their cards?

Re: Let players change card order

Posted: 10 March 2022, 03:39
by Shazzypaz
I'm finishing up a card game in which the players can reorder their cards, including moving cards to the middle of the hand. I'm using css flex with card order saved in a separate table. My first attempt used stock, but it was awkward.

Re: Let players change card order

Posted: 10 March 2022, 04:42
by RavingWanderer
The stock Stock object doesn't really do user-controlled card order. In one of my projects (contractrummy) I replaced some of its guts in order to accomplish this. This is risky, since it involved changing things that are not documented and thus not actually supported.

Re: Let players change card order

Posted: 10 March 2022, 06:23
by Tisaac
Shazzypaz wrote: 10 March 2022, 03:39 I'm finishing up a card game in which the players can reorder their cards, including moving cards to the middle of the hand. I'm using css flex with card order saved in a separate table. My first attempt used stock, but it was awkward.
Yep, the simple solution is simply to not use stock.