<commit_before>import Dungeon from '../dungeons/Dungeon.js';
import Creature from '../entities/creatures/Creature.js';
import Tile from '../tiles/Tile.js';

export default class Ability {
    /**
      * @class Ability
      * @description Represents a non-attack action that a creature can perform
      */
    constructor() {
    }

    getReasonIllegal(dungeon, creature, optionalTargetTile, isFree) {
        if(!(dungeon instanceof Dungeon)) {
            return 'No dungeon specified';
        } else if(!(creature instanceof Creature)) {
            return 'No creature specified';
        } else if(!isFree && this.getManaCost() > creature.getCurrentMana()) {
            return 'Not enough mana';
        } else if(this.isTargetted()) {
            if(!(optionalTargetTile instanceof Tile)) {
                return 'This ability requires a target tile';
            } else if(this.mustTargetBeVisible() && !creature.canSee(dungeon, optionalTargetTile)) {
                return 'Tile not visible';
            } else if(this.isTargetCreature() && !optionalTargetTile.getCreature()) {
                return 'Target tile has no creature';
            } else if(dungeon.getTile(creature).getDirectDistance(optionalTargetTile) > this.getRange()) {
                return 'Target not in range';
            }
        } else {
            return null;
        }
    }

    use(dungeon, creature, optionalTargetTile, isFree) {
        var reason  = this.getReasonIllegal(dungeon, creature, optionalTargetTile, isFree);
        if(reason) {
            throw new Error(reason);
        }
        if(!isFree) {
            creature.modifyMana(-this.getManaCost());
        }
    }

    isTargetted() {
        throw new Error('Abstract method not implemented');
    }

    isTargetCreature() {
        throw new Error('Abstract method not implemented');
    }

    isMovementAbility() {<commit_msg>Bugfix<commit_after>import Dungeon from '../dungeons/Dungeon.js';
import Creature from '../entities/creatures/Creature.js';
import Tile from '../tiles/Tile.js';

export default class Ability {
    /**
      * @class Ability
      * @description Represents a non-attack action that a creature can perform
      */
    constructor() {
    }

    getReasonIllegal(dungeon, creature, optionalTargetTile, isFree) {
        if(!(dungeon instanceof Dungeon)) {
            return 'No dungeon specified';
        } else if(!(creature instanceof Creature)) {
            return 'No creature specified';
        } else if(!isFree && this.getManaCost() > creature.getCurrentMana()) {
            return 'Not enough mana';
        } else if(this.isTargetted()) {
            if(!(optionalTargetTile instanceof Tile)) {
                return 'This ability requires a target tile';
            } else if(this.mustTargetBeVisible() && !creature.canSee(dungeon, optionalTargetTile)) {
                return 'Tile not visible';
            } else if(this.isTargetCreature() && !optionalTargetTile.getCreature()) {
                return 'Target tile has no creature';
            } else if(dungeon.getTile(creature).getDirectDistance(optionalTargetTile) > this.getRange()) {
                return 'Target not in range';
            } else if(this.getRange() > 0 && optionalTargetTile === dungeon.getTile(creature)) {
                return 'Not a self-target ability';
            }
        } else {
            return null;
        }
    }

    use(dungeon, creature, optionalTargetTile, isFree) {
        var reason  = this.getReasonIllegal(dungeon, creature, optionalTargetTile, isFree);
        if(reason) {
            throw new Error(reason);
        }
        if(!isFree) {
            creature.modifyMana(-this.getManaCost());
        }
    }

    isTargetted() {
        throw new Error('Abstract method not implemented');
    }

    isTargetCreature() {
        throw new Error('Abstract method not implemented');
    }

    isMovementAbility() {
{'fraction_non_alphanumeric': 0.11314053779807204, 'fraction_numerical': 0.0002536783358701167, 'mean_word_length': 2.2885738115095915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2542414', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1062, 'n_words': 264}