Skip to content

Commit

Permalink
Bounty-Hunter.js -> Bounty-Hunter.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
allmtz committed Jul 30, 2023
1 parent ae69a2e commit 97c98ff
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/abilities/Bounty-Hunter.js → src/abilities/Bounty-Hunter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Trigger>` 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
Expand Down Expand Up @@ -129,6 +141,7 @@ export default (G) => {

G.grid.queryCreature({
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
},
team: this._targetTeam,
Expand All @@ -139,7 +152,7 @@ export default (G) => {
},

//activate():
activate: function (target) {
activate: function (target: Creature) {
const targetOriginalHealth = target.health;

const ability = this;
Expand All @@ -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
Expand Down Expand Up @@ -188,43 +201,37 @@ export default (G) => {
true,
true,
swine.id,
swine.team,
)
.concat(
arrayUtils.filterCreature(
G.grid.getHexMap(swine.x, swine.y, 0, false, straitrow),
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 (
Expand Down Expand Up @@ -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,
});
},
Expand Down Expand Up @@ -358,6 +366,7 @@ export default (G) => {
G.activeCreature.queryMove();
},
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
},
hexes: hexes,
Expand All @@ -366,7 +375,7 @@ export default (G) => {
},

// activate() :
activate: function (hex) {
activate: function (hex: Hex) {
const ability = this;
const swine = this.creature;

Expand Down Expand Up @@ -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);
}
},
Expand Down

0 comments on commit 97c98ff

Please sign in to comment.