<commit_before><commit_msg>implement halder<commit_after>const _ = require('underscore');

const DrawCard = require('../../../drawcard.js');

class Halder extends DrawCard {
    setupCardAbilities() {
        this.action({
            title: 'Kneel a location or attachment',
            method: 'kneel'
        });

        this.cardsAffected = [];
    }    

    kneel(player) {
        this.game.promptForSelect(player, {
            cardCondition: card => card.getFaction() === 'thenightswatch' && (card.getType() === 'attachment' || card.getType() === 'location') && !card.kneeled,
            activePromptTitle: 'Select location',
            waitingPromptTitle: 'Waiting for opponent to use ' + this.name,
            onSelect: (player, card) => this.onCardSelected(player, card)
        });

        return true;
    }
    
    onCardSelected(player, card) {
        this.game.promptForSelect(player, {
            cardCondition: card => card.getFaction() === 'thenightswatch' && card.getType() === 'character',
            activePromptTitle: 'Select character',
            waitingPromptTitle: 'Waiting for opponent to use ' + this.name,
            onSelect: (player, card) => this.onStrCardSelected(player, card)
        });

        this.kneelingCard = card;

        return true;
    }

    onStrCardSelected(player, card) {
        this.game.addMessage('{0} uses {1} to kneels {2} to give {3} +1 STR until the end of the phase', player, this, this.kneelingCard, card);

        if(!this.eventRegistered) {
            this.game.once('onPhaseEnded', this.onPhaseEnded.bind(this));

            this.eventRegistered = true;
        }

        card.strengthModifier++;

        this.cardsAffected.push(card);

        return true;
    }

    onPhaseEnded() {
        _.each(this.cardsAffected, card => {
            card.strengthModifier--;
        });

        this.cardsAffected = [];
    }
}

Halder.code = '02065';

module.exports = Halder;
{'fraction_non_alphanumeric': 0.13810741687979539, 'fraction_numerical': 0.005115089514066497, 'mean_word_length': 2.32088285229202, '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': '4320483', 'n_tokens_mistral': 591, 'n_tokens_neox': 574, 'n_words': 118}