diff --git a/src/abilities/Headless.js b/src/abilities/Headless.ts similarity index 97% rename from src/abilities/Headless.js rename to src/abilities/Headless.ts index c81d1e8a1..c71a0efc8 100755 --- a/src/abilities/Headless.js +++ b/src/abilities/Headless.ts @@ -5,12 +5,13 @@ import * as arrayUtils from '../utility/arrayUtils'; import { Creature } from '../creature'; import { Effect } from '../effect'; import { Direction } from '../utility/hex'; +import Game from '../game'; /** Creates the abilities * @param {Object} G the game object * @return {void} */ -export default (G) => { +export default (G: Game) => { G.abilities[39] = [ /** * First Ability: Larva Infest @@ -98,6 +99,7 @@ export default (G) => { /* Headless position is the front hex of its two hexes, so we look for an enemy unit two hexes back which will be the hex directly behind Headless. */ matrices.inlineback2hex, + false, ); }, }, @@ -119,7 +121,7 @@ export default (G) => { //At least one target if ( - !this.atLeastOneTarget(crea.getHexMap(matrices.frontnback2hex), { + !this.atLeastOneTarget(crea.getHexMap(matrices.frontnback2hex, false), { team: this._targetTeam, }) ) { @@ -135,12 +137,13 @@ export default (G) => { G.grid.queryCreature({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, team: this._targetTeam, id: crea.id, flipped: crea.player.flipped, - hexes: crea.getHexMap(matrices.frontnback2hex), + hexes: crea.getHexMap(matrices.frontnback2hex, false), }); }, @@ -246,6 +249,7 @@ export default (G) => { G.grid.queryDirection({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, team: this._targetTeam, @@ -372,13 +376,14 @@ export default (G) => { G.grid.queryChoice({ fnOnConfirm: function () { + // eslint-disable-next-line ability.animation(...arguments); }, team: Team.Both, requireCreature: 0, id: crea.id, flipped: crea.player.flipped, - choices: [crea.getHexMap(hexes), crea.getHexMap(hexes, true)], + choices: [crea.getHexMap(hexes, false), crea.getHexMap(hexes, true)], }); }, @@ -404,6 +409,7 @@ export default (G) => { damages, //Damage Type [], //Effects ability.getTargets(hexes), //Targets + false, ); }, }, diff --git a/src/ability.ts b/src/ability.ts index cba6a548b..8e903abee 100644 --- a/src/ability.ts +++ b/src/ability.ts @@ -41,7 +41,8 @@ export type Trigger = | 'onStartOfRound' | 'oncePerDamageChain' | 'onCreatureMove onOtherCreatureMove' - | 'onCreatureSummon onDamage onHeal'; + | 'onCreatureSummon onDamage onHeal' + | 'onStartPhase onEndPhase'; // Could get rid of the union and optionals by creating a separate (or conditional) type for Dark Priest's Cost // This might narrow down the types in the constructor by checking `creature.name` @@ -78,7 +79,7 @@ export class Ability { upgraded: boolean; title: string; - // TODO properly type all these unknowns + // TODO properly type all `unknown` types // These properties come from extending a specific ability from `src/abilities` requirements?: Requirement | undefined; costs?: Cost | undefined; @@ -89,11 +90,12 @@ export class Ability { affectedByMatSickness?: boolean; activate?: (target?: any, hex?: any, path?: Hex[]) => unknown; getAnimationData?: (...args: unknown[]) => unknown; - damages?: CreatureMasteries & { pure?: number }; + damages?: Partial & { pure?: number }; effects?: AbilityEffect[]; message?: string; movementType?: () => 'flying'; // Currently, this functon only exists in `Scavenger.js` triggeredThisChain?: boolean; + range?: { minimum?: number; regular: number; upgraded: number }; _lastBonus?: number; @@ -108,6 +110,9 @@ export class Ability { getAbilityName?: (name: string) => string; getMovementBuff?: (buff: number) => number; getOffenseBuff?: (buff: number) => number; + _getHexes?: () => any; + _getMaxDistance: () => number; + _directions?: Direction[]; _targetTeam: Team; // Below methods exist in Snow-Bunny.ts diff --git a/src/utility/hexgrid.ts b/src/utility/hexgrid.ts index 3128c2a99..e222d066f 100644 --- a/src/utility/hexgrid.ts +++ b/src/utility/hexgrid.ts @@ -77,7 +77,7 @@ interface QueryOptions { */ arg: any; - optTest: () => boolean; + optTest: (arg: Creature) => boolean; /** * Function applied when clicking on one of the available hexes. @@ -579,6 +579,7 @@ export class HexGrid { fillOnlyHoveredCreature: false, }; + // Overwrite any default options with options passed in through `o` o = { ...defaultOpt, ...o }; let hexes = [];