Giter VIP home page Giter VIP logo

lab-javascript-clue's Introduction

logo_ironhack_blue 7

LAB | JS Clue - Mixing objects and arrays

Do you remember the classic detective board game Clue? It was a very popular game in the 90's.

The plot starts with the death of Mr. Boddy, the very wealthy owner of Tudor Manor. He was killed under highly suspicious circumstances, and it's the players mission to uncover which suspect murdered him, what weapon was used, and in which room of the mansion the crime took place.

When playing Clue, these three details are represented by a suspect card, a weapon card and a room card that are kept hidden in an envelope for the duration of the game. By progressively revealing the remaining cards, the players can infer which are the three cards that are hidden. When a player is confident that they know the solution to the mystery, they will try to reveal it. If a player guesses correctly, they win the game.

Requirements

  • Fork this repo
  • Clone this repo

Submission

  • Upon completion, run the following commands:

    git add .
    git commit -m "done"
    git push origin master
    
  • Create Pull Request so your TAs can check up your work.

Deliverables

Write all of your code in the src/clue.js file.

Upon completion, commit your changes, push them to your remote fork, and create a pull request so that the TAs can review your submission.

Remember our tests!

We will be working with automated tests again! Please, open the SpecRunner.html in your browser and use it to debug your solution of the Lab.

Iteration 1: Create the cards

Clue has three different card types: suspects, rooms, and weapons. We'll be given the same amount of information for any given card with the same card type.

As such, let's create an array for every card type, that is going contain the objects representing each card. These arrays should be named suspectsArray, weaponsArray, roomsArray.

All of the information you need about suspects, rooms, and weapons can be found on the DATA.md file.

Suggestion: Copy this data into the clue.js file and model it into objects nested inside your cards arrays. This is a great chance for you to experiment with IDE shortcuts, multiple-line selection, find and replace, and other great features that VSCode provides you with.

Game suspects

All of six possible suspects in Clue have a first name, last name, occupation, age, description, image and color.

To complete this iteration, you should have an array that looks something like the following:

const suspectsArray = [
  {
    firstName: 'Jacob',
    lastName: 'Green',
    occupation: 'Entrepreneur'
    // ...
  }
  // ...
];

Available weapons

There are a total of nine weapons. Each of them has a different name and weight.

Mansion rooms

The game board represents the blueprints of the mansion and features fifteen different rooms. Each room will only have a name.

Iteration 2: Create the mystery

At the beginning of the game, players shuffle each of the card stacks to create a combination of suspect, weapon and room. This will be the mystery to solve.

Random selector

Declare a function named selectRandom to randomly select one element from a card stack. The function should expect an array as an argument, and should return a random element from the array.

Create the mystery

Declare a function named pickMystery that takes no arguments and returns an object with three properties, suspect, weapon and room, each holding as a value a card of that specific type. You can get a random card of each type by calling selectRandom on each card stack.

Iteration 3: Reveal the mystery

At last, we're ready to unveil the mystery.

Declare a function named revealMystery that receives an envelope object (such as the one returned by pickMystery) as the single argument, and returns a reveal message in the following format:

<FIRST NAME> <LAST NAME> killed Mr. Boddy using the <WEAPON> in the <ROOM>!

Extra Resources

Happy coding! ๐Ÿ’™

lab-javascript-clue's People

Contributors

sandrabosk avatar mjarraya avatar nickborbe avatar diurivj avatar papuarza avatar ta-web-mad avatar hectorbliss avatar josecarneiro avatar lluisarevalo avatar ta-web-paris avatar fontcuberta avatar

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.