GithubHelp home page GithubHelp logo

js-gladiator's Introduction

JS Gladiator Arena

The Emperor has commissioned you to build a Gladiator Arena.

How to do this assignment

The provided index.html file will be useful for testing out your code.

Part 1 - The Gladiator

Create a Gladiator class that has the following properties:

  • a name
  • a weapon (one of Spear, Club, Trident)
var max = new Gladiator("Maximus","Trident")
console.log(max.name) // "Maximus"
console.log(max.weapon) // "Trident"

Bonus

How could you prevent creating Gladiators with a different weapon?

e.g. new Gladiator("Jesse","Taco") throws an error.

Part 2 - The Arena

Create an Arena class that meets the following conditions:

An arena has a name

var colosseum = new Arena("Colosseum")
console.log(colosseum.name) // => Colosseum

The name should be capitalized

var colosseum = new Arena("megalopolis")
console.log(colosseum.name) // => Megalopolis

An arena can have gladiators

var colosseum = new Arena("Colosseum")
console.log(colosseum.gladiators) // => []

You can add a gladiator to the arena

var max = new Gladiator("Maximus","Trident")
var colosseum = new Arena("Colosseum")
colosseum.addGladiator(max)
console.log(colosseum.gladiators) // => [Gladiator]

The arena should never have more than 2 gladiators in it at a time

var max = new Gladiator("Maximus","Trident")
var titus = new Gladiator("Titus","Sword")
var andronicus = new Gladiator("Andronicus","Sword")
var colosseum = new Arena("Colosseum")
colosseum.addGladiator(max)
colosseum.addGladiator(titus)
colosseum.addGladiator(andronicus)
console.log(colosseum.gladiators.length) // => 2

If there are two gladiators in the arena, you can call a fight method that results in the elimination of one of the gladiators from the arena.

  • Winning conditions:
    • Trident beats Spear
    • Spear beats Club
    • Club beats Trident
    • If the two gladiators have the same weapon, they are both eliminated.
var max = new Gladiator("Maximus","Trident")
var titus = new Gladiator("Titus","Spear")
var colosseum = new Arena("Colosseum")
colosseum.addGladiator(max)
colosseum.addGladiator(titus)
colosseum.fight()
console.log(colosseum.gladiators) // => [max]

Double Bonus!

  • Add a method to remove gladiators from the arena by name
  • Update your winning conditions so that if the gladiator named "Maximus" is in the fight, he wins.
  • Add a method to check to see if the crowd is entertained (.entertained?). The crowd is only entertained if Maximus is in the arena.
  • Before a losing gladiator is eliminated, the user should be prompted to put their thumbs up or down. If user votes down, the losing gladiator is removed. If the user votes up, the gladiator stays in the arena and his opponent is removed. (Life isn't fair.)

js-gladiator's People

Contributors

jshawl avatar robertakarobin avatar nolds9 avatar adambray avatar justin-shin avatar

Watchers

James Cloos 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.