Git Product home page Git Product logo

card-matching's Introduction

Card Matching Game

Description

This is an interactive application that lets a single player match sets of 2 cards in a matching game.

  • The game consists of a regular 52 card deck
  • To start a game, the cards are randomly shuffled and placed on a game board
  • A user can:
    • turn cards over
    • choose 2 cards per “turn” from the board
      • if the card values match (ignoring suit), the cards are removed from the game board
      • if not, cards are returned to the game board in their previous positions
    • view successfully matched pairs of cards
    • count how many matched pairs they have found
  • Other requirements
    • The cards on the board maintain their initial location on the board when other cards are removed
    • Game completes when all pairs have been found

The game also integrates a 2 player turn based system with a “computer” player.

  • The game can distinguish between the turns of two players
  • The game keeps a count of the matched pairs for each player
  • A single user’s turn may continue if they successfully match a pair
  • The computer can:
    • select cards from the board
    • “remember” the values of cards that have previously turned over
    • choose cards off the board based upon it’s knowledge of the board

Instructions

You can view the live version or clone the repo. To run, simply open index.html in your favorite browser.

Credit to groove.co for the instructions.

card-matching's People

Contributors

nozbzh avatar

Watchers

 avatar

card-matching's Issues

No draw scenario

When playing VS computer and player and computer get 13 pairs each, it will show 'you lose'.

The end game logic should have 3 checks:

  • playerScore > computerScore
  • playerScore < computerScore
  • playerScore === computerScore

Changes required:

  • Add equality check in updateScore() function (gameplay.js)
  • Add message for draw
  • Add image for draw

Computer should not be allowed to pick same card twice

Only an issue when the computer is picking a random card.

Right now there's 2 cases:

  1. computer picks from unknown cards as long there are unknown cards
  2. if there are no unknown cards, computer picks one from the known cards

The bug only occurs in the second case.

The way it is now, a card is removed from knownCards only when a player finds a match. This means that when the computer picks from knownCards, that card is not removed from knownCards. What can happen then is that it picks the same card as its second pick. This creates a bug where the computer cannot make a match and gives an unfair advantage to the player.

Changes required:

  • Temporarily remove computer's picks from knownCards to prevent selecting the same card twice
  • Make sure to add the cards back into knownCards at the end of the turn if no match is found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.