Clone user decklist for a card game deckbuilder app

I am currently developing a deckbuilder project for a card game.

I am looking to add a feature that allows users to clone a deck on their own profile.

Users should be able to view any decklist, press a button, and find that list on their profile.

My problem is that I don’t see how to copy all the cards at once.

I have a Decks table with general deck information and a Decks_Items table where I have a row for each card in a deck. Both are related by the ID of the deck obviously.

If you have some ideas or even solutions, please comment! :slight_smile:

Does any of the content of the deck of cards change in any way from user to user, or is the deck of cards exactly the same for everyone, a little bit like a global piece of contact that can be accessed or not by different users?

If the content in global, maybe you could create a table where each row would be a relation between a user and a deck of card: User ID, Deck ID. You could use that to then display deck of cards per user.

No, each user can create a deck and put whatever cards they want in it. Here, I want a button that allows users to copy another user’s deck to their own profile (mainly to find it more easily and work on it later).

The decklist could be public or private.

I would probably have the global deck table with all possible cards, that isn’t tied to a specific user. Then in each user table row, I would probably have a column with a comma delimited list of card IDs or a json object with card IDs. Something you could use to build an array to create a relation to the global deck table. Then if you want to copy a deck, you just have to copy one column cell value from one user row instead of multiple rows.

I see how your solution could work but in my case I can’t because as I said, I have one line for each card in a Deck_Items table (which is bad, I admit it).
I already have some columns to export in JSON format in my Decks table BUT after that, I don’t get how to access to every card on the deck ID. I need to loop on it to add all lines to my Deck_Items table.

Add a Manual Workflow with two inputs: deckID and userID (the user who wants to copy the deck).

Create a User-Triggered Workflow that calls this Manual Workflow, passing in the current deck’s ID and the signed-in user’s ID.

In the Manual Workflow:

  1. Loop through the Decks table to find the row with the matching deckID. Set the match limit to 1. Inside that loop, use an Add Row action to create a new deck using the data from the existing deck. This will give you a new deckID for the cloned deck.
  2. Still inside that same loop, loop through the relation to Deck_Items for the original deck. In this inner loop, add each related item as a new row in the Deck_Items table, but set its deckID to the new deckID you just created.
1 Like

Thanks for that, it worked well!

But this solution will burn my 500 updates too fast because I clone 34 lines on each trigger.
So sadly, I couldn’t publish it…

I’m only on the Maker plan btw.

If it’s not too time-consuming for you, explore doing Big Tables for the Deck Items table, and for the loop above, instead of doing a loop, craft a flow to stash and add that stash to the Big Table. It will save you updates.

Or, like Jeff said, convert the approach to using a comma-delimited list of card IDs instead of a table. Then, you can just add a new row in the Decks table with the comma-delimited IDs.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.