Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/// <reference path="./global.d.ts" />
// @ts-check

/**
* Get the first card in the given deck
*
* @param {Card[]} deck
*
* @returns {Card} the first card in the deck
*/
export function getFirstCard(deck) {
const [first] = deck;
return first;
}

/**
* Get the second card in the given deck
*
* @param {Card[]} deck
*
* @returns {Card} the second card in the deck
*/
export function getSecondCard(deck) {
const [,second] = deck;
return second;
}

/**
* Switch the position of the two cards
*
* @param {[Card, Card]} deck
*
* @returns {[Card, Card]} new deck with the 2 cards swapped
*/
export function swapTwoCards(deck) {
const [first,second,...rest] = deck;
return [second, first,...rest];

}

/**
* Rotate (shift) the position of the three cards (by one place)
*
* @param {[Card, Card, Card]} deck
*
* @returns {[Card, Card, Card]} new deck with the 3 cards shifted by one position
*/
export function shiftThreeCardsAround(deck) {
const [first,second,third,...rest] = deck;
return [second,third,first,... rest];
}

/**
* Grab the chosen pile from the available piles
*
* @param {{ chosen: Card[], disregarded: Card[] }} piles
*
* @returns {Card[]} the pile named chosen
*/
export function pickNamedPile({chosen }) {
// 🚨 Do NOT use piles.chosen or piles.disregarded.


return chosen;

}

/**
* Swap the chosen pile for the disregarded pile and the disregarded pile for the chosen pile
*
* @param {{ chosen: Card[], disregarded: Card[] }} piles
* @returns {{ chosen: Card[], disregarded: Card[] }} new piles where the two piles are swapped
*/
export function swapNamedPile({ chosen, disregarded }) {
// 🪄 Don't break the magic.
// 🚨 Do NOT use piles.chosen or piles.disregarded.
// 🚨 Do NOT touch the next line or Elyse will accidentally reveal the trick.


return { chosen: disregarded, disregarded: chosen };
}