Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

working with global style!

  • Loading branch information...
commit 6ae8fc7098a2ef9b593eb0abd4aca921d7c2f1dc 1 parent 6b41554
@seanhess authored
View
2  Makefile
@@ -1,2 +1,2 @@
all:
- tsc --module amd public/app.ts
+ tsc --out public/main.js public/app.ts
View
42 public/app.js
@@ -1,23 +1,21 @@
-define(["require", "exports", 'controllers/Identify'], function(require, exports, __Identify__) {
- var Identify = __Identify__;
-
- var app = angular.module('uarbg2', [], function ($routeProvider) {
- $routeProvider.when('/game/:gameId', {
- templateUrl: 'partials/game.html',
- controller: "GameCtrl"
- });
- $routeProvider.when('/paid', {
- templateUrl: 'partials/paid.html',
- controller: "PaymentCtrl"
- });
- $routeProvider.when('/identify', {
- templateUrl: 'partials/identify.html',
- controller: Identify.Controller
- });
- $routeProvider.otherwise({
- redirectTo: '/identify'
- });
+console.log("app.ts");
+var app = angular.module('app', [
+ 'controllers'
+], function ($routeProvider) {
+ console.log("In Router");
+ $routeProvider.when('/game/:gameId', {
+ templateUrl: 'partials/game.html',
+ controller: "GameCtrl"
});
- exports.main = app;
-})
-
+ $routeProvider.when('/paid', {
+ templateUrl: 'partials/paid.html',
+ controller: "PaymentCtrl"
+ });
+ $routeProvider.when('/identify', {
+ templateUrl: 'partials/identify.html',
+ controller: "IdentifyCtrl"
+ });
+ $routeProvider.otherwise({
+ redirectTo: '/identify'
+ });
+});
View
23 public/app.ts
@@ -2,22 +2,21 @@
///<reference path="def/angular.d.ts"/>
///<reference path="def/underscore.d.ts"/>
-import Identify = module('controllers/Identify')
+// Require stuff (modules must be first!)
+///<reference path="modules.ts"/>
+///<reference path="controllers/Identify.ts"/>
-var app = angular.module('uarbg2', [], function ($routeProvider: ng.IRouteProviderProvider) {
+// sometimes you're going to want to reference controllers dynamically.
+// so register them
+
+console.log("app.ts")
+
+var app = angular.module('app', ['controllers'], function ($routeProvider: ng.IRouteProviderProvider) {
+ console.log("In Router")
$routeProvider.when('/game/:gameId', {templateUrl: 'partials/game.html', controller: "GameCtrl"})
$routeProvider.when('/paid', {templateUrl: 'partials/paid.html', controller: "PaymentCtrl"})
- $routeProvider.when('/identify', {templateUrl: 'partials/identify.html', controller: Identify.Controller})
+ $routeProvider.when('/identify', {templateUrl: 'partials/identify.html', controller: "IdentifyCtrl"})
$routeProvider.otherwise({redirectTo: '/identify'})
})
-// so app.main would be your thing
-export var main = app
-
-// I want to EXPORT this thing.
-
-// RequireJS = MUST HAVE (but could ignore it, if you go the ANGULAR way)
-// ok, so ignore it
-// you'll be fine
-
View
123 public/controllers/Identify.js
@@ -1,67 +1,60 @@
-define(["require", "exports"], function(require, exports) {
-
- var Controller = (function () {
- function Controller($scope, $location, Players, CurrentPlayer, AppVersion) {
- $scope.intro = "intro";
- setTimeout(function () {
- $scope.$apply(function () {
- $scope.intro = "show";
- });
- }, 1200);
- $scope.version = AppVersion;
- $scope.player = CurrentPlayer.loadPreferences();
- $scope.gameId = $scope.player.gameId || "global";
- var players = Players.connect($scope.gameId);
- $scope.players = players;
- $scope.avatars = [
- 'player2',
- 'player5',
- 'player3',
- 'player1',
- 'player4',
- 'player6'
- ];
- $scope.freeAvatars = [
- 'player1',
- 'player2'
- ];
- $scope.avatarIsFree = function (avatarName) {
- return ($scope.freeAvatars.indexOf(avatarName) != -1);
- };
- $scope.avatarIsAvailable = function (avatarName) {
- return (players.isPaid || $scope.freeAvatars.indexOf(avatarName) != -1);
- };
- $scope.avatarIsLocked = function (avatarName) {
- return ($scope.avatarIsAvailable(avatarName) != true);
- };
- $scope.join = function () {
- if(!$scope.player || !$scope.player.avatar || !$scope.player.name) {
- $scope.error = "Please select a valid name and an avatar";
- return;
- }
- if(Players.playerByName(players.all, $scope.player.name)) {
- $scope.error = '"' + $scope.player.name + '" is already taken';
- return;
- }
- CurrentPlayer.player = $scope.player;
- CurrentPlayer.savePreferences(CurrentPlayer.player, $scope.gameId);
- $location.path("/game/" + $scope.gameId);
- };
- $scope.selectAvatar = function (name) {
- if($scope.avatarIsAvailable(name)) {
- $scope.player = $scope.player || {
- };
- $scope.player.avatar = name;
- } else {
- window.location.href = "https://spb.io/s/osgtq3F3kS";
- }
- };
- $scope.isPlayerAvatar = function (name) {
- return ($scope.player && $scope.player.avatar == name);
+console.log("Register: IdentifyCtrl");
+angular.module('controllers').controller('IdentifyCtrl', function ($scope, $location, Players, CurrentPlayer, AppVersion) {
+ $scope.intro = "intro";
+ setTimeout(function () {
+ $scope.$apply(function () {
+ $scope.intro = "show";
+ });
+ }, 1200);
+ $scope.version = AppVersion;
+ $scope.player = CurrentPlayer.loadPreferences();
+ $scope.gameId = $scope.player.gameId || "global";
+ var players = Players.connect($scope.gameId);
+ $scope.players = players;
+ $scope.avatars = [
+ 'player2',
+ 'player5',
+ 'player3',
+ 'player1',
+ 'player4',
+ 'player6'
+ ];
+ $scope.freeAvatars = [
+ 'player1',
+ 'player2'
+ ];
+ $scope.avatarIsFree = function (avatarName) {
+ return ($scope.freeAvatars.indexOf(avatarName) != -1);
+ };
+ $scope.avatarIsAvailable = function (avatarName) {
+ return (players.isPaid || $scope.freeAvatars.indexOf(avatarName) != -1);
+ };
+ $scope.avatarIsLocked = function (avatarName) {
+ return ($scope.avatarIsAvailable(avatarName) != true);
+ };
+ $scope.join = function () {
+ if(!$scope.player || !$scope.player.avatar || !$scope.player.name) {
+ $scope.error = "Please select a valid name and an avatar";
+ return;
+ }
+ if(Players.playerByName(players.all, $scope.player.name)) {
+ $scope.error = '"' + $scope.player.name + '" is already taken';
+ return;
+ }
+ CurrentPlayer.player = $scope.player;
+ CurrentPlayer.savePreferences(CurrentPlayer.player, $scope.gameId);
+ $location.path("/game/" + $scope.gameId);
+ };
+ $scope.selectAvatar = function (name) {
+ if($scope.avatarIsAvailable(name)) {
+ $scope.player = $scope.player || {
};
+ $scope.player.avatar = name;
+ } else {
+ window.location.href = "https://spb.io/s/osgtq3F3kS";
}
- return Controller;
- })();
- exports.Controller = Controller;
-})
-
+ };
+ $scope.isPlayerAvatar = function (name) {
+ return ($scope.player && $scope.player.avatar == name);
+ };
+});
View
19 public/controllers/Identify.ts
@@ -1,17 +1,18 @@
-///<reference path="../def/jquery.d.ts"/>
///<reference path="../def/angular.d.ts"/>
-import ps = module("../services/Players")
+///<reference path="../services/Players"/>
+///<reference path="../services/CurrentPlayer"/>
-export interface Scope extends ng.IScope {
+console.log("Register: IdentifyCtrl")
+interface IdentifyScope extends ng.IScope {
intro:string;
error:string;
version:any;
player:any;
gameId:string;
- players:ps.IPlayerState;
+ players:IPlayerState;
avatars:string [];
freeAvatars:string [];
@@ -21,11 +22,10 @@ export interface Scope extends ng.IScope {
join(): void;
selectAvatar(name: string): void;
isPlayerAvatar(name:string): bool;
-
}
-export class Controller {
- constructor ($scope: Scope, $location: any, Players:ps.IPlayerService, CurrentPlayer: any, AppVersion: any) {
+angular.module('controllers').controller('IdentifyCtrl', function($scope: IdentifyScope, $location: any, Players:IPlayerService, CurrentPlayer: any, AppVersion: string) {
+
// HACKY way to do the transition
$scope.intro = "intro"
@@ -52,6 +52,7 @@ export class Controller {
$scope.avatarIsFree = function (avatarName) {
return ($scope.freeAvatars.indexOf(avatarName) != -1);
}
+
$scope.avatarIsAvailable = function (avatarName) {
return (players.isPaid || $scope.freeAvatars.indexOf(avatarName) != -1);
}
@@ -94,7 +95,7 @@ export class Controller {
$scope.isPlayerAvatar = function(name) {
return ($scope.player && $scope.player.avatar == name)
}
- }
-}
+
+})
View
1  public/def/angular.d.ts
View
2  public/def/angular.d.ts
@@ -0,0 +1,2 @@
+///<reference path="../jquery.d.ts"/>
+///<reference path="../components/DefinitelyTyped/Definitions/angular-1.0.d.ts"/>
View
1  public/def/jquery.d.ts
View
1  public/def/jquery.d.ts
@@ -0,0 +1 @@
+///<reference path="../components/DefinitelyTyped/Definitions/jquery-1.8.d.ts"/>
View
1  public/def/underscore.d.ts
View
1  public/def/underscore.d.ts
@@ -0,0 +1 @@
+///<reference path="../components/DefinitelyTyped/Definitions/underscore-1.4.d.ts"/>
View
4 public/index.html
@@ -1,5 +1,5 @@
<!doctype html>
-<html lang="en">
+<html lang="en" ng-app="app">
<head>
<meta charset="utf-8">
<title>Underwater Adventure Rocket Bazooka Guys II</title>
@@ -15,7 +15,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
<!-- Application Code -->
- <script data-main="main" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.1/require.min.js"></script>
+ <script src="main.js"></script>
</body>
</html>
View
453 public/main.js
@@ -1,52 +1,405 @@
-require.config({
- // we don't need much config right now, since we HAVE to load angular and jquery globally
- // Typescript is stupid about AMD-loading 3rd party modules with ambient files right now
+console.log("INITIALIZING MODULES");
+angular.module('services', []);
+angular.module('directives', []);
+angular.module('filters', []);
+angular.module('controllers', [
+ 'services',
+ 'filters',
+ 'directives'
+]);
+var firebase;
+(function (firebase) {
+ var FB = (function () {
+ function FB($rootScope) {
+ this.$rootScope = $rootScope;
+ }
+ FB.prototype.game = function (gameId) {
+ var ref = new Firebase("https://seanhess.firebaseio.com/uarbg2/" + gameId);
+ return ref;
+ };
+ FB.prototype.apply = function (f) {
+ var _this = this;
+ return function (ref) {
+ if((_this.$rootScope).$$phase) {
+ return f(ref.val());
+ }
+ _this.$rootScope.$apply(function () {
+ f(ref.val());
+ });
+ }
+ };
+ FB.prototype.update = function (ref, obj) {
+ for(var key in obj) {
+ if(obj[key] === undefined) {
+ delete obj[key];
+ }
+ }
+ ref.set(_.omit(obj, "$$hashKey"));
+ };
+ return FB;
+ })();
+ firebase.FB = FB;
+})(firebase || (firebase = {}));
- //paths: {
- //jquery: '../lib/jquery/jquery-1.8.2.min',
- //underscore: '../lib/underscore/underscore',
- //angular: '../lib/angular/angular',
- //angularResource: '../lib/angular/angular-resource',
- //text: '../lib/require/text'
- //},
- //shim: {
- //'angular' : {'exports' : 'angular'},
- //'angular-resource' : {deps:['angular']},
- //'bootstrap': {deps:['jquery']},
- //'underscore': {exports: '_'}
- //},
- //priority: [
- //"angular"
- //],
- //urlArgs: 'v=1.1'
+angular.module('services').factory('FB', function ($rootScope) {
+ return new firebase.FB($rootScope);
+});
+angular.module('services').factory('AppVersion', function ($rootScope) {
+ return "1.1";
+});
+angular.module('services').factory('Board', function ($rootScope) {
+ var WIDTH = 800;
+ var HEIGHT = 600;
+ var UNIT = 50;
+ var GRID = {
+ x: WIDTH / UNIT,
+ y: HEIGHT / UNIT
+ };
+ var Board = {
+ move: move,
+ getPosition: getPosition,
+ isHit: isHit,
+ randomX: makeRandomN(GRID.x),
+ randomY: makeRandomN(GRID.y),
+ LEFT: "left",
+ RIGHT: "right",
+ UP: "up",
+ DOWN: "down"
+ };
+ return Board;
+ function getPosition(direction) {
+ if(direction === Board.UP) {
+ return {
+ axis: 'y',
+ distance: -1
+ };
+ }
+ if(direction === Board.RIGHT) {
+ return {
+ axis: 'x',
+ distance: 1
+ };
+ }
+ if(direction === Board.DOWN) {
+ return {
+ axis: 'y',
+ distance: 1
+ };
+ }
+ if(direction === Board.LEFT) {
+ return {
+ axis: 'x',
+ distance: -1
+ };
+ } else {
+ console.log("BAD DIRECTION", direction);
+ return null;
+ }
+ }
+ function move(object, position) {
+ var axis = position.axis;
+ var distance = position.distance;
+ var potential = object[axis] + distance;
+ var direction;
+ if(axis == 'x' && distance > 0) {
+ direction = Board.RIGHT;
+ } else {
+ if(axis == 'x' && distance < 0) {
+ direction = Board.LEFT;
+ } else {
+ if(axis == 'y' && distance > 0) {
+ direction = Board.DOWN;
+ } else {
+ if(axis == 'y' && distance < 0) {
+ direction = Board.UP;
+ } else {
+ console.log("BAD MOVE", axis, distance);
+ }
+ }
+ }
+ }
+ if(GRID[axis] <= potential || potential < 0) {
+ return null;
+ }
+ return {
+ axis: axis,
+ location: potential,
+ facing: direction
+ };
+ }
+ function isHit(one, two) {
+ return (one.x == two.x && one.y == two.y);
+ }
+ function makeRandomN(max) {
+ return function () {
+ return Math.floor(Math.random() * max);
+ }
+ }
+});
+angular.module('services').factory('Players', function ($rootScope, FB, Board, AppVersion) {
+ return {
+ isAlive: isAlive,
+ alivePlayers: alivePlayers,
+ playerByName: playerByName,
+ latestVersion: latestVersion,
+ connect: connect,
+ join: join,
+ killPlayer: killPlayer,
+ move: move
+ };
+ function connect(gameId) {
+ var gameRef = FB.game(gameId);
+ var playersRef = gameRef.child('players');
+ var state = {
+ myname: null,
+ gameRef: gameRef,
+ playersRef: playersRef,
+ current: null,
+ winner: null,
+ taunt: null,
+ isPaid: isPaid(),
+ all: []
+ };
+ playersRef.on('child_added', FB.apply(function (p) {
+ return onJoin(state, p);
+ }));
+ playersRef.on('child_changed', FB.apply(function (p) {
+ return onUpdate(state, p);
+ }));
+ playersRef.on('child_removed', FB.apply(function (p) {
+ return onQuit(state, p);
+ }));
+ return state;
+ }
+ function isAlive(p) {
+ return (p.state == STATE.ALIVE);
+ }
+ function alivePlayers(players) {
+ return players.filter(isAlive);
+ }
+ function join(state, player) {
+ state.myname = player.name;
+ player.x = Board.randomX();
+ player.y = Board.randomY();
+ player.sprite = '1';
+ player.facing = "down";
+ player.state = STATE.ALIVE;
+ player.wins = player.wins || 0;
+ player.losses = player.losses || 0;
+ player.message = null;
+ player.version = AppVersion.num;
+ var ref = state.playersRef.child(player.name);
+ ref.removeOnDisconnect();
+ FB.update(ref, player);
+ }
+ function onJoin(state, player) {
+ if(!state.current && player.name == state.myname) {
+ state.current = player;
+ }
+ state.all.push(player);
+ }
+ function onUpdate(state, remotePlayer) {
+ var player = playerByName(state.all, remotePlayer.name);
+ if(!player) {
+ return console.log("Error, player not found: " + remotePlayer.name);
+ }
+ player.x = remotePlayer.x;
+ player.y = remotePlayer.y;
+ player.facing = remotePlayer.facing;
+ player.state = remotePlayer.state;
+ player.wins = remotePlayer.wins;
+ player.losses = remotePlayer.losses;
+ if(remotePlayer.killer) {
+ player.killer = remotePlayer.killer;
+ }
+ if(player.state == STATE.DEAD) {
+ $rootScope.$broadcast("kill", player);
+ checkWin(state);
+ }
+ }
+ function onQuit(state, player) {
+ state.all = state.all.filter(function (p) {
+ return p.name != player.name;
+ });
+ }
+ function checkWin(state) {
+ var alive = alivePlayers(state.all);
+ if(alive.length > 1) {
+ return;
+ }
+ var winner = alive[0];
+ if(state.current == null || winner != state.current) {
+ return;
+ }
+ winner.wins += 1;
+ state.playersRef.child(winner.name).child("wins").set(winner.wins);
+ state.gameRef.child("winner").removeOnDisconnect();
+ FB.update(state.gameRef.child("winner"), winner);
+ }
+ function onWinner(state, player) {
+ if(!player) {
+ state.winner = null;
+ state.taunt = null;
+ return;
+ }
+ if(state.winner && state.winner.name == player.name) {
+ return;
+ }
+ state.winner = player;
+ state.taunt = TAUNT_LIST[Math.floor(Math.random() * TAUNT_LIST.length)];
+ if(state.current && state.current.name == player.name) {
+ setTimeout(function () {
+ return resetGame(state);
+ }, 3000);
+ }
+ }
+ function resetGame(state) {
+ console.log("Initialize Game");
+ state.gameRef.child('winner').remove();
+ state.all.forEach(function (player) {
+ player.x = Board.randomX();
+ player.y = Board.randomY();
+ player.sprite = '1';
+ player.facing = "down";
+ player.state = STATE.ALIVE;
+ FB.update(state.playersRef.child(player.name), player);
+ });
+ }
+ function killPlayer(state, player, killerName) {
+ player.state = STATE.DEAD;
+ player.losses += 1;
+ player.killer = killerName;
+ FB.update(state.playersRef.child(player.name), player);
+ }
+ function move(state, player) {
+ var playerRef = state.playersRef.child(player.name);
+ FB.update(playerRef, player);
+ }
+ function playerByName(players, name) {
+ return players.filter(function (p) {
+ return (p.name == name);
+ })[0];
+ }
+ function latestVersion(players) {
+ return _.max(players, function (player) {
+ return player.version;
+ });
+ }
+ function isPaid() {
+ return (localStorage.getItem("payment_status") == "paid");
+ }
+});
+var TAUNT_LIST = [
+ "Oooh yeah!",
+ "I fart in your general direction.",
+ "Your mother was a hamster and your father smelt of elderberries.",
+ "All your base are belong to us!",
+ "OK, next round, try it WITH your glasses on.",
+ "If your daddy's aim is as bad as yours, I'm surprised you're here at all!",
+ "Boom!"
+];
+var STATE = {
+ DEAD: "dead",
+ ALIVE: "alive"
+};
+angular.module('services').factory('CurrentPlayer', function () {
+ var storage = localStorage;
+ function loadPreferences() {
+ return {
+ avatar: storage.avatar,
+ name: storage.name,
+ gameId: storage.gameId
+ };
+ }
+ function savePreferences(player, gameId) {
+ storage.avatar = player.avatar;
+ storage.name = player.name;
+ storage.gameId = gameId;
+ }
+ return {
+ player: null,
+ loadPreferences: loadPreferences,
+ savePreferences: savePreferences
+ };
+});
+console.log("Register: IdentifyCtrl");
+angular.module('controllers').controller('IdentifyCtrl', function ($scope, $location, Players, CurrentPlayer, AppVersion) {
+ $scope.intro = "intro";
+ setTimeout(function () {
+ $scope.$apply(function () {
+ $scope.intro = "show";
+ });
+ }, 1200);
+ $scope.version = AppVersion;
+ $scope.player = CurrentPlayer.loadPreferences();
+ $scope.gameId = $scope.player.gameId || "global";
+ var players = Players.connect($scope.gameId);
+ $scope.players = players;
+ $scope.avatars = [
+ 'player2',
+ 'player5',
+ 'player3',
+ 'player1',
+ 'player4',
+ 'player6'
+ ];
+ $scope.freeAvatars = [
+ 'player1',
+ 'player2'
+ ];
+ $scope.avatarIsFree = function (avatarName) {
+ return ($scope.freeAvatars.indexOf(avatarName) != -1);
+ };
+ $scope.avatarIsAvailable = function (avatarName) {
+ return (players.isPaid || $scope.freeAvatars.indexOf(avatarName) != -1);
+ };
+ $scope.avatarIsLocked = function (avatarName) {
+ return ($scope.avatarIsAvailable(avatarName) != true);
+ };
+ $scope.join = function () {
+ if(!$scope.player || !$scope.player.avatar || !$scope.player.name) {
+ $scope.error = "Please select a valid name and an avatar";
+ return;
+ }
+ if(Players.playerByName(players.all, $scope.player.name)) {
+ $scope.error = '"' + $scope.player.name + '" is already taken';
+ return;
+ }
+ CurrentPlayer.player = $scope.player;
+ CurrentPlayer.savePreferences(CurrentPlayer.player, $scope.gameId);
+ $location.path("/game/" + $scope.gameId);
+ };
+ $scope.selectAvatar = function (name) {
+ if($scope.avatarIsAvailable(name)) {
+ $scope.player = $scope.player || {
+ };
+ $scope.player.avatar = name;
+ } else {
+ window.location.href = "https://spb.io/s/osgtq3F3kS";
+ }
+ };
+ $scope.isPlayerAvatar = function (name) {
+ return ($scope.player && $scope.player.avatar == name);
+ };
+});
+console.log("app.ts");
+var app = angular.module('app', [
+ 'controllers'
+], function ($routeProvider) {
+ console.log("In Router");
+ $routeProvider.when('/game/:gameId', {
+ templateUrl: 'partials/game.html',
+ controller: "GameCtrl"
+ });
+ $routeProvider.when('/paid', {
+ templateUrl: 'partials/paid.html',
+ controller: "PaymentCtrl"
+ });
+ $routeProvider.when('/identify', {
+ templateUrl: 'partials/identify.html',
+ controller: "IdentifyCtrl"
+ });
+ $routeProvider.otherwise({
+ redirectTo: '/identify'
+ });
});
-
-// put EVERYTHING you want loaded in here
-// since we're using Angular, the TS modules won't load each other automatically
-require([
- 'app',
- 'controllers/Identify',
- 'controllers/GameCtrl',
- 'controllers/PaymentCtrl',
- 'services/Board',
- 'services/Players',
- 'services/Missiles',
- 'services/FB',
- 'services/CurrentPlayer',
- 'services/SoundEffects',
- 'services/AppVersion',
- 'directives/keys',
- 'directives/sprite',
- 'filters/position'
-], function(app) {
-
- //This function will be called when all the dependencies
- //listed above are loaded. Note that this function could
- //be called before the page is loaded.
- //This callback is optional.
-
- angular.element(document).ready(function () {
- angular.bootstrap(document, ['uarbg2'])
- })
-
-})
View
9 public/modules.js
@@ -0,0 +1,9 @@
+console.log("INITIALIZING MODULES");
+angular.module('services', []);
+angular.module('directives', []);
+angular.module('filters', []);
+angular.module('controllers', [
+ 'services',
+ 'filters',
+ 'directives'
+]);
View
6 public/modules.ts
@@ -0,0 +1,6 @@
+console.log("INITIALIZING MODULES")
+// Initialize Angular Modules
+angular.module('services',[])
+angular.module('directives',[])
+angular.module('filters',[])
+angular.module('controllers',['services', 'filters', 'directives'])
View
13 public/services/AppVersion.js
@@ -1,10 +1,3 @@
-define(["require", "exports", "../app"], function(require, exports, __app__) {
- var app = __app__;
-
- app.main.factory('AppVersion', function ($rootScope) {
- return {
- num: "1.1"
- };
- });
-})
-
+angular.module('services').factory('AppVersion', function ($rootScope) {
+ return "1.1";
+});
View
10 public/services/AppVersion.ts
@@ -1,9 +1,5 @@
-import app = module("../app")
+///<reference path="../def/angular.d.ts"/>
-export interface IAppVersion {
- num: string;
-}
-
-app.main.factory('AppVersion', function($rootScope) {
- return {num: "1.1"}
+angular.module('services').factory('AppVersion', function($rootScope) {
+ return "1.1"
})
View
166 public/services/Board.js
@@ -1,97 +1,89 @@
-define(["require", "exports", "../app"], function(require, exports, __app__) {
- var app = __app__;
-
- var MAP;
- (function (MAP) {
- MAP.width = 800;
- MAP.height = 600;
- MAP.unit = 50;
- MAP.grid = {
- x: MAP.width / MAP.unit,
- y: MAP.width / MAP.unit
- };
- })(MAP || (MAP = {}));
-
- exports.LEFT = "left";
- exports.RIGHT = "right";
- exports.UP = "up";
- exports.DOWN = "down";
- app.main.factory('Board', function ($rootScope) {
- return {
- move: move,
- getPosition: getPosition,
- isHit: isHit,
- randomX: makeRandomN(MAP.grid.x),
- randomY: makeRandomN(MAP.grid.y)
- };
- function getPosition(direction) {
- if(direction === exports.UP) {
- return {
- axis: 'y',
- distance: -1
- };
- }
- if(direction === exports.RIGHT) {
- return {
- axis: 'x',
- distance: 1
- };
- }
- if(direction === exports.DOWN) {
- return {
- axis: 'y',
- distance: 1
- };
- }
- if(direction === exports.LEFT) {
- return {
- axis: 'x',
- distance: -1
- };
- } else {
- console.log("BAD DIRECTION", direction);
- return null;
- }
+angular.module('services').factory('Board', function ($rootScope) {
+ var WIDTH = 800;
+ var HEIGHT = 600;
+ var UNIT = 50;
+ var GRID = {
+ x: WIDTH / UNIT,
+ y: HEIGHT / UNIT
+ };
+ var Board = {
+ move: move,
+ getPosition: getPosition,
+ isHit: isHit,
+ randomX: makeRandomN(GRID.x),
+ randomY: makeRandomN(GRID.y),
+ LEFT: "left",
+ RIGHT: "right",
+ UP: "up",
+ DOWN: "down"
+ };
+ return Board;
+ function getPosition(direction) {
+ if(direction === Board.UP) {
+ return {
+ axis: 'y',
+ distance: -1
+ };
+ }
+ if(direction === Board.RIGHT) {
+ return {
+ axis: 'x',
+ distance: 1
+ };
}
- function move(object, position) {
- var axis = position.axis;
- var distance = position.distance;
- var potential = object[axis] + distance;
- var direction;
- if(axis == 'x' && distance > 0) {
- direction = exports.RIGHT;
+ if(direction === Board.DOWN) {
+ return {
+ axis: 'y',
+ distance: 1
+ };
+ }
+ if(direction === Board.LEFT) {
+ return {
+ axis: 'x',
+ distance: -1
+ };
+ } else {
+ console.log("BAD DIRECTION", direction);
+ return null;
+ }
+ }
+ function move(object, position) {
+ var axis = position.axis;
+ var distance = position.distance;
+ var potential = object[axis] + distance;
+ var direction;
+ if(axis == 'x' && distance > 0) {
+ direction = Board.RIGHT;
+ } else {
+ if(axis == 'x' && distance < 0) {
+ direction = Board.LEFT;
} else {
- if(axis == 'x' && distance < 0) {
- direction = exports.LEFT;
+ if(axis == 'y' && distance > 0) {
+ direction = Board.DOWN;
} else {
- if(axis == 'y' && distance > 0) {
- direction = exports.DOWN;
+ if(axis == 'y' && distance < 0) {
+ direction = Board.UP;
} else {
- if(axis == 'y' && distance < 0) {
- direction = exports.UP;
- } else {
- console.log("BAD MOVE", axis, distance);
- }
+ console.log("BAD MOVE", axis, distance);
}
}
}
- if(MAP.grid[axis] <= potential || potential < 0) {
- return null;
- }
- return {
- axis: axis,
- location: potential,
- facing: direction
- };
}
- function isHit(one, two) {
- return (one.x == two.x && one.y == two.y);
+ if(GRID[axis] <= potential || potential < 0) {
+ return null;
}
- function makeRandomN(max) {
- return function () {
- return Math.floor(Math.random() * max);
- }
+ return {
+ axis: axis,
+ location: potential,
+ facing: direction
+ };
+ }
+ function isHit(one, two) {
+ return (one.x == two.x && one.y == two.y);
+ }
+ function makeRandomN(max) {
+ return function () {
+ return Math.floor(Math.random() * max);
}
- });
-})
-
+ }
+});
View
78 public/services/Board.ts
@@ -1,75 +1,77 @@
-// I could just use reference
+///<reference path="../def/angular.d.ts"/>
-
-import app = module("../app")
-
-module MAP {
- export var width = 800
- export var height = 600
- export var unit = 50
-
- export var grid = {
- x:width / unit,
- y:width / unit,
- }
-}
-
-// Directions
-export var LEFT = "left"
-export var RIGHT = "right"
-export var UP = "up"
-export var DOWN = "down"
-
-export interface IPosition {
+interface IPosition {
axis:string;
distance:number;
}
-export interface IPoint {
+interface IPoint {
x:number;
y:number;
}
-export interface IBoard {
+interface IBoard {
getPosition(direction:string):IPosition;
move(object:IPoint, position:IPosition);
isHit(one:IPoint, two:IPoint):bool;
randomX():number;
randomY():number;
+
+ // constants
+ LEFT: string;
+ RIGHT: string;
+ UP: string;
+ DOWN: string;
}
// these are the worst variable names of all time
-export interface IMove {
+interface IMove {
axis: string;
location: number;
facing: string;
}
-app.main.factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
+angular.module('services').factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
- return {
+ var WIDTH = 800
+ var HEIGHT = 600
+ var UNIT = 50
+ var GRID = {
+ x: WIDTH / UNIT,
+ y: HEIGHT / UNIT,
+ }
+
+ var Board = {
move: move,
getPosition: getPosition,
isHit: isHit,
- randomX: makeRandomN(MAP.grid.x),
- randomY: makeRandomN(MAP.grid.y),
+ randomX: makeRandomN(GRID.x),
+ randomY: makeRandomN(GRID.y),
+
+ // Direction Constants
+ LEFT: "left",
+ RIGHT: "right",
+ UP: "up",
+ DOWN: "down",
}
+ return Board
+
function getPosition(direction:string):IPosition {
- if(direction === UP) {
+ if(direction === Board.UP) {
return {axis: 'y', distance: -1}
}
- if(direction === RIGHT) {
+ if(direction === Board.RIGHT) {
return {axis: 'x', distance: 1}
}
- if(direction === DOWN) {
+ if(direction === Board.DOWN) {
return {axis: 'y', distance: 1}
}
- if(direction === LEFT) {
+ if(direction === Board.LEFT) {
return {axis: 'x', distance: -1}
}
@@ -84,13 +86,13 @@ app.main.factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
var distance = position.distance
var potential = object[axis] + distance;
var direction;
- if (axis == 'x' && distance > 0) direction = RIGHT
- else if (axis == 'x' && distance < 0) direction = LEFT
- else if (axis == 'y' && distance > 0) direction = DOWN
- else if (axis == 'y' && distance < 0) direction = UP
+ if (axis == 'x' && distance > 0) direction = Board.RIGHT
+ else if (axis == 'x' && distance < 0) direction = Board.LEFT
+ else if (axis == 'y' && distance > 0) direction = Board.DOWN
+ else if (axis == 'y' && distance < 0) direction = Board.UP
else console.log("BAD MOVE", axis, distance)
- if (MAP.grid[axis] <= potential || potential < 0) {
+ if (GRID[axis] <= potential || potential < 0) {
return null
}
View
51 public/services/CurrentPlayer.js
@@ -1,31 +1,20 @@
-define(function(require) {
- var app = require('app')
- app.main
-
-.factory('CurrentPlayer', function() {
- // lets you share the current player
-
- function loadPreferences() {
- return {
- avatar: localStorage.avatar,
- name: localStorage.name,
- gameId: localStorage.gameId
- }
- }
-
- function savePreferences(player, gameId) {
- localStorage.avatar = player.avatar
- localStorage.name = player.name
- localStorage.gameId = gameId
- }
-
-
- return {
- player: null,
- loadPreferences: loadPreferences,
- savePreferences: savePreferences
- }
-})
-
-
-})
+angular.module('services').factory('CurrentPlayer', function () {
+ var storage = localStorage;
+ function loadPreferences() {
+ return {
+ avatar: storage.avatar,
+ name: storage.name,
+ gameId: storage.gameId
+ };
+ }
+ function savePreferences(player, gameId) {
+ storage.avatar = player.avatar;
+ storage.name = player.name;
+ storage.gameId = gameId;
+ }
+ return {
+ player: null,
+ loadPreferences: loadPreferences,
+ savePreferences: savePreferences
+ };
+});
View
35 public/services/CurrentPlayer.ts
@@ -0,0 +1,35 @@
+///<reference path="../def/angular.d.ts"/>
+
+interface IPreferencesStorage extends Storage {
+ avatar:string;
+ name:string;
+ gameId:string;
+}
+
+
+angular.module('services').factory('CurrentPlayer', function() {
+ // lets you share the current player
+
+ var storage:IPreferencesStorage = <IPreferencesStorage> localStorage;
+
+ function loadPreferences() {
+ return {
+ avatar: storage.avatar,
+ name: storage.name,
+ gameId: storage.gameId
+ }
+ }
+
+ function savePreferences(player, gameId) {
+ storage.avatar = player.avatar
+ storage.name = player.name
+ storage.gameId = gameId
+ }
+
+
+ return {
+ player: null,
+ loadPreferences: loadPreferences,
+ savePreferences: savePreferences
+ }
+})
View
15 public/services/FB.js
@@ -1,6 +1,5 @@
-define(["require", "exports", '../app'], function(require, exports, __app__) {
- var app = __app__;
-
+var firebase;
+(function (firebase) {
var FB = (function () {
function FB($rootScope) {
this.$rootScope = $rootScope;
@@ -30,9 +29,9 @@ define(["require", "exports", '../app'], function(require, exports, __app__) {
};
return FB;
})();
- exports.FB = FB;
- app.main.factory('FB', function ($rootScope) {
- return new FB($rootScope);
- });
-})
+ firebase.FB = FB;
+})(firebase || (firebase = {}));
+angular.module('services').factory('FB', function ($rootScope) {
+ return new firebase.FB($rootScope);
+});
View
101 public/services/FB.ts
@@ -1,65 +1,76 @@
-import app = module('../app')
+///<reference path="../def/angular.d.ts"/>
+///<reference path="../def/underscore.d.ts"/>
+// TODO switch to firebase.d.ts
declare var Firebase;
-export interface IRef {
- child(name:string);
- val();
- on(event:string, cb:IRefCB);
- set(val:any);
- removeOnDisconnect();
-}
+module firebase {
-export interface IRefCB {
- (ref:IRef);
-}
+ export interface IRef {
+ child(name:string);
+ val();
+ on(event:string, cb:IRefCB);
+ set(val:any);
+ removeOnDisconnect();
+ }
-export interface IValueCB {
- (val:any);
-}
+ export interface IRefCB {
+ (ref:IRef);
+ }
-export interface IFB {
- (gameId:string):IRef;
- apply(cb:IValueCB):IRefCB;
- update(ref:IRef, obj:any);
-}
+ export interface IValueCB {
+ (val:any);
+ }
+ export interface IFB {
+ game(gameId:string):IRef;
+ apply(cb:IValueCB):IRefCB;
+ update(ref:IRef, obj:any);
+ }
-// Functional Style Class: it's the same as the module that you were looking for!
-// wait, this sucks. To call other functions in the module, you have to use this
-// oh, it's not that bad
-export class FB {
+ // Functional Style Class: it's the same as the module that you were looking for!
+ // wait, this sucks. To call other functions in the module, you have to use this
+ // oh, it's not that bad
- constructor(
- private $rootScope:ng.IRootScopeService
- ) { }
+ // KEEP AROUND: as an example of the class function method
+ // plus: you can define all the typing inline
+ // minus: you have to use "this" for all dependencies
+ // minus: can lose this pointer
+ // minus: you should be using an interface type, so you have to define the interface twice anyway
- game(gameId:string):IRef {
- var ref = new Firebase("https://seanhess.firebaseio.com/uarbg2/" + gameId)
- return ref
- }
+ export class FB {
+
+ constructor(
+ private $rootScope:ng.IRootScopeService
+ ) { }
- apply(f:IValueCB):IRefCB {
- return (ref:IRef) => {
- if ((<any>this.$rootScope).$$phase)
- return f(ref.val())
- this.$rootScope.$apply(function() {
- f(ref.val())
- })
+ game(gameId:string):IRef {
+ var ref = new Firebase("https://seanhess.firebaseio.com/uarbg2/" + gameId)
+ return ref
}
- }
- update(ref:IRef, obj:any) {
- for (var key in obj) {
- if (obj[key] === undefined)
- delete obj[key]
+ apply(f:IValueCB):IRefCB {
+ return (ref:IRef) => {
+ if ((<any>this.$rootScope).$$phase)
+ return f(ref.val())
+ this.$rootScope.$apply(function() {
+ f(ref.val())
+ })
+ }
}
- ref.set(_.omit(obj, "$$hashKey"))
+ update(ref:IRef, obj:any) {
+ for (var key in obj) {
+ if (obj[key] === undefined)
+ delete obj[key]
+ }
+
+ ref.set(_.omit(obj, "$$hashKey"))
+ }
}
}
-app.main.factory('FB', function($rootScope) {
- return new FB($rootScope)
+angular.module('services').factory('FB', function($rootScope) {
+ return new firebase.FB($rootScope)
})
View
8 public/services/Missiles.js
@@ -1,10 +1,6 @@
-define(function(require) {
- var app = require('app')
- app.main
-
// This service keeps track of the missiles
-.factory('Missiles', function($rootScope, FB, Board) {
+angular.module('services').factory('Missiles', function($rootScope, FB, Board) {
return function(gameId, Players) {
var gameRef = FB.game(gameId)
@@ -103,5 +99,3 @@ define(function(require) {
}
})
-
-})
View
318 public/services/Players.js
@@ -1,174 +1,166 @@
-define(["require", "exports", "../app"], function(require, exports, __app__) {
- var app = __app__;
-
-
-
-
- app.main.factory('Players', function ($rootScope, FB, Board, AppVersion) {
- return {
- isAlive: isAlive,
- alivePlayers: alivePlayers,
- playerByName: playerByName,
- latestVersion: latestVersion,
- connect: connect,
- join: join,
- killPlayer: killPlayer,
- move: move
+angular.module('services').factory('Players', function ($rootScope, FB, Board, AppVersion) {
+ return {
+ isAlive: isAlive,
+ alivePlayers: alivePlayers,
+ playerByName: playerByName,
+ latestVersion: latestVersion,
+ connect: connect,
+ join: join,
+ killPlayer: killPlayer,
+ move: move
+ };
+ function connect(gameId) {
+ var gameRef = FB.game(gameId);
+ var playersRef = gameRef.child('players');
+ var state = {
+ myname: null,
+ gameRef: gameRef,
+ playersRef: playersRef,
+ current: null,
+ winner: null,
+ taunt: null,
+ isPaid: isPaid(),
+ all: []
};
- function connect(gameId) {
- var gameRef = FB.game(gameId);
- var playersRef = gameRef.child('players');
- var state = {
- myname: null,
- gameRef: gameRef,
- playersRef: playersRef,
- current: null,
- winner: null,
- taunt: null,
- isPaid: isPaid(),
- all: []
- };
- playersRef.on('child_added', FB.apply(function (p) {
- return onJoin(state, p);
- }));
- playersRef.on('child_changed', FB.apply(function (p) {
- return onUpdate(state, p);
- }));
- playersRef.on('child_removed', FB.apply(function (p) {
- return onQuit(state, p);
- }));
- return state;
+ playersRef.on('child_added', FB.apply(function (p) {
+ return onJoin(state, p);
+ }));
+ playersRef.on('child_changed', FB.apply(function (p) {
+ return onUpdate(state, p);
+ }));
+ playersRef.on('child_removed', FB.apply(function (p) {
+ return onQuit(state, p);
+ }));
+ return state;
+ }
+ function isAlive(p) {
+ return (p.state == STATE.ALIVE);
+ }
+ function alivePlayers(players) {
+ return players.filter(isAlive);
+ }
+ function join(state, player) {
+ state.myname = player.name;
+ player.x = Board.randomX();
+ player.y = Board.randomY();
+ player.sprite = '1';
+ player.facing = "down";
+ player.state = STATE.ALIVE;
+ player.wins = player.wins || 0;
+ player.losses = player.losses || 0;
+ player.message = null;
+ player.version = AppVersion.num;
+ var ref = state.playersRef.child(player.name);
+ ref.removeOnDisconnect();
+ FB.update(ref, player);
+ }
+ function onJoin(state, player) {
+ if(!state.current && player.name == state.myname) {
+ state.current = player;
}
- function isAlive(p) {
- return (p.state == STATE.ALIVE);
+ state.all.push(player);
+ }
+ function onUpdate(state, remotePlayer) {
+ var player = playerByName(state.all, remotePlayer.name);
+ if(!player) {
+ return console.log("Error, player not found: " + remotePlayer.name);
}
- function alivePlayers(players) {
- return players.filter(isAlive);
+ player.x = remotePlayer.x;
+ player.y = remotePlayer.y;
+ player.facing = remotePlayer.facing;
+ player.state = remotePlayer.state;
+ player.wins = remotePlayer.wins;
+ player.losses = remotePlayer.losses;
+ if(remotePlayer.killer) {
+ player.killer = remotePlayer.killer;
}
- function join(state, player) {
- state.myname = player.name;
- player.x = Board.randomX();
- player.y = Board.randomY();
- player.sprite = '1';
- player.facing = "down";
- player.state = STATE.ALIVE;
- player.wins = player.wins || 0;
- player.losses = player.losses || 0;
- player.message = null;
- player.version = AppVersion.num;
- var ref = state.playersRef.child(player.name);
- ref.removeOnDisconnect();
- FB.update(ref, player);
- }
- function onJoin(state, player) {
- if(!state.current && player.name == state.myname) {
- state.current = player;
- }
- state.all.push(player);
+ if(player.state == STATE.DEAD) {
+ $rootScope.$broadcast("kill", player);
+ checkWin(state);
}
- function onUpdate(state, remotePlayer) {
- var player = playerByName(state.all, remotePlayer.name);
- if(!player) {
- return console.log("Error, player not found: " + remotePlayer.name);
- }
- player.x = remotePlayer.x;
- player.y = remotePlayer.y;
- player.facing = remotePlayer.facing;
- player.state = remotePlayer.state;
- player.wins = remotePlayer.wins;
- player.losses = remotePlayer.losses;
- if(remotePlayer.killer) {
- player.killer = remotePlayer.killer;
- }
- if(player.state == STATE.DEAD) {
- $rootScope.$broadcast("kill", player);
- checkWin(state);
- }
+ }
+ function onQuit(state, player) {
+ state.all = state.all.filter(function (p) {
+ return p.name != player.name;
+ });
+ }
+ function checkWin(state) {
+ var alive = alivePlayers(state.all);
+ if(alive.length > 1) {
+ return;
}
- function onQuit(state, player) {
- state.all = state.all.filter(function (p) {
- return p.name != player.name;
- });
+ var winner = alive[0];
+ if(state.current == null || winner != state.current) {
+ return;
}
- function checkWin(state) {
- var alive = alivePlayers(state.all);
- if(alive.length > 1) {
- return;
- }
- var winner = alive[0];
- if(state.current == null || winner != state.current) {
- return;
- }
- winner.wins += 1;
- state.playersRef.child(winner.name).child("wins").set(winner.wins);
- state.gameRef.child("winner").removeOnDisconnect();
- FB.update(state.gameRef.child("winner"), winner);
+ winner.wins += 1;
+ state.playersRef.child(winner.name).child("wins").set(winner.wins);
+ state.gameRef.child("winner").removeOnDisconnect();
+ FB.update(state.gameRef.child("winner"), winner);
+ }
+ function onWinner(state, player) {
+ if(!player) {
+ state.winner = null;
+ state.taunt = null;
+ return;
}
- function onWinner(state, player) {
- if(!player) {
- state.winner = null;
- state.taunt = null;
- return;
- }
- if(state.winner && state.winner.name == player.name) {
- return;
- }
- state.winner = player;
- state.taunt = TAUNT_LIST[Math.floor(Math.random() * TAUNT_LIST.length)];
- if(state.current && state.current.name == player.name) {
- setTimeout(function () {
- return resetGame(state);
- }, 3000);
- }
+ if(state.winner && state.winner.name == player.name) {
+ return;
}
- function resetGame(state) {
- console.log("Initialize Game");
- state.gameRef.child('winner').remove();
- state.all.forEach(function (player) {
- player.x = Board.randomX();
- player.y = Board.randomY();
- player.sprite = '1';
- player.facing = "down";
- player.state = STATE.ALIVE;
- FB.update(state.playersRef.child(player.name), player);
- });
+ state.winner = player;
+ state.taunt = TAUNT_LIST[Math.floor(Math.random() * TAUNT_LIST.length)];
+ if(state.current && state.current.name == player.name) {
+ setTimeout(function () {
+ return resetGame(state);
+ }, 3000);
}
- function killPlayer(state, player, killerName) {
- player.state = STATE.DEAD;
- player.losses += 1;
- player.killer = killerName;
+ }
+ function resetGame(state) {
+ console.log("Initialize Game");
+ state.gameRef.child('winner').remove();
+ state.all.forEach(function (player) {
+ player.x = Board.randomX();
+ player.y = Board.randomY();
+ player.sprite = '1';
+ player.facing = "down";
+ player.state = STATE.ALIVE;
FB.update(state.playersRef.child(player.name), player);
- }
- function move(state, player) {
- var playerRef = state.playersRef.child(player.name);
- FB.update(playerRef, player);
- }
- function playerByName(players, name) {
- return players.filter(function (p) {
- return (p.name == name);
- })[0];
- }
- function latestVersion(players) {
- return _.max(players, function (player) {
- return player.version;
- });
- }
- function isPaid() {
- return (localStorage.getItem("payment_status") == "paid");
- }
- });
- var TAUNT_LIST = [
- "Oooh yeah!",
- "I fart in your general direction.",
- "Your mother was a hamster and your father smelt of elderberries.",
- "All your base are belong to us!",
- "OK, next round, try it WITH your glasses on.",
- "If your daddy's aim is as bad as yours, I'm surprised you're here at all!",
- "Boom!"
- ];
- var STATE = {
- DEAD: "dead",
- ALIVE: "alive"
- };
-})
-
+ });
+ }
+ function killPlayer(state, player, killerName) {
+ player.state = STATE.DEAD;
+ player.losses += 1;
+ player.killer = killerName;
+ FB.update(state.playersRef.child(player.name), player);
+ }
+ function move(state, player) {
+ var playerRef = state.playersRef.child(player.name);
+ FB.update(playerRef, player);
+ }
+ function playerByName(players, name) {
+ return players.filter(function (p) {
+ return (p.name == name);
+ })[0];
+ }
+ function latestVersion(players) {
+ return _.max(players, function (player) {
+ return player.version;
+ });
+ }
+ function isPaid() {
+ return (localStorage.getItem("payment_status") == "paid");
+ }
+});
+var TAUNT_LIST = [
+ "Oooh yeah!",
+ "I fart in your general direction.",
+ "Your mother was a hamster and your father smelt of elderberries.",
+ "All your base are belong to us!",
+ "OK, next round, try it WITH your glasses on.",
+ "If your daddy's aim is as bad as yours, I'm surprised you're here at all!",
+ "Boom!"
+];
+var STATE = {
+ DEAD: "dead",
+ ALIVE: "alive"
+};
View
27 public/services/Players.ts
@@ -1,20 +1,13 @@
-// I have a freaking circular reference. LAME!
-// There's no reason to, I guess
-// Except that I have no way to bind it otherwise :)
-
-// So, pretty much all I'm doing is exporting interfaces
-// and using them. Everything else is the same
-
// And I like passing the state around instead of making it internal
// but keep it minimal (use state.all instead of state)
-import app = module("../app")
-import fb = module("./FB")
-import av = module("./AppVersion")
-import b = module("./Board")
+///<reference path="../def/angular.d.ts"/>
+///<reference path="./FB"/>
+///<reference path="./AppVersion"/>
+///<reference path="./Board"/>
-export interface IPlayer {
+interface IPlayer {
x:number;
y:number;
sprite:string;
@@ -29,7 +22,7 @@ export interface IPlayer {
}
// only variables
-export interface IPlayerState {
+interface IPlayerState {
current: IPlayer;
winner: IPlayer;
taunt: string;
@@ -38,12 +31,12 @@ export interface IPlayerState {
// private stuff. not for binding
myname:string;
- gameRef:fb.IRef;
- playersRef:fb.IRef;
+ gameRef:firebase.IRef;
+ playersRef:firebase.IRef;
}
// only methods
-export interface IPlayerService {
+interface IPlayerService {
isAlive(p:IPlayer):bool;
alivePlayers(players:IPlayer[]):IPlayer[];
@@ -56,7 +49,7 @@ export interface IPlayerService {
move(state:IPlayerState, player:IPlayer);
}
-app.main.factory('Players', function($rootScope:ng.IScope, FB:fb.FB, Board:b.IBoard, AppVersion:av.IAppVersion):IPlayerService {
+angular.module('services').factory('Players', function($rootScope:ng.IScope, FB:firebase.IFB, Board:IBoard, AppVersion:any):IPlayerService {
// the big cheese. Does the deed
// you can make fancy bindings here, no?
View
7 public/services/SoundEffects.js
@@ -1,8 +1,4 @@
-define(function(require) {
- var app = require('app')
- app.main
-
-.factory('SoundEffects', function() {
+angular.module('services').factory('SoundEffects', function() {
// simple sound, lets you play/pause, with a beginning offset
function simpleSound(file, seconds) {
@@ -60,4 +56,3 @@ define(function(require) {
}
})
-})
Please sign in to comment.
Something went wrong with that request. Please try again.