-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
280 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2014. | ||
* | ||
* @author Andy Tang | ||
*/ | ||
(function VersusSceneModel(angular, clazz) { | ||
'use strict'; | ||
|
||
var app = angular.module('jsWars'); | ||
|
||
app.factory('VersusScene', ['Saber', 'SwordSoldier', 'Scene', | ||
function VersusSceneFactory(Saber, SwordSoldier) { | ||
return clazz(function VersusScene() { | ||
this.extend = 'Scene'; | ||
|
||
this.private = { | ||
createNewUnits: function createNewUnits(list) { | ||
list.add(0, new Saber()); | ||
for (var i = 1; i < 5; i++) { | ||
list.add(i, new SwordSoldier()); | ||
} | ||
}, | ||
calculatPositions: function calculatePositions(unitsAdded, x, y) { | ||
var position = { | ||
x: x, | ||
y: y | ||
}; | ||
var positionCalculator = unitsAdded % 5; | ||
|
||
if (positionCalculator === 1) { | ||
position.x = x + 1; | ||
} else if (positionCalculator === 2) { | ||
position.y = y - 1; | ||
} else if (positionCalculator === 3) { | ||
position.x = x - 1; | ||
} else if (positionCalculator === 4) { | ||
position.y = y + 1; | ||
} | ||
|
||
return position; | ||
}, | ||
positionUnits: function positionUnits(list, x, y) { | ||
var unitNode = list.getFirst(); | ||
var unit; | ||
var unitsAdded = 0; | ||
var position; | ||
do { | ||
position = this.private.calculatPositions(unitsAdded, x, y); | ||
unit = unitNode.getValue(); | ||
this.public.getPosition(position.x, position.y).setGameObject(unit); | ||
unitsAdded++; | ||
} while ((unitNode = unitNode.getNext()) !== null); | ||
} | ||
}; | ||
|
||
this.protected = { | ||
addUnits: function addUnits() { | ||
var playerList = this.public.getPlayers(); | ||
var playerOne = playerList.getFirst(); | ||
var playerTwo = playerList.getLast(); | ||
var unitsOne = playerOne.getValue().getUnits(); | ||
var unitsTwo = playerTwo.getValue().getUnits(); | ||
this.private.createNewUnits(unitsOne); | ||
this.private.positionUnits(unitsOne, 2, 5); | ||
this.private.createNewUnits(unitsTwo); | ||
this.private.positionUnits(unitsTwo, 17, 5); | ||
} | ||
}; | ||
|
||
this.constructor = function constructor() { | ||
this.super.constructor(20, 10); | ||
this.protected.initializePlayers(); | ||
}; | ||
}); | ||
}]); | ||
}(window.angular, window.clazz, window.LinkedHashMap)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!-- | ||
~ Copyright (c) 2014. | ||
~ | ||
~ @author Andy Tang | ||
--> | ||
<h1>Versus</h1> | ||
<section data-versus=""></section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- | ||
~ Copyright (c) 2014. | ||
~ | ||
~ @author Andy Tang | ||
--> | ||
<section> | ||
<div class="game-board" | ||
data-ng-class="{ 'move-mode': isInMoveMode(), 'attack-mode': isInAttackMode()}"> | ||
<h2>{{ getCurrentPlayer().getName() }}</h2> | ||
|
||
<div class="view-port"> | ||
<div class="view-content"> | ||
<div class="column" | ||
data-ng-repeat="column in map"> | ||
<div data-ng-repeat="square in column"> | ||
<div data-ng-class="{ | ||
'move-allowed': isInMoveRange($parent.$index, $index), | ||
'attack-allowed': isInAttackRange($parent.$index, $index) | ||
}" | ||
data-game-square="square" | ||
data-ng-click="action($parent.$index, $index)"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="button" | ||
data-ng-click="endTurn()">End Turn | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- | ||
~ Copyright (c) 2014. | ||
~ | ||
~ @author Andy Tang | ||
--> | ||
<div data-game-board="scene"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2014. | ||
* | ||
* @author Andy Tang | ||
*/ | ||
(function tutorialWidget(angular) { | ||
'use strict'; | ||
|
||
var app = angular.module('jsWars'); | ||
|
||
app.controller('tutorialViewModel', | ||
function tutorialViewModel($scope, FirstAttackScene) { | ||
$scope.scene = new FirstAttackScene(3, 2, 5, 2); | ||
}); | ||
|
||
app.directive('tutorial', function tutorialDirective() { | ||
return { | ||
restrict: 'A', | ||
templateUrl: 'tutorial', | ||
scope: { | ||
}, | ||
controller: 'tutorialViewModel' | ||
}; | ||
}); | ||
}(window.angular)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- | ||
~ Copyright (c) 2014. | ||
~ | ||
~ @author Andy Tang | ||
--> | ||
<div data-game-board="scene"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2014. | ||
* | ||
* @author Andy Tang | ||
*/ | ||
(function versusWidget(angular) { | ||
'use strict'; | ||
|
||
var app = angular.module('jsWars'); | ||
|
||
app.controller('versusViewModel', | ||
function versusViewModel($scope, VersusScene) { | ||
$scope.scene = new VersusScene(); | ||
}); | ||
|
||
app.directive('versus', function versusDirective() { | ||
return { | ||
restrict: 'A', | ||
templateUrl: 'versus', | ||
scope: { | ||
}, | ||
controller: 'versusViewModel' | ||
}; | ||
}); | ||
}(window.angular)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2014. | ||
* | ||
* @author Andy Tang | ||
*/ | ||
(function VersusScene() { | ||
'use strict'; | ||
|
||
describe('Versus Scene Scenarios', function VersusScene() { | ||
|
||
beforeEach(function navigateTo() { | ||
browser().navigateTo('/#/versus'); | ||
}); | ||
|
||
it('should have 20 x 10 game squares', function gameSquares() { | ||
expect(element('.game-square').count()).toEqual(20 * 10); | ||
}); | ||
|
||
it('should spawn two sabers', function spawnTwoSabers() { | ||
expect(element('.saber').count()).toEqual(2); | ||
}); | ||
|
||
it('should spawn 10 sword soldiers', function swordSoldiers() { | ||
expect(element('.sword-soldier').count()).toEqual(8); | ||
}); | ||
}); | ||
}()); |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.