Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Question about combining and paring down card decks in play

1684501800
Doctor Cameron
Pro
Marketplace Creator
Sheet Author
Hi there.  I'm trying to implement a card-based system for an RPG. First: Is there any way that cards from one deck can be combined with another deck in the middle of the game without someone really messing with the UI?  Second: is there a way to select 18 cards from a collection of 28 and form a new deck with just those chosen cards?
1684502819
The Aaron
Roll20 Production Team
API Scripter
Not really. For the First, there isn't a way via the UI to create a deck that is the combination of cards from multiple decks.  The best you can do is create piles of cards on the tabletop, but there's not a way built into the UI to shuffle a pile of cards.  With a Mod API Script, you can partially address this.  You can shuffle a stack of cards with a script, though because of how it needs to work, it is very slow (about a second per card in the stack).  You can also create a new deck from a selection of cards with a script, with the caveat that none of the artwork can be from the Marketplace, it must all be in a User Library. For the Second, you can't create a new deck with a subset of cards.  Depending on what you're doing, you can get a semblance of this by drawing all the cards in the deck, discarding what you want to keep, shuffle the deck including discards, then discard the cards you don't want.  Kind of tedious and not really applicable to all situations.  With a Mod API Script, you can do this, with the caveats listed above.
Hi, I did this for a Halloween Strahd and needed a reduced deck to cut out locations outside the castle - I opened the main deck, scrolled to the bottom, hit duplicate deck.  Open duplicate and clicked on the cards I didn't want, scroll to bottom of card and hit delete.  Save deck. Not sure which method is more tedious, but I don't remember it being too arduous
1684504426
The Aaron
Roll20 Production Team
API Scripter
Ah, that's not a bad method for the Second ask, Simon!
1684544869
Doctor Cameron
Pro
Marketplace Creator
Sheet Author
Can you point me to an Mod API script that would sort cards in play?
1684603020
The Aaron
Roll20 Production Team
API Scripter
Do you mean shuffle a pile of cards on the table?  Here's a script that does that. Use the command: !shuffle-selected With all the cards in a pile selected. const RandomDepth = (() => { // eslint-disable-line no-unused-vars const version = 0.2; // eslint-disable-line no-unused-vars const fixedToBack = (()=>{ let queue=[]; let last=0; const DELAY = 100; let callbacks = []; const burndownQueue = ()=>{ let o = queue.shift(); toBack(o); last = Date.now(); if(queue.length){ setTimeout(burndownQueue,DELAY); } else { let cblist = [...callbacks]; callbacks = []; cblist.forEach(cb => cb()); } }; return (obj, cb = ()=>{}) => { callbacks.push(cb); if(queue.length){ queue.push(obj); } else { let t = Date.now(); if(last+DELAY > t){ queue.push(obj); setTimeout(burndownQueue,(last+DELAY-t)); } else { toBack(obj); last = t; } } }; })(); const randomToFrontList = (l,cb) => { while( l.length > 1) { let i = randomInteger(l.length)-1; fixedToBack(l[i]); l = l.filter((o,k)=>k!==i); } fixedToBack(l[0],cb); }; const handleMessages = (msg) => { if('api' !== msg.type ) { return; } let args = msg.content.split(/\s+/); let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); switch(args.shift()) { case '!shuffle-selected': case '!random-depth': { let tokens = (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) ; let count = tokens.length; if(count){ randomToFrontList(tokens,()=>{ sendChat('',`/w "${who}" Finished shuffling."`); }); sendChat('',`/w "${who}" Shuffling ${count} items."`); } else { sendChat('',`/w "${who}" Please select something and run the command again."`); } } break; } }, registerEventHandlers = function(){ on('chat:message',handleMessages); }; on('ready',registerEventHandlers); return { }; })();
1684644850
The Aaron
Roll20 Production Team
API Scripter
This conversation makes me think there's a remove functionality that might work for your Second ask:&nbsp; <a href="https://app.roll20.net/forum/post/11469836/cards-question-how-do-recall-a-removed-card" rel="nofollow">https://app.roll20.net/forum/post/11469836/cards-question-how-do-recall-a-removed-card</a>
1684652430
Gauss
Forum Champion
The Aaron said: This conversation makes me think there's a remove functionality that might work for your Second ask:&nbsp; <a href="https://app.roll20.net/forum/post/11469836/cards-question-how-do-recall-a-removed-card" rel="nofollow">https://app.roll20.net/forum/post/11469836/cards-question-how-do-recall-a-removed-card</a> What?! Something I said has a use? No, say it ain't so Aaron! :D