Skip to content

Commit

Permalink
fix "target is undefined"
Browse files Browse the repository at this point in the history
  • Loading branch information
allmtz committed Sep 13, 2023
1 parent d57ce94 commit 5bf40c6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/abilities/Abolished.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5bf40c6

Please sign in to comment.