Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stefanie-hansen/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/node_modules/*
**/vendor/*
**/*.min.js
/*.md
/package.json
/npm-debug.log
/procfile
/build
41 changes: 41 additions & 0 deletions stefanie-hansen/.eslintrc
Original file line number Diff line number Diff line change
@@ -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"
}
86 changes: 86 additions & 0 deletions stefanie-hansen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# application specific
db/
build/

# Created by https://www.gitignore.io/api/node,osx,vim

### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Vim ###
# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags
5 changes: 5 additions & 0 deletions stefanie-hansen/app/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
background-color: teal;
font-size: 20px;
font-family: Arial;
}
25 changes: 25 additions & 0 deletions stefanie-hansen/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body ng-app="AdventureApp">
<main ng-controller="GameController as game" ng-cloak data-ng-init="game.gameStart()">
<h1>Adventure!</h1>
<form>
<label>Action:
<input type="text" ng-model="game.input" />
</label>
<button ng-click="game.action()">Choose Wisely</button>
</form>
<ul>
<li ng-repeat="history in game.gameLog track by $index">
<span>{{history}}</span>
</li>
</ul>
</main>
<script src="bundle.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions stefanie-hansen/app/js/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const angular = require('angular');

const AdventureApp = angular.module('AdventureApp', []);

require('./controllers/game-controller')(AdventureApp);
148 changes: 148 additions & 0 deletions stefanie-hansen/app/js/controllers/game-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
'use strict';

module.exports = function(app) {
app.controller('GameController', GameController);
};

function GameController() {
this.hasWeapon = false;
this.alive = true;
this.location = 'monsterRoom';
this.gameLog = [];
this.input = '';
this.actions = ['hyperventilate', 'pick up weapon', 'leave', 'philosophize', 'whimper', 'poke', 'call mom', 'taunt', 'yolo', 'reason', 'hadouken'];

this.weaponRoom = {};
this.weaponRoom.noWeaponActions = {
'hyperventilate': this.hyperventilate,
'pick up weapon': this.pickUpWeapon,
'leave': this.exit
};
this.weaponRoom.hasWeaponActions = {
'philosophize': this.philosophize,
'leave': this.exit
};

this.monsterRoom = {};
this.monsterRoom.noWeaponActions = {
'whimper': this.whimper,
'poke': this.poke,
'call mom': this.callMom,
'taunt': this.taunt,
'leave': this.exit
};
this.monsterRoom.hasWeaponActions = {
'yolo': this.yolo,
'reason': this.reason,
'leave': this.exit
};
}

GameController.prototype.action = function() {
let input = this.input.toLowerCase();
if (this.gameLog.length > 10) {
this.gameLog = [];
}
if (input === '?') {
this.seeActions();
} else if (!input || this.actions.indexOf(input) === -1) {
this.tryAgain();
} else if (this.location === 'monsterRoom') {
if (this.hasWeapon === false) {
this.monsterRoom.noWeaponActions[input].call(this);
} else {
this.monsterRoom.hasWeaponActions[input].call(this);
}
} else if (this.hasWeapon === false) {
this.weaponRoom.noWeaponActions[input].call(this);
} else {
this.weaponRoom.hasWeaponActions[input].call(this);
}
};

GameController.prototype.tryAgain = function() {
this.gameLog.push('Sorry, that is not a valid command. Enter ? to see the actions available in this room.');
};

GameController.prototype.seeActions = function() {
let location = (this.location === 'monsterRoom') ? this.monsterRoom : this.weaponRoom;
let actions = (this.hasWeapon === true) ? location.hasWeaponActions : location.noWeaponActions;
for (let key in actions) {
this.gameLog.push(key);
}
};

GameController.prototype.hyperventilate = function() {
if (this.location === 'weaponRoom' && this.hasWeapon === false) {
return this.gameLog.push('You get lightheaded and make poor decisions');
}
this.tryAgain();
};

GameController.prototype.pickUpWeapon = function() {
if (this.location === 'weaponRoom' && this.hasWeapon === false) {
this.hasWeapon = true;
return this.gameLog.push('You are now in possession of a feral weasel. Congratulations?');
}
this.tryAgain();
};

GameController.prototype.philosophize = function() {
if (this.location === 'weaponRoom' && this.hasWeapon === true) {
return this.gameLog.push('You consider the moral and ethical implications of killing a sentient being. But you decide that you\'d be doing the monster a favor, as he knows no life beyond those four digital walls.');
}
this.tryAgain();
};

GameController.prototype.poke = function() {
if (this.location === 'monsterRoom' && this.hasWeapon === false) {
this.alive = false;
return this.gameLog.push('You edge toward the monster and poke him, then giggle again run away. The monster is furious and decapitates you in one fell chomp.');
}
this.tryAgain();
};

GameController.prototype.whimper = function() {
if (this.location === 'monsterRoom' && this.hasWeapon === false) {
return this.gameLog.push('You whimper softly in the corner, hoping that the monster will let you live out your days... until you die of starvation. You should probably try to kill the monster so at least you have something to eat.');
}
this.tryAgain();
};

GameController.prototype.callMom = function() {
if (this.location === 'monsterRoom' && this.hasWeapon === false) {
this.alive = false;
return this.gameLog.push('You try to express your situation to your mother, but she thinks that you\'ve had too much to drink. Your dependence on your mother annoys the monster and he impales you with a talon.');
}
this.tryAgain();
};

GameController.prototype.taunt = function() {
if (this.location === 'monsterRoom' && this.hasWeapon === false) {
return this.gameLog.push('You taunt the monster and he is taken aback with your stupidity. He remains lost in thought.');
}
this.tryAgain();
};

GameController.prototype.yolo = function() {
if (this.location === 'monsterRoom' && this.hasWeapon === true) {
return this.gameLog.push('Your feral weasel goes for monster\'s face! Thou hath slain the Jabberwock! Oh, frabjous day!');
}
this.tryAgain();
};

GameController.prototype.reason = function() {
if (this.location === 'monsterRoom' && this.hasWeapon === true) {
return this.gameLog.push('You try to reason with the monster and tell him that you don\'t want to have to kill him, but he does not speak English. Sorry. You die.');
}
this.tryAgain();
};

GameController.prototype.exit = function() {
this.location === 'monsterRoom' ? this.location = 'weaponRoom' : this.location = 'monsterRoom';
this.gameLog.push('You walk into the adjacent room.');
};

GameController.prototype.gameStart = function() {
this.gameLog.push('You wake up and find yourself in a windowless room with a fearsome Jabberwocky. He is eyeing you with a mixture of curiosity and hunger. There is a door to your left. What shall you do? (Type ? at any time to see your options)');
};
27 changes: 27 additions & 0 deletions stefanie-hansen/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

const gulp = require('gulp');
const webpack = require('webpack-stream');

gulp.task('webpack:dev', function() {
return gulp.src('./app/js/client.js')
.pipe(webpack({
output: {
filename: 'bundle.js'
}
}))
.pipe(gulp.dest('build/'));
});

gulp.task('staticfiles:dev', function() {
return gulp.src('./app/**/*.html')
.pipe(gulp.dest('build/'));
});

gulp.task('staticcssfiles:dev', function() {
return gulp.src('./app/css/*.css')
.pipe(gulp.dest('build/'));
});

gulp.task('build:dev', ['staticfiles:dev','staticcssfiles:dev', 'webpack:dev']);
gulp.task('default', ['build:dev']);
21 changes: 21 additions & 0 deletions stefanie-hansen/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "stefanie-hansen",
"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"
},
"devDependencies": {
"gulp": "^3.9.1",
"webpack-stream": "^3.2.0"
}
}
9 changes: 9 additions & 0 deletions stefanie-hansen/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';
const express = require('express');
const app = express();

app.use(express.static(__dirname + '/build'));

app.listen(8080, () => {
console.log('server is running on 8080');
});