Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSurabian committed May 12, 2020
1 parent 4ef4940 commit f3d213f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
3 changes: 0 additions & 3 deletions eslint/eslint-babel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"ecmaFeatures": {
"modules": true
},
"env": {
"es6": true
},
Expand Down
14 changes: 8 additions & 6 deletions src/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ module.exports.directionOfTravel = function(pointStart, pointEnd) {
};

module.exports.toggleFullscreen = function() {
var doc = window.document;
var docEl = doc.documentElement;
const doc = window.document;
const docEl = doc.documentElement;

var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
const requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen ||
docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
const cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen ||
doc.webkitExitFullscreen || doc.msExitFullscreen;

if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
requestFullScreen.call(docEl);
}
else {
cancelFullScreen.call(doc);
}
}
};
6 changes: 3 additions & 3 deletions src/modules/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Character extends extras.AnimatedSprite {
constructor(spriteId, spritesheet, states) {
const gameTextures = loader.resources[spritesheet].textures;
for (const textureKey in gameTextures) {
if (!gameTextures.hasOwnProperty(textureKey) || textureKey.indexOf(spriteId) === -1) {
if (!Object.prototype.hasOwnProperty.call(gameTextures,textureKey) || textureKey.indexOf(spriteId) === -1) {
continue;
}

Expand All @@ -28,7 +28,7 @@ class Character extends extras.AnimatedSprite {
continue;
}

if (stateObj.hasOwnProperty('textures')) {
if (Object.prototype.hasOwnProperty.call(stateObj,'textures')) {
stateObj.textures.push(gameTextures[textureKey]);
} else {
Object.defineProperty(stateObj, 'textures', {
Expand Down Expand Up @@ -106,7 +106,7 @@ class Character extends extras.AnimatedSprite {
}
this.textures = stateObj.textures;
this.animationSpeed = stateObj.animationSpeed;
this.loop = stateObj.hasOwnProperty('loop') ? stateObj.loop : true;
this.loop = Object.prototype.hasOwnProperty.call(stateObj,'loop') ? stateObj.loop : true;
this.play();
}

Expand Down
36 changes: 18 additions & 18 deletions src/modules/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BOTTOM_LINK_STYLE = {
fontSize: '15px',
align: 'left',
fill: 'white'
}
};

class Game {
/**
Expand Down Expand Up @@ -50,7 +50,7 @@ class Game {

if (this.stage && this.stage.hud) {

if (!this.stage.hud.hasOwnProperty('ducksMissed')) {
if (!Object.prototype.hasOwnProperty.call(this.stage.hud,'ducksMissed')) {
this.stage.hud.createTextureBasedCounter('ducksMissed', {
texture: 'hud/score-live/0.png',
spritesheet: this.spritesheet,
Expand All @@ -73,7 +73,7 @@ class Game {

if (this.stage && this.stage.hud) {

if (!this.stage.hud.hasOwnProperty('ducksShot')) {
if (!Object.prototype.hasOwnProperty.call(this.stage.hud,'ducksShot')) {
this.stage.hud.createTextureBasedCounter('ducksShot', {
texture: 'hud/score-dead/0.png',
spritesheet: this.spritesheet,
Expand Down Expand Up @@ -106,7 +106,7 @@ class Game {

if (this.stage && this.stage.hud) {

if (!this.stage.hud.hasOwnProperty('bullets')) {
if (!Object.prototype.hasOwnProperty.call(this.stage.hud,'bullets')) {
this.stage.hud.createTextureBasedCounter('bullets', {
texture: 'hud/bullet/0.png',
spritesheet: this.spritesheet,
Expand Down Expand Up @@ -141,7 +141,7 @@ class Game {

if (this.stage && this.stage.hud) {

if (!this.stage.hud.hasOwnProperty('score')) {
if (!Object.prototype.hasOwnProperty.call(this.stage.hud,'score')) {
this.stage.hud.createTextBox('score', {
style: {
fontFamily: 'Arial',
Expand Down Expand Up @@ -182,7 +182,7 @@ class Game {

if (this.stage && this.stage.hud) {

if (!this.stage.hud.hasOwnProperty('waveStatus')) {
if (!Object.prototype.hasOwnProperty.call(this.stage.hud,'waveStatus')) {
this.stage.hud.createTextBox('waveStatus', {
style: {
fontFamily: 'Arial',
Expand Down Expand Up @@ -223,7 +223,7 @@ class Game {

if (this.stage && this.stage.hud) {

if (!this.stage.hud.hasOwnProperty('gameStatus')) {
if (!Object.prototype.hasOwnProperty.call(this.stage.hud,'gameStatus')) {
this.stage.hud.createTextBox('gameStatus', {
style: {
fontFamily: 'Arial',
Expand Down Expand Up @@ -307,7 +307,7 @@ class Game {
y: 1
}
});
this.stage.hud.levelCreatorLink = "level creator (c)";
this.stage.hud.levelCreatorLink = 'level creator (c)';
}

bindEvents() {
Expand All @@ -322,20 +322,20 @@ class Game {
this.pause();
}

if(event.key === 'm') {
if (event.key === 'm') {
this.mute();
}

if(event.key === 'c') {
if (event.key === 'c') {
this.openLevelCreator();
}

if(event.key === 'f') {
if (event.key === 'f') {
this.fullscreen();
}
});

document.addEventListener('fullscreenchange', (event) => {
document.addEventListener('fullscreenchange', () => {
if (document.fullscreenElement) {
this.stage.hud.fullscreenLink = 'unfullscreen (f)';
} else {
Expand Down Expand Up @@ -368,20 +368,20 @@ class Game {
this.stage.pause();
this.activeSounds.forEach((soundId) => {
sound.pause(soundId);
})
});
} else {
this.timePaused += (Date.now() - this.pauseStartTime) / 1000;
this.stage.resume();
this.activeSounds.forEach(soundId => {
this.activeSounds.forEach((soundId) => {
sound.play(soundId);
})
});
}
}, 40);
}

removeActiveSound(soundId) {
_remove(this.activeSounds, function(item) {
return item === soundId
return item === soundId;
});
}

Expand Down Expand Up @@ -506,7 +506,7 @@ class Game {
getScoreMessage() {
let scoreMessage;

let percentage = (this.score / this.maxScore) * 100;
const percentage = (this.score / this.maxScore) * 100;

if (percentage === 100) {
scoreMessage = 'Flawless victory.';
Expand Down Expand Up @@ -566,7 +566,7 @@ class Game {
return;
}

if(this.stage.clickedFullscreenLink(clickPoint)) {
if (this.stage.clickedFullscreenLink(clickPoint)) {
this.fullscreen();
return;
}
Expand Down
20 changes: 10 additions & 10 deletions src/modules/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ class Stage extends Container {
this.dog.timeline.pause();
this.ducks.forEach((duck) => {
duck.timeline.pause();
})
});
}

resume() {
this.dog.timeline.play();
this.ducks.forEach((duck) => {
duck.timeline.play();
})
});
}

/**
Expand Down Expand Up @@ -250,29 +250,29 @@ class Stage extends Container {
}

clickedLevelCreatorLink(clickPoint) {
let scaledClickPoint = this.getScaledClickLocation(clickPoint);
const scaledClickPoint = this.getScaledClickLocation(clickPoint);

// with this link we have a very narrow hit box, radius search is not appropriate
return _inRange(scaledClickPoint.x, HUD_LOCATIONS.LEVEL_CREATOR_LINK.x-110, HUD_LOCATIONS.LEVEL_CREATOR_LINK.x) &&
_inRange(scaledClickPoint.y, HUD_LOCATIONS.LEVEL_CREATOR_LINK.y-30, HUD_LOCATIONS.LEVEL_CREATOR_LINK.y+10)
_inRange(scaledClickPoint.y, HUD_LOCATIONS.LEVEL_CREATOR_LINK.y-30, HUD_LOCATIONS.LEVEL_CREATOR_LINK.y+10);
}

clickedPauseLink(clickPoint) {
let scaledClickPoint = this.getScaledClickLocation(clickPoint);
const scaledClickPoint = this.getScaledClickLocation(clickPoint);
return _inRange(scaledClickPoint.x, HUD_LOCATIONS.PAUSE_LINK.x-110, HUD_LOCATIONS.PAUSE_LINK.x) &&
_inRange(scaledClickPoint.y, HUD_LOCATIONS.PAUSE_LINK.y-30, HUD_LOCATIONS.PAUSE_LINK.y+10)
_inRange(scaledClickPoint.y, HUD_LOCATIONS.PAUSE_LINK.y-30, HUD_LOCATIONS.PAUSE_LINK.y+10);
}

clickedFullscreenLink(clickPoint) {
let scaledClickPoint = this.getScaledClickLocation(clickPoint);
const scaledClickPoint = this.getScaledClickLocation(clickPoint);
return _inRange(scaledClickPoint.x, HUD_LOCATIONS.FULL_SCREEN_LINK.x-110, HUD_LOCATIONS.FULL_SCREEN_LINK.x) &&
_inRange(scaledClickPoint.y, HUD_LOCATIONS.FULL_SCREEN_LINK.y-30, HUD_LOCATIONS.FULL_SCREEN_LINK.y+10)
_inRange(scaledClickPoint.y, HUD_LOCATIONS.FULL_SCREEN_LINK.y-30, HUD_LOCATIONS.FULL_SCREEN_LINK.y+10);
}

clickedMuteLink(clickPoint) {
let scaledClickPoint = this.getScaledClickLocation(clickPoint);
const scaledClickPoint = this.getScaledClickLocation(clickPoint);
return _inRange(scaledClickPoint.x, HUD_LOCATIONS.MUTE_LINK.x-110, HUD_LOCATIONS.MUTE_LINK.x) &&
_inRange(scaledClickPoint.y, HUD_LOCATIONS.MUTE_LINK.y-30, HUD_LOCATIONS.MUTE_LINK.y+10)
_inRange(scaledClickPoint.y, HUD_LOCATIONS.MUTE_LINK.y-30, HUD_LOCATIONS.MUTE_LINK.y+10);
}

getScaledClickLocation(clickPoint) {
Expand Down

0 comments on commit f3d213f

Please sign in to comment.