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
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules

*.md

npm-debug.log
Empty file added .eslintrc
Empty file.
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@

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

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

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

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# 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

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### 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

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/node,osx,windows,linux
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions app/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

require('./scss/main.scss');

const angular = require('angular');

angular.module('gollumsGame', []);

// Services
require('./service/player-service.js');
require('./service/map-service.js');

// Components
require('./component/gamepad/game-pad.js');
require('./component/player-info/player-info.js');
require('./component/game-history/game-history.js');
19 changes: 19 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html ng-app="gollumsGame">
<head>
<meta charset="utf-8">
<title>Gollums Game</title>
</head>
<body>

<header>
<h1>Gollums Game</h1>
</header>

<main>
<ui-view></ui-view>
</main>

<footer>&copy; Nikko Pisciotti 2017</footer>
</body>
</html>
Empty file added app/scss/main.scss
Empty file.
39 changes: 39 additions & 0 deletions app/service/map-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

const angular = require('angular');

const gollumsGame = angular.module('gollumsGame');

gollumsGame.factory('mapService', ['$log', mapService]);

function mapService($log) {
$log.debug('map service');

let service = {};

service.coordinates = ['a1','a2','a3','a4',
'b1','b2','b3','b4',
'c1','c2','c3','c4',
'd1','d2','d3','d4'
];

service.mapData = {
a1: { name: 'a1', east: 'a2', south: 'b1', hasRing: false },
a2: { name: 'a2', east: 'a3', south: 'b2', west: 'a1', hasRing: false },
a3: { name: 'a3', east: 'a4', south: 'b3', west: 'a2', hasRing: false },
a4: { name: 'a4', west: 'a3', south: 'b4', hasRing: false },
b1: { name: 'b1', north: 'a1', east: 'b2', south: 'c1', hasRing: false },
b2: { name: 'b2', north: 'a2', east: 'b3', south: 'c2', west: 'b1', hasRing: false },
b3: { name: 'b3', north: 'a3', east: 'b4', south: 'c3', west: 'b2', hasRing: false },
b4: { name: 'b4', north: 'a4', south: 'c4', west: 'b3', hasRing: false },
c1: { name: 'c1', north: 'b1', east: 'c2', south: 'd1', hasRing: false },
c2: { name: 'c2', north: 'b2', east: 'c3', south: 'd2', west: 'c1', hasRing: false },
c3: { name: 'c3', north: 'b3', east: 'c4', south: 'd3', west: 'c2', hasRing: false },
c4: { name: 'c4', north: 'b4', south: 'd4', west: 'c3', hasRing: false },
d1: { name: 'd1', north: 'c1', east: 'd2', hasRing: false },
d2: { name: 'd2', north: 'c2', east: 'd3', west: 'd1', hasRing: false },
d3: { name: 'd3', north: 'c3', east: 'd4', west: 'd2', hasRing: false },
d4: { name: 'd4', north: 'c4', west: 'd3', hasRing: false }
}
return service;
}
70 changes: 70 additions & 0 deletions app/service/player-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';

const angular = require('angular');
const gollumsGame = angular.module('gollumsGame');

gollumsGame.factory('playerService', ['$q', '$log', 'mapService', 'questionsService', playerService]);

function playerService($q, $log, mapService) {
$log.debug('player service');

let service = {};

let turn = 0;
let player = service.player = {
name: 'Bilbo',
location: service.randomStart(),
hp: 3
};

let history = service.history = [
{
turn = 0,
desc: 'Welcome to Gollums Game',
location: player.location,
hp: player.hp
}
];

service.randomStart = function() {
let randomIdx = (Math.ceil(Math.random() * mapService.coordinates.length()));
return mapService.coordinates[randomIdx];
}

service.setRing = function() {
let randomIdx = (Math.ceil(Math.random() * mapService.coordinates.length()));
mapService.coordinates[randomIdx].hasRing = true;
$log.debug('ring was set!');
}

service.movePlayer = function(direction) {
return new $q((resolve, reject) => {
turn++;

let current = player.location;
let newLocation = mapService.mapData[current][direction];

if (!newLocation) {
history.unshift({
turn,
desc: 'you have hit a wall!!',
location: player.location,
hp: player.hp
});
return reject('no room in that direction');
}

history.unshift({
turn,
location: player.location,
desc: mapService.mapData[newLocation].desc,
hp: player.hp
});

player.location = newLocation;
return resolve(player.location);
});
};
service.setRing();
return service;
}
58 changes: 58 additions & 0 deletions app/service/question-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

const angular = require('angular');

const gollumsGame = angular.module('gollumsGame');

gollumsGame.factory('questionService', ['$log', questionService]);

function questionService($log) {
$log.debug('question service');

let service = {};

service.questions = [
{
question: 'What is 2 + 2 precious? (hint use only numeric values)',
answer: '4'
},
{
question: 'What\'s taters precious? (think of sam, answer is plural, no hyphens)',
answer: 'potatoes'
},
{
question: 'Complete this sentence precious: "Stupid, --- hobbitses!"',
answer: 'fat'
},
{
question: 'What does master have, that smeagol wants? (hint: "the --------")',
answer: 'the precious'
},
{
question: 'If smeagol could be anything, what would smeagol be? (hint: "the --------")',
answer: 'the precious'
},
{
question: 'What does smeagol use, to help smeagol feel good about itself? (hint: "the --------")',
answer: 'the precious'
},
{
question: 'Here\'s a riddle precious: "This thing all things devours; Birds, beasts, trees, flowers; Gnaws iron, bites steel; Grinds hard stones to meal; Slays king, ruins town; And beats mountain down." (hint: read "The Hobbit", or google it)',
answer: 'time'
},
{
question: 'Where are we precious? (hint: in the book, which mountain range are Bilbo and Smeagol in? the ----- ---------)',
answer: 'the misty mountains'
},
{
question: 'Can you answer this riddle precious? "Alive without breath, As cold as death;Never thirsty, ever drinking; All in mail never clinking." (hint: read "The Hobbit", or google it)',
answer: 'fish'
},
{
question: 'How did smeagol get the precious, precious? (hint: "for my --------")',
answer: 'for my birthday'
}
];

return service;
}
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "Gollums Game",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are restrictions on the name property. It has to be one word with no spaces and no capital letters. Otherwise npm will throw an error and not load your packages.

"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "./node_modules/webpack/bin/webpack.js",
"watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot",
"lint": "./node_modules/eslint/bin/eslint.js ./*"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"angular": "^1.6.3",
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.0",
"css-loader": "^0.27.3",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.28.0",
"node-sass": "^4.5.1",
"resolve-url-loader": "^2.0.2",
"sass-loader": "^6.0.3",
"style-loader": "^0.16.0",
"url-loader": "^0.5.8",
"webpack": "^2.3.1"
},
"devDependencies": {
"eslint": "^3.18.0",
"webpack-dev-server": "^2.4.2"
}
}
Loading