diff --git a/src/abilities/Bounty-Hunter.js b/src/abilities/Bounty-Hunter.ts similarity index 92% rename from src/abilities/Bounty-Hunter.js rename to src/abilities/Bounty-Hunter.ts index 900bc0909..de63f541a 100644 --- a/src/abilities/Bounty-Hunter.js +++ b/src/abilities/Bounty-Hunter.ts @@ -4,12 +4,24 @@ import { Team } from '../utility/team'; import * as matrices from '../utility/matrices'; import * as arrayUtils from '../utility/arrayUtils'; import { Effect } from '../effect'; +import Game from '../game'; +import { Creature } from '../creature'; +import { Hex } from '../utility/hex'; + +/* + *TODO + * + * Fix ts-error 2554: Need to properly type the `on` functions in `game.ts`. + * This can be done once all the `abilities` files are converted to TS. + * + * Fix eslint errors: prefer rest params + */ /** Creates the abilities * @param {Object} G the game object * @return {void} */ -export default (G) => { +export default (G: Game) => { /* * * Bounty Hunter abilities @@ -129,6 +141,7 @@ export default (G) => { G.grid.queryCreature({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, team: this._targetTeam, @@ -139,7 +152,7 @@ export default (G) => { }, //activate(): - activate: function (target) { + activate: function (target: Creature) { const targetOriginalHealth = target.health; const ability = this; @@ -154,7 +167,7 @@ export default (G) => { G, ); target.takeDamage(damage); - /** damage dealt is og health - current health + /** damage dealt is original health - current health * if current health is lower than damage dealt, * and the ability is upgraded, * make a second attack @@ -188,7 +201,6 @@ export default (G) => { true, true, swine.id, - swine.team, ) .concat( arrayUtils.filterCreature( @@ -196,35 +208,30 @@ export default (G) => { true, true, swine.id, - swine.team, ), arrayUtils.filterCreature( G.grid.getHexMap(swine.x, swine.y, 0, false, bellowrow), true, true, swine.id, - swine.team, ), arrayUtils.filterCreature( G.grid.getHexMap(swine.x, swine.y - 2, 0, true, bellowrow), true, true, swine.id, - swine.team, ), arrayUtils.filterCreature( G.grid.getHexMap(swine.x, swine.y, 0, true, straitrow), true, true, swine.id, - swine.team, ), arrayUtils.filterCreature( G.grid.getHexMap(swine.x, swine.y, 0, true, bellowrow), true, true, swine.id, - swine.team, ), ); if ( @@ -263,12 +270,13 @@ export default (G) => { G.grid.queryChoice({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, // fnOnConfirm team: this._targetTeam, requireCreature: 1, id: swine.id, - flipped: swine.flipped, + flipped: swine.player.flipped, choices: choices, }); }, @@ -358,6 +366,7 @@ export default (G) => { G.activeCreature.queryMove(); }, fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, hexes: hexes, @@ -366,7 +375,7 @@ export default (G) => { }, // activate() : - activate: function (hex) { + activate: function (hex: Hex) { const ability = this; const swine = this.creature; @@ -403,19 +412,23 @@ export default (G) => { } return this.trap.hex.creature.type != 'A1'; }, - effectFn: function (effect, crea) { - crea.remainingMove--; + effectFn: function (effect, creatureHexOrDamage) { + if (creatureHexOrDamage instanceof Creature) { + creatureHexOrDamage.remainingMove--; + } }, }, G, ), ]; + // TODO: `createTrap` is deprecated hex.createTrap('mud-bath', effects, ability.creature.player); G.soundsys.playSFX('sounds/mudbath'); // Trigger trap immediately if on self if (isSelf) { // onCreatureMove is Spa Goggles' trigger event + // @ts-expect-error 2554 G.onCreatureMove(swine, hex); } },