Giter VIP home page Giter VIP logo

space-invaders's Introduction

Space Invaders Lab

Instructions

Space flight is no joke, and neither is this lab. You're going to need to create two ES6 JS classes, Spaceship and CrewMember. These classes will pump out instances that are by default unable to interact with one another. A space ship will be inactive if it is created without a crew. And a crew member by default will be hanging out in the Cantina looking for a ride if they were not put inside a ship when it is initialized.

Crew members will also be unable to use their special abilities if they're not assigned to a ship. For example, a pilot cannot engageWarpDrive if s/he is not in a ship and, therefore, can't make the Kessel Run in less than twelve parsecs. Crew members also should be unable to perform certain actions that their positions are incapable of doing.

To have these two objects be aware of one another, we need to have the ship become aware of its crew members on instantiation. This will also require you to make sure a crew member becomes aware of their ship when they are added to it.

TLDR;

A ship cannot exist without a crew and an individual crew member can't use their special ability if not assigned to a ship.

alt text

View Space Invaders Lab on Learn.co and start learning to code for free.

space-invaders's People

Contributors

annjohn avatar arelenglish avatar aturkewi avatar blake41 avatar c1505 avatar danielseehausen avatar deniznida avatar fislabstest avatar fs-lms-test-bot avatar gj avatar howardbdev avatar maxwellbenton avatar mrmitchboyer avatar pletcher avatar realandrewcohn avatar sarogers avatar scottcreynolds avatar tsiege avatar victoria-huang avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

space-invaders's Issues

Lights turn green when all tests fail

I opened the lab and ran learn. "Passed Local Tests" lights turned green even though the tests failed locally.

screen shot 2017-05-27 at 11 46 55 am

![screen shot 2017-05-27 at 11 47 04 am](https://cloud.githubusercontent.com/assets/19792273/26523756/9bab75b8-42d2-11e7-93c5-6d90977958ab.png) ![screen shot 2017-05-27 at 11 47 15 am](https://cloud.githubusercontent.com/assets/19792273/26523759/c00ff6f4-42d2-11e7-9aae-548ee286bc90.png) ![screen shot 2017-05-27 at 11 47 25 am](https://cloud.githubusercontent.com/assets/19792273/26523760/c0109b54-42d2-11e7-9142-33c6d27d0925.png)

Update tests

Tests should move away from the browser so they work in the IDE

A few clarifications

This lab needs clearer specs and change the currentShip property to be the actual ship.

order of tests incorrect

expect(aluminumFalcon.warpDrive).to.match(/disengaged/i);

A ship defaults to having its warp drive "disengaged". This test has a crew member engaging warp drive and then expects warp drive to be "disengaged". This should change to "engaged" and then the subsequent test, when warp drive is engaged again, should turn the warp drive back to "disengaged"

Passing scope to forEach not yet explained

The forEach function changes the value of this. To avoid this issue (this issue!), the solution saves a variable that as this prior to the loop. Though this is solution does work, it's not ideal, plus the idea of forEach changing the scope hasn't been explained.

There should either be frontmatter in this lab or in a separate readme that describes what to do when you encounter a scoping issues when working with objects in JS. See this StackOverflow post for more details.

The solution in lib/spaceship.js features this code:

// line 20
function(){
  var that = this;
  this.crew.forEach(function(crewMember){
    crewMember.currentShip = that;
  });
}

Order of tests

Cloaked was before the association between spaceship and crew members. Consider changing order of tests.

Spec typo

space-invaders-spec.js line 74 reads "Ship with a crew a crew member should return their ship when currentShip is called on them".

Test

๐Ÿ‘‹ , ignore me :)

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.