Commit 3c630ca7 authored by Matthew Odle's avatar Matthew Odle

rename knobsAndLevers to dials

parent cf0b5191
......@@ -40,7 +40,7 @@ var collisions = {
this.removeDestroyedTargets(targets);
},
checkPlayerVsEnemies : function(player, targets) {
if (!knobsAndLevers.game.playerCollisionsEnabled) {
if (!dials.game.playerCollisionsEnabled) {
return;
};
targets.forEach(target => {
......
......@@ -29,8 +29,8 @@ var centipedes = {
this.add(centipede);
},
make : function() {
let centipede = Object.assign(new Component(knobsAndLevers.centipede.args), knobsAndLevers.centipede.defaults);
let pointValue = knobsAndLevers.centipede.pointValue;
let centipede = Object.assign(new Component(dials.centipede.args), dials.centipede.defaults);
let pointValue = dials.centipede.pointValue;
centipede.pointValue = supporting.getRandom(pointValue, pointValue + 20);
centipede.sound = sounds.getSound('centipede');
return centipede;
......@@ -61,8 +61,8 @@ var centipedes = {
this.buildCentipedeStructure();
},
buildCentipedeStructure : function() {
let tier = knobsAndLevers.game.tier;
this.segments = tier.current * 2 + knobsAndLevers.centipede.maxNumber;
let tier = dials.game.tier;
this.segments = tier.current * 2 + dials.centipede.maxNumber;
this.positions = [];
let upperLimit = tier.isMaxed ? tier.max : tier.current;
while (this.positions.length < supporting.getRandom(1, upperLimit)) {
......@@ -77,7 +77,7 @@ var centipedes = {
return this.numberSpawned < this.segments;
},
setXPosition : function() {
knobsAndLevers.centipede.args.x = this.positions[this.centipedes.length % this.positions.length];
dials.centipede.args.x = this.positions[this.centipedes.length % this.positions.length];
},
cannotAdd : function(centipede) {
return this.centipedes.find(checkCentipede => checkCentipede.crashWith(centipede));
......@@ -103,7 +103,7 @@ var centipedes = {
if (centipede.getBottom() > game.gameArea.canvas.height) {
centipede.reverseDirectionY = true;
centipede.poisoned = false;
} else if (centipede.getTop() < knobsAndLevers.player.topLimit && centipede.distanceMovedFromBottom > 0) {
} else if (centipede.getTop() < dials.player.topLimit && centipede.distanceMovedFromBottom > 0) {
centipede.reverseDirectionY = true;
centipede.distanceMovedFromBottom = 0;
};
......
......@@ -7,9 +7,9 @@ var gameObjects = {
Object.assign(this, gameObjectsBase);
supporting.applyOverrides(this);
this.intervals = {
fleas : knobsAndLevers.fleas.initialInterval,
worms : knobsAndLevers.worms.initialInterval,
spiders : knobsAndLevers.spiders.initialInterval,
fleas : dials.fleas.initialInterval,
worms : dials.worms.initialInterval,
spiders : dials.spiders.initialInterval,
};
console.log('gameObjects initialized');
},
......@@ -26,14 +26,14 @@ var gameObjects = {
},
spawn : function(type) {
this.setMax(type);
if (this[type].length >= knobsAndLevers[type].maxNumber) {
if (this[type].length >= dials[type].maxNumber) {
return;
};
this.make(type);
},
make : function(type) {
let spawnedCreature = new Component(knobsAndLevers[type].args);
let pointValue = knobsAndLevers[type].pointValue;
let spawnedCreature = new Component(dials[type].args);
let pointValue = dials[type].pointValue;
spawnedCreature.pointValue = supporting.getRandom(pointValue, pointValue + 400);
spawnedCreature.sound = sounds.getSound(type);
this[type].push(spawnedCreature);
......@@ -71,26 +71,26 @@ var gameObjects = {
},
spawnCreatureAtIntervals(type) {
if (supporting.everyinterval(game.gameArea.frameNo, this.intervals[type])) {
this.intervals[type] = supporting.getRandom(knobsAndLevers[type].interval.min, knobsAndLevers[type].interval.max);
this.intervals[type] = supporting.getRandom(dials[type].interval.min, dials[type].interval.max);
this.spawn(type);
if (type == 'fleas') {
knobsAndLevers.fleas.mushroomCreateInterval = supporting.getRandom(75, 150);
dials.fleas.mushroomCreateInterval = supporting.getRandom(75, 150);
};
};
},
setMax : function(type) {
let tier = knobsAndLevers.game.tier;
knobsAndLevers[type].maxNumber = tier.isMaxed ? tier.max : tier.current;
let tier = dials.game.tier;
dials[type].maxNumber = tier.isMaxed ? tier.max : tier.current;
},
setSpeed : function(creature, type) {
let speedLimits = knobsAndLevers[type].speedLimits;
let speedLimits = dials[type].speedLimits;
creature.speedX = Math.sign(creature.speedX) * (supporting.roll(10).crit ? speedLimits.max : speedLimits.min);
creature.speedY = creature.directionY * (supporting.roll(10).crit ? speedLimits.max : speedLimits.min);
},
setDirection : function(creature) {
if (creature.getBottom() > game.gameArea.canvas.height) {
creature.directionY = -1;
} else if (creature.getTop() < game.gameArea.canvas.height - (knobsAndLevers.player.areaHeight * 2)) {
} else if (creature.getTop() < game.gameArea.canvas.height - (dials.player.areaHeight * 2)) {
creature.directionY = 1;
};
},
......@@ -102,7 +102,7 @@ var gameObjects = {
eligibleToDrop : function() {
return supporting.everyinterval(
game.gameArea.frameNo,
knobsAndLevers.fleas.mushroomCreateInterval
dials.fleas.mushroomCreateInterval
);
},
removeMushrooms : function(creature) {
......
......@@ -29,8 +29,8 @@ var lasers = {
this.lasers[player.name].push(this.make(player));
},
make : function(player) {
let laserArgs = knobsAndLevers.lasers.args;
laserArgs.extraArgs.speed.y = -1 * knobsAndLevers.lasers.speed.value;
let laserArgs = dials.lasers.args;
laserArgs.extraArgs.speed.y = -1 * dials.lasers.speed.value;
laserArgs.x = player.x + player.width / 2;
laserArgs.y = player.y;
return new Component(laserArgs);
......@@ -49,9 +49,9 @@ var lasers = {
},
},
eligibleToSpawn : function(player) {
let eligible = this.lasers[player.name].length < knobsAndLevers.lasers.quantity.value
let eligible = this.lasers[player.name].length < dials.lasers.quantity.value
&& supporting.everyinterval(
game.gameArea.frameNo, knobsAndLevers.lasers.interval
game.gameArea.frameNo, dials.lasers.interval
)
&& controls.isFiring(player);
return eligible;
......
......@@ -9,7 +9,7 @@ var mushrooms = {
functionOverrides : {
manage : function() {
if (game.gameArea.frameNo == 1) {
this.spawn(knobsAndLevers.mushrooms.initialAmount);
this.spawn(dials.mushrooms.initialAmount);
};
this.update();
},
......@@ -19,17 +19,17 @@ var mushrooms = {
coordinates = this.getCoordinates();
// while it is possible this will be an infinite loop
// it is unlikely so long as maxMushrooms is reasonable
if (coordinates.y > knobsAndLevers.player.topLimit) {
if (coordinates.y > dials.player.topLimit) {
continue;
};
this.make(coordinates, knobsAndLevers.mushrooms.color);
this.make(coordinates, dials.mushrooms.color);
};
},
make : function(coordinates, color) {
if (coordinates.x == undefined || coordinates.y == undefined) {
throw new Error('coordinate error: x: ' + coordinates.x + ', y: ' + coordinates.y);
};
color = color ? color : knobsAndLevers.mushrooms.color;
color = color ? color : dials.mushrooms.color;
coordinates.x = supporting.getClosest(game.gameArea.xVertices, coordinates.x);
coordinates.y = supporting.getClosest(game.gameArea.yVertices, coordinates.y);
let mushroom = this.generate(coordinates, color);
......@@ -39,9 +39,9 @@ var mushrooms = {
this.mushrooms.push(mushroom);
},
generate : function(coordinates, color) {
let mushroom = new Component(knobsAndLevers.mushrooms.args);
mushroom.x = coordinates.x + knobsAndLevers.mushrooms.scaleFactor,
mushroom.y = coordinates.y + knobsAndLevers.mushrooms.scaleFactor,
let mushroom = new Component(dials.mushrooms.args);
mushroom.x = coordinates.x + dials.mushrooms.scaleFactor,
mushroom.y = coordinates.y + dials.mushrooms.scaleFactor,
mushroom.pointValue = metrics.currentLevel;
return mushroom;
},
......
......@@ -2,13 +2,13 @@ players = {
currentSelection : undefined,
init : function() {
Object.assign(this, playersBase);
this.buildPlayers(game.numberOfPlayers, knobsAndLevers.player.args);
this.buildPlayers(game.numberOfPlayers, dials.player.args);
supporting.applyOverrides(this);
console.log('players initialized');
},
functionOverrides : {
setBoundaries : function(player) {
this.boundaries.belowTop = player.getTop() > knobsAndLevers.player.topLimit;
this.boundaries.belowTop = player.getTop() > dials.player.topLimit;
this.boundaries.insideRight = player.getRight() < game.gameArea.canvas.width;
this.boundaries.aboveBottom = player.getBottom() < game.gameArea.canvas.height;
this.boundaries.insideLeft = player.getLeft() > 0;
......
var game = {
init : function() {
Object.assign(this, gameBase);
this.gameArea.init(knobsAndLevers);
this.gameArea.init(dials);
supporting.applyOverrides(this);
console.log('game initialized');
},
......
......@@ -2,7 +2,7 @@ var init = {
run : function() {
console.log('start centipede init');
knobsAndLevers.init();
dials.init();
dom.init();
game.init();
......@@ -26,7 +26,7 @@ var init = {
},
afterGameOver : function() {
console.log('reset everything');
knobsAndLevers.init();
dials.init();
menus.init();
metrics.init();
texts.init();
......
......@@ -7,8 +7,8 @@
* init/runner.js accomplishes this.
*/
// var libsPath = '../canvas-libs/app/scripts/';
var libsPath = 'libs/app/scripts/';
var libsPath = '../canvas-libs/app/scripts/';
// var libsPath = 'libs/app/scripts/';
var scriptsPath = 'app/scripts/';
var libs = [
......
// abstract common knobsAndLevers and move them to canvas-libs
var knobsAndLevers = {
// abstract common dials and move them to canvas-libs
var dials = {
init : function() {
this.general.init(this);
this.centipede.init(this);
......@@ -10,7 +10,7 @@ var knobsAndLevers = {
this.spiders.init(this);
this.text.init(this);
this.worms.init(this);
console.log('knobsAndLevers initialized');
console.log('dials initialized');
},
resetCheats : function() {
this.lasers.resetCheats();
......@@ -88,6 +88,11 @@ var knobsAndLevers = {
components : {
imageTypes : ['centipede', 'flea', 'worm', 'mushroom', 'spider', 'player'],
},
dom : {
blogUrl : 'http://blog.matthewodle.com/category/centipede/',
sourceUrl : 'https://gitlab.com/taciturn-pachyderm/centipede',
gifLocation : 'app/static/media/images/background.gif',
},
fleas : {
maxNumber : 0,
pointValue : 200,
......@@ -110,7 +115,7 @@ var knobsAndLevers = {
return 'one';
},
constructorFunctions : {
setX : function(flea) { flea.x = supporting.getRandom(0, knobsAndLevers.canvas.width) },
setX : function(flea) { flea.x = supporting.getRandom(0, dials.canvas.width) },
}
},
init : function(configs) {
......@@ -190,8 +195,8 @@ var knobsAndLevers = {
console.log('laser defaults initialized');
},
resetCheats : function() {
knobsAndLevers.resetParameter(this.speed);
knobsAndLevers.resetParameter(this.quantity);
dials.resetParameter(this.speed);
dials.resetParameter(this.quantity);
},
},
mushrooms : {
......@@ -243,7 +248,7 @@ var knobsAndLevers = {
},
constructorFunctions : {
setX : function(player) {
player.x = knobsAndLevers.player.startX[Object.keys(players.players).length];
player.x = dials.player.startX[Object.keys(players.players).length];
},
},
},
......@@ -270,7 +275,7 @@ var knobsAndLevers = {
this.args.y = this.startY;
},
resetCheats : function() {
knobsAndLevers.resetParameter(this.speed);
dials.resetParameter(this.speed);
},
},
spiders : {
......@@ -296,7 +301,7 @@ var knobsAndLevers = {
},
constructorFunctions : {
setY : function(spider) {
spider.y = supporting.getRandom(knobsAndLevers.player.topLimit - knobsAndLevers.player.areaHeight, game.gameArea.canvas.height);
spider.y = supporting.getRandom(dials.player.topLimit - dials.player.areaHeight, game.gameArea.canvas.height);
},
setX : function(spider) {
let theRoll = supporting.roll(sides = 2);
......@@ -390,7 +395,7 @@ var knobsAndLevers = {
};
},
setY : function(worm) {
let randomYPos = supporting.getRandom(0, knobsAndLevers.player.topLimit - knobsAndLevers.player.areaHeight * 2);
let randomYPos = supporting.getRandom(0, dials.player.topLimit - dials.player.areaHeight * 2);
worm.y = supporting.getClosest(game.gameArea.yVertices, randomYPos);
},
},
......
......@@ -50,33 +50,33 @@ var menusProps = {
// TODO demigod - a ton of lives
laserQTY : {
update : function() {
this.text = knobsAndLevers.lasers.quantity.setting.render();
this.text = dials.lasers.quantity.setting.render();
},
action : function() {
knobsAndLevers.toggleParameter(knobsAndLevers.lasers.quantity);
game.activeCheats['laserQty'] = knobsAndLevers.lasers.quantity.setting.state == "ON";
dials.toggleParameter(dials.lasers.quantity);
game.activeCheats['laserQty'] = dials.lasers.quantity.setting.state == "ON";
this.update();
menus.display('cheats');
},
},
laserSpeed : {
update : function() {
this.text = knobsAndLevers.lasers.speed.setting.render();
this.text = dials.lasers.speed.setting.render();
},
action : function() {
knobsAndLevers.toggleParameter(knobsAndLevers.lasers.speed);
game.activeCheats['laserSpeed'] = knobsAndLevers.lasers.speed.setting.state == "ON";
dials.toggleParameter(dials.lasers.speed);
game.activeCheats['laserSpeed'] = dials.lasers.speed.setting.state == "ON";
this.update();
menus.display('cheats');
},
},
shipSpeed : {
update : function() {
this.text = knobsAndLevers.player.speed.setting.render();
this.text = dials.player.speed.setting.render();
},
action : function() {
knobsAndLevers.toggleParameter(knobsAndLevers.player.speed);
game.activeCheats['shipSpeed'] = knobsAndLevers.player.speed.setting.state == "ON";
dials.toggleParameter(dials.player.speed);
game.activeCheats['shipSpeed'] = dials.player.speed.setting.state == "ON";
this.update();
menus.display('cheats');
},
......@@ -84,7 +84,7 @@ var menusProps = {
reset : {
text : 'RESET',
action : function() {
knobsAndLevers.resetCheats();
dials.resetCheats();
menus.screens.cheats.update();
menus.display('cheats');
},
......@@ -248,12 +248,12 @@ var menusProps = {
// can't really do anything with centipede speed until the vertical movement logic gets
sound : {
update : function() {
this.text = knobsAndLevers.game.sounds.setting.render();
this.text = dials.game.sounds.setting.render();
},
action : function() {
knobsAndLevers.toggleParameter(knobsAndLevers.game.sounds);
dials.toggleParameter(dials.game.sounds);
this.update();
if (knobsAndLevers.game.sounds.value) {
if (dials.game.sounds.value) {
sounds.playAvailableLaserSound();
};
menus.display('settings');
......
......@@ -8,7 +8,7 @@ var sounds = {
died : {filename : 'player-died.mp3', volume : 0.3, qty : 1, pool : [], index : 0},
tierChange : {filename : 'tier-change.mp3', volume : 0.3, qty : 1, pool : [], index : 0},
laser : {filename : 'laser.mp3', volume : 0.3, qty : 20, pool : [], index : 0},
impact : {filename : 'laser-impact.mp3', volume : 0.3, qty : knobsAndLevers.lasers.quantity.value, pool : [], index : 0},
impact : {filename : 'laser-impact.mp3', volume : 0.3, qty : dials.lasers.quantity.value, pool : [], index : 0},
},
init : function() {
Object.assign(this, soundsBase);
......
......@@ -8,10 +8,10 @@ describe('COLLISIONS SPEC: ', () => {
});
beforeEach(function () {
testObj = Object.assign({}, collisions);
knobsAndLevers.init();
dials.init();
});
function createAnObjectFromLaserArgs() {
let laserArgs = knobsAndLevers.lasers.args;
let laserArgs = dials.lasers.args;
laserArgs.x = 10;
laserArgs.y = 10;
laserArgs.width = 10;
......@@ -137,7 +137,7 @@ describe('COLLISIONS SPEC: ', () => {
it('updateTargetAppearance adjusts height of target when target type is mushroom', () => {
let baseHeight = knobsAndLevers.mushroomSide;
let baseHeight = dials.mushroomSide;
let target1 = {type : 'mushroom', height : baseHeight};
let target2 = {type : 'somethingElse', height : baseHeight};
......@@ -191,7 +191,7 @@ describe('COLLISIONS SPEC: ', () => {
});
it('checkPlayerVsEnemies does not process if playerCollisions are disabled', () => {
knobsAndLevers.game.playerCollisionsEnabled = false;
dials.game.playerCollisionsEnabled = false;
game.gameOver = false;
player.init();
spyOn(player.gamePiece, 'crashWith').and.returnValue(true);
......@@ -205,7 +205,7 @@ describe('COLLISIONS SPEC: ', () => {
expect(game.gameOver).toBeFalsy();
});
it('checkPlayerVsEnemies calls killsPlayer if crashWith', () => {
knobsAndLevers.game.playerCollisionsEnabled = true;
dials.game.playerCollisionsEnabled = true;
game.gameOver = false;
player.init();
spyOn(player.gamePiece, 'crashWith').and.returnValue(true);
......@@ -220,7 +220,7 @@ describe('COLLISIONS SPEC: ', () => {
expect(game.gameOver).toBeFalsy();
});
it('checkGamePieceVsEnemy handles 0 length target list', () => {
knobsAndLevers.game.playerCollisionsEnabled = true;
dials.game.playerCollisionsEnabled = true;
game.gameOver = false;
player.init();
spyOn(player.gamePiece, 'crashWith').and.callThrough();
......
......@@ -8,7 +8,7 @@ describe('COMPONENT SPEC: ', () => {
});
beforeEach(function () {
component = constructComponent({});
knobsAndLevers.init();
dials.init();
game.init();
});
function constructComponent(args) {
......
......@@ -119,7 +119,7 @@ describe('CENTIPEDES SPEC: ', () => {
);
});
it('moveDownwardInitially sets moveVertically and updated to true if above first mushroom layer', () => {
knobsAndLevers.init();
dials.init();
game.init();
testObj.centipedes = [
{moveVertically : false, updated : false, y : game.gameArea.gridStart - 2},
......@@ -159,10 +159,10 @@ describe('CENTIPEDES SPEC: ', () => {
expect(testObj.centipedes[0].reverseDirectionY).toBe(true);
});
it('checkYDirectionInPlayerArea sets reverseDirectionY when hitting playerTopLimit while moving up', () => {
knobsAndLevers.init();
dials.init();
game.init();
player.init();
let top = knobsAndLevers.player.topLimit - 10;
let top = dials.player.topLimit - 10;
let bottom = top + 20;
testObj.centipedes = [
{
......@@ -181,7 +181,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(testObj.centipedes[0].reverseDirectionY).toBe(true);
});
it('checkHorizontalCollisions does not set moveVertically to true if no collisions', () => {
knobsAndLevers.init();
dials.init();
game.init();
spyOn(testObj, 'hasCollidedWithWall').and.returnValue(false);
spyOn(testObj, 'hasCollidedWithMushroom').and.returnValue(false);
......@@ -198,7 +198,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(centipede.updated).toBe(true);
});
it('checkHorizontalCollisions sets moveVertically to true if wall collisions', () => {
knobsAndLevers.init();
dials.init();
game.init();
spyOn(testObj, 'hasCollidedWithWall').and.returnValue(true);
spyOn(testObj, 'hasCollidedWithMushroom').and.returnValue(false);
......@@ -218,7 +218,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(centipede.moveVertically).toBe(true);
});
it('checkHorizontalCollisions sets moveVertically to true if mushroom collisions but not wall collisions', () => {
knobsAndLevers.init();
dials.init();
game.init();
spyOn(testObj, 'hasCollidedWithWall').and.returnValue(false);
spyOn(testObj, 'hasCollidedWithMushroom').and.returnValue(true);
......@@ -238,7 +238,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(centipede.moveVertically).toBe(true);
});
it('checkHorizontalCollisions does not update if distanceMovedY is not 0', () => {
knobsAndLevers.init();
dials.init();
game.init();
spyOn(testObj, 'hasCollidedWithWall').and.returnValue(false);
spyOn(testObj, 'hasCollidedWithMushroom').and.returnValue(false);
......@@ -255,7 +255,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(centipede.updated).toBe(false);
});
it('hasCollidedWithWall should return false if inside canvas sides and has moved horizontally', () => {
knobsAndLevers.init();
dials.init();
game.init();
let centipede = {
getLeft : function(){return 10;},
......@@ -269,7 +269,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(actual).toBe(expected);
});
it('hasCollidedWithWall should return true if outside canvas sides and has moved horizontally', () => {
knobsAndLevers.init();
dials.init();
game.init();
let centipede = {
getLeft : function(){return 10;},
......@@ -283,7 +283,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(actual).toBe(expected);
});
it('hasCollidedWithMushrooms does a whole bunch of crap I do not want to test', () => {
knobsAndLevers.init();
dials.init();
game.init();
mushrooms.mushrooms = [{y : 1}];
let crashWith = function(){return true;};
......@@ -321,7 +321,7 @@ describe('CENTIPEDES SPEC: ', () => {
});
it('reverseHorizontalAtNextLayer does stuff', () => {
knobsAndLevers.init();
dials.init();
game.init();
centipede = {
updated : false,
......@@ -338,7 +338,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(centipede.reverseDirectionX).toBe(true);
});
it('updateDirections does stuff', () => {
knobsAndLevers.init();
dials.init();
game.init();
testObj.centipedes = [
{
......@@ -371,7 +371,7 @@ describe('CENTIPEDES SPEC: ', () => {
expect(testObj.centipedes[1].reverseDirectionX).toBe(false);
});
it('updateCoordinates does stuff', () => {
knobsAndLevers.init();
dials.init();
game.init();
let defaults = {
moveVertically : true,
......
......@@ -7,7 +7,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
console.log(spec + ' SPEC complete');
});
beforeEach(function () {
knobsAndLevers.init();
dials.init();
game.init();
testObj = Object.assign({}, gameObjects);
testObj.init();
......@@ -90,7 +90,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
it('eligibleToDrop returns false if not valid interval', () => {
game.frameNo = 1;
knobsAndLevers.fleas.mushroomCreateInterval = 2;
dials.fleas.mushroomCreateInterval = 2;
let canDrop = testObj.eligibleToDrop();
expect(canDrop).toBeFalsy();
......@@ -98,7 +98,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
it('spawn once creates one worm', () => {
testObj.worms = []
knobsAndLevers.worms.maxNumber = 1;
dials.worms.maxNumber = 1;
spyOn(testObj, 'executeConstructorFunctions');
spyOn(testObj, 'make');
......@@ -108,11 +108,11 @@ describe('INTERVAL CREATURES SPEC: ', () => {
expect(testObj.make).toHaveBeenCalled();
});
it('spawn more than max worms does not create more than max worms', () => {
for (let i = 0; i < knobsAndLevers.worms.maxNumber + 100; i++) {
for (let i = 0; i < dials.worms.maxNumber + 100; i++) {
testObj.spawn('worms');
};
expect(testObj.worms.length).toBe(knobsAndLevers.worms.maxNumber);
expect(testObj.worms.length).toBe(dials.worms.maxNumber);
});
it('update calls component.newPos', () => {
testObj.worms = [{newPos : function(){}, update : function(){}}];
......
......@@ -48,13 +48,13 @@ describe('LASERS SPEC: ', () => {
it('eligibleToSpawn returns false if lasers is at max', () => {
testObj.lasers = [];
while (testObj.lasers.length < knobsAndLevers.lasers.quantity.value) {
while (testObj.lasers.length < dials.lasers.quantity.value) {
testObj.lasers.push({});
};
spyOn(supporting, 'everyinterval').and.returnValue(true);
spyOn(controls, 'isFiring').and.returnValue(true);
expect(testObj.lasers.length).toBe(knobsAndLevers.lasers.quantity.value);
expect(testObj.lasers.length).toBe(dials.lasers.quantity.value);
let spawnEligibility = testObj.eligibleToSpawn();
......@@ -67,7 +67,7 @@ describe('LASERS SPEC: ', () => {
spyOn(supporting, 'everyinterval').and.returnValue(true);
spyOn(controls, 'isFiring').and.returnValue(true);
expect(testObj.lasers.length).toBeLessThan(knobsAndLevers.lasers.quantity.value);
expect(testObj.lasers.length).toBeLessThan(dials.lasers.quantity.value);
let spawnEligibility = testObj.eligibleToSpawn();
......@@ -87,11 +87,11 @@ describe('LASERS SPEC: ', () => {
});
it('make laser makes a laser', () => {
knobsAndLevers.init();
dials.init();
player.init();
let laser = testObj.make();
expect(laser.speedY).toBe(-knobsAndLevers.lasers.speed.value);
expect(laser.speedY).toBe(-dials.lasers.speed.value);
expect(laser.x).toBe(player.gamePiece.x + player.gamePiece.width / 2);
expect(laser.y).toBe(player.gamePiece.y);
})
......
......@@ -93,7 +93,7 @@ describe('METRICS SPEC: ', () => {
testObj.reset();
expect(testObj.lives).toBe(knobsAndLevers.player.defaultLives);
expect(testObj.lives).toBe(dials.player.defaultLives);
expect(testObj.currentLevel).toBe(1);
expect(testObj.score.value).toBe(0);
});
......
......@@ -8,7 +8,7 @@ describe('MUSHROOMS SPEC: ', () => {
});
beforeEach(function () {
testObj = Object.assign({}, mushrooms);
knobsAndLevers.init();
dials.init();
game.init();
});
it('manage calls spawn and update on frame 1', () => {
......@@ -64,7 +64,7 @@ describe('MUSHROOMS SPEC: ', () => {
});
it('update calls update on mushroom objects', () => {
knobsAndLevers.mushrooms.scaleFactor = 0.1
dials.mushrooms.scaleFactor = 0.1
let coordinates = {hitPoints: 5, x: 5, y: 5};
testObj.mushrooms = [{hitPoints: 5, x: 5.1, y: 5.1}];
......
......@@ -42,7 +42,7 @@ describe('PLAYER SPEC: ', () => {
});
it('reset resets position and calls removeMushroomsFromStartingArea', () => {
testObj.init();
let expected = {x : knobsAndLevers.gamePieceStartX, y : knobsAndLevers.gamePieceStartY};
let expected = {x : dials.gamePieceStartX, y : dials.gamePieceStartY};
testObj.gamePiece.x = expected.x - 1;
testObj.gamePiece.y = expected.y - 1;
spyOn(testObj, 'removeMushroomsFromStartingArea');
......
......@@ -8,10 +8,10 @@ describe('SPIDERS SPEC: ', () => {
});