You would need to use the Execute Java Script action to do this. Here's some code:
var cards = [1, 2, 3, 4, 5]; // Array of cards
// Function to shuffle the cards array randomly function shuffle(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; // Swap elements } return array; }
var shuffled = shuffle(cards); // Shuffled deck
// Function to pick a random card from the deck and remove it function pickCard(array) { var randomIndex = Math.floor(Math.random() * array.length); // Get random index var pickedCard = array.splice(randomIndex, 1)[0]; // Remove and return picked card return pickedCard; }
var card = pickCard(shuffled); // Picked card print(card); // Output picked card
Feel free to ask if you have any questions. Welcome to CopperCube!
|