5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | The Legend of Cheryl
13 |
14 |
15 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/index.tests.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/js/app/boot.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 |
3 | define(['Phaser', 'preload', 'start', 'game', 'game_over', 'creator'],
4 | function (Phaser, Preload, Start, Game, Game_Over, Creator) {
5 | 'use strict';
6 |
7 | var SCREEN_WIDTH = window.innerWidth * window.devicePixelRatio,
8 | SCREEN_HEIGHT = window.innerHeight * window.devicePixelRatio,
9 |
10 | game = new Phaser.Game(800, 600, Phaser.CANVAS, 'screen');
11 |
12 | game.state.add('Preload', Preload);
13 | game.state.add('Creator', Creator);
14 | game.state.add('Start', Start);
15 | game.state.add('Game', Game);
16 | game.state.add('Game_Over', Game_Over);
17 |
18 | game.state.start('Preload');
19 | });
--------------------------------------------------------------------------------
/js/app/creator.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 |
3 | define(['Phaser'], function (Phaser) {
4 | 'use strict';
5 |
6 | var Creator = {
7 |
8 | create: function () {
9 | this.add.button(0, 0, 'scroll', this.createRogue, this);
10 | this.add.button(160, 0, 'scroll', this.createPaladin, this);
11 | this.add.button(320, 0, 'scroll', this.createWarrior, this);
12 | this.add.button(480, 0, 'scroll', this.createEngineer, this);
13 | this.add.button(640, 0, 'scroll', this.createMage, this);
14 |
15 | this.add.sprite(0, 50, 'spriteCard');
16 | },
17 |
18 | /**
19 | * the player object with paramaters needed to call _makePlayer in creatures.js
20 | */
21 | player: {
22 | name: 'Player',
23 | hp: '',
24 | mp: '',
25 | str: '',
26 | def: '',
27 | crit: '',
28 | vision: '',
29 | class: ''
30 | },
31 |
32 | /**
33 | * the Rouge Class
34 | * features lower health and defense, average health, magic, and strength, and high critical chance
35 | */
36 | createRogue: function () {
37 | this.player.hp = 20;
38 | this.player.mp = 20;
39 | this.player.str = 3;
40 | this.player.def = 1;
41 | this.player.crit = 5;
42 | this.player.vision = 10;
43 | this.player.class = 'rogue';
44 |
45 | this.startGame();
46 | },
47 |
48 | /**
49 | * the Paladin Class
50 | * features lower critical chance, average magic and strength, and high health and defense
51 | */
52 | createPaladin: function () {
53 | this.player.hp = 30;
54 | this.player.mp = 15;
55 | this.player.str = 4;
56 | this.player.def = 3;
57 | this.player.crit = 2;
58 | this.player.vision = 6;
59 | this.player.class = 'paladin';
60 |
61 | this.startGame();
62 | },
63 |
64 | /**
65 | * the Warrior Class
66 | * features lower magic and critical chance, average defense, and high health and strength.
67 | */
68 | createWarrior: function () {
69 | this.player.hp = 28;
70 | this.player.mp = 10;
71 | this.player.str = 6;
72 | this.player.def = 2;
73 | this.player.crit = 2;
74 | this.player.vision = 5;
75 | this.player.class = 'warrior';
76 |
77 | this.startGame();
78 | },
79 |
80 | /**
81 | * the Engineer Class
82 | * features average health, magic, strength, defense, and critical chance
83 | */
84 | createEngineer: function () {
85 | this.player.hp = 25;
86 | this.player.mp = 20;
87 | this.player.str = 4;
88 | this.player.def = 2;
89 | this.player.crit = 3;
90 | this.player.vision = 7;
91 | this.player.class = 'engineer';
92 |
93 | this.startGame();
94 | },
95 |
96 | /**
97 | * the Mage Class
98 | * features lower health, strength, and defense, high magic and critical chance
99 | */
100 | createMage: function () {
101 | this.player.hp = 20;
102 | this.player.mp = 30;
103 | this.player.str = 2;
104 | this.player.def = 1;
105 | this.player.crit = 4;
106 | this.player.vision = 8;
107 | this.player.class = 'mage';
108 |
109 | this.startGame();
110 | },
111 |
112 | /**
113 | * changes the game to the Game state
114 | * @function startGame
115 | */
116 | startGame: function () {
117 | this.state.start('Game');
118 | }
119 |
120 | };
121 |
122 | return Creator;
123 | });
--------------------------------------------------------------------------------
/js/app/game_over.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 |
3 | define(['Phaser', 'game'], function (Phaser, Game) {
4 | 'use strict';
5 |
6 | var Game_Over = {
7 |
8 | create: function () {
9 | var width = (800) / 2,
10 | height = (600) / 2,
11 |
12 | retry_button = this.add.text(width, height, 'Retry', {
13 | font: '30pt wingsofDarkness',
14 | fill: 'white',
15 | align: 'center'
16 | });
17 |
18 | retry_button.inputEnabled = true;
19 | retry_button.events.onInputUp.add(this.startGame, this);
20 | retry_button.anchor.setTo(0.5);
21 |
22 | this.add.text(width, height - 100, 'GAME OVER', {
23 | font: '50pt wingsofDarkness',
24 | fill: 'red',
25 | align: 'center'
26 | }).anchor.setTo(0.5);
27 | },
28 |
29 | /**
30 | * changes the game to the Start state
31 | * @function startGame
32 | */
33 | startGame: function () {
34 | // Change the state back to Start.
35 | this.state.start('Start');
36 |
37 | }
38 | };
39 |
40 | return Game_Over;
41 |
42 | });
--------------------------------------------------------------------------------
/js/app/items.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 | /*jslint nomen: true */
3 |
4 | define(['ROT', 'Phaser'], function (ROT, Phaser) {
5 | 'use strict';
6 | return {
7 | /**
8 | * @module creatures
9 | */
10 |
11 | //array of spritesheets
12 | _sprites: ['Armor.png', 'Potion.png', 'LongWep.png', 'Map.png', 'Chest.png', 'Key.png'],
13 |
14 | _items_chest1: ['Old Map'],
15 | _items_area1: ['Health Potion', 'Antivenom', 'Old Map', 'Key'],
16 |
17 | /**
18 | * Choose a random item from a pool, based on the level given
19 | * @function _pickItem
20 | * @param {number} level the current floor
21 | * @return {string} returns the chosen item's name
22 | */
23 | _pickItem: function (level) {
24 | if (level >= 1 && level <= 5) { //pick a random item from section 1
25 | return this._items_area1[Math.floor(Math.random()* this._items_area1.length)];
26 | }
27 | return (this._items_area1[Math.floor(Math.random())]); //If calculation breaks then just return area1
28 | },
29 |
30 | _pickChest: function (type){
31 | if(type === 1){
32 |
33 | }
34 | },
35 |
36 | /**
37 | * gives an item to the caller based on the level given.
38 | * @function _putItem
39 | * @param {number} level the current floor
40 | * @param {number} x the x value of where to place the item
41 | * @param {number} y the y value of where to place the item
42 | * @param {boolean} isDrop whether this is a monster dropping or not
43 | * @return {item} returns the selected item back to the caller
44 | */
45 | _putItem: function (level, x, y, isDrop) {
46 | var itemName;
47 | if (isDrop ===false){
48 | itemName = this._pickItem(level);
49 | }
50 | else {
51 | if(Math.floor(Math.random()*10)=== 1){
52 | return this._chest(x, y, level);
53 | }
54 | else{
55 | itemName = this._pickItem(level);
56 | }
57 | }
58 | if (itemName === 'Health Potion') {
59 | return this.Potion(x, y);
60 | }
61 | if (itemName === 'Antivenom') {
62 | return this.Antivenom(x, y);
63 | }
64 |
65 | if (itemName === 'Old Map'){
66 | return this.OldMap(x, y);
67 | }
68 |
69 | if (itemName ==='Key'){
70 | return this.Key(x, y);
71 | }
72 | },
73 |
74 | /**
75 | * gives an item to the caller based on the level given.
76 | * @function spawnDrop
77 | * @param {number} level the current floor
78 | * @param {number} x the x value of where to place the item
79 | * @param {number} y the y value of where to place the item
80 | * @return {item} returns the selected item back to the caller
81 | */
82 | spawnDrop: function (name, dropchance, level) {
83 | if (Math.floor(Math.random() * dropchance) === 1) {
84 | return this._putItem(level, 0, 0, true);
85 | } else {
86 | return 'nothing';
87 | }
88 | },
89 |
90 | /**
91 | * Chest creation factory
92 | * @param {number} x x location of chest
93 | * @param {number} y y location of chest
94 | * @param {number} level what floor it is on
95 | * @return {chest} returns a chest
96 | */
97 | _chest: function (x, y, level){
98 | return {
99 | x: x,
100 | y: y,
101 | opened: false,
102 | contents:this._pickChest(1)
103 | };
104 | },
105 |
106 | /**
107 | * An item creation factory
108 | * @function _generic
109 | * @param {string} name name of the item
110 | * @param {string} sprite name of the spritesheet to use
111 | * @param {number} frame what frame from the spritesheet to use
112 | * @param {number} str the strength value of the item (where applicable)
113 | * @param {number} def the defense value of the item (where applicable)
114 | * @param {number} x the x location of the item in the dungeon
115 | * @param {number} y the y location of the item in the dungeon
116 | * @return {item} returns the created item back to the caller
117 | */
118 | _generic: function (name, sprite, frame, str, def, x, y) {
119 | return {
120 | name: name,
121 | sprite: sprite,
122 | frame: frame,
123 | str: str,
124 | def: def,
125 | x: x,
126 | y: y,
127 |
128 | /**
129 | * the player tries to use the item
130 | * @function use
131 | * @param {creature} player the player
132 | * @return {array} returns results of function (each variable is explained in code)
133 | */
134 | use: function (player) {
135 | var returnarray = {
136 | success: 0, // 1 if item is used, 0 if item cannot be used
137 | explainFail: '', // if the item cannot be used, this is where the reason is explained
138 | removeType: 0, /*this tells the game how to handle the item after this function is called.
139 | 0: (default) the item will be removed from inventory after use
140 | 1: the item will remain in the inventory after use.
141 | 2: clears the map and deletes on return.
142 | */
143 | playSound: ''// tells the game what sound should be played (if any)
144 | };
145 | if (this.name === 'Health Potion'){
146 | player.hp+= 15;
147 | if (player.hp > player.max_hp){
148 | player.hp = player.max_hp;
149 | }
150 | returnarray.success = 1;
151 | returnarray.playSound = 'potion';
152 | return returnarray;
153 | }
154 |
155 | if (this.name === 'Antivenom'){
156 | if (player.isPoisoned === 1){
157 | player.isPoisoned = 0;
158 | player.poisonTimer = 0;
159 | returnarray.success = 1;
160 | returnarray.playSound = 'potion';
161 | return returnarray;
162 | }
163 | else{
164 | returnarray.explainFail = 'You are not poisoned.';
165 | return returnarray;
166 | }
167 | }
168 |
169 | if (this.name === 'Old Map'){
170 | returnarray.success = 1;
171 | returnarray.removeType = 2;
172 | return returnarray;
173 | }
174 | if (this.name === 'Key'){
175 | returnarray.removeType = 1;
176 | returnarray.explainFail = 'You cannot use a key, simply walk into a lock to use it.';
177 | return returnarray;
178 | }
179 |
180 | returnarray.explainFail= "Oops we're not certain why you can't use this... sorry (you shouldn't see this message)";
181 | return returnarray;
182 | }
183 | };
184 | },
185 | //------------------------------------------------------------
186 | //General Items
187 | /**
188 | * creates a potion item
189 | * @param {number} x the x position of the item in the dungeon
190 | * @param {nubmer} y the y position of the item in the dungeon
191 | * @return {item} returns the item to the caller
192 | */
193 |
194 | Potion: function (x, y) {
195 | return this._generic('Health Potion', 'potion', 1, 0, 0, x, y);
196 | },
197 |
198 | /**
199 | * creates an antivenom item
200 | * @param {number} x the x position of the item in the dungeon
201 | * @param {nubmer} y the y position of the item in the dungeon
202 | * @return {item} returns the item to the caller
203 | */
204 | Antivenom: function(x, y){
205 | return this._generic('Antivenom', 'potion', 5, 0, 0, x, y);
206 | },
207 |
208 | Key: function(x, y){
209 | return this._generic('Key', 'key', 0, 0, 0, x, y);
210 | },
211 | // ----------------------------------------------------------------------
212 | //Special ITEMS
213 | OldMap: function (x, y){
214 | return this._generic('Old Map', 'map', 2, 0, 0, x, y);
215 | },
216 | // ----------------------------------------------------------------------
217 | // EQUIPABLE ITEMS
218 | /**
219 | * creates a wood armor item
220 | * @param {number} x the x position of the item in the dungeon
221 | * @param {nubmer} y the y position of the item in the dungeon
222 | * @return {item} returns the item to the caller
223 | */
224 | WoodArmor: function (x, y) {
225 | return this._generic('Wooden Armor', 'armor', 0, 0, 1, x, y);
226 | },
227 |
228 | /**
229 | * creates a stone spear item
230 | * @param {number} x the x position of the item in the dungeon
231 | * @param {nubmer} y the y position of the item in the dungeon
232 | * @return {item} returns the item to the caller
233 | */
234 | StoneSpear: function (x, y) {
235 | return this._generic('Stone Spear', 'longwep', 1, 1, 0, x, y);
236 | }
237 | };
238 | });
239 |
--------------------------------------------------------------------------------
/js/app/loading.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 |
3 | define(['Phaser'], function (Phaser) {
4 | 'use strict';
5 | var Loading = {
6 | preload: function () {
7 | this.load.image('load', 'assets/loading.png');
8 | },
9 |
10 | create: function () {
11 | this.state.start('Preload');
12 | }
13 | };
14 | return Loading;
15 | });
--------------------------------------------------------------------------------
/js/app/preload.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 | /*jslint nomen: true */
3 |
4 | define(['Phaser', 'dungeon'], function (Phaser, dungeon) {
5 | 'use strict';
6 | var creatures = dungeon.creatures,
7 | items = dungeon.items,
8 | TILE_SIZE = dungeon.TILE_SIZE,
9 | //loadingscreen = this.load.image('load', 'assets/loading.png'),
10 | // TODO: Move this list to a player.js file or something of the sort
11 | classes = ['Warrior', 'Engineer', 'Mage', 'Paladin', 'Rogue'],
12 |
13 | Preload = {
14 | // Import assets
15 | preload: function () {
16 | // Used to avoid conflicts
17 | var vm = this;
18 | // Add loading text for player to wait
19 | vm.add.text(800 / 2, 600 / 2, 'Loading . . .', {
20 | font: 'bold 20pt "Lucida Sans Typewriter"',
21 | fill: 'white',
22 | align: 'center'
23 | }).anchor.setTo(0.5);
24 |
25 | vm.load.image('splash', 'assets/splash.png');
26 | vm.load.spritesheet('removeItem', 'assets/removeItem.png', 24, 24);
27 | vm.load.image('fullscreen', 'assets/fs.png');
28 | vm.load.image('dungeon', 'assets/Wall.png');
29 | vm.load.image('inventoryTile', 'assets/inventoryTile.png');
30 | vm.load.image('shadow', 'assets/shadow.png');
31 | vm.load.image('spriteCard', 'assets/spriteCard.png');
32 | vm.load.image('scroll', 'assets/Scroll.png');
33 |
34 | //status effects
35 | vm.load.image('STAT_poison', 'assets/GUI/poison.png');
36 |
37 | vm.load.spritesheet('door', 'assets/Door.png', TILE_SIZE, TILE_SIZE);
38 | vm.load.spritesheet('door_open', 'assets/Door_Open.png', TILE_SIZE, TILE_SIZE);
39 | vm.load.spritesheet('objects', 'assets/Objects.png', TILE_SIZE, TILE_SIZE);
40 |
41 | // Load player sprites
42 | classes.forEach(function (name) {
43 | vm.load.spritesheet(name.toLowerCase(), 'assets/' + name + '.png', TILE_SIZE, TILE_SIZE);
44 | });
45 | // Load monster sprites
46 | creatures._sprites.forEach(function (sprite) {
47 | Preload.load.spritesheet(sprite.toLowerCase().replace('.png', ''), 'assets/monsters/' + sprite, TILE_SIZE, TILE_SIZE);
48 | });
49 |
50 | // Load item sprites
51 | items._sprites.forEach(function (sprite) {
52 | Preload.load.spritesheet(sprite.toLowerCase().replace('.png', ''), 'assets/items/' + sprite, TILE_SIZE, TILE_SIZE);
53 | });
54 |
55 | // Load Sound Effects
56 | vm.load.audio('SND_door_open', 'assets/sounds/Door.wav');
57 | vm.load.audio('SND_hit', 'assets/sounds/Hit.wav');
58 | vm.load.audio('SND_teleport', ['assets/sounds/Teleport.ogg', 'assets/sounds/Teleport.wav']);
59 | vm.load.audio('SND_item', 'assets/sounds/Item.wav');
60 | vm.load.audio('SND_potion', 'assets/sounds/Potion.wav');
61 | vm.load.audio('SND_click', 'assets/sounds/Click.wav');
62 | // Load Music
63 | vm.load.audio('MUS_dungeon1', ['assets/music/Adventure_Meme.ogg', 'assets/music/Adventure_Meme.mp3']);
64 | vm.load.audio('MUS_dungeon2', ['assets/music/Wonderful_Nightmare.ogg', 'assets/music/Wonderful_Nightmare.mp3']);
65 |
66 | // Fonts
67 | vm.load.bitmapFont('wingsofDarkness', 'assets/Fonts/Wings_of_Darkness.png', 'assets/Fonts/Wings_of_Darkness.fnt');
68 | vm.load.bitmapFont('fleshWound', 'assets/Fonts/Flesh Wound.png', 'assets/Fonts/Flesh Wound.fnt');
69 | },
70 |
71 | create: function () {
72 | this.state.start('Start');
73 | }
74 | };
75 | return Preload;
76 |
77 | });
78 |
--------------------------------------------------------------------------------
/js/app/start.js:
--------------------------------------------------------------------------------
1 | /*globals define*/
2 |
3 | define(['Phaser'], function (Phaser) {
4 | 'use strict';
5 |
6 | var Start = {
7 |
8 | create: function () {
9 | var width = (800) / 2,
10 | height = (600) / 2,
11 |
12 | splash = this.add.sprite(0, 0, 'splash'),
13 |
14 | // Add Start text to use as button
15 | play_button = this.add.text(width, height - 20, 'Start', {
16 | font: '46pt wingsofDarkness',
17 | fill: 'white',
18 | align: 'center'
19 | });
20 |
21 | play_button.inputEnabled = true;
22 | play_button.events.onInputUp.add(this.startCreator, this);
23 | play_button.anchor.setTo(0.5);
24 |
25 | play_button.stroke = 'black';
26 | play_button.strokeThickness = 4;
27 | play_button.setShadow(2, 2, "#000", 2, true, true);
28 |
29 | // Add Game Title
30 | var title = this.add.text(width, height - 150, 'The Legend of Cheryl', {
31 | font: '50pt wingsofDarkness',
32 | fill: '#fff',
33 | align: 'center'
34 | });
35 |
36 | title.anchor.setTo(0.5);
37 |
38 | title.stroke = 'black';
39 | title.strokeThickness = 4;
40 | title.setShadow(2, 2, "#000", 2, true, true);
41 |
42 | // Add color gradient to text
43 |
44 | var grd = play_button.context.createLinearGradient(0, 0, 0, play_button.height);
45 |
46 | // Add in 2 color stops
47 | grd.addColorStop(0, '#fff');
48 | grd.addColorStop(1, '#338');
49 |
50 | // And apply to the Text
51 | play_button.fill = grd;
52 |
53 | grd = title.context.createLinearGradient(0, 0, 0, title.height);
54 |
55 | // Add in 2 color stops
56 | grd.addColorStop(0, '#5f5');
57 | grd.addColorStop(1, '#050');
58 |
59 | // And apply to the Text
60 | title.fill = grd;
61 |
62 | },
63 |
64 | /**
65 | * changes the game to the Creator state
66 | * @function startGame
67 | */
68 | startCreator: function () {
69 | this.state.start('Creator');
70 | }
71 | };
72 | return Start;
73 | });
--------------------------------------------------------------------------------
/js/app/tests.js:
--------------------------------------------------------------------------------
1 | /*globals define, it, expect, jasmine, describe*/
2 | /*jslint nomen: true */
3 |
4 | define(['dungeon'], function (dungeon) {
5 | 'use strict';
6 |
7 | // From dictionary
8 | function expectType(variable, model, types) {
9 | it('should have variable "' + variable + '" of type "' + types[variable].name + '"', function () {
10 | expect(model[variable]).toEqual(jasmine.any(types[variable]));
11 | });
12 | }
13 |
14 | function expectValidDungeon(i, model) {
15 |
16 | // From simple input
17 | function expectSimpleType(variable, type, desc) {
18 | it(desc || 'should be of type "' + type.name + '"', function () {
19 | expect(variable).toEqual(jasmine.any(type));
20 | });
21 | }
22 |
23 | // From simple input
24 | function expectSimpleMatch(variable, pattern) {
25 | it('should match pattern "' + pattern + '"', function () {
26 | expect(variable).toMatch(pattern);
27 | });
28 | }
29 |
30 | function expectValidDoor(door) {
31 | describe('Door at ' + door, function () {
32 | // Each door should be a string of 'x,y' pattern
33 | expectSimpleMatch(door, /^(\d+),(\d+)$/);
34 |
35 | var match = door.match(/^(\d+),(\d+)$/),
36 |
37 | x = +match[1],
38 | y = +match[2];
39 |
40 | it('should occupy its tile', function () {
41 | expect(model._isAvailable(x, y)).toBe(false);
42 | });
43 |
44 | it('should return "true" when calling "model._hasDoor(x, y)"', function () {
45 | expect(model._hasDoor(x, y)).toBe(true);
46 | });
47 | });
48 | }
49 |
50 | function expectValidMonster(monster) {
51 | describe(monster.name + ' at ' + monster.x + ',' + monster.y, function () {
52 |
53 | expectSimpleType(monster, Object);
54 |
55 | var types = {
56 | frame: Number,
57 | hp: Number,
58 | name: String,
59 | sprite: String,
60 | str: Number,
61 | x: Number,
62 | y: Number
63 | },
64 | variable;
65 | for (variable in types) {
66 | if (types.hasOwnProperty(variable)) {
67 | expectType(variable, monster, types);
68 | }
69 | }
70 |
71 | it('should be at a valid tile', function () {
72 | expect(model._validTile(monster.x, monster.y)).toBe(true);
73 | });
74 |
75 | it('should occupy its tile', function () {
76 | expect(model._isAvailable(monster.x, monster.y)).toBe(false);
77 | });
78 | });
79 | }
80 |
81 | function expectValidTile(key) {
82 | describe('Tile at ' + key, function () {
83 | // Each key should be a string of 'x,y' pattern
84 | expectSimpleMatch(key, /^(\d+),(\d+)$/);
85 |
86 | var match = key.match(/^(\d+),(\d+)$/),
87 |
88 | x = +match[1],
89 | y = +match[2];
90 |
91 | expectSimpleType(model.tiles[key], Number, 'should have a numeric tilesheet index');
92 |
93 | it('should be a valid tile', function () {
94 | expect(model._validTile(x, y)).toBe(true);
95 | });
96 | });
97 | }
98 |
99 | function expectValidWall(key) {
100 | describe('Wall at ' + key, function () {
101 | // Each key should be a string of 'x,y' pattern
102 | expectSimpleMatch(key, /^(\d+),(\d+)$/);
103 |
104 | var match = key.match(/^(\d+),(\d+)$/),
105 |
106 | x = +match[1],
107 | y = +match[2];
108 |
109 | expectSimpleType(model.walls[key], Number, 'should have a numeric tilesheet index');
110 |
111 | it('should be an invalid tile', function () {
112 | expect(model._validTile(x, y)).toBe(false);
113 | });
114 | });
115 | }
116 |
117 | describe('Dungeon Instance ' + i, function () {
118 |
119 | describe('Base Model', function () {
120 | var types = {
121 | width: Number,
122 | height: Number,
123 | level: Number,
124 | _init: Function,
125 | _getSeed: Function,
126 | _validTile: Function,
127 | _hasMonster: Function,
128 | _getMonster: Function,
129 | _hasDoor: Function,
130 | _moveCreature: Function,
131 | _isAvailable: Function,
132 | _generate: Function,
133 | _spawnPlayer: Function,
134 | _spawnStairs: Function,
135 | _spawnMonsters: Function,
136 | _placeDoors: Function,
137 | _placeWalls: Function
138 | },
139 | variable;
140 | for (variable in types) {
141 | if (types.hasOwnProperty(variable)) {
142 | expectType(variable, model, types);
143 | }
144 | }
145 | });
146 |
147 | model._init();
148 |
149 | describe('Initialized Model (Seed ' + model._getSeed() + ')', function () {
150 | var types = {
151 | doors: Array,
152 | monsters: Array,
153 | rooms: Array,
154 | digger: Object,
155 | player: Object,
156 | stairs: Object,
157 | tiles: Object,
158 | walls: Object
159 | },
160 | variable;
161 | for (variable in types) {
162 | if (types.hasOwnProperty(variable)) {
163 | expectType(variable, model, types);
164 | }
165 | }
166 |
167 | describe('Doors', function () {
168 | it('should have length > 0', function () {
169 | expect(model.doors.length).toBeGreaterThan(0);
170 | });
171 | model.doors.forEach(function (door) {
172 | expectValidDoor(door);
173 | });
174 | });
175 |
176 | describe('Monsters', function () {
177 | it('should have length > 0', function () {
178 | expect(model.monsters.length).toBeGreaterThan(0);
179 | });
180 |
181 | model.monsters.forEach(function (monster) {
182 | expectValidMonster(monster);
183 | });
184 | });
185 |
186 | describe('Stairs', function () {
187 | it('should be at a valid tile', function () {
188 | expect(model._validTile(model.stairs.x, model.stairs.y)).toBe(true);
189 | });
190 |
191 | it('should be an unoccupied its tile', function () {
192 | expect(model._isAvailable(model.stairs.x, model.stairs.y)).toBe(true);
193 | });
194 | });
195 |
196 | describe('Player', function () {
197 | it('should be at a valid tile', function () {
198 | expect(model._validTile(model.player.x, model.player.y)).toBe(true);
199 | });
200 |
201 | it('should occupy its tile', function () {
202 | expect(model._isAvailable(model.player.x, model.player.y)).toBe(false);
203 | });
204 | });
205 |
206 | describe('Tiles', function () {
207 | var key;
208 | for (key in model.tiles) {
209 | if (model.tiles.hasOwnProperty(key)) {
210 | expectValidTile(key);
211 | }
212 | }
213 | });
214 |
215 | describe('Walls', function () {
216 | var key;
217 | for (key in model.walls) {
218 | if (model.walls.hasOwnProperty(key)) {
219 | expectValidWall(key);
220 | }
221 | }
222 | });
223 | });
224 | });
225 | }
226 |
227 | describe('Dungeon Class', function () {
228 | var types = {
229 | TILE_SIZE: Number,
230 | dungeon: Object,
231 | tiles: Object,
232 | creatures: Object,
233 | _dungeon: Function
234 | },
235 | variable,
236 | i;
237 | for (variable in types) {
238 | if (types.hasOwnProperty(variable)) {
239 | expectType(variable, dungeon, types);
240 | }
241 | }
242 | // Able to bulk test across multiple dungeon instances
243 | for (i = 1; i <= 1; i += 1) {
244 | expectValidDungeon(i, dungeon._dungeon());
245 | }
246 | });
247 |
248 | });
--------------------------------------------------------------------------------
/js/lib/boot.js:
--------------------------------------------------------------------------------
1 | /**
2 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
3 |
4 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
5 |
6 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
7 |
8 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem
9 | */
10 |
11 | (function() {
12 |
13 | /**
14 | * ## Require & Instantiate
15 | *
16 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
17 | */
18 | window.jasmine = jasmineRequire.core(jasmineRequire);
19 |
20 | /**
21 | * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
22 | */
23 | jasmineRequire.html(jasmine);
24 |
25 | /**
26 | * Create the Jasmine environment. This is used to run all specs in a project.
27 | */
28 | var env = jasmine.getEnv();
29 |
30 | /**
31 | * ## The Global Interface
32 | *
33 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
34 | */
35 | var jasmineInterface = jasmineRequire.interface(jasmine, env);
36 |
37 | /**
38 | * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
39 | */
40 | extend(window, jasmineInterface);
41 |
42 | /**
43 | * ## Runner Parameters
44 | *
45 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
46 | */
47 |
48 | var queryString = new jasmine.QueryString({
49 | getWindowLocation: function() { return window.location; }
50 | });
51 |
52 | var catchingExceptions = queryString.getParam("catch");
53 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
54 |
55 | var throwingExpectationFailures = queryString.getParam("throwFailures");
56 | env.throwOnExpectationFailure(throwingExpectationFailures);
57 |
58 | /**
59 | * ## Reporters
60 | * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
61 | */
62 | var htmlReporter = new jasmine.HtmlReporter({
63 | env: env,
64 | onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
65 | onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
66 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
67 | getContainer: function() { return document.body; },
68 | createElement: function() { return document.createElement.apply(document, arguments); },
69 | createTextNode: function() { return document.createTextNode.apply(document, arguments); },
70 | timer: new jasmine.Timer()
71 | });
72 |
73 | /**
74 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
75 | */
76 | env.addReporter(jasmineInterface.jsApiReporter);
77 | env.addReporter(htmlReporter);
78 |
79 | /**
80 | * Filter which specs will be run by matching the start of the full name against the `spec` query param.
81 | */
82 | var specFilter = new jasmine.HtmlSpecFilter({
83 | filterString: function() { return queryString.getParam("spec"); }
84 | });
85 |
86 | env.specFilter = function(spec) {
87 | return specFilter.matches(spec.getFullName());
88 | };
89 |
90 | /**
91 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
92 | */
93 | window.setTimeout = window.setTimeout;
94 | window.setInterval = window.setInterval;
95 | window.clearTimeout = window.clearTimeout;
96 | window.clearInterval = window.clearInterval;
97 |
98 | /**
99 | * ## Execution
100 | *
101 | * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
102 | */
103 | var currentWindowOnload = window.onload;
104 |
105 | window.onload = function() {
106 | if (currentWindowOnload) {
107 | currentWindowOnload();
108 | }
109 | htmlReporter.initialize();
110 | env.execute();
111 | };
112 |
113 | /**
114 | * Helper function for readability above.
115 | */
116 | function extend(destination, source) {
117 | for (var property in source) destination[property] = source[property];
118 | return destination;
119 | }
120 |
121 | }());
122 |
--------------------------------------------------------------------------------
/js/main.js:
--------------------------------------------------------------------------------
1 | /*globals requirejs*/
2 |
3 | // Load modules
4 | requirejs.config({
5 | baseUrl: 'js/lib',
6 | paths: {
7 | // Libraries
8 | Phaser: 'phaser.min',
9 | lodash: 'lodash.min',
10 | ROT: 'rot.min',
11 |
12 | // Game Files
13 | creatures: '../app/creatures',
14 | items: '../app/items',
15 | dungeon: '../app/dungeon',
16 | game: '../app/game',
17 | start: '../app/start',
18 | preload: '../app/preload',
19 | game_over: '../app/game_over',
20 | creator: '../app/creator'
21 | }
22 | });
23 |
24 | // Start the app
25 | requirejs(['../app/boot']);
26 |
--------------------------------------------------------------------------------
/js/main.tests.js:
--------------------------------------------------------------------------------
1 | /*globals require*/
2 | // Load modules
3 | require.config({
4 | baseUrl: 'js/lib',
5 | paths: {
6 | 'Phaser': 'phaser.min',
7 | 'lodash': 'lodash.min',
8 | 'ROT': 'rot.min',
9 | 'jasmine': 'jasmine',
10 | 'jasmine-html': 'jasmine-html',
11 | 'jasmine-boot': 'boot',
12 | 'creatures': '../app/creatures',
13 | 'items': '../app/items',
14 | 'dungeon': '../app/dungeon',
15 | 'preload': '../app/preload',
16 | 'start': '../app/start',
17 | 'boot': '../app/boot',
18 | 'gameover': '../app/game_over',
19 | 'creator': '../app/creator'
20 | },
21 | // shim: makes external libraries compatible with requirejs (AMD)
22 | shim: {
23 | 'jasmine-html': {
24 | deps: ['jasmine']
25 | },
26 | 'jasmine-boot': {
27 | deps: ['jasmine', 'jasmine-html']
28 | }
29 | }
30 | });
31 |
32 | require(['jasmine-boot'], function () {
33 | 'use strict';
34 | require(['../app/tests'], function () {
35 | //trigger Jasmine
36 | window.onload();
37 | });
38 | });
--------------------------------------------------------------------------------
/out/creatures.js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | JSDoc: Source: creatures.js
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
Source: creatures.js
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
/*globals define, console*/
30 | /*jslint nomen: true */
31 |
32 | define(['ROT', 'Phaser', 'items'], function (ROT, Phaser, items) {
33 | 'use strict';
34 |
35 | /**
36 | * @module creatures
37 | */
38 |
39 | return {
40 | _sprites: ['Reptile0.png', 'Reptile1.png', 'Undead0.png', 'Undead1.png', 'Humanoid0.png', 'Humanoid1.png'],
41 | _creatures_area1: ['skeleton', 'snake', 'fairy'], //Creature pool for area 1
42 |
43 | /**
44 | * Picks a random crature from the proper creature pool.
45 | *
46 | * @param {number} level - What level of the dungeon the player is currently on
47 | * @return {string} The name of the creature that has been picked to be placed
48 | */
49 | _pickCreature: function (level) {
50 | if (level >= 1 && level <= 5) { //pick a random creature from section 1
51 | return this._creatures_area1[Math.floor(Math.random() * 2)];
52 | }
53 | return (this._creatures_area1[Math.floor(Math.random() * 2)]); //If calculation breaks then just return area1
54 | },
55 |
56 | /**
57 | * Creates a creature that is to be put into the dungeon. It calls the _pickCreature function to randomly select
58 | * a creature. This function creates the randomly chosen enemy and returns that creature.
59 | *
60 | * @param {number} level What level of the dungeon the player is currently on
61 | * @param {number} x X coordinate of where the creature is to be placed.
62 | * @param {number} y Y coordinate of where the creature is to be placed.
63 | * @return {creature} The creature created is returned.
64 | */
65 | _putCreature: function (level, x, y) {
66 | var creatureName = this._pickCreature(level);
67 | if (creatureName === 'skeleton') {
68 | return this.skeleton(x, y);
69 | } else if (creatureName === 'fairy') {
70 | return this.fairy(x, y);
71 | } else {
72 | return this.snake(x, y); //If all else fails put snake
73 | }
74 | },
75 | /**
76 | * A factory that creates an enemy based upon the given data
77 | *
78 | * @param {string} name Creatures name
79 | * @param {number} hp Health will also become the max_hp
80 | * @param {number} str Strength
81 | * @param {number} def Defense
82 | * @param {number} crit Critical hit ratio
83 | * @param {number} expgain Experience point gain
84 | * @param {string} sprite Sprite sheet name
85 | * @param {number} frame What frame from the spritesheet to use
86 | * @param {number} x X coordinate of where the sprite is located in the dungeon
87 | * @param {number} y Y coordinate of where the sprite is located in the dungeon
88 | * @return {creature} The created creature object is returned to the caller
89 | */
90 | _generic: function (name, hp, str, def, crit, expgain, sprite, frame, x, y) {
91 | return {
92 | name: name,
93 | hp: hp,
94 | max_hp: hp,
95 | str: str,
96 | def: def,
97 | crit: crit, //The lower this value is the higher the chance of a critical hit
98 | expgain: expgain,
99 | sprite: sprite,
100 | frame: frame,
101 | x: x,
102 | y: y,
103 | isDead: 0,
104 | /**
105 | * Moves the changes the x and y coordinate of the creature
106 | * @param {number} _x Tells the creature where to move relative to its current position
107 | * @param {number} _y Tells the creature where to move relative to its current position
108 | */
109 | move: function (_x, _y) {
110 | if (this.isDead === 0) { //cannot move if dead
111 | this.x += _x;
112 | this.y += _y;
113 | }
114 | if (this.name === 'Skeleton' && this.isDead === 1) { //Skeletons may revive each turn
115 | var revive = Math.floor(Math.random() * 10);
116 | if (revive === 1) {
117 | this.isDead = 0;
118 | }
119 | }
120 | },
121 | /**
122 | * Performs any action that must be done upon death (ex. item drop)
123 | */
124 | die: function () {},
125 | /**
126 | * Performs any non attack action that the player may do to the creature (ex. talk)
127 | */
128 | interact: function () {
129 | //This function is for if the player runs into the creature without intent to attack.
130 | },
131 | /**
132 | * Perform a special creature specific action that isnt an attack. (ex. fairy teleport)
133 | */
134 | special: function () {
135 | //This is for any special move that the creature can perform, outside of the attack.
136 | },
137 | /**
138 | * The creature attacks the creature that is passed to it. Calculations are made to determine damage given.
139 | *
140 | * @param {creature} creature The creature that is being attacked
141 | */
142 | attack: function (creature) {
143 | //This is called when the creature attacks
144 | var damage = this.str;
145 | if (Math.floor(Math.random() * this.crit) === 1) {
146 | damage *= 2; // Critical Hit double the damage.
147 |
148 | console.log('CRITICAL HIT!');
149 | }
150 | if (this.name === 'Snake' && Math.floor(Math.random() * 5) === 1) {
151 | creature.isPoisoned = 1;
152 | creature.poisonTimer = 10;
153 | console.log('Player poisoned');
154 | }
155 | damage -= creature.def;
156 | creature.hp -= damage;
157 |
158 | console.log('Creature did ' + damage + ' damage');
159 | console.log('Player health now ' + creature.hp);
160 |
161 | if (creature.hp <= 0) {
162 | creature.hp = 0;
163 | creature.isDead = 1;
164 | creature.frame = 0;
165 | }
166 | }
167 | };
168 | },
169 |
170 | /**
171 | * A factory that creates the player based upon the data given
172 | * @param {string} name Name is 'Player' !!DO NOT CHANGE THIS!!
173 | * @param {number} hp Health of the player, will also become the max_hp
174 | * @param {number} str Strength of the player
175 | * @param {number} def Defense of the player
176 | * @param {number} crit Critical hit ratio
177 | * @param {string} Class Name of the class the player is
178 | * @return {creature} Returns the created player to the caller
179 | */
180 | _makePlayer: function (name, hp, str, def, crit, Class) {
181 | return {
182 | name: name,
183 | level: 1,
184 | exp: 0,
185 | hp: hp,
186 | max_hp: hp,
187 | str: str,
188 | def: def,
189 | crit: crit, //The lower this value is the higher the chance of a critical hit
190 | isPoisoned: 0,
191 | poisonTimer: 0,
192 | charClass: Class, //The class of the character 'rogue, warrior etc'
193 | isDead: 0, //Not sure if necessary
194 | inventory: ['none', 'none', 'none', 'none', 'none', 'none', 'none', 'none', 'none', 'none'],
195 |
196 | /**
197 | * The playerattacks the creature that is passed to it. Calculations are made to determine damage given.
198 | * @param {creature} creature The creature that is being attacked
199 | */
200 | attack: function (creature) {
201 | var damage = this.str;
202 | if (Math.floor(Math.random() * this.crit) === 1) {
203 | damage *= 2; // Critical Hit double the damage.
204 | }
205 | damage -= creature.def;
206 | creature.hp -= damage;
207 |
208 | console.log('Player did ' + damage + ' damage');
209 | console.log('Monster health is now ' + creature.hp);
210 |
211 | if (creature.hp <= 0) {
212 | creature.hp = 0;
213 | creature.isDead = 1;
214 | creature.frame = 0;
215 | this.exp += (creature.expgain - (this.level * 2));
216 |
217 | if (this.exp >= 100) { //Leveling up system ;D
218 | this.exp -= 100;
219 | this.level += 1;
220 | this.str += 2;
221 | this.def += 1;
222 | this.hp += 3;
223 | }
224 | }
225 | },
226 |
227 | turnTick: function () {
228 | if (this.poisonTimer >= 1) {
229 | this.poisonTimer -= 1;
230 | this.hp -= 1;
231 | console.log('Player suffers from poison' + ' hp now ' + this.hp);
232 | if (this.poisonTimer === 0) {
233 | this.isPoisoned = 0;
234 | console.log('Player no longer poisoned');
235 | }
236 | }
237 | if (this.hp <= 0) {
238 | this.hp = 0;
239 | this.isDead = 1;
240 | }
241 | },
242 |
243 | /**
244 | * Checks if the player has an empty spot in their inventory
245 | *
246 | * @return {number} Returns the index of free space if space is found and -1 if no space is found.
247 | */
248 | checkInventorySpace: function () {
249 | var i;
250 | for (i = 0; i < this.inventory.length; i += 1) {
251 | if (this.inventory[i] === 'none') {
252 | return i;
253 | }
254 | }
255 | return -1;
256 | }
257 | };
258 | },
259 |
260 | /**
261 | * Create a snake at (x, y)
262 | * @param {number} x
263 | * @param {number} y
264 | * @return {creature}
265 | */
266 | snake: function (x, y) {
267 | return this._generic('Snake', 8, 5, 1, 20, 10, 'reptile0', 43, x, y);
268 | },
269 |
270 | /**
271 | * Create a skeleton at (x, y)
272 | * @param {number} x
273 | * @param {number} y
274 | * @return {creature}
275 | */
276 | skeleton: function (x, y) {
277 | return this._generic('Skeleton', 15, 4, 0, 20, 10, 'undead0', 24, x, y);
278 | },
279 |
280 | /**
281 | * Create a fairy at (x, y)
282 | * @param {number} x
283 | * @param {number} y
284 | * @return {creature}
285 | */
286 | fairy: function (x, y) {
287 | return this._generic('Fairy', 25, 4, 0, 20, 10, 'humanoid0', 34, x, y);
288 | },
289 |
290 | /**
291 | * Create the player
292 | * @return {player}
293 | */
294 | player: function () {
295 | return this._makePlayer('Player', 30, 5, 1, 20, 'Warrior');
296 | }
297 | };
298 | });
168 |
169 |
170 |
171 |
172 |
173 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
--------------------------------------------------------------------------------
/out/scripts/bootstrap-dropdown.js:
--------------------------------------------------------------------------------
1 | /* ============================================================
2 | * bootstrap-dropdown.js v2.3.2
3 | * http://getbootstrap.com/2.3.2/javascript.html#dropdowns
4 | * ============================================================
5 | * Copyright 2013 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * ============================================================ */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* DROPDOWN CLASS DEFINITION
27 | * ========================= */
28 |
29 | var toggle = '[data-toggle=dropdown]'
30 | , Dropdown = function (element) {
31 | var $el = $(element).on('click.dropdown.data-api', this.toggle)
32 | $('html').on('click.dropdown.data-api', function () {
33 | $el.parent().removeClass('open')
34 | })
35 | }
36 |
37 | Dropdown.prototype = {
38 |
39 | constructor: Dropdown
40 |
41 | , toggle: function (e) {
42 | var $this = $(this)
43 | , $parent
44 | , isActive
45 |
46 | if ($this.is('.disabled, :disabled')) return
47 |
48 | $parent = getParent($this)
49 |
50 | isActive = $parent.hasClass('open')
51 |
52 | clearMenus()
53 |
54 | if (!isActive) {
55 | if ('ontouchstart' in document.documentElement) {
56 | // if mobile we we use a backdrop because click events don't delegate
57 | $('').insertBefore($(this)).on('click', clearMenus)
58 | }
59 | $parent.toggleClass('open')
60 | }
61 |
62 | $this.focus()
63 |
64 | return false
65 | }
66 |
67 | , keydown: function (e) {
68 | var $this
69 | , $items
70 | , $active
71 | , $parent
72 | , isActive
73 | , index
74 |
75 | if (!/(38|40|27)/.test(e.keyCode)) return
76 |
77 | $this = $(this)
78 |
79 | e.preventDefault()
80 | e.stopPropagation()
81 |
82 | if ($this.is('.disabled, :disabled')) return
83 |
84 | $parent = getParent($this)
85 |
86 | isActive = $parent.hasClass('open')
87 |
88 | if (!isActive || (isActive && e.keyCode == 27)) {
89 | if (e.which == 27) $parent.find(toggle).focus()
90 | return $this.click()
91 | }
92 |
93 | $items = $('[role=menu] li:not(.divider):visible a', $parent)
94 |
95 | if (!$items.length) return
96 |
97 | index = $items.index($items.filter(':focus'))
98 |
99 | if (e.keyCode == 38 && index > 0) index-- // up
100 | if (e.keyCode == 40 && index < $items.length - 1) index++ // down
101 | if (!~index) index = 0
102 |
103 | $items
104 | .eq(index)
105 | .focus()
106 | }
107 |
108 | }
109 |
110 | function clearMenus() {
111 | $('.dropdown-backdrop').remove()
112 | $(toggle).each(function () {
113 | getParent($(this)).removeClass('open')
114 | })
115 | }
116 |
117 | function getParent($this) {
118 | var selector = $this.attr('data-target')
119 | , $parent
120 |
121 | if (!selector) {
122 | selector = $this.attr('href')
123 | selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
124 | }
125 |
126 | $parent = selector && $(selector)
127 |
128 | if (!$parent || !$parent.length) $parent = $this.parent()
129 |
130 | return $parent
131 | }
132 |
133 |
134 | /* DROPDOWN PLUGIN DEFINITION
135 | * ========================== */
136 |
137 | var old = $.fn.dropdown
138 |
139 | $.fn.dropdown = function (option) {
140 | return this.each(function () {
141 | var $this = $(this)
142 | , data = $this.data('dropdown')
143 | if (!data) $this.data('dropdown', (data = new Dropdown(this)))
144 | if (typeof option == 'string') data[option].call($this)
145 | })
146 | }
147 |
148 | $.fn.dropdown.Constructor = Dropdown
149 |
150 |
151 | /* DROPDOWN NO CONFLICT
152 | * ==================== */
153 |
154 | $.fn.dropdown.noConflict = function () {
155 | $.fn.dropdown = old
156 | return this
157 | }
158 |
159 |
160 | /* APPLY TO STANDARD DROPDOWN ELEMENTS
161 | * =================================== */
162 |
163 | $(document)
164 | .on('click.dropdown.data-api', clearMenus)
165 | .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
166 | .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
167 | .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
168 |
169 | }(window.jQuery);
170 |
--------------------------------------------------------------------------------
/out/scripts/bootstrap-tab.js:
--------------------------------------------------------------------------------
1 | /* ========================================================
2 | * bootstrap-tab.js v2.3.0
3 | * http://twitter.github.com/bootstrap/javascript.html#tabs
4 | * ========================================================
5 | * Copyright 2012 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * ======================================================== */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* TAB CLASS DEFINITION
27 | * ==================== */
28 |
29 | var Tab = function (element) {
30 | this.element = $(element)
31 | }
32 |
33 | Tab.prototype = {
34 |
35 | constructor: Tab
36 |
37 | , show: function () {
38 | var $this = this.element
39 | , $ul = $this.closest('ul:not(.dropdown-menu)')
40 | , selector = $this.attr('data-target')
41 | , previous
42 | , $target
43 | , e
44 |
45 | if (!selector) {
46 | selector = $this.attr('href')
47 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
48 | }
49 |
50 | if ( $this.parent('li').hasClass('active') ) return
51 |
52 | previous = $ul.find('.active:last a')[0]
53 |
54 | e = $.Event('show', {
55 | relatedTarget: previous
56 | })
57 |
58 | $this.trigger(e)
59 |
60 | if (e.isDefaultPrevented()) return
61 |
62 | $target = $(selector)
63 |
64 | this.activate($this.parent('li'), $ul)
65 | this.activate($target, $target.parent(), function () {
66 | $this.trigger({
67 | type: 'shown'
68 | , relatedTarget: previous
69 | })
70 | })
71 | }
72 |
73 | , activate: function ( element, container, callback) {
74 | var $active = container.find('> .active')
75 | , transition = callback
76 | && $.support.transition
77 | && $active.hasClass('fade')
78 |
79 | function next() {
80 | $active
81 | .removeClass('active')
82 | .find('> .dropdown-menu > .active')
83 | .removeClass('active')
84 |
85 | element.addClass('active')
86 |
87 | if (transition) {
88 | element[0].offsetWidth // reflow for transition
89 | element.addClass('in')
90 | } else {
91 | element.removeClass('fade')
92 | }
93 |
94 | if ( element.parent('.dropdown-menu') ) {
95 | element.closest('li.dropdown').addClass('active')
96 | }
97 |
98 | callback && callback()
99 | }
100 |
101 | transition ?
102 | $active.one($.support.transition.end, next) :
103 | next()
104 |
105 | $active.removeClass('in')
106 | }
107 | }
108 |
109 |
110 | /* TAB PLUGIN DEFINITION
111 | * ===================== */
112 |
113 | var old = $.fn.tab
114 |
115 | $.fn.tab = function ( option ) {
116 | return this.each(function () {
117 | var $this = $(this)
118 | , data = $this.data('tab')
119 | if (!data) $this.data('tab', (data = new Tab(this)))
120 | if (typeof option == 'string') data[option]()
121 | })
122 | }
123 |
124 | $.fn.tab.Constructor = Tab
125 |
126 |
127 | /* TAB NO CONFLICT
128 | * =============== */
129 |
130 | $.fn.tab.noConflict = function () {
131 | $.fn.tab = old
132 | return this
133 | }
134 |
135 |
136 | /* TAB DATA-API
137 | * ============ */
138 |
139 | $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
140 | e.preventDefault()
141 | $(this).tab('show')
142 | })
143 |
144 | }(window.jQuery);
--------------------------------------------------------------------------------
/out/scripts/linenumber.js:
--------------------------------------------------------------------------------
1 | /*global document */
2 | (function() {
3 | var source = document.getElementsByClassName('prettyprint source linenums');
4 | var i = 0;
5 | var lineNumber = 0;
6 | var lineId;
7 | var lines;
8 | var totalLines;
9 | var anchorHash;
10 |
11 | if (source && source[0]) {
12 | anchorHash = document.location.hash.substring(1);
13 | lines = source[0].getElementsByTagName('li');
14 | totalLines = lines.length;
15 |
16 | for (; i < totalLines; i++) {
17 | lineNumber++;
18 | lineId = 'line' + lineNumber;
19 | lines[i].id = lineId;
20 | if (lineId === anchorHash) {
21 | lines[i].className += ' selected';
22 | }
23 | }
24 | }
25 | })();
26 |
--------------------------------------------------------------------------------
/out/scripts/prettify/Apache-License-2.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/out/scripts/prettify/lang-css.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([
2 | ["pln", /^[\t\n\f\r ]+/, null, " \t\r\n"]
3 | ], [
4 | ["str", /^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/, null],
5 | ["str", /^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/, null],
6 | ["lang-css-str", /^url\(([^"')]*)\)/i],
7 | ["kwd", /^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i, null],
8 | ["lang-css-kw", /^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],
9 | ["com", /^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],
10 | ["com", /^(?:<\!--|--\>)/],
11 | ["lit", /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],
12 | ["lit", /^#[\da-f]{3,6}/i],
13 | ["pln", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],
14 | ["pun", /^[^\s\w"']+/]
15 | ]), ["css"]);
16 | PR.registerLangHandler(PR.createSimpleLexer([], [
17 | ["kwd", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]
18 | ]), ["css-kw"]);
19 | PR.registerLangHandler(PR.createSimpleLexer([], [
20 | ["str", /^[^"')]+/]
21 | ]), ["css-str"]);
--------------------------------------------------------------------------------
/out/scripts/toc.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.toc = function(options) {
3 | var self = this;
4 | var opts = $.extend({}, jQuery.fn.toc.defaults, options);
5 |
6 | var container = $(opts.container);
7 | var headings = $(opts.selectors, container);
8 | var headingOffsets = [];
9 | var activeClassName = opts.prefix+'-active';
10 |
11 | var scrollTo = function(e) {
12 | if (opts.smoothScrolling) {
13 | e.preventDefault();
14 | var elScrollTo = $(e.target).attr('href');
15 | var $el = $(elScrollTo);
16 |
17 | $('body,html').animate({ scrollTop: $el.offset().top }, 400, 'swing', function() {
18 | location.hash = elScrollTo;
19 | });
20 | }
21 | $('li', self).removeClass(activeClassName);
22 | $(e.target).parent().addClass(activeClassName);
23 | };
24 |
25 | //highlight on scroll
26 | var timeout;
27 | var highlightOnScroll = function(e) {
28 | if (timeout) {
29 | clearTimeout(timeout);
30 | }
31 | timeout = setTimeout(function() {
32 | var top = $(window).scrollTop(),
33 | highlighted;
34 | for (var i = 0, c = headingOffsets.length; i < c; i++) {
35 | if (headingOffsets[i] >= top) {
36 | $('li', self).removeClass(activeClassName);
37 | highlighted = $('li:eq('+(i-1)+')', self).addClass(activeClassName);
38 | opts.onHighlight(highlighted);
39 | break;
40 | }
41 | }
42 | }, 50);
43 | };
44 | if (opts.highlightOnScroll) {
45 | $(window).bind('scroll', highlightOnScroll);
46 | highlightOnScroll();
47 | }
48 |
49 | return this.each(function() {
50 | //build TOC
51 | var el = $(this);
52 | var ul = $('