Skip to content

Commit

Permalink
Merge pull request #1425 from russon77/issue/1422
Browse files Browse the repository at this point in the history
lint should check all relevant js files, fixes #1422
  • Loading branch information
DreadKnight committed Jul 6, 2018
2 parents ab9976b + 2f97674 commit e1cbf91
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 65 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
'no-else-return': 'off',
'no-empty-function': 'off',
'no-eq-null': 'error',
'no-eval': 'error',
'no-eval': 'warn',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
Expand All @@ -104,7 +104,7 @@ module.exports = {
'no-negated-condition': 'off',
'no-negated-in-lhs': 'error',
'no-nested-ternary': 'error',
'no-new': 'error',
'no-new': 'warn',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-require': 'error',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"start": "cross-env NODE_ENV=production node server.js",
"start:dev": "cross-env NODE_ENV=development node server.js",
"generateManifest": "node manifestGenerator.js",
"lint": "eslint -c .eslintrc.json src/**/*.js",
"lint-fix": "eslint -c .eslintrc.json src/**/*.js --fix",
"lint": "eslint -c .eslintrc.json --ignore-pattern manifest.js src/*.js src/**/*.js",
"lint-fix": "eslint -c .eslintrc.json --fix --ignore-pattern manifest.js src/*.js src/**/*.js",
"format": "prettier-eslint --write \"src/**/*.js\"",
"postinstall": "scripts/postinstall.sh",
"precommit": "lint-staged",
Expand Down
46 changes: 22 additions & 24 deletions src/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class Animations {

game.freezedInput = true;

let anim_id = Math.random();
game.animationQueue.push(anim_id);
let animId = Math.random();
game.animationQueue.push(animId);

let hexId = 0;

Expand All @@ -32,7 +32,7 @@ export class Animations {
if (hexId < path.length && (creature.remainingMove > 0 || opts.ignoreMovementPoint)) {
this.leaveHex(creature, hex, opts);
} else {
this.movementComplete(creature, path[path.length - 1], anim_id, opts);
this.movementComplete(creature, path[path.length - 1], animId, opts);
return;
}

Expand All @@ -41,7 +41,7 @@ export class Animations {

let tween = game.Phaser.add
.tween(creature.grp)
.to(nextPos.displayPos, parseInt(speed), Phaser.Easing.Linear.None)
.to(nextPos.displayPos, parseInt(speed, 10), Phaser.Easing.Linear.None)
.start();

// Ignore traps for hover creatures, unless this is the last hex
Expand All @@ -55,7 +55,7 @@ export class Animations {
tween.onComplete.add(() => {
if (creature.dead) {
// Stop moving if creature has died while moving
this.movementComplete(creature, hex, anim_id, opts);
this.movementComplete(creature, hex, animId, opts);
return;
}

Expand Down Expand Up @@ -93,10 +93,8 @@ export class Animations {

game.freezedInput = true;

let anim_id = Math.random();
game.animationQueue.push(anim_id);

let hexId = 0;
let animId = Math.random();
game.animationQueue.push(animId);

creature.healthHide();

Expand All @@ -111,7 +109,7 @@ export class Animations {

let tween = game.Phaser.add
.tween(creature.grp)
.to(currentHex.displayPos, parseInt(speed), Phaser.Easing.Linear.None)
.to(currentHex.displayPos, parseInt(speed, 10), Phaser.Easing.Linear.None)
.start();

tween.onComplete.add(() => {
Expand All @@ -122,7 +120,7 @@ export class Animations {
// Determine distance
let distance = 0;
let k = 0;
while (!distance && start != currentHex) {
while (!distance) {
k++;

if (arrayUtils.findPos(start.adjacentHex(k), currentHex)) {
Expand All @@ -137,7 +135,7 @@ export class Animations {
}

this.enterHex(creature, hex, opts);
this.movementComplete(creature, hex, anim_id, opts);
this.movementComplete(creature, hex, animId, opts);
return;
});
}
Expand All @@ -149,8 +147,8 @@ export class Animations {

this.leaveHex(creature, currentHex, opts);

let anim_id = Math.random();
game.animationQueue.push(anim_id);
let animId = Math.random();
game.animationQueue.push(animId);

// FadeOut
let tween = game.Phaser.add
Expand All @@ -173,7 +171,7 @@ export class Animations {
creature.grp.y = currentHex.displayPos.y;

// FadeIn
let tween = game.Phaser.add
game.Phaser.add
.tween(creature.grp)
.to(
{
Expand All @@ -185,7 +183,7 @@ export class Animations {
.start();

this.enterHex(creature, hex, opts);
this.movementComplete(creature, hex, anim_id, opts);
this.movementComplete(creature, hex, animId, opts);
return;
});
}
Expand Down Expand Up @@ -226,7 +224,7 @@ export class Animations {
game.grid.orderCreatureZ();
}

movementComplete(creature, hex, anim_id, opts) {
movementComplete(creature, hex, animId, opts) {
let game = this.game;

if (opts.customMovementPoint > 0) {
Expand All @@ -243,13 +241,13 @@ export class Animations {

game.onCreatureMove(creature, hex); // Trigger

creature.hexagons.forEach(hex => {
hex.pickupDrop(creature);
creature.hexagons.forEach(h => {
h.pickupDrop(creature);
});

game.grid.orderCreatureZ();

let queue = game.animationQueue.filter(item => item != anim_id);
let queue = game.animationQueue.filter(item => item != animId);

if (queue.length === 0) {
game.freezedInput = false;
Expand All @@ -258,19 +256,19 @@ export class Animations {
game.animationQueue = queue;
}

projectile(this_2, target, sprite_id, path, args, start_x, start_y) {
projectile(this2, target, spriteId, path, args, startX, startY) {
let game = this.game,
dist = arrayUtils.filterCreature(path.slice(0), false, false).length,
emissionPoint = {
x: this_2.creature.grp.x + start_x,
y: this_2.creature.grp.y + start_y
x: this2.creature.grp.x + startX,
y: this2.creature.grp.y + startY
},
targetPoint = {
x: target.grp.x + 52,
y: target.grp.y - 20
},
// Sprite id here
sprite = game.grid.creatureGroup.create(emissionPoint.x, emissionPoint.y, sprite_id),
sprite = game.grid.creatureGroup.create(emissionPoint.x, emissionPoint.y, spriteId),
duration = dist * 75;

sprite.anchor.setTo(0.5);
Expand Down
5 changes: 3 additions & 2 deletions src/assetLoader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Manifest from './manifest';

/**
/** getUrl
*
* @param {String | Array} path path to the string
* @return {?} ? ?
*/
export function getUrl(path) {
if (typeof path === 'string') {
Expand All @@ -17,7 +18,7 @@ export function getUrl(path) {
// prev = children (starts with the manifest)
// current = what we are looking at now
return path.reduce((prev, current) => {
const entity = prev.find(entity => entity.id === current);
const entity = prev.find(e => e.id === current);
if (entity === undefined) {
throw new Error(`Could not find asset with path: ${path.join('/')}`);
}
Expand Down
63 changes: 40 additions & 23 deletions src/creature.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,24 @@ export class Creature {

this.updateHex();

let dp =
this.type !== '--'
? ''
: this.team === 0 ? 'red' : this.team === 1 ? 'blue' : this.team === 2 ? 'orange' : 'green';
let dp = '';

if (this.type === '--') {
switch (this.team) {
case 0:
dp = 'red';
break;
case 1:
dp = 'blue';
break;
case 2:
dp = 'orange';
break;
case 3:
dp = 'green';
break;
}
}

// Creature Container
this.grp = game.Phaser.add.group(game.grid.creatureGroup, 'creatureGrp_' + this.id);
Expand Down Expand Up @@ -309,7 +323,7 @@ export class Creature {
// Frozen effect
if (stats.frozen) {
varReset();
var interval = setInterval(() => {
let interval = setInterval(() => {
if (!game.turnThrottle) {
clearInterval(interval);
game.skipTurn({
Expand All @@ -329,7 +343,7 @@ export class Creature {

this.materializationSickness = false;

var interval = setInterval(() => {
let interval = setInterval(() => {
if (!game.freezedInput) {
clearInterval(interval);
if (game.turn >= game.minimumTurnBeforeFleeing) {
Expand All @@ -351,8 +365,8 @@ export class Creature {
*/
deactivate(wait) {
let game = this.game;

this.hasWait = this.delayed = Boolean(wait);
this.delayed = Boolean(wait);
this.hasWait = this.delayed;
this.stats.frozen = false;

// Effects triggers
Expand Down Expand Up @@ -618,10 +632,12 @@ export class Creature {
}
}

let flipped;

if (facefrom.y % 2 === 0) {
var flipped = faceto.x <= facefrom.x;
flipped = faceto.x <= facefrom.x;
} else {
var flipped = faceto.x < facefrom.x;
flipped = faceto.x < facefrom.x;
}

if (flipped) {
Expand Down Expand Up @@ -722,8 +738,7 @@ export class Creature {
*
*/
tracePath(hex) {
let game = this.game,
x = hex.x,
let x = hex.x,
y = hex.y,
path = this.calculatePath(x, y); // Store path in grid to be able to compare it later

Expand Down Expand Up @@ -814,9 +829,9 @@ export class Creature {
*
*/
calcOffset(x, y) {
let offset = game.players[this.team].flipped ? this.size - 1 : 0,
mult = game.players[this.team].flipped ? 1 : -1, // For FLIPPED player
game = this.game;
let game = this.game,
offset = game.players[this.team].flipped ? this.size - 1 : 0,
mult = game.players[this.team].flipped ? 1 : -1; // For FLIPPED player

for (let i = 0; i < this.size; i++) {
// Try next hexagons to see if they fit
Expand Down Expand Up @@ -1007,9 +1022,10 @@ export class Creature {
}
}

/**
/** recharge
* @param {number} amount: amount of energy to restore
* @return {void}
* Restore energy up to the max limit
* amount: amount of energy to restore
*/
recharge(amount) {
this.energy = Math.min(this.stats.energy, this.energy + amount);
Expand Down Expand Up @@ -1276,12 +1292,13 @@ export class Creature {
}
}

/**
/** replaceEffect
* Add effect, but if the effect is already attached, replace it with the new
* effect.
* Note that for stackable effects, this is the same as addEffect()
*
* effect - the effect to add
* @param {Effect} effect: the effect to add
* @return {void}
*/
replaceEffect(effect) {
if (!effect.stackable && this.findEffect(effect.name).length !== 0) {
Expand All @@ -1291,10 +1308,11 @@ export class Creature {
this.addEffect(effect);
}

/**
/** removeEffect
* Remove an effect by name
*
* name - name of effect
* @param {string} name: name of effect
* @return {void}
*/
removeEffect(name) {
let totalEffects = this.effects.length;
Expand Down Expand Up @@ -1649,7 +1667,6 @@ export class Creature {

getBuffDebuff(stat) {
let buffDebuffArray = this.effects.concat(this.dropCollection),
buff = 0,
debuff = 0,
buffObjs = {
effects: [],
Expand Down Expand Up @@ -1712,7 +1729,7 @@ export class Creature {
});

return {
buff: buff,
buff: 0,
debuff: debuff,
objs: buffObjs
};
Expand Down
4 changes: 3 additions & 1 deletion src/creature_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export class CreatureQueue {
this.nextQueue = [];
}

/**
/** addByInitiative
* @param {Object} creature Creature
* @returns {void}
* Add a creature to the next turn's queue by initiative
* creature - The creature to add
*/
Expand Down
14 changes: 7 additions & 7 deletions src/damage.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as $j from 'jquery';

/*
* Damage Class
/* Damage Class
*
* TODO: This documentation needs to be updated with things that are determined dynamically like #melee and #counter
*/
export class Damage {
/**
* attacker : Creature : Unit that initiated the damage
* damages : Object : Object containing the damage by type {frost : 5} for example
* area : Integer : Number of hexagons being hit
* effects : Array : Contains Effect object to apply to the target
/** Constructor
* @param {Creature} attacker Unit that initiated the damage
* @param {Object} damages Object containing the damage by type {frost : 5} for example
* @param {number} area Number of hexagons being hit
* @param {array} effects Contains Effect object to apply to the target
* @param {Object} game Game object
*/
constructor(attacker, damages, area, effects, game) {
this.game = game;
Expand Down

0 comments on commit e1cbf91

Please sign in to comment.