Coder Social home page Coder Social logo

lab-javascript-clue's Introduction

logo_ironhack_blue 7

JS | Clue - Mixing objects and arrays

Do you remember de classic detective game?

Clue was a very popular game in the 90's. The plot starts with Mr. Boddy being killed by one of his guests. He was the very rich owner of Tudor Close, who takes the stock character of a generic victim. After his dead, Clue players have to discover who murdered him, with what implement, and where the crime scene took place in his mansion.

Hasbro, the toy maker company and owner of Cluedo, recently changed some of the characters bio. Use the bio to gather information from the characters.

Clue Picture

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 your JavaScript in the provided src/clue.js file.

Iteration 1 - Creating the cards

Clue has three different types of cards: suspects, rooms, and weapons. These three types of cards are always separated. Use data structures to model and create these cards.

In order to do this, you will need to know the game's characters (possible killers), available weapons and house rooms.

Game Characters

This Clue board game has a new roster of playable characters. All of them have first names, last names, occupations, age, description, and images. On the clue.js file you will find all the info about them.

Available Weapons

There are nine weapons. Each of them has different weight, same as the characters, you will find all the info needed on the clue.js file.

House Rooms

The game board represents the blueprints of a mansion and features fifteen different rooms. Yes, you guess, on the clue.js file you have all the info.

Data Structuring

Create one data structure for each of the people, weapons, and rooms described above. Each document must have all the info.

After creating the data structure, create an array for each type of data and push every document into their corresponding array.

For example:

const mrGreen = {
  first_name: "Jacob",
  last_name: "Green"
  // ...
};

const rope = {
  // properties
};

// etc

After creating the data structure, put every document into their corresponding array. charactersArray, weaponsArray, roomsArray.

Iteration 2 - Creating the mystery

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

Remember our tests!

We will be working with test again! You need to open the SpecRunner.html file in order to see them. The following instructions will guide you through all the functions and functionality your code should have to pass all the tests.

Random Selector

Create a function randomSelector to randomly select one element from a card stack. The method should receive an array as an argument, and return randomly one of the elements of the array.

Create the mystery

We need to create a pickMystery function that will call randomSelector for each card stack, and return an object with the 3 picked cards, a suspect, a weapon and a room. Our mystery should be stored on a mysteryEnvelope variable.

Iteration 3 - Revealing the mystery

Finally, we need to reveal the mystery. Create a revealMystery function, that will receive our mysteryEnvelope object as an argument and return the revealed mystery like this:

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

Extra Resources

Happy coding! ❤️

lab-javascript-clue's People

Contributors

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

Watchers

 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.