0.2.15 • Published 1 year ago

@marcelotivelabs/memory v0.2.15

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

memory-game

installing library

  • To install memory-game library in your project just run the following command:
npm i @tive-labs/memory-game

Using memory-game library

  1. Import the library

  • At the beginning of the js file in which you are going to use the library import as follows:
import {initGame, selectCard} from @tive-labs/memory-game
  1. initGame

  • initGame receives two parameters, category and level.
    • Category must be 'animals' or 'numbers'
    • Level must be 'easy' or 'medium' or 'hard'
const memoryGame = initGame('animals', 'easy');
  • initGame returns an object with a 2d array of hidden cards, and the length of the array (xLength and yLength):
 {
    cards,
    xLength,
    yLength
 }
  1. selectCard

  • selectCard receives two parameters, position x and position y.

    • x must be a number representing the x position (vertival position) on the 2d array.
    • y must be a number representing the y position (horizontal position) on the 2d array.

      const selected = selectCard(0, 1);
  • selectCard returns an object with three properties:

    {
        cardData,
        cardMatch,
        isThereAWinner
    }
    • cardData: Contains an object with the data of the discovered card (id, name, shortName)
    • cardMatch: Contains an object with a boolean value (isNewMatched) that indicates if exist a new card match, and an object (matchedCards) with the positions of the matched cards (x_y):

      {
          isNewMatched,
          matchedCards: {
              firstCard,
              lastCard
          }
      }
    • isThereAWinner: Contains a boolean value indicating if the player won the game.

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago