ArnoldSmith86 / virtualtabletop

a virtual surface in the browser on which you can play board, dice and card games
https://virtualtabletop.io
GNU General Public License v3.0
169 stars 31 forks source link

Improve parallels between Holders and Collections #275

Open rogerl50 opened 3 years ago

rogerl50 commented 3 years ago

FLIP allows the use of a holder rather than a collection as its input, with precisely the same results. While MOVE, MOVEXY, ROTATE, and SORT do not, the Wiki clearly indicates that someone thought it would be a good idea if they did. It seems to me that in a lot of cases, holders and collections should both be accepted by these functions; from the programmer's point of view they may be similar, and not infrequently a SELECT is used to select all items from a holder into a collection.

We should change the following functions to accept either: CLICK, CLONE, COUNT, DELETE, GET, LABEL (right now, LABEL accepts neither; it operates only on a single label), MOVE (source parameter only), MOVEXY, ROTATE, SELECT, SET.

larkob commented 3 years ago

Yeah, that's what I'm working on. I'm trying to get all operations to support collections, but I don't plan to add holders to operations that already support collections. The only operation I've added holder to is COUNT because it feels relevant to be able to count the items within a holder (not just cards, but also other widgets).

Here's the current status of operations that support collections:

I plan to add collections to the remaining operations as well, but will have to wait for the pile re-design before I can work on MOVE and MOVEXY.

Holders and collections actually don't work the same. With holders, you're operating on the cards within the holder, not just any widget whose parent is the holder. So, if you put a button or game piece in a holder, you won't affect it with ROTATE for example. That's something I encountered when I tried to COUNT the holder's children and is why I'm not planning to add holder parameters everywhere.

rogerl50 commented 3 years ago

This issue was motivated by the difficulty I was having using CLONE to clone a card and then move those clones into another holder. The only way I can think of to do it is so convoluted that I might just as well have all the copies of the card in an off-screen holder. (This is for poker chips, which are all the same and of which you need lots of copies.)

Also, it's worth noting that holders get used for other things as well, not just to hold cards (or decks).

robartsd commented 3 years ago

I plan to add collections to the remaining operations as well, but will have to wait for the pile re-design before I can work on MOVE and MOVEXY.

Change to make piles not be widgets has been officially cancelled. Any particular pile issues that need resolving?