UNPKG

@leofavre/memory-game-component

Version:

A memory game web component.

37 lines 1.31 kB
export var getNumberOfCards = function getNumberOfCards(_ref) { var cards = _ref.cards; return cards.length * 2; }; export var getCardAtPosition = function getCardAtPosition(position, _ref2) { var cards = _ref2.cards; return cards.find(function (card) { return card.positions.includes(position); }); }; export var isCardRevealed = function isCardRevealed(position, _ref3) { var revealed = _ref3.revealed; return revealed.includes(position); }; export var isCardMatched = function isCardMatched(position, _ref4) { var matched = _ref4.matched; return matched.includes(position); }; export var isCardInTheGame = function isCardInTheGame(position, _ref5) { var revealed = _ref5.revealed, matched = _ref5.matched; return revealed.includes(position) || matched.includes(position); }; export var isPairOfCardsVisible = function isPairOfCardsVisible(_ref6) { var revealed = _ref6.revealed; return revealed.length === 2; }; export var isVisiblePairOfCardsAMatch = function isVisiblePairOfCardsAMatch(_ref7) { var revealed = _ref7.revealed, matched = _ref7.matched; return revealed.every(function (position) { return matched.includes(position); }); }; export var isGameOver = function isGameOver(state) { return getNumberOfCards(state) === state.matched.length; };