add final level

This commit is contained in:
Juraj Michalek
2014-12-29 14:08:10 +00:00
parent 1c0aeefa4d
commit dbaf088b16
4 changed files with 43 additions and 10 deletions

View File

@@ -80,7 +80,7 @@
<div id="levelCompleteContent" ng-controller="LevelCompleteController" ng-show="isLevelCompleteVisible"> <div id="levelCompleteContent" ng-controller="LevelCompleteController" ng-show="isLevelCompleteVisible">
<div id="congratulation">Congratulations!</div> <div id="congratulation">Congratulations!</div>
<div> <div>
<a class="levelButton" id="replayButton" ng-click="restartLevel()"><i class="fa fa-repeat"></i>Play again</a> <a class="levelButton" id="replayButton" ng-click="restartLevel()" ng-hide="isFinalScreenVisible"><i class="fa fa-repeat"></i>Play again</a>
<a class="levelButton" id="nextButton" ng-click="nextLevel()" ng-hide="isFinalScreenVisible"><i class="fa fa-arrow-right" ></i>Next level</a> <a class="levelButton" id="nextButton" ng-click="nextLevel()" ng-hide="isFinalScreenVisible"><i class="fa fa-arrow-right" ></i>Next level</a>
</div> </div>
<div> <div>

View File

@@ -9,6 +9,7 @@ angular.module('level-complete', [])
$scope.completeLevel = function(event, args) { $scope.completeLevel = function(event, args) {
$scope.isLevelCompleteVisible = true; $scope.isLevelCompleteVisible = true;
$scope.isFinalScreenVisible = args.isFinalLevel;
$scope.levelIndex = args.levelIndex; $scope.levelIndex = args.levelIndex;
}; };

View File

@@ -201,3 +201,16 @@ var alphabetCards = {
'morse': '--..' 'morse': '--..'
} }
}; };
var finaleCards = {
'outro': {
'1':'P',
'2':'F',
'3':' ',
'4':'2',
'5':'0',
'6':'1',
'7':'5'
}
};

View File

@@ -92,21 +92,22 @@ angular.module('app', ['angular-flippy', 'level-selector', 'level-complete'])
chainLength: 2, chainLength: 2,
cardSet: alphabetCards, cardSet: alphabetCards,
cardTypes: ['key', 'morse'] cardTypes: ['key', 'morse']
}, { },/* {
levelName: "05: Picture + Word", levelName: "09: Picture + Word",
totalCards: 4*4, totalCards: 4*4,
cardsPerRow: 4, cardsPerRow: 4,
chainLength: 2, chainLength: 2,
cardSet: basicCards, cardSet: basicCards,
cardTypes: ['picture', 'en-US'] cardTypes: ['picture', 'en-US']
}, { }, {
levelName: "06: Picture + Foreign Word", levelName: "10: Foreign Word",
totalCards: 4*4, totalCards: 4*4,
cardsPerRow: 4, cardsPerRow: 4,
chainLength: 2, chainLength: 2,
cardSet: basicCards, cardSet: basicCards,
cardTypes: ['picture', 'oneLanguage'] cardTypes: ['picture', 'oneLanguage']
}, { }, {
levelName: "10: Random Word",
totalCards: 4*4, totalCards: 4*4,
cardsPerRow: 4, cardsPerRow: 4,
chainLength: 2, chainLength: 2,
@@ -125,11 +126,19 @@ angular.module('app', ['angular-flippy', 'level-selector', 'level-complete'])
cardSet: basicCards, cardSet: basicCards,
cardTypes: ['picture', 'randomLanguage', 'randomLanguage'] cardTypes: ['picture', 'randomLanguage', 'randomLanguage']
}, { }, {
totalCards: 4*4, levelName: "10: Grand MIX",
cardsPerRow: 4, totalCards: 5*5,
chainLength: 4, cardsPerRow: 5,
chainLength: 2,
cardSet: basicCards, cardSet: basicCards,
cardTypes: ['picture', 'randomLanguage', 'randomLanguage', 'randomLanguage'] cardTypes: ['picture', 'randomLanguage', 'randomLanguage', 'randomLanguage']
},*/ {
levelName: "Finale",
totalCards: 7*1,
cardsPerRow: 7,
chainLength: 7,
cardSet: finaleCards,
cardTypes: ['1','2','3','4','5','6','7']
} }
]; ];
@@ -167,6 +176,10 @@ angular.module('app', ['angular-flippy', 'level-selector', 'level-complete'])
}; };
}; };
$scope.isFinallevel = function() {
return ($scope.levelIndex == $scope.levels.length - 1);
};
/** /**
* Generate game board. * Generate game board.
*/ */
@@ -200,14 +213,19 @@ angular.module('app', ['angular-flippy', 'level-selector', 'level-complete'])
} }
} }
var isFinalLevel = $scope.isFinallevel();
for (var index = 0; index < totalCount; index++) { for (var index = 0; index < totalCount; index++) {
var coordinate = Math.floor((Math.random()* stack.length)); var coordinate = 0;
if (!isFinalLevel) {
coordinate = Math.floor((Math.random()* stack.length));
}
$scope.board.push(stack[coordinate]); $scope.board.push(stack[coordinate]);
stack.splice(coordinate, 1); stack.splice(coordinate, 1);
} }
}; };
$scope.selectionCounter = 0; $scope.selectionCounter = 0;
$scope.selectedCards = []; $scope.selectedCards = [];
@@ -357,7 +375,8 @@ angular.module('app', ['angular-flippy', 'level-selector', 'level-complete'])
*/ */
$scope.completeLevel = function() { $scope.completeLevel = function() {
var args = { var args = {
levelIndex: $scope.levelIndex levelIndex: $scope.levelIndex,
isFinalLevel: $scope.isFinallevel()
}; };
$rootScope.$emit('completeLevel', args); $rootScope.$emit('completeLevel', args);
}; };