diff --git a/src/abilities/Uncle-Fungus.js b/src/abilities/Uncle-Fungus.ts similarity index 93% rename from src/abilities/Uncle-Fungus.js rename to src/abilities/Uncle-Fungus.ts index 11e09ecc1..89a02f4f6 100755 --- a/src/abilities/Uncle-Fungus.js +++ b/src/abilities/Uncle-Fungus.ts @@ -4,12 +4,13 @@ import * as matrices from '../utility/matrices'; import * as arrayUtils from '../utility/arrayUtils'; import { Effect } from '../effect'; import { getDirectionFromDelta } from '../utility/position'; +import Game from '../game'; /** Creates the abilities * @param {Object} G the game object * @return {void} */ -export default (G) => { +export default (G: Game) => { G.abilities[3] = [ // First Ability: Toxic Spores { @@ -30,7 +31,7 @@ export default (G) => { } // Check that attack is melee from actual creature, not from trap - if (damage && damage.melee !== undefined) { + if (damage instanceof Damage && damage.melee !== undefined) { return damage.melee && !damage.isFromTrap; } // Always return true so that ability is highlighted in UI @@ -93,7 +94,7 @@ export default (G) => { // At least one target if ( - !this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex), { + !this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex, false), { team: this._targetTeam, }) ) { @@ -114,7 +115,7 @@ export default (G) => { team: this._targetTeam, id: uncle.id, flipped: uncle.player.flipped, - hexes: uncle.getHexMap(matrices.frontnback2hex), + hexes: uncle.getHexMap(matrices.frontnback2hex, false), }); }, @@ -194,14 +195,6 @@ export default (G) => { return this.testRequirements() && this.creature.stats.moveable; }, - fnOnSelect: function (hex) { - this.creature.tracePosition({ - x: hex.x, - y: hex.y, - overlayClass: 'creature moveto selected player' + this.creature.team, - }); - }, - // query() : query: function () { const ability = this; @@ -213,8 +206,19 @@ export default (G) => { const hexes = this._getHexRange(stopOnCreature); G.grid.queryHexes({ - fnOnSelect: function () { - ability.fnOnSelect(...arguments); + fnOnSelect: function (...args) { + const hex = args[0]; + + if (hex) { + // Uncle Fungus is 2 hexes wide, but the selected hex is only 1 hex wide. + // `tracePosition` ensures that both hexes are highlighted when hovering over the selected hex. + uncle.tracePosition({ + x: hex.x, + y: hex.y, + overlayClass: 'creature moveto selected player' + uncle.team, + }); + hex.game.activeCreature.faceHex(hex); + } }, fnOnConfirm: function () { if (arguments[0].x == ability.creature.x && arguments[0].y == ability.creature.y) { @@ -263,7 +267,7 @@ export default (G) => { // Shake the screen upon landing to simulate the jump G.Phaser.camera.shake(0.03, 90, true, G.Phaser.camera.SHAKE_VERTICAL, true); - G.onStepIn(ability.creature, ability.creature.hexagons[0]); + G.onStepIn(ability.creature, ability.creature.hexagons[0], false); const interval = setInterval(function () { if (!G.freezedInput) { diff --git a/src/ability.ts b/src/ability.ts index b688ecf31..811a56c58 100644 --- a/src/ability.ts +++ b/src/ability.ts @@ -44,7 +44,9 @@ export type Trigger = | 'onCreatureSummon onDamage onHeal' | 'onStartPhase onEndPhase' | 'onDamage onStartPhase' - | 'onStartPhase onDamage'; + | 'onStartPhase onDamage' + | 'onUnderAttack onAttack' + | 'onUnderAttack'; // 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` @@ -134,6 +136,9 @@ export class Ability { _damage: (target: Creature, runPath: Hex[]) => void; _pushTarget: (target: Creature, pushPath: Hex[], args: any) => void; + _isSecondLowJump: () => boolean; + _getHexRange: (stopOnCreature: boolean) => Hex[]; + _defenseBuff: number; _maxDefenseBuff: number; _damageTaken: boolean;