diff --git a/src/abilities/Cyber-Wolf.js b/src/abilities/Cyber-Wolf.ts similarity index 92% rename from src/abilities/Cyber-Wolf.js rename to src/abilities/Cyber-Wolf.ts index d6eb50eb0..dbb2fbd67 100755 --- a/src/abilities/Cyber-Wolf.js +++ b/src/abilities/Cyber-Wolf.ts @@ -4,12 +4,14 @@ import { Team, isTeam } from '../utility/team'; import * as matrices from '../utility/matrices'; import * as arrayUtils from '../utility/arrayUtils'; import { Creature } from '../creature'; +import Game from '../game'; +import { Hex } from '../utility/hex'; /** Creates the abilities * @param {Object} G the game object * @return {void} */ -export default (G) => { +export default (G: Game) => { G.abilities[31] = [ // First Ability: Bad Doggie { @@ -29,7 +31,7 @@ export default (G) => { activate: function () { // Check if there's an enemy creature in front - const hexesInFront = this.creature.getHexMap(matrices.inlinefront2hex); + const hexesInFront = this.creature.getHexMap(matrices.inlinefront2hex, false); if (hexesInFront.length < 1) { return; } @@ -71,14 +73,9 @@ export default (G) => { return false; } - if ( - !this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex), { - team: this._targetTeam, - }) - ) { - return false; - } - return true; + return this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex, false), { + team: this._targetTeam, + }); }, // query() : @@ -88,17 +85,18 @@ export default (G) => { G.grid.queryCreature({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, // fnOnConfirm team: this._targetTeam, id: crea.id, flipped: crea.player.flipped, - hexes: crea.getHexMap(matrices.frontnback2hex), + hexes: crea.getHexMap(matrices.frontnback2hex, false), }); }, // activate() : - activate: function (target) { + activate: function (target: Creature) { const ability = this; ability.end(); G.Phaser.camera.shake(0.01, 150, true, G.Phaser.camera.SHAKE_HORIZONTAL, true); @@ -210,14 +208,12 @@ export default (G) => { ), ]; - choices[0].choiceId = 0; - choices[1].choiceId = 1; - G.grid.queryChoice({ fnOnCancel: function () { G.activeCreature.queryMove(); }, fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, team: Team.Both, @@ -228,7 +224,7 @@ export default (G) => { }, // activate() : - activate: function (choice) { + activate: function (choice: Hex[]) { const ability = this; ability.end(); G.Phaser.camera.shake(0.02, 350, true, G.Phaser.camera.SHAKE_HORIZONTAL, true); @@ -238,8 +234,9 @@ export default (G) => { const straitrow = matrices.straitrow; const bellowrow = matrices.bellowrow; - let rows; - if (choice.choiceId === 0) { + let rows: Hex[][]; + // Check to first hex to determine which direction was chosen + if (choice[0].x >= this.creature.x) { // Front rows = [ arrayUtils.filterCreature( @@ -338,6 +335,7 @@ export default (G) => { G.grid.queryCreature({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, // fnOnConfirm team: Team.Enemy, @@ -348,7 +346,7 @@ export default (G) => { }, // activate() : - activate: function (crea) { + activate: function (crea: Creature) { const ability = this; ability.end(); G.Phaser.camera.shake(0.03, 333, true, G.Phaser.camera.SHAKE_VERTICAL, true); diff --git a/src/ability.ts b/src/ability.ts index 8e903abee..3c1d6022b 100644 --- a/src/ability.ts +++ b/src/ability.ts @@ -669,7 +669,7 @@ export class Ability { * * @param hexes Array of hexes to test. * @param {Object} o - * @return At least one valid target? + * @return bool */ atLeastOneTarget(hexes: Hex[], o): boolean { const defaultOpt = {