From 5bf40c6b4a962f6f4b9160a8b9c9cdc83f31d00d Mon Sep 17 00:00:00 2001 From: Allan Martinez Date: Wed, 13 Sep 2023 15:52:41 -0700 Subject: [PATCH] fix "`target` is undefined" --- src/abilities/Abolished.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/abilities/Abolished.js b/src/abilities/Abolished.js index ea40c3ae7..9366b71b5 100644 --- a/src/abilities/Abolished.js +++ b/src/abilities/Abolished.js @@ -3,6 +3,7 @@ import { Team } from '../utility/team'; import { Creature } from '../creature'; import { Effect } from '../effect'; import * as arrayUtils from '../utility/arrayUtils'; +import { getPointFacade } from '../utility/pointfacade'; /** Creates the abilities * @param {Object} G the game object @@ -130,7 +131,12 @@ export default (G) => { activate(path, args) { const ability = this; - const target = arrayUtils.last(path).creature; + const hexWithTarget = path.find((hex) => { + const creature = getPointFacade().getCreaturesAt({ x: hex.x, y: hex.y })[0]; + return creature && creature != this.creature; + }); + + const target = getPointFacade().getCreaturesAt(hexWithTarget.x, hexWithTarget.y)[0]; ability.end(); G.Phaser.camera.shake(0.01, 100, true, G.Phaser.camera.SHAKE_HORIZONTAL, true);