Commit f3bd0145 authored by Matthew Odle's avatar Matthew Odle

rename fly to flea

parent 68130a16
......@@ -17,7 +17,7 @@ var collisions = {
targets.push(...mushrooms.mushrooms);
targets.push(...centipedes.centipedes);
targets.push(...gameObjects.worms);
targets.push(...gameObjects.flies);
targets.push(...gameObjects.fleas);
targets.push(...gameObjects.spiders);
return targets;
},
......@@ -72,7 +72,7 @@ var collisions = {
getPlayerEnemies : function() {
targets = [];
targets.push(...centipedes.centipedes);
targets.push(...gameObjects.flies);
targets.push(...gameObjects.fleas);
targets.push(...gameObjects.spiders);
return targets;
},
......@@ -102,7 +102,7 @@ var collisions = {
mushrooms.mushrooms = mushrooms.mushrooms.filter(mushroom => mushroom.hitPoints > 0);
centipedes.centipedes = centipedes.centipedes.filter(centipede => centipede.hitPoints > 0);
gameObjects.worms = gameObjects.worms.filter(worm => worm.hitPoints > 0);
gameObjects.flies = gameObjects.flies.filter(fly => fly.hitPoints > 0);
gameObjects.fleas = gameObjects.fleas.filter(flea => flea.hitPoints > 0);
gameObjects.spiders = gameObjects.spiders.filter(spider => spider.hitPoints > 0);
},
};
/*jslint white: true */
var gameObjects = {
worms : [],
flies : [],
fleas : [],
spiders : [],
init : function() {
this.intervals = {
flies : knobsAndLevers.flies.initialInterval,
fleas : knobsAndLevers.fleas.initialInterval,
worms : knobsAndLevers.worms.initialInterval,
spiders : knobsAndLevers.spiders.initialInterval,
};
......@@ -25,8 +25,8 @@ var gameObjects = {
if (supporting.everyinterval(game.gameArea.frameNo, this.intervals[type])) {
this.intervals[type] = supporting.getRandom(knobsAndLevers[type].interval.min, knobsAndLevers[type].interval.max);
this.spawn(type);
if (type == 'flies') {
knobsAndLevers.flies.mushroomCreateInterval = supporting.getRandom(75, 150);
if (type == 'fleas') {
knobsAndLevers.fleas.mushroomCreateInterval = supporting.getRandom(75, 150);
};
};
},
......@@ -62,7 +62,7 @@ var gameObjects = {
this.setDirection(creature);
this.removeMushrooms(creature);
};
if (type == 'flies') {
if (type == 'fleas') {
this.dropMushrooms(creature);
};
if (type == 'worms') {
......@@ -92,7 +92,7 @@ var gameObjects = {
eligibleToDrop : function() {
return supporting.everyinterval(
game.gameArea.frameNo,
knobsAndLevers.flies.mushroomCreateInterval
knobsAndLevers.fleas.mushroomCreateInterval
);
},
removeMushrooms : function(creature) {
......@@ -112,7 +112,7 @@ var gameObjects = {
},
clear : function() {
this.worms = [];
this.flies = [];
this.fleas = [];
this.spiders = [];
},
};
......@@ -3,7 +3,7 @@ var knobsAndLevers = {
init : function() {
this.general.init(this);
this.centipede.init(this);
this.flies.init(this);
this.fleas.init(this);
this.player.init(this);
this.lasers.init(this);
this.mushrooms.init(this);
......@@ -86,9 +86,9 @@ var knobsAndLevers = {
},
},
components : {
imageTypes : ['centipede', 'fly', 'worm', 'mushroom', 'spider', 'player'],
imageTypes : ['centipede', 'flea', 'worm', 'mushroom', 'spider', 'player'],
},
flies : {
fleas : {
maxNumber : 0,
pointValue : 200,
interval : {
......@@ -100,7 +100,7 @@ var knobsAndLevers = {
extraArgs : {
animationInterval : 50,
hitPoints : 2,
type : 'fly',
type : 'flea',
speed : {x : 0, y : 2},
},
sprites : {
......@@ -110,7 +110,7 @@ var knobsAndLevers = {
return 'one';
},
constructorFunctions : {
setX : function(fly) { fly.x = supporting.getRandom(0, knobsAndLevers.canvas.width) },
setX : function(flea) { flea.x = supporting.getRandom(0, knobsAndLevers.canvas.width) },
}
},
init : function(configs) {
......@@ -119,7 +119,7 @@ var knobsAndLevers = {
this.args.height = configs.general.gridSquareSideLength * 0.75;
this.args.y = -configs.canvas.height / 10;
this.interval = supporting.clone(configs.game.interval);
console.log('flies defaults initialized');
console.log('fleas defaults initialized');
},
},
game : {
......
......@@ -239,8 +239,8 @@ var menusProps = {
entries : {
// difficulty
// easy - no spiders
// hard - 10 flies
// impossible - 100 flies
// hard - 10 fleas
// impossible - 100 fleas
// spider aggression
// high/normal
// centipedes
......
......@@ -5,7 +5,7 @@ var sounds = {
this.tracks = {
centipede : this.buildSound("centipede", 0.5),
spider : this.buildSound("spider", 0.3),
fly : this.buildSound("fly", 0.3),
flea : this.buildSound("flea", 0.3),
worm : this.buildSound("worm", 0.5, "loop"),
playerDied : this.buildSound("player-died", 0.5),
tierChange : this.buildSound("tier-change", 0.3),
......@@ -30,7 +30,7 @@ var sounds = {
};
this.manageCentipedeSounds();
this.manageSpiderSounds();
this.manageFlySounds();
this.manageFleaSounds();
this.manageWormSounds();
},
manageCentipedeSounds : function() {
......@@ -51,9 +51,9 @@ var sounds = {
this.playSound(this.getSound('spider'));
};
},
manageFlySounds : function() {
let sound = this.tracks['fly'];
if (gameObjects.flies != false) {
manageFleaSounds : function() {
let sound = this.tracks['flea'];
if (gameObjects.fleas != false) {
if (!sound.played) {
this.playSound(sound);
};
......@@ -98,7 +98,7 @@ var sounds = {
this.stopSound('centipede');
this.stopSound('spider');
this.stopSound('worm');
this.stopSound('fly');
this.stopSound('flea');
this.stopSound('tierChange');
},
};
......@@ -35,7 +35,7 @@ describe('COLLISIONS SPEC: ', () => {
mushrooms.mushrooms = [];
centipedes.centipedes = [];
gameObjects.worms = [];
gameObjects.flies = ['anObj'];
gameObjects.fleas = ['anObj'];
spiders.spiders = ['anObj'];
targets = testObj.getLaserTargets();
......@@ -182,7 +182,7 @@ describe('COLLISIONS SPEC: ', () => {
it('getPlayerEnemies combines multiple enemy Arrays', () => {
centipedes.centipedes = [];
gameObjects.flies = ['anObj'];
gameObjects.fleas = ['anObj'];
spiders.spiders = ['anObj'];
targets = testObj.getPlayerEnemies();
......@@ -289,7 +289,7 @@ describe('COLLISIONS SPEC: ', () => {
mushrooms.mushrooms = [{hitPoints : 0}, {hitPoints : 1}];
centipedes.centipedes = [{hitPoints : 0}, {hitPoints : 1}];
gameObjects.worms = [{hitPoints : 0}, {hitPoints : 1}];
gameObjects.flies = [{hitPoints : 0}, {hitPoints : 1}];
gameObjects.fleas = [{hitPoints : 0}, {hitPoints : 1}];
spiders.spiders = [{hitPoints : 0}, {hitPoints : 1}];
testObj.removeDestroyedTargets();
......@@ -297,7 +297,7 @@ describe('COLLISIONS SPEC: ', () => {
expect(mushrooms.mushrooms.length).toEqual(1);
expect(centipedes.centipedes.length).toEqual(1);
expect(gameObjects.worms.length).toEqual(1);
expect(gameObjects.flies.length).toEqual(1);
expect(gameObjects.fleas.length).toEqual(1);
expect(spiders.spiders.length).toEqual(1);
});
});
......@@ -12,7 +12,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
testObj = Object.assign({}, gameObjects);
testObj.init();
testObj.worms = [];
testObj.flies = [];
testObj.fleas = [];
});
function mockTestObj() {
spyOn(testObj, 'spawnCreatureAtIntervals');
......@@ -80,9 +80,9 @@ describe('INTERVAL CREATURES SPEC: ', () => {
spyOn(testObj, 'eligibleToDrop').and.returnValue(true);
spyOn(mushrooms, 'make').and.returnValue({});
mushrooms.mushrooms = [];
let fly = {x : 5, y : 100};
let flea = {x : 5, y : 100};
testObj.dropMushrooms(fly);
testObj.dropMushrooms(flea);
expect(testObj.eligibleToDrop).toHaveBeenCalled();
expect(mushrooms.make).toHaveBeenCalled();
......@@ -90,7 +90,7 @@ describe('INTERVAL CREATURES SPEC: ', () => {
it('eligibleToDrop returns false if not valid interval', () => {
game.frameNo = 1;
knobsAndLevers.flies.mushroomCreateInterval = 2;
knobsAndLevers.fleas.mushroomCreateInterval = 2;
let canDrop = testObj.eligibleToDrop();
expect(canDrop).toBeFalsy();
......@@ -146,32 +146,32 @@ describe('INTERVAL CREATURES SPEC: ', () => {
expect(testObj.worms.length).toBe(0);
});
it('clearOutsideCanvas clears flies with y greater than canvas height', () => {
testObj.flies = [{}];
testObj.flies[0].y = game.gameArea.canvas.height + 1;
it('clearOutsideCanvas clears fleas with y greater than canvas height', () => {
testObj.fleas = [{}];
testObj.fleas[0].y = game.gameArea.canvas.height + 1;
testObj.flies = testObj.clearOutsideCanvas('flies');
testObj.fleas = testObj.clearOutsideCanvas('fleas');
expect(testObj.flies.length).toBe(0);
expect(testObj.fleas.length).toBe(0);
});
it('clearOutsideCanvas does not clear flies with y less than canvas height', () => {
testObj.flies = [{}]
expect(testObj.flies.length).toBe(1);
it('clearOutsideCanvas does not clear fleas with y less than canvas height', () => {
testObj.fleas = [{}]
expect(testObj.fleas.length).toBe(1);
testObj.flies[0].y = game.gameArea.canvas.height * 2;
testObj.flies[0].x = game.gameArea.canvas.width * 2;
testObj.fleas[0].y = game.gameArea.canvas.height * 2;
testObj.fleas[0].x = game.gameArea.canvas.width * 2;
testObj.clearOutsideCanvas('flies');
testObj.clearOutsideCanvas('fleas');
expect(testObj.flies.length).toBe(1);
expect(testObj.fleas.length).toBe(1);
});
it('clearOutsideCanvas does not clear flies with y less than canvas height', () => {
testObj.flies = [];
expect(testObj.flies.length).toBe(0);
it('clearOutsideCanvas does not clear fleas with y less than canvas height', () => {
testObj.fleas = [];
expect(testObj.fleas.length).toBe(0);
testObj.clearOutsideCanvas('flies');
testObj.clearOutsideCanvas('fleas');
expect(testObj.flies.length).toBe(0);
expect(testObj.fleas.length).toBe(0);
});
it('clear results in empty worms list', () => {
testObj.worms = [{}];
......@@ -180,11 +180,11 @@ describe('INTERVAL CREATURES SPEC: ', () => {
expect(testObj.worms.length).toBe(0);
});
it('clear results in empty flies list', () => {
testObj.flies = [{}];
it('clear results in empty fleas list', () => {
testObj.fleas = [{}];
testObj.clear();
expect(testObj.flies.length).toBe(0);
expect(testObj.fleas.length).toBe(0);
});
});
......@@ -13,7 +13,7 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
it('init should call parameter init functions', () => {
spyOn(testObj.general, 'init');
spyOn(testObj.centipede, 'init');
spyOn(testObj.flies, 'init');
spyOn(testObj.fleas, 'init');
spyOn(testObj.player, 'init');
spyOn(testObj.laser, 'init');
spyOn(testObj.mushrooms, 'init');
......@@ -25,7 +25,7 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
expect(testObj.general.init).toHaveBeenCalled();
expect(testObj.centipede.init).toHaveBeenCalled();
expect(testObj.flies.init).toHaveBeenCalled();
expect(testObj.fleas.init).toHaveBeenCalled();
expect(testObj.player.init).toHaveBeenCalled();
expect(testObj.laser.init).toHaveBeenCalled();
expect(testObj.mushrooms.init).toHaveBeenCalled();
......@@ -47,13 +47,13 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
expect(testObj.centipede.args.height).toBeTruthy();
expect(testObj.centipede.args.x).toBeTruthy();
});
it('flies.init initializes flies parameters', () => {
testObj.flies.init(knobsAndLevers);
it('fleas.init initializes fleas parameters', () => {
testObj.fleas.init(knobsAndLevers);
expect(testObj.flies.initialInterval).toBeDefined();
expect(testObj.flies.args.width).toBeTruthy();
expect(testObj.flies.args.height).toBeTruthy();
expect(testObj.flies.args.y).not.toBeUndefined();
expect(testObj.fleas.initialInterval).toBeDefined();
expect(testObj.fleas.args.width).toBeTruthy();
expect(testObj.fleas.args.height).toBeTruthy();
expect(testObj.fleas.args.y).not.toBeUndefined();
});
it('player.init initializes player parameters', () => {
testObj.player.init(knobsAndLevers);
......@@ -99,9 +99,9 @@ describe('KNOBS AND LEVERS SPEC: ', () => {
expect(testObj.worms.args.width).toBeTruthy();
expect(testObj.worms.args.height).toBeTruthy();
});
it('flies.args.constructorFunctions.setX should set knobsAndLevers.flies.args.x', () => {
it('fleas.args.constructorFunctions.setX should set knobsAndLevers.fleas.args.x', () => {
knobsAndLevers.init();
knobsAndLevers.flies.args.constructorFunctions.setX();
expect(knobsAndLevers.flies.args.x).toBeDefined();
knobsAndLevers.fleas.args.constructorFunctions.setX();
expect(knobsAndLevers.fleas.args.x).toBeDefined();
});
});
......@@ -32,7 +32,7 @@ describe('SOUND SPEC: ', () => {
it('manageSounds delegates to sound manage functions', () => {
spyOn(testObj, 'manageCentipedeSounds');
spyOn(testObj, 'manageSpiderSounds');
spyOn(testObj, 'manageFlySounds');
spyOn(testObj, 'manageFleaSounds');
spyOn(testObj, 'manageWormSounds');
knobsAndLevers.game.sounds.value = true;
......@@ -40,7 +40,7 @@ describe('SOUND SPEC: ', () => {
expect(testObj.manageCentipedeSounds).toHaveBeenCalled();
expect(testObj.manageSpiderSounds).toHaveBeenCalled();
expect(testObj.manageFlySounds).toHaveBeenCalled();
expect(testObj.manageFleaSounds).toHaveBeenCalled();
expect(testObj.manageWormSounds).toHaveBeenCalled();
});
it('buildManySounds builds expected number of sounds', () => {
......@@ -88,35 +88,35 @@ describe('SOUND SPEC: ', () => {
expect(testObj.playSound).not.toHaveBeenCalled();
});
it('manageFlySounds calls fly sound play', () => {
gameObjects.flies = [{}];
it('manageFleaSounds calls flea sound play', () => {
gameObjects.fleas = [{}];
let testSound = {};
testObj.tracks.fly = testSound;
testObj.tracks.flea = testSound;
spyOn(testObj, 'playSound');
testObj.manageFlySounds();
testObj.manageFleaSounds();
expect(testObj.playSound).toHaveBeenCalledWith(testSound);
expect(testObj.tracks['fly'].played).toBeTruthy();
expect(testObj.tracks['flea'].played).toBeTruthy();
});
it('manageFlySounds does not call fly sound play if played is true', () => {
gameObjects.flies = [{}];
spyOn(testObj.tracks['fly'], 'play');
testObj.tracks['fly'].played = true;
it('manageFleaSounds does not call flea sound play if played is true', () => {
gameObjects.fleas = [{}];
spyOn(testObj.tracks['flea'], 'play');
testObj.tracks['flea'].played = true;
testObj.manageFlySounds();
testObj.manageFleaSounds();
expect(testObj.tracks['fly'].play).not.toHaveBeenCalled();
expect(testObj.tracks['fly'].played).toBeTruthy();
expect(testObj.tracks['flea'].play).not.toHaveBeenCalled();
expect(testObj.tracks['flea'].played).toBeTruthy();
});
it('manageFlySounds sets played to false when fly is not present', () => {
gameObjects.flies = [];
spyOn(testObj.tracks['fly'], 'play');
it('manageFleaSounds sets played to false when flea is not present', () => {
gameObjects.fleas = [];
spyOn(testObj.tracks['flea'], 'play');
testObj.manageFlySounds();
testObj.manageFleaSounds();
expect(testObj.tracks['fly'].play).not.toHaveBeenCalled();
expect(testObj.tracks['fly'].played).toBeFalsy();
expect(testObj.tracks['flea'].play).not.toHaveBeenCalled();
expect(testObj.tracks['flea'].played).toBeFalsy();
});
it('manageWormSounds calls worm sound play', () => {
gameObjects.worms.push({});
......@@ -204,13 +204,13 @@ describe('SOUND SPEC: ', () => {
spyOn(testObj.tracks['centipede'], 'stop');
spyOn(testObj.tracks['spider'], 'stop');
spyOn(testObj.tracks['worm'], 'stop');
spyOn(testObj.tracks['fly'], 'stop');
spyOn(testObj.tracks['flea'], 'stop');
testObj.stopAllSounds();
expect(testObj.tracks['centipede'].stop).toHaveBeenCalled();
expect(testObj.tracks['spider'].stop).toHaveBeenCalled();
expect(testObj.tracks['worm'].stop).toHaveBeenCalled();
expect(testObj.tracks['fly'].stop).toHaveBeenCalled();
expect(testObj.tracks['flea'].stop).toHaveBeenCalled();
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment