diff --git a/ruben/.DS_Store b/ruben/.DS_Store deleted file mode 100644 index 434e9e4..0000000 Binary files a/ruben/.DS_Store and /dev/null differ diff --git a/ruben/.eslintignore b/ruben/.eslintignore new file mode 100644 index 0000000..7608114 --- /dev/null +++ b/ruben/.eslintignore @@ -0,0 +1,4 @@ + +node_modules/ +test/test_bundle.js +package.json diff --git a/ruben/.eslintrc b/ruben/.eslintrc new file mode 100644 index 0000000..5f3d636 --- /dev/null +++ b/ruben/.eslintrc @@ -0,0 +1,45 @@ +{ +"rules": { +"no-console": 0, +"indent": [ +2, +2, +{ +"SwitchCase": 1 +} +], +"quotes": [ +2, +"single" +], +"linebreak-style": [ +2, +"unix" +], +"semi": [ +2, +"always" +] +}, +"env": { +"es6": true, +"node": true, +"browser": true, +"mocha": true, +"jasmine": true +}, +"globals": { +"describe": false, +"it": false, +"beforeEach": false, +"afterEach": false, +"before": false, +"after": false +}, +"ecmaFeatures": { +"modules": true, +"experimentalObjectRestSpread": true, +"impliedStrict": true +}, +"extends": "eslint:recommended" +} diff --git a/ruben/.gitignore b/ruben/.gitignore index c2658d7..db39712 100644 --- a/ruben/.gitignore +++ b/ruben/.gitignore @@ -1 +1,3 @@ node_modules/ +build/ +test/test_bundle.js diff --git a/ruben/app/js/game/controllers/game-controller.js b/ruben/app/js/game/controllers/game-controller.js index 7eac013..4340183 100644 --- a/ruben/app/js/game/controllers/game-controller.js +++ b/ruben/app/js/game/controllers/game-controller.js @@ -5,121 +5,117 @@ module.exports = function(app) { }; function GameController() { - this.userLocation = 'start'; - this.userHasBall = false; - this.command = ''; - this.gamelog = []; - this.location = { - 'start': { - commands: ['Enter ? for available commands at any time.'], - prompt: 'Welcome to the NBA Finals. You are in a stadium with a Monstar from Space Jam.' - }, - 'stadium': { - commands: ['take ball', 'look for the basket', 'say ', 'walk onto court'], - prompt: 'You are on the court. There is a spalding ball on the halfcourt line.' - }, - 'courtwithoutball': { - commands: ['walk through door', 'say '], - prompt: 'You are on the court with a Monstar.' - }, - 'courtwithball': { - commands: ['shoot ball'], - prompt: 'You are on the court with a Monstar and you have a ball.' - } - } - }; - GameController.prototype.startGame = function() { - this.gamelog = []; - this.userLocation = 'start'; - this.userHasBall = false; - this.command = ''; + this.userLocation = 'start'; + this.userHasBall = false; + this.command = ''; + this.gamelog = []; + this.location = { + 'start': { + commands: ['Enter ? for available commands.'], + prompt: 'Welcome to the NBA Finals. You are in a stadium with a Monstar from Space Jam.' + }, + 'stadium': { + commands: ['walk onto court'], + prompt: 'You are on the court. There is a spalding ball on the halfcourt line.' + }, + 'courtwithoutball': { + commands: ['take ball'], + prompt: 'You are on the court with a Monstar and there is a ball' + }, + 'courtwithball': { + commands: ['shoot ball'], + prompt: 'Shoot the ball!' + } + }; +} +GameController.prototype.startGame = function() { + this.gamelog = []; + this.userLocation = 'start'; + this.userHasBall = false; + this.command = ''; + this.gamelog.push({ + src: 'game', + msg: this.location.start.prompt + }); + var gamelog = this.gamelog; + this.location.start.commands.forEach(function(item) { + gamelog.push({ + src: 'command', + msg: item + }); + }); + this.userLocation = 'courtwithoutball'; +}; +GameController.prototype.processInput = function() { + this.gamelog.push({ + src: 'user', + msg: this.command + }); + + switch (this.command) { + case '?': this.gamelog.push({ src: 'game', - msg: this.location.start.prompt - }); - var gamelog = this.gamelog; - this.location.start.commands.forEach(function(item) { - gamelog.push({ - src: 'command', - msg: item - }); - }); - this.userLocation = 'courtwithoutball'; - }; - GameController.prototype.processInput = function() { - this.gamelog.push({ - src: 'user', - msg: this.command + msg: this.currentHelpMsg() }); - - switch (this.command) { - case '?': + break; + case 'walk onto court': + var currentLocation = this.userLocation; + if (currentLocation === 'stadium') { + currentLocation = this.userLocation = this.userHasBall ? 'courtwithball' : 'courtwithoutball'; this.gamelog.push({ src: 'game', - msg: this.currentHelpMsg() + msg: this.location[currentLocation].prompt }); - break; - case 'walk onto court': - var currentLocation = this.userLocation; - if (currentLocation === 'stadium') { - currentLocation = this.userLocation = this.userHasWeapon ? 'courtwithball' : 'courtwithoutball'; - this.gamelog.push({ - src: 'game', - msg: this.location[currentLocation].prompt - }); - } else { - this.userLocation = 'stadium'; - this.gamelog.push({ - src: 'game', - msg: this.location.weaponroom.prompt - }); - } - - + } else { + this.userLocation = 'stadium'; this.gamelog.push({ src: 'game', - msg: this.currentHelpMsg() + msg: this.location.stadium.prompt }); - break; - - case 'take ball': - this.userHasWeapon = true; - break; - - default: - var sayArr = this.command.split(' '); - if (sayArr[0] === 'say') { - this.gamelog.push({ - src: 'game', - msg: sayArr[1] || 'SAY SOMETHING!' - }); - } else { - this.gamelog.push({ - src: 'game', - msg: 'BAD COMMAND: Enter ? to see commands' - }); - } } - this.command = ''; //clear command after processing - }; - GameController.prototype.currentHelpMsg = function() { - var str = ''; - switch (this.userLocation) { - case 'stadium': - this.location.weaponroom.commands.forEach(function(item, index) { - str += index > 0 ? ' | ' : ''; - str += item; + this.gamelog.push({ + src: 'game', + msg: this.currentHelpMsg() + }); + break; + case 'take ball': + this.userHasBall = true; + break; + default: + var sayArr = this.command.split(' '); + if (sayArr[0] === 'say') { + this.gamelog.push({ + src: 'game', + msg: sayArr[1] || 'SAY SOMETHING!' }); - break; - - case 'courtwithoutball': - this.location.courtwithoutball.commands.forEach(function(item, index) { - str += index > 0 ? ' | ' : ''; - str += item; + } else { + this.gamelog.push({ + src: 'game', + msg: 'BAD COMMAND: Enter ? to see commands' }); - break; } - return str; - }; + } + this.command = ''; //clear command after processing + +}; +GameController.prototype.currentHelpMsg = function() { + var str = ''; + switch (this.userLocation) { + case 'stadium': + this.location.stadium.commands.forEach(function(item, index) { + str += index > 0 ? ' | ' : ''; + str += item; + }); + break; + case 'courtwithoutball': + this.location.courtwithoutball.commands.forEach(function(item, index) { + str += index > 0 ? ' | ' : ''; + str += item; + }); + break; + } + return str; +}; diff --git a/ruben/build/bundle.js b/ruben/build/bundle.js index cf7035c..d06c786 100644 --- a/ruben/build/bundle.js +++ b/ruben/build/bundle.js @@ -31108,124 +31108,120 @@ }; function GameController() { - this.userLocation = 'start'; - this.userHasBall = false; - this.command = ''; - this.gamelog = []; - this.location = { - 'start': { - commands: ['Enter ? for available commands at any time.'], - prompt: 'Welcome to the NBA Finals. You are in a stadium with a Monstar from Space Jam.' - }, - 'stadium': { - commands: ['take ball', 'look for the basket', 'say ', 'walk onto court'], - prompt: 'You are on the court. There is a spalding ball on the halfcourt line.' - }, - 'courtwithoutball': { - commands: ['walk through door', 'say '], - prompt: 'You are on the court with a Monstar.' - }, - 'courtwithball': { - commands: ['shoot ball'], - prompt: 'You are on the court with a Monstar and you have a ball.' - } - } - }; - GameController.prototype.startGame = function() { - this.gamelog = []; - this.userLocation = 'start'; - this.userHasBall = false; - this.command = ''; + this.userLocation = 'start'; + this.userHasBall = false; + this.command = ''; + this.gamelog = []; + this.location = { + 'start': { + commands: ['Enter ? for available commands.'], + prompt: 'Welcome to the NBA Finals. You are in a stadium with a Monstar from Space Jam.' + }, + 'stadium': { + commands: ['walk onto court'], + prompt: 'You are on the court. There is a spalding ball on the halfcourt line.' + }, + 'courtwithoutball': { + commands: ['take ball'], + prompt: 'You are on the court with a Monstar and there is a ball' + }, + 'courtwithball': { + commands: ['shoot ball'], + prompt: 'Shoot the ball!' + } + }; + } + GameController.prototype.startGame = function() { + this.gamelog = []; + this.userLocation = 'start'; + this.userHasBall = false; + this.command = ''; + this.gamelog.push({ + src: 'game', + msg: this.location.start.prompt + }); + var gamelog = this.gamelog; + this.location.start.commands.forEach(function(item) { + gamelog.push({ + src: 'command', + msg: item + }); + }); + this.userLocation = 'courtwithoutball'; + }; + GameController.prototype.processInput = function() { + this.gamelog.push({ + src: 'user', + msg: this.command + }); + + switch (this.command) { + case '?': this.gamelog.push({ src: 'game', - msg: this.location.start.prompt + msg: this.currentHelpMsg() }); - var gamelog = this.gamelog; - this.location.start.commands.forEach(function(item) { - gamelog.push({ - src: 'command', - msg: item - }); - }); - this.userLocation = 'courtwithoutball'; - }; - GameController.prototype.processInput = function() { - this.gamelog.push({ - src: 'user', - msg: this.command - }); - - switch (this.command) { - case '?': + break; + case 'walk onto court': + var currentLocation = this.userLocation; + if (currentLocation === 'stadium') { + currentLocation = this.userLocation = this.userHasBall ? 'courtwithball' : 'courtwithoutball'; this.gamelog.push({ src: 'game', - msg: this.currentHelpMsg() + msg: this.location[currentLocation].prompt }); - break; - case 'walk onto court': - var currentLocation = this.userLocation; - if (currentLocation === 'stadium') { - currentLocation = this.userLocation = this.userHasWeapon ? 'courtwithball' : 'courtwithoutball'; - this.gamelog.push({ - src: 'game', - msg: this.location[currentLocation].prompt - }); - } else { - this.userLocation = 'stadium'; - this.gamelog.push({ - src: 'game', - msg: this.location.weaponroom.prompt - }); - } - - + } else { + this.userLocation = 'stadium'; this.gamelog.push({ src: 'game', - msg: this.currentHelpMsg() + msg: this.location.stadium.prompt }); - break; - - case 'take ball': - this.userHasWeapon = true; - break; - - default: - var sayArr = this.command.split(' '); - if (sayArr[0] === 'say') { - this.gamelog.push({ - src: 'game', - msg: sayArr[1] || 'SAY SOMETHING!' - }); - } else { - this.gamelog.push({ - src: 'game', - msg: 'BAD COMMAND: Enter ? to see commands' - }); - } } - this.command = ''; //clear command after processing - }; - GameController.prototype.currentHelpMsg = function() { - var str = ''; - switch (this.userLocation) { - - case 'stadium': - this.location.weaponroom.commands.forEach(function(item, index) { - str += index > 0 ? ' | ' : ''; - str += item; - }); - break; - case 'courtwithoutball': - this.location.courtwithoutball.commands.forEach(function(item, index) { - str += index > 0 ? ' | ' : ''; - str += item; + this.gamelog.push({ + src: 'game', + msg: this.currentHelpMsg() + }); + break; + case 'take ball': + this.userHasBall = true; + break; + default: + var sayArr = this.command.split(' '); + if (sayArr[0] === 'say') { + this.gamelog.push({ + src: 'game', + msg: sayArr[1] || 'SAY SOMETHING!' + }); + } else { + this.gamelog.push({ + src: 'game', + msg: 'BAD COMMAND: Enter ? to see commands' }); - break; } - return str; - }; + } + this.command = ''; //clear command after processing + + }; + GameController.prototype.currentHelpMsg = function() { + var str = ''; + switch (this.userLocation) { + case 'stadium': + this.location.stadium.commands.forEach(function(item, index) { + str += index > 0 ? ' | ' : ''; + str += item; + }); + break; + case 'courtwithoutball': + this.location.courtwithoutball.commands.forEach(function(item, index) { + str += index > 0 ? ' | ' : ''; + str += item; + }); + break; + } + return str; + }; /***/ } diff --git a/ruben/gulpfile.js b/ruben/gulpfile.js index eba5a97..af52c10 100644 --- a/ruben/gulpfile.js +++ b/ruben/gulpfile.js @@ -29,7 +29,7 @@ gulp.task('bundle:test', () => { filename: 'test_bundle.js' } })) - .pipe(gulp.dest(__dirname + '/test')) + .pipe(gulp.dest(__dirname + '/test')); }); gulp.task('watch', () => { @@ -38,4 +38,4 @@ gulp.task('watch', () => { gulp.watch('./app/css/app.css', ['copy']); }); -gulp.task('default', ['bundle:test', 'bundle', 'copy',]); +gulp.task('default', ['bundle:test', 'bundle', 'copy']); diff --git a/ruben/karma.conf.js b/ruben/karma.conf.js index 7e3fef4..973e74b 100644 --- a/ruben/karma.conf.js +++ b/ruben/karma.conf.js @@ -65,5 +65,5 @@ module.exports = function(config) { // Concurrency level // how many browser should be started simultaneous concurrency: Infinity - }) -} + }); +}; diff --git a/ruben/server.js b/ruben/server.js index b3e0d1c..2c87326 100644 --- a/ruben/server.js +++ b/ruben/server.js @@ -1,4 +1,4 @@ -'use strict;' +'use strict'; const express = require('express'); diff --git a/ruben/test/test.js b/ruben/test/test.js index d4cbe1c..f88bfed 100644 --- a/ruben/test/test.js +++ b/ruben/test/test.js @@ -17,8 +17,8 @@ describe('Controller Tests', () => { }); it('should have a property notes', ()=>{ - expect(Array.isArray(firstctrl.gamelog)).toBe(true); - }); + expect(Array.isArray(firstctrl.gamelog)).toBe(true); + }); it('should have a command property with type of String', () => { expect(typeof firstctrl.command).toBe('string'); @@ -36,12 +36,12 @@ describe('Controller Tests', () => { expect(firstctrl.location.start.commands.length).toBe(1); }); - it('should have three commands in the stadium', () => { - expect(firstctrl.location.stadium.commands.length).toBe(3); + it('should have one command in the stadium', () => { + expect(firstctrl.location.stadium.commands.length).toBe(1); }); - it('should have two commands on the courtwithoutball location', () => { - expect(firstctrl.location.courtwithoutball.commands.length).toBe(2); + it('should have one command on the courtwithoutball location', () => { + expect(firstctrl.location.courtwithoutball.commands.length).toBe(1); }); it('should have one command on the courtwithball location', () => { diff --git a/ruben/test/test_bundle.js b/ruben/test/test_bundle.js index 46672f1..ccbd718 100644 --- a/ruben/test/test_bundle.js +++ b/ruben/test/test_bundle.js @@ -82,12 +82,12 @@ expect(firstctrl.location.start.commands.length).toBe(1); }); - it('should have three commands in the stadium', () => { - expect(firstctrl.location.stadium.commands.length).toBe(3); + it('should have one command in the stadium', () => { + expect(firstctrl.location.stadium.commands.length).toBe(1); }); - it('should have two commands on the courtwithoutball location', () => { - expect(firstctrl.location.courtwithoutball.commands.length).toBe(2); + it('should have one command on the courtwithoutball location', () => { + expect(firstctrl.location.courtwithoutball.commands.length).toBe(1); }); it('should have one command on the courtwithball location', () => { @@ -34289,124 +34289,120 @@ }; function GameController() { - this.userLocation = 'start'; - this.userHasBall = false; - this.command = ''; - this.gamelog = []; - this.location = { - 'start': { - commands: ['Enter ? for available commands at any time.'], - prompt: 'Welcome to the NBA Finals. You are in a stadium with a Monstar from Space Jam.' - }, - 'stadium': { - commands: ['take ball', 'look for the basket', 'say ', 'walk onto court'], - prompt: 'You are on the court. There is a spalding ball on the halfcourt line.' - }, - 'courtwithoutball': { - commands: ['walk through door', 'say '], - prompt: 'You are on the court with a Monstar.' - }, - 'courtwithball': { - commands: ['shoot ball'], - prompt: 'You are on the court with a Monstar and you have a ball.' - } - } - }; - GameController.prototype.startGame = function() { - this.gamelog = []; - this.userLocation = 'start'; - this.userHasBall = false; - this.command = ''; + this.userLocation = 'start'; + this.userHasBall = false; + this.command = ''; + this.gamelog = []; + this.location = { + 'start': { + commands: ['Enter ? for available commands.'], + prompt: 'Welcome to the NBA Finals. You are in a stadium with a Monstar from Space Jam.' + }, + 'stadium': { + commands: ['walk onto court'], + prompt: 'You are on the court. There is a spalding ball on the halfcourt line.' + }, + 'courtwithoutball': { + commands: ['take ball'], + prompt: 'You are on the court with a Monstar and there is a ball' + }, + 'courtwithball': { + commands: ['shoot ball'], + prompt: 'Shoot the ball!' + } + }; + } + GameController.prototype.startGame = function() { + this.gamelog = []; + this.userLocation = 'start'; + this.userHasBall = false; + this.command = ''; + this.gamelog.push({ + src: 'game', + msg: this.location.start.prompt + }); + var gamelog = this.gamelog; + this.location.start.commands.forEach(function(item) { + gamelog.push({ + src: 'command', + msg: item + }); + }); + this.userLocation = 'courtwithoutball'; + }; + GameController.prototype.processInput = function() { + this.gamelog.push({ + src: 'user', + msg: this.command + }); + + switch (this.command) { + case '?': this.gamelog.push({ src: 'game', - msg: this.location.start.prompt + msg: this.currentHelpMsg() }); - var gamelog = this.gamelog; - this.location.start.commands.forEach(function(item) { - gamelog.push({ - src: 'command', - msg: item - }); - }); - this.userLocation = 'courtwithoutball'; - }; - GameController.prototype.processInput = function() { - this.gamelog.push({ - src: 'user', - msg: this.command - }); - - switch (this.command) { - case '?': + break; + case 'walk onto court': + var currentLocation = this.userLocation; + if (currentLocation === 'stadium') { + currentLocation = this.userLocation = this.userHasBall ? 'courtwithball' : 'courtwithoutball'; this.gamelog.push({ src: 'game', - msg: this.currentHelpMsg() + msg: this.location[currentLocation].prompt }); - break; - case 'walk onto court': - var currentLocation = this.userLocation; - if (currentLocation === 'stadium') { - currentLocation = this.userLocation = this.userHasWeapon ? 'courtwithball' : 'courtwithoutball'; - this.gamelog.push({ - src: 'game', - msg: this.location[currentLocation].prompt - }); - } else { - this.userLocation = 'stadium'; - this.gamelog.push({ - src: 'game', - msg: this.location.weaponroom.prompt - }); - } - - + } else { + this.userLocation = 'stadium'; this.gamelog.push({ src: 'game', - msg: this.currentHelpMsg() + msg: this.location.stadium.prompt }); - break; - - case 'take ball': - this.userHasWeapon = true; - break; - - default: - var sayArr = this.command.split(' '); - if (sayArr[0] === 'say') { - this.gamelog.push({ - src: 'game', - msg: sayArr[1] || 'SAY SOMETHING!' - }); - } else { - this.gamelog.push({ - src: 'game', - msg: 'BAD COMMAND: Enter ? to see commands' - }); - } } - this.command = ''; //clear command after processing - }; - GameController.prototype.currentHelpMsg = function() { - var str = ''; - switch (this.userLocation) { - - case 'stadium': - this.location.weaponroom.commands.forEach(function(item, index) { - str += index > 0 ? ' | ' : ''; - str += item; - }); - break; - case 'courtwithoutball': - this.location.courtwithoutball.commands.forEach(function(item, index) { - str += index > 0 ? ' | ' : ''; - str += item; + this.gamelog.push({ + src: 'game', + msg: this.currentHelpMsg() + }); + break; + case 'take ball': + this.userHasBall = true; + break; + default: + var sayArr = this.command.split(' '); + if (sayArr[0] === 'say') { + this.gamelog.push({ + src: 'game', + msg: sayArr[1] || 'SAY SOMETHING!' + }); + } else { + this.gamelog.push({ + src: 'game', + msg: 'BAD COMMAND: Enter ? to see commands' }); - break; } - return str; - }; + } + this.command = ''; //clear command after processing + + }; + GameController.prototype.currentHelpMsg = function() { + var str = ''; + switch (this.userLocation) { + case 'stadium': + this.location.stadium.commands.forEach(function(item, index) { + str += index > 0 ? ' | ' : ''; + str += item; + }); + break; + case 'courtwithoutball': + this.location.courtwithoutball.commands.forEach(function(item, index) { + str += index > 0 ? ' | ' : ''; + str += item; + }); + break; + } + return str; + }; /***/ }