From e2f3615466f0b851ef2d27ee319d1bd7e54eac8f Mon Sep 17 00:00:00 2001 From: Allan Martinez Date: Sat, 17 Feb 2024 18:27:08 -0800 Subject: [PATCH 1/4] Cyber-Wolf.js -> Cyber-Wolf.ts --- .../{Cyber-Wolf.js => Cyber-Wolf.ts} | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) rename src/abilities/{Cyber-Wolf.js => Cyber-Wolf.ts} (94%) diff --git a/src/abilities/Cyber-Wolf.js b/src/abilities/Cyber-Wolf.ts similarity index 94% rename from src/abilities/Cyber-Wolf.js rename to src/abilities/Cyber-Wolf.ts index d6eb50eb0..9cbcb9de4 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; } @@ -72,7 +74,7 @@ export default (G) => { } if ( - !this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex), { + !this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex, false), { team: this._targetTeam, }) ) { @@ -88,17 +90,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 +213,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 +229,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); @@ -239,7 +240,8 @@ export default (G) => { const bellowrow = matrices.bellowrow; let rows; - if (choice.choiceId === 0) { + // Check to first hex to determine which direction was chosen + if (choice[0].x >= this.creature.x) { // Front rows = [ arrayUtils.filterCreature( @@ -338,6 +340,7 @@ export default (G) => { G.grid.queryCreature({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, // fnOnConfirm team: Team.Enemy, From 0191e89f5a6b95e1082b3cf748ef73a91ed60c89 Mon Sep 17 00:00:00 2001 From: Allan Martinez Date: Sat, 17 Feb 2024 18:38:33 -0800 Subject: [PATCH 2/4] refactor Metal Hand: directly return `atLeastOneTarget` --- src/abilities/Cyber-Wolf.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/abilities/Cyber-Wolf.ts b/src/abilities/Cyber-Wolf.ts index 9cbcb9de4..fb9f6a333 100755 --- a/src/abilities/Cyber-Wolf.ts +++ b/src/abilities/Cyber-Wolf.ts @@ -73,14 +73,9 @@ export default (G: Game) => { return false; } - if ( - !this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex, false), { - team: this._targetTeam, - }) - ) { - return false; - } - return true; + return this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex, false), { + team: this._targetTeam, + }); }, // query() : From 6ab03f10426998b76924729beed2055b05bf5de6 Mon Sep 17 00:00:00 2001 From: Allan Martinez Date: Sat, 17 Feb 2024 18:39:48 -0800 Subject: [PATCH 3/4] change @return from description to primitive --- src/ability.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = { From 4dc8f8c7d326e47495399972b721bd56ea39f971 Mon Sep 17 00:00:00 2001 From: Allan Martinez Date: Sat, 17 Feb 2024 18:41:41 -0800 Subject: [PATCH 4/4] add type annotations --- src/abilities/Cyber-Wolf.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/abilities/Cyber-Wolf.ts b/src/abilities/Cyber-Wolf.ts index fb9f6a333..dbb2fbd67 100755 --- a/src/abilities/Cyber-Wolf.ts +++ b/src/abilities/Cyber-Wolf.ts @@ -234,7 +234,7 @@ export default (G: Game) => { const straitrow = matrices.straitrow; const bellowrow = matrices.bellowrow; - let rows; + let rows: Hex[][]; // Check to first hex to determine which direction was chosen if (choice[0].x >= this.creature.x) { // Front @@ -346,7 +346,7 @@ export default (G: Game) => { }, // 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);