From 8177edda1eb26e1c8c0dd755460d08a48dcee128 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Tue, 14 Jun 2016 23:45:35 -0700 Subject: [PATCH 01/11] basic file structure, server setup --- vic-class22-assignment/.eslintignore | 8 ++++ vic-class22-assignment/.eslintrc | 41 +++++++++++++++++++ vic-class22-assignment/.gitignore | 2 + vic-class22-assignment/app/css/app.css | 0 vic-class22-assignment/app/css/app.css.sav | 0 vic-class22-assignment/app/index.html | 0 vic-class22-assignment/app/js/client.js | 0 .../js/game/controllers/game-controller.js | 0 vic-class22-assignment/app/js/game/game.js | 0 vic-class22-assignment/gulpfile.js | 0 vic-class22-assignment/package.json | 24 +++++++++++ vic-class22-assignment/server.js | 10 +++++ 12 files changed, 85 insertions(+) create mode 100644 vic-class22-assignment/.eslintignore create mode 100644 vic-class22-assignment/.eslintrc create mode 100644 vic-class22-assignment/.gitignore create mode 100644 vic-class22-assignment/app/css/app.css create mode 100644 vic-class22-assignment/app/css/app.css.sav create mode 100644 vic-class22-assignment/app/index.html create mode 100644 vic-class22-assignment/app/js/client.js create mode 100644 vic-class22-assignment/app/js/game/controllers/game-controller.js create mode 100644 vic-class22-assignment/app/js/game/game.js create mode 100644 vic-class22-assignment/gulpfile.js create mode 100644 vic-class22-assignment/package.json create mode 100644 vic-class22-assignment/server.js diff --git a/vic-class22-assignment/.eslintignore b/vic-class22-assignment/.eslintignore new file mode 100644 index 0000000..5348393 --- /dev/null +++ b/vic-class22-assignment/.eslintignore @@ -0,0 +1,8 @@ +**/node_modules/* +**/vendor/* +**/build/* +**/*.min.js +*.md +package.json +Procfile +npm-debug.log diff --git a/vic-class22-assignment/.eslintrc b/vic-class22-assignment/.eslintrc new file mode 100644 index 0000000..6d505ad --- /dev/null +++ b/vic-class22-assignment/.eslintrc @@ -0,0 +1,41 @@ +{ +"rules": { +"no-console": 0, +"indent": [ +2, +2 +], +"quotes": [ +2, +"single" +], +"linebreak-style": [ +2, +"unix" +], +"semi": [ +2, +"always" +] +}, +"env": { +"es6": true, +"node": true, +"browser": true, +"mocha": 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/vic-class22-assignment/.gitignore b/vic-class22-assignment/.gitignore new file mode 100644 index 0000000..dd87e2d --- /dev/null +++ b/vic-class22-assignment/.gitignore @@ -0,0 +1,2 @@ +node_modules +build diff --git a/vic-class22-assignment/app/css/app.css b/vic-class22-assignment/app/css/app.css new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/app/css/app.css.sav b/vic-class22-assignment/app/css/app.css.sav new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/app/index.html b/vic-class22-assignment/app/index.html new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/app/js/client.js b/vic-class22-assignment/app/js/client.js new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/app/js/game/controllers/game-controller.js b/vic-class22-assignment/app/js/game/controllers/game-controller.js new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/app/js/game/game.js b/vic-class22-assignment/app/js/game/game.js new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/gulpfile.js b/vic-class22-assignment/gulpfile.js new file mode 100644 index 0000000..e69de29 diff --git a/vic-class22-assignment/package.json b/vic-class22-assignment/package.json new file mode 100644 index 0000000..705432d --- /dev/null +++ b/vic-class22-assignment/package.json @@ -0,0 +1,24 @@ +{ + "name": "vic-class22-assignment", + "version": "1.0.0", + "description": "", + "main": "gulpfile.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "angular": "^1.5.6", + "express": "^4.13.4", + "express-static": "^1.0.3" + }, + "devDependencies": { + "gulp": "^3.9.1", + "gulp-eslint": "^2.0.0", + "gulp-watch": "^4.3.6", + "webpack-stream": "^3.2.0" + } +} diff --git a/vic-class22-assignment/server.js b/vic-class22-assignment/server.js new file mode 100644 index 0000000..3cbd943 --- /dev/null +++ b/vic-class22-assignment/server.js @@ -0,0 +1,10 @@ +'use strict'; + +const express = require('express'); +const app = express(); + +app.use(express.static(__dirname + '/build')); + +const server = app.listen(3000, function() { + console.log('server is listening on %s', server.address().port); +}); From 2b50bdb93c69333ec7be82ac94fcfe7cbfb67a86 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 00:23:32 -0700 Subject: [PATCH 02/11] gulpfile added --- vic-class22-assignment/gulpfile.js | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/vic-class22-assignment/gulpfile.js b/vic-class22-assignment/gulpfile.js index e69de29..6ba3b62 100644 --- a/vic-class22-assignment/gulpfile.js +++ b/vic-class22-assignment/gulpfile.js @@ -0,0 +1,47 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const webpack = require('webpack-stream'); + +var files = ['*.js', './app/*.js', './app/js/*.js', './app/js/game/*.js', './app/js/game/controllers/*.js']; + +const paths = { + js:__dirname + '/app/js/*.js', + html:__dirname + '/app/index.html', + css:__dirname + '/app/css/*.css' +}; + +gulp.task('lint', () => { + return gulp.src(files) + .pipe(eslint()) + .pipe(eslint.format()); +}); + +gulp.task('webpack:dev', () => { + return gulp.src(paths.js) + .pipe(webpack({ + output: { + filename: 'bundle.js' + } + })) + .pipe(gulp.dest('build/')); +}); + +gulp.task('staticfiles:dev', () => { + return gulp.src(paths.html) + .pipe(gulp.dest('./build')); +}); + +gulp.task('staticcssfiles:dev', () => { + return gulp.src(paths.css) + .pipe(gulp.dest('./build')); +}); + +gulp.task('build:dev', ['staticfiles:dev', 'staticcssfiles:dev', 'webpack:dev']); + +gulp.task('watch', () => { + gulp.watch(paths.js, ['lint', 'webpack:dev']); + gulp.watch(paths.html, ['staticfiles:dev']); + gulp.watch(paths.css, ['staticcssfiles:dev']); +}); From 81a5e9269c17af7674a6975957a3e35477dfcdee Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 09:40:58 -0700 Subject: [PATCH 03/11] client requires angular and is modular --- vic-class22-assignment/app/js/client.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vic-class22-assignment/app/js/client.js b/vic-class22-assignment/app/js/client.js index e69de29..e1e23e9 100644 --- a/vic-class22-assignment/app/js/client.js +++ b/vic-class22-assignment/app/js/client.js @@ -0,0 +1,5 @@ +'use strict'; + +const angular = require('angular'); + +var adventureApp = angular.module('adventure', []); require('./game/game')(adventureApp); From 345f870515afed9f166c0a7e6b4c454800786b41 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 10:18:34 -0700 Subject: [PATCH 04/11] basic index.html complete will need to revise later --- vic-class22-assignment/app/index.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/vic-class22-assignment/app/index.html b/vic-class22-assignment/app/index.html index e69de29..ba96995 100644 --- a/vic-class22-assignment/app/index.html +++ b/vic-class22-assignment/app/index.html @@ -0,0 +1,27 @@ + + + + + + + + Text Adventure Game + + +
+

Adventure Game:

+
+ + +
+
    +
  • + {{choice.msg}} +
  • +
+
+ + + From 3fa6f88e41a18f88aa336712874a46bcc26b8e68 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 10:24:40 -0700 Subject: [PATCH 05/11] game.js requires game-controller, avialable for app --- vic-class22-assignment/app/js/game/game.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vic-class22-assignment/app/js/game/game.js b/vic-class22-assignment/app/js/game/game.js index e69de29..7f2d2c6 100644 --- a/vic-class22-assignment/app/js/game/game.js +++ b/vic-class22-assignment/app/js/game/game.js @@ -0,0 +1,3 @@ +module.exports = function(app) { + require('./controllers/game-controller')(app); +}; From 79cab0a131639b973c39c48fb564b4ee87f53c0d Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 11:29:19 -0700 Subject: [PATCH 06/11] started game controller --- .../js/game/controllers/game-controller.js | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/vic-class22-assignment/app/js/game/controllers/game-controller.js b/vic-class22-assignment/app/js/game/controllers/game-controller.js index e69de29..37aa00d 100644 --- a/vic-class22-assignment/app/js/game/controllers/game-controller.js +++ b/vic-class22-assignment/app/js/game/controllers/game-controller.js @@ -0,0 +1,120 @@ +module.exports = function(app) { + app.controller('GameController', GameController); +}; + +function GameController() { + this.model = { + userLocation: 'start', + userHasWeapon: false, + command: '', + gamelog: [], + location: { + 'start': { + commands: ['Enter ? for available commands at any time'], + prompt: 'Welcome to your Quest. You must acquire a weapon to defeat the a monster in order to leave this building.' + }, + 'weaponroom': { + commands: ['take the dick\'s burger', 'take the beard oil', 'take the soccerball', 'take the iced tea', 'say ', 'walk through door'], + prompt: 'You are in the weapon room. There is a weapon in each corner, a dick\'s burger, beard oil, a soccerball, and iced tea. One of these items may defeat the monster you encounter.' + }, + 'monsterroomwithoutweapon': { + commands: ['walk through door', 'say '], + prompt: 'You are in a room with a hairy monster.' + }, + 'monsterroomwithweapon': { + commands:['pour beard oil on floor', 'feed monster dick\'s burger', 'quench monster thirst with iced tea', 'distract with soccerball'], + prompt: 'You are in a room with a monster and you have a weapon.' + } + } + }; + this.startGame = function() { + this.model.gamelog = []; + this.model.userLocation = 'start'; + this.model.userHasWeapon = false; + this.model.command = ''; + this.model.gamelog.push({ + src: 'game', + msg: this.model.location.start.prompt + }); + this.model.location.start.commands.forEach(function(choice) { + this.model.gamelog.push({ + src: 'command', + msg: choice + }); + }); + this.model.userLocation = 'monsterroomwithoutweapon'; + }; + this.processInput = function() { + this.model.gamelog.push({ + src: 'user', + msg: this.model.command + }); + + switch (this.model.command) { + case '?': + this.model.gamelog.push({ + src: 'game', + msg: this.currentHelpMsg() + }); + break; + case 'walk through door': + var currentLocation = this.model.userLocation; + if(currentLocation === 'weaponroom') { + currentLocation = this.model.userLocation = this.model.userHasWeapon ? 'monsterroomwithweapon' : 'monsterroomwithoutweapon'; + this.model.gamelog.push({ + src: 'game', + msg: this.model.location[currentLocation].prompt + }); + } else { + this.model.userLocation = 'weaponroom'; + this.model.gamelog.push({ + src: 'game', + msg: this.model.location.weaponroom.prompt + }); + } + + this.model.gamelog.push({ + src: 'game', + msg: this.currentHelpMsg() + }); + break; + case 'take the dick\'s burger': + this.model.userHasWeapon = true; + break; + + default: + + var sayArr = this.model.command.split(' '); + if(sayArr[0] === 'say') { + this.model.gamelog.push({ + src:'game', + msg: sayArr[1] || 'SPEAK!' + }); + } else { + this.model.gamelog.push({ + src: 'game', + msg: 'BAD COMMAND: Enter ? to see commands' + }); + } + } + this.model.command = ''; + }; + this.currentHelpMsg = function() { + var str = ''; + switch(this.model.userLocation) { + case 'weaponroom': + this.model.location.weaponroom.commands.forEach(function(choice, index) { + str += index > 0 ? ' | ' : ''; + str += choice; + }); + break; + case 'monsterroomwithoutweapon': + this.model.location.monsterroomwithoutweapon.commands.forEach(function(choice, index) { + str += index > 0 ? ' | ' : ''; + str += choice; + }); + break; + } + return str; + }; +} From 2d2b4de1fa69d943ef70868d6f91b1c26d97c38d Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 13:05:35 -0700 Subject: [PATCH 07/11] correcting naming in game-controller and index.html --- vic-class22-assignment/app/index.html | 8 ++++---- vic-class22-assignment/app/js/client.js | 2 +- .../app/js/game/controllers/game-controller.js | 14 ++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/vic-class22-assignment/app/index.html b/vic-class22-assignment/app/index.html index ba96995..845ce94 100644 --- a/vic-class22-assignment/app/index.html +++ b/vic-class22-assignment/app/index.html @@ -8,16 +8,16 @@ Text Adventure Game -
+

Adventure Game:

-
+
    -
  • +
  • {{choice.msg}}
diff --git a/vic-class22-assignment/app/js/client.js b/vic-class22-assignment/app/js/client.js index e1e23e9..2d01b4c 100644 --- a/vic-class22-assignment/app/js/client.js +++ b/vic-class22-assignment/app/js/client.js @@ -2,4 +2,4 @@ const angular = require('angular'); -var adventureApp = angular.module('adventure', []); require('./game/game')(adventureApp); +var adventureApp = angular.module('adventureApp', []); require('./game/game')(adventureApp); diff --git a/vic-class22-assignment/app/js/game/controllers/game-controller.js b/vic-class22-assignment/app/js/game/controllers/game-controller.js index 37aa00d..d893d29 100644 --- a/vic-class22-assignment/app/js/game/controllers/game-controller.js +++ b/vic-class22-assignment/app/js/game/controllers/game-controller.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = function(app) { app.controller('GameController', GameController); }; @@ -27,7 +29,7 @@ function GameController() { } } }; - this.startGame = function() { + GameController.prototype.startGame = function() { this.model.gamelog = []; this.model.userLocation = 'start'; this.model.userHasWeapon = false; @@ -36,7 +38,7 @@ function GameController() { src: 'game', msg: this.model.location.start.prompt }); - this.model.location.start.commands.forEach(function(choice) { + this.model.location.start.commands.forEach((choice) => { this.model.gamelog.push({ src: 'command', msg: choice @@ -44,7 +46,7 @@ function GameController() { }); this.model.userLocation = 'monsterroomwithoutweapon'; }; - this.processInput = function() { + GameController.prototype.processInput = function() { this.model.gamelog.push({ src: 'user', msg: this.model.command @@ -99,17 +101,17 @@ function GameController() { } this.model.command = ''; }; - this.currentHelpMsg = function() { + GameController.prototype.currentHelpMsg = function() { var str = ''; switch(this.model.userLocation) { case 'weaponroom': - this.model.location.weaponroom.commands.forEach(function(choice, index) { + this.model.location.weaponroom.commands.forEach((choice, index) => { str += index > 0 ? ' | ' : ''; str += choice; }); break; case 'monsterroomwithoutweapon': - this.model.location.monsterroomwithoutweapon.commands.forEach(function(choice, index) { + this.model.location.monsterroomwithoutweapon.commands.forEach((choice, index) => { str += index > 0 ? ' | ' : ''; str += choice; }); From 473da3321bfbc01aaec802652ba3c893e17c28d0 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Wed, 15 Jun 2016 23:57:17 -0700 Subject: [PATCH 08/11] added color to text, fixed say message so more than one word prints --- vic-class22-assignment/app/css/app.css | 20 +++++++++++++++++++ .../js/game/controllers/game-controller.js | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/vic-class22-assignment/app/css/app.css b/vic-class22-assignment/app/css/app.css index e69de29..6b7fd67 100644 --- a/vic-class22-assignment/app/css/app.css +++ b/vic-class22-assignment/app/css/app.css @@ -0,0 +1,20 @@ +main ul { + list-style-type: none; + margin: 5px; + display: block; + height: 400px; + width: 600px; + border: 1px solid black; +} + +span.game-input { + color: green; +} + +span.command-input { + color: blue; +} + +span.user-input { + color: red; +} diff --git a/vic-class22-assignment/app/js/game/controllers/game-controller.js b/vic-class22-assignment/app/js/game/controllers/game-controller.js index d893d29..0d23554 100644 --- a/vic-class22-assignment/app/js/game/controllers/game-controller.js +++ b/vic-class22-assignment/app/js/game/controllers/game-controller.js @@ -90,7 +90,7 @@ function GameController() { if(sayArr[0] === 'say') { this.model.gamelog.push({ src:'game', - msg: sayArr[1] || 'SPEAK!' + msg: sayArr.split(1, sayArr.length).join(' ') || 'SPEAK!' }); } else { this.model.gamelog.push({ From aae64296d7053ad76d4ad058041bf4a1e320e983 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Thu, 16 Jun 2016 13:12:17 -0700 Subject: [PATCH 09/11] added karma config and a test for controller --- vic-class22-assignment/.eslintignore | 1 + vic-class22-assignment/.gitignore | 1 + vic-class22-assignment/app/js/client.js | 3 +- vic-class22-assignment/gulpfile.js | 10 +++ vic-class22-assignment/karma.conf.js | 69 +++++++++++++++++++++ vic-class22-assignment/package.json | 1 + vic-class22-assignment/test/browser_test.js | 22 +++++++ 7 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 vic-class22-assignment/karma.conf.js create mode 100644 vic-class22-assignment/test/browser_test.js diff --git a/vic-class22-assignment/.eslintignore b/vic-class22-assignment/.eslintignore index 5348393..e90e85f 100644 --- a/vic-class22-assignment/.eslintignore +++ b/vic-class22-assignment/.eslintignore @@ -2,6 +2,7 @@ **/vendor/* **/build/* **/*.min.js +*_bundle.js *.md package.json Procfile diff --git a/vic-class22-assignment/.gitignore b/vic-class22-assignment/.gitignore index dd87e2d..19e2dfb 100644 --- a/vic-class22-assignment/.gitignore +++ b/vic-class22-assignment/.gitignore @@ -1,2 +1,3 @@ node_modules build +*_bundle.js diff --git a/vic-class22-assignment/app/js/client.js b/vic-class22-assignment/app/js/client.js index 2d01b4c..54f0d1c 100644 --- a/vic-class22-assignment/app/js/client.js +++ b/vic-class22-assignment/app/js/client.js @@ -2,4 +2,5 @@ const angular = require('angular'); -var adventureApp = angular.module('adventureApp', []); require('./game/game')(adventureApp); +var adventureApp = angular.module('adventureApp', []); +require('./game/game')(adventureApp); diff --git a/vic-class22-assignment/gulpfile.js b/vic-class22-assignment/gulpfile.js index 6ba3b62..8676c22 100644 --- a/vic-class22-assignment/gulpfile.js +++ b/vic-class22-assignment/gulpfile.js @@ -38,6 +38,16 @@ gulp.task('staticcssfiles:dev', () => { .pipe(gulp.dest('./build')); }); +gulp.task('bundle:test', () => { + return gulp.src(__dirname + '/test/*_test.js') + .pipe(webpack({ + output: { + filename: 'test_bundle.js' + } + })) + .pipe(gulp.dest(__dirname + '/test')); +}); + gulp.task('build:dev', ['staticfiles:dev', 'staticcssfiles:dev', 'webpack:dev']); gulp.task('watch', () => { diff --git a/vic-class22-assignment/karma.conf.js b/vic-class22-assignment/karma.conf.js new file mode 100644 index 0000000..a59771c --- /dev/null +++ b/vic-class22-assignment/karma.conf.js @@ -0,0 +1,69 @@ +// Karma configuration +// Generated on Thu Jun 16 2016 10:07:33 GMT-0700 (PDT) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'test/test_bundle.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }); +}; diff --git a/vic-class22-assignment/package.json b/vic-class22-assignment/package.json index 705432d..a1f336f 100644 --- a/vic-class22-assignment/package.json +++ b/vic-class22-assignment/package.json @@ -16,6 +16,7 @@ "express-static": "^1.0.3" }, "devDependencies": { + "angular-mocks": "^1.5.7", "gulp": "^3.9.1", "gulp-eslint": "^2.0.0", "gulp-watch": "^4.3.6", diff --git a/vic-class22-assignment/test/browser_test.js b/vic-class22-assignment/test/browser_test.js new file mode 100644 index 0000000..bf5643d --- /dev/null +++ b/vic-class22-assignment/test/browser_test.js @@ -0,0 +1,22 @@ +'use strict'; + +const angular = require('angular'); + +require('angular-mocks'); +require('../app/js/client'); + +describe('Controller Tests', () => { + let firstctrl; + + beforeEach(() => { + angular.mock.module('adventureApp'); + angular.mock.inject(function($controller) { + firstctrl = new $controller('GameController'); + }); + }); + + it('should have a property gamelog', () => { + console.log(firstctrl); + expect(Array.isArray(firstctrl.model.gamelog)).toBe(true); + }); +}); From 3dd527fd54fce6585a56a91b0935dbc773609f47 Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Thu, 16 Jun 2016 23:33:57 -0700 Subject: [PATCH 10/11] added start game function test, and fixed eslint issue --- vic-class22-assignment/.eslintrc | 3 ++- vic-class22-assignment/test/browser_test.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/vic-class22-assignment/.eslintrc b/vic-class22-assignment/.eslintrc index 6d505ad..4d749b1 100644 --- a/vic-class22-assignment/.eslintrc +++ b/vic-class22-assignment/.eslintrc @@ -22,7 +22,8 @@ "es6": true, "node": true, "browser": true, -"mocha": true +"mocha": true, +"jasmine": true }, "globals": { "describe": false, diff --git a/vic-class22-assignment/test/browser_test.js b/vic-class22-assignment/test/browser_test.js index bf5643d..736317c 100644 --- a/vic-class22-assignment/test/browser_test.js +++ b/vic-class22-assignment/test/browser_test.js @@ -19,4 +19,9 @@ describe('Controller Tests', () => { console.log(firstctrl); expect(Array.isArray(firstctrl.model.gamelog)).toBe(true); }); + + it('should start the game', () => { + firstctrl.startGame(); + expect(firstctrl.model.userLocation).toBe('start'); + }); }); From c3b230b7421948c31dd889e38889111dcbe1849d Mon Sep 17 00:00:00 2001 From: Victor Benavente Date: Thu, 16 Jun 2016 23:57:29 -0700 Subject: [PATCH 11/11] still working on game logic --- .../app/js/game/controllers/game-controller.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vic-class22-assignment/app/js/game/controllers/game-controller.js b/vic-class22-assignment/app/js/game/controllers/game-controller.js index 0d23554..cadcae5 100644 --- a/vic-class22-assignment/app/js/game/controllers/game-controller.js +++ b/vic-class22-assignment/app/js/game/controllers/game-controller.js @@ -12,7 +12,7 @@ function GameController() { gamelog: [], location: { 'start': { - commands: ['Enter ? for available commands at any time'], + commands: ['Enter ? for available commands at any time', 'enter door on left', 'enter door on right'], prompt: 'Welcome to your Quest. You must acquire a weapon to defeat the a monster in order to leave this building.' }, 'weaponroom': { @@ -44,7 +44,7 @@ function GameController() { msg: choice }); }); - this.model.userLocation = 'monsterroomwithoutweapon'; + this.model.userLocation = 'start'; }; GameController.prototype.processInput = function() { this.model.gamelog.push({ @@ -55,11 +55,11 @@ function GameController() { switch (this.model.command) { case '?': this.model.gamelog.push({ - src: 'game', + src: 'command', msg: this.currentHelpMsg() }); break; - case 'walk through door': + case 'enter door on left': var currentLocation = this.model.userLocation; if(currentLocation === 'weaponroom') { currentLocation = this.model.userLocation = this.model.userHasWeapon ? 'monsterroomwithweapon' : 'monsterroomwithoutweapon'; @@ -104,6 +104,12 @@ function GameController() { GameController.prototype.currentHelpMsg = function() { var str = ''; switch(this.model.userLocation) { + case 'start': + this.model.location.start.commands.forEach((choice, index) => { + str += index > 0 ? ' | ' : ''; + str += choice; + }); + break; case 'weaponroom': this.model.location.weaponroom.commands.forEach((choice, index) => { str += index > 0 ? ' | ' : '';