Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of github.com:outworlder/Elite.js

Conflicts:
	public/scripts/analytics.js
	src/analytics.coffee
  • Loading branch information...
commit 4158fd8cb20b2b6b86e3839d5133c01bec064aad 2 parents 458bc6c + 43c0d04
Stephen Pedrosa Eilert authored
2  Procfile
... ... @@ -1 +1 @@
1   -web: node web.js
  1 +web: node boot.js
2  boot.js
... ... @@ -0,0 +1,2 @@
  1 +require('coffee-script');
  2 +require('./web.coffee')
61 spec/commander_spec.coffee
... ... @@ -0,0 +1,61 @@
  1 +Commander = require('../src/commander').Commander
  2 +
  3 +describe 'Commander', ->
  4 + beforeEach ->
  5 + @commander = new Commander()
  6 +
  7 + describe "Initial state", ->
  8 + it "Should initialize a commander" ,->
  9 + expect(@commander).toBeDefined()
  10 +
  11 + it "The initial commander name must be 'Jameson'", ->
  12 + expect(@commander.name).toEqual "Jameson"
  13 +
  14 + it "The initial legal status must be 'Clean", ->
  15 + expect(@commander.legal_status).toEqual 'Clean'
  16 +
  17 + it "The commander must start with 100.0 credits", ->
  18 + expect(@commander.credits).toEqual 100.0
  19 +
  20 + it "New GalCop pilot licenses are issued only at 'Lave'", ->
  21 + expect(@commander.current_system).toEqual 'Lave'
  22 +
  23 + it "A fresh pilot should have 0 kills", ->
  24 + expect(@commander.kills).toEqual 0
  25 +
  26 + it "Commanders start out as 'Harmless'", ->
  27 + expect(@commander.elite_rating).toEqual "Harmless"
  28 +
  29 + describe "Elite Rating", ->
  30 + it "Should award the rating 'Mostly Harmless' after 8 kills", ->
  31 + @commander.confirmed_kill(1) for kill in [0..7]
  32 + expect(@commander.elite_rating).toEqual "Mostly Harmless"
  33 +
  34 + it "Should award the rating 'Poor' after 16 kills", ->
  35 + @commander.confirmed_kill(1) for kill in [0..15]
  36 + expect(@commander.elite_rating).toEqual "Poor"
  37 +
  38 + it "Should award the rating 'Average' after 32 kills", ->
  39 + @commander.confirmed_kill(1) for kill in [0..31]
  40 + expect(@commander.elite_rating).toEqual "Average"
  41 +
  42 + it "Should award the rating 'Above Average' after 64 kills", ->
  43 + @commander.confirmed_kill(1) for kill in [0..63]
  44 + expect(@commander.elite_rating).toEqual "Above Average"
  45 +
  46 + it "Should award the rating 'Competent' after 128 kills", ->
  47 + @commander.confirmed_kill(1) for kill in [0..127]
  48 + expect(@commander.elite_rating).toEqual "Competent"
  49 +
  50 + it "Should award the rating 'Dangerous' after 512 kills", ->
  51 + @commander.confirmed_kill(1) for kill in [0..511]
  52 + expect(@commander.elite_rating).toEqual "Dangerous"
  53 +
  54 + it "Should award the rating 'Deadly' after 2560 kills", ->
  55 + @commander.confirmed_kill(1) for kill in [0..2559]
  56 + expect(@commander.elite_rating).toEqual "Deadly"
  57 +
  58 + it "Should award the rating 'Elite' after 6400 kills", ->
  59 + @commander.confirmed_kill(1) for kill in [0..6399]
  60 + expect(@commander.elite_rating).toEqual "Elite"
  61 +
38 src/commander.coffee
... ... @@ -0,0 +1,38 @@
  1 +class Commander
  2 + legal_status: 'Clean'
  3 + credits: 100.0
  4 + current_system: 'Lave'
  5 + kills: 0
  6 +
  7 + right_on_commander: ->
  8 + console.log "Right on, Commander!"
  9 +
  10 + # Tried to do clever bit manipulation, but became confusing
  11 + calc_elite_rating: ->
  12 + galcop_elite_ratings =
  13 + 0: "Harmless",
  14 + 8: "Mostly Harmless",
  15 + 16: "Poor",
  16 + 32: "Average",
  17 + 64: "Above Average",
  18 + 128: "Competent",
  19 + 512: "Dangerous",
  20 + 2560: "Deadly",
  21 + 6400: "Elite"
  22 +
  23 + largest = 0
  24 + for i, rating of galcop_elite_ratings
  25 + largest = i if this.kills >= i
  26 + this.elite_rating = galcop_elite_ratings[largest]
  27 +
  28 + confirmed_kill: (bounty) ->
  29 + this.kills = this.kills + 1
  30 + this.credits = this.credits + bounty
  31 + this.calc_elite_rating()
  32 +
  33 + constructor: (@name = "Jameson") ->
  34 + this.calc_elite_rating()
  35 +
  36 +# As explained here: http://autotelicum.github.com/Smooth-CoffeeScript/interactive/interactive-coffeescript.html#object-oriented-programming
  37 +(exports ? this).Commander = Commander
  38 +
0  src/web.coffee → web.coffee
File renamed without changes

0 comments on commit 4158fd8

Please sign in to comment.
Something went wrong with that request. Please try again.