Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/webpack #2

Merged
merged 7 commits into from Nov 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -70,3 +70,7 @@ Icon?
Thumbs.db
packages
build
dist

# Webpack
src/bundle.js
6 changes: 6 additions & 0 deletions jsconfig.json
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}
26 changes: 25 additions & 1 deletion package.json
Expand Up @@ -2,7 +2,14 @@
"name": "angular-blackjack",
"version": "0.0.1",
"devDependencies": {
"babel": "^6.1.18",
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"css-loader": "^0.23.0",
"del": "^1.1.1",
"file-loader": "^0.8.5",
"gulp": "^3.8.11",
"gulp-concat": "^2.5.0",
"gulp-gh-pages": "^0.5.0",
Expand All @@ -12,6 +19,23 @@
"karma": "^0.12.31",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4",
"main-bower-files": "^2.5.0"
"main-bower-files": "^2.5.0",
"ng-annotate-loader": "0.0.10",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"angular": "^1.4.8",
"angular-hotkeys": "^1.6.0",
"bootstrap": "^3.3.6",
"jquery": "^2.1.4",
"mousetrap": "^1.5.3"
},
"scripts": {
"start": "node_modules/.bin/webpack-dev-server --content-base src",
"build": "NODE_ENV=production node node_modules/.bin/webpack && cp src/index.html dist/index.html"
}
}
59 changes: 3 additions & 56 deletions src/app/card/card.directive.js
@@ -1,14 +1,7 @@
(function () {
'use strict';

angular
.module('blackjack.card')
.directive('blackjackCard', BlackjackCard)
.controller('BlackjackCardController', BlackjackCardController);
import BlackjackCardController from './card';

BlackjackCard.$inject = ['$window'];

BlackjackCardController.$inject = ['$scope'];
/* @ngInject */
function BlackjackCard($window)
{
Expand All @@ -26,58 +19,12 @@
card: '=',
cardIndex: '@'
},
controller: 'BlackjackCardController',
controller: BlackjackCardController,
controllerAs: 'vm',
bindToController: true
};
return directive;

}

/* @ngInject */
function BlackjackCardController($scope){
var vm = this;

vm.rank;
vm.suit;

vm.init = function(){
vm.displayCard();

$scope.$watchCollection('vm.card',function(newC,oldC){
vm.displayCard();
});
};

vm.displayCard = function(){
if(vm.hideValue){
vm.suit = 'back';
vm.rank = '';
}
else {
vm.rank = vm.card.rank;
var cardSuit;
switch (vm.card.suit) {
//'C', 'D', 'S', 'H'
case 'C':
cardSuit = 'suitclubs';
break;
case 'D':
cardSuit = 'suitdiamonds';
break;
case 'H':
cardSuit = 'suithearts';
break;
case 'S':
cardSuit = 'suitspades';
break;
}
vm.suit = cardSuit;
}

vm.cardIndexClass = 'card-index-' + vm.cardIndex;
};

vm.init();
}
})();
export default BlackjackCard;
10 changes: 2 additions & 8 deletions src/app/card/card.hand.directive.js
@@ -1,10 +1,3 @@
(function () {
'use strict';

angular
.module('blackjack.card')
.directive('blackjackHand', BlackjackHand);

/* @ngInject */
function BlackjackHand()
{
Expand All @@ -24,4 +17,5 @@
return directive;

}
})();

export default BlackjackHand;
50 changes: 50 additions & 0 deletions src/app/card/card.js
@@ -0,0 +1,50 @@
BlackjackCardController.$inject = ['$scope'];

/* @ngInject */
function BlackjackCardController($scope){
var vm = this;

vm.rank;
vm.suit;

vm.init = function(){
vm.displayCard();

$scope.$watchCollection('vm.card',function(newC,oldC){
vm.displayCard();
});
};

vm.displayCard = function(){
if(vm.hideValue){
vm.suit = 'back';
vm.rank = '';
}
else {
vm.rank = vm.card.rank;
var cardSuit;
switch (vm.card.suit) {
//'C', 'D', 'S', 'H'
case 'C':
cardSuit = 'suitclubs';
break;
case 'D':
cardSuit = 'suitdiamonds';
break;
case 'H':
cardSuit = 'suithearts';
break;
case 'S':
cardSuit = 'suitspades';
break;
}
vm.suit = cardSuit;
}

vm.cardIndexClass = 'card-index-' + vm.cardIndex;
};

vm.init();
}

export default BlackjackCardController;
6 changes: 0 additions & 6 deletions src/app/card/card.module.js

This file was deleted.

10 changes: 1 addition & 9 deletions src/app/card/card.service.js
@@ -1,11 +1,3 @@
(function () {
'use strict';

angular
.module('blackjack.card')
.factory('CardService', CardService);


function CardService(){
var service = {
newDeck: newDeck,
Expand Down Expand Up @@ -92,4 +84,4 @@

}

})();
export default CardService;
13 changes: 13 additions & 0 deletions src/app/card/index.js
@@ -0,0 +1,13 @@
import angular from 'angular';
import BlackjackCard from './card.directive';
import CardService from './card.service';
import BlackjackHand from './card.hand.directive';

let cardModule = angular.module('blackjack.card', []);

cardModule
.directive('blackjackCard', BlackjackCard)
.factory('CardService', CardService)
.directive('blackjackHand', BlackjackHand);

export default cardModule;
6 changes: 0 additions & 6 deletions src/app/dealer/dealer.module.js

This file was deleted.

12 changes: 1 addition & 11 deletions src/app/dealer/dealer.service.js
@@ -1,10 +1,3 @@
(function () {
'use strict';

angular
.module('blackjack.dealer')
.factory('DealerService', DealerService);

DealerService.$inject =['$timeout','GameService'];

function DealerService($timeout, GameService){
Expand Down Expand Up @@ -119,9 +112,6 @@
return service;

////////////////



}

})();
export default DealerService;
9 changes: 9 additions & 0 deletions src/app/dealer/index.js
@@ -0,0 +1,9 @@
import angular from 'angular';
import DealerService from './dealer.service';

let dealerModule = angular.module('blackjack.dealer', []);

dealerModule
.factory('DealerService', DealerService);

export default dealerModule;
11 changes: 3 additions & 8 deletions src/app/game/game.controller.js
@@ -1,10 +1,3 @@
(function(){
'use strict';

angular
.module('blackjack.game')
.controller('GameController',GameController);

GameController.$inject = ['$timeout','PlayerService', 'CardService', 'GameService', 'DealerService', 'hotkeys'];

function GameController($timeout, PlayerService, CardService, GameService, DealerService, hotkeys){
Expand Down Expand Up @@ -237,4 +230,6 @@

game.init();
}
})();

export default GameController;

20 changes: 9 additions & 11 deletions src/app/game/game.directive.js
@@ -1,16 +1,14 @@
(function(){
'use strict';
import GameController from './game.controller';
import template from './game.directive.html';

angular
.module('blackjack.game')
.directive('blackjackGame', blackjackGame);

function blackjackGame(){
let GameDirective =
function (){
return {
restrict: 'E',
templateUrl: 'app/game/game.directive.html',
controller: 'GameController',
template: template,
controller: GameController,
controllerAs: 'game'
}
}
})();
};

export default GameDirective;
6 changes: 0 additions & 6 deletions src/app/game/game.module.js

This file was deleted.

10 changes: 2 additions & 8 deletions src/app/game/game.service.js
@@ -1,10 +1,3 @@
(function(){
'use strict';

angular
.module('blackjack.game')
.factory('GameService', GameService);

function GameService(){
var service = {
handValue: handValue,
Expand Down Expand Up @@ -63,4 +56,5 @@

return service;
}
})();

export default GameService;
11 changes: 11 additions & 0 deletions src/app/game/index.js
@@ -0,0 +1,11 @@
import angular from 'angular';
import GameDirective from './game.directive';
import GameService from './game.service';

let gameModule = angular.module('blackjack.game', []);

gameModule
.directive('blackjackGame', GameDirective)
.factory('GameService', GameService);

export default gameModule;
9 changes: 9 additions & 0 deletions src/app/player/index.js
@@ -0,0 +1,9 @@
import angular from 'angular';
import PlayerService from './player.service';

let playerModule = angular.module('blackjack.player', []);

playerModule
.factory('PlayerService', PlayerService);

export default playerModule;
7 changes: 0 additions & 7 deletions src/app/player/player.module.js

This file was deleted.