def cube_packs(setup: dict, user_data: list):
        # Create a separate 'more_setup' dict here and merge it into the setup dict at the end.
        # Creating it here makes it easy to see what keys are added.
        more_setup = {
            'packs': [],  # pack id to pack mapping
            'picks':
            [],  # { 'user_id': id, 'pack_id': pack_id, 'card_id': card_id }
        }

        cube = Cube.query.get(setup['cube_id'])
        wrapper = CubeWrapper(cube)
        card_data = wrapper.card_data(include_removed=False)

        num_packs = setup['num_packs']
        pack_size = setup['pack_size']
        pack_count = len(user_data) * num_packs
        card_count = pack_count * pack_size

        if len(card_data) < card_count:
            raise ValueError(
                f"Not enough cards for {num_users} users * {num_packs} packs * {pack_size} cards"
            )

        included_card_data = {}

        card_ids = [str(x) for x in card_data.keys()]
        random.shuffle(card_ids)
        for i in range(pack_count):
            start = i * pack_size
            end = start + pack_size
            user_id = user_data[i // num_packs]['id']

            pack = {
                'pack_id': i,
                'card_ids': card_ids[start:end],
                'user_id': user_id,  # User who opens pack
                'pack_num': i % num_packs,  # Order of pack opening
                'waiting_id': user_id,  # User who needs to pick from this pack
                'waiting_picks': 1,
                'picked_ids': [],
                'events': [],
                'opened': False,
            }

            more_setup['packs'].append(pack)

            for card_id in pack['card_ids']:
                included_card_data[card_id] = card_data[int(card_id)]

        setup.update(more_setup)

        return included_card_data
    def rotisserie(setup: dict, user_data: list):
        cube = Cube.query.get(setup['cube_id'])
        wrapper = CubeWrapper(cube)
        card_data = wrapper.card_data(include_removed=False)

        first_pick_id = random.choice(user_data)['id']

        setup.update({
            'card_ids': [str(x) for x in card_data.keys()],
            'waiting_id': first_pick_id,
            'picked_ids': [],
            'events': [],
        })
        return card_data