<commit_before>const _ = require('underscore');

const AgendaCard = require('../../agendacard.js');

class TheRainsOfCastamere extends AgendaCard {
    constructor(owner, cardData) {
        super(owner, cardData);

        // TODO: This is a hack - should not be considered an interrupt but
        //       should fire approx at that timeframe.
        this['onPlotFlip:forcedinterrupt'] = () => this.onPlotFlip();

        this.registerEvents(['onDecksPrepared', 'onPlotFlip:forcedinterrupt']);
    }

    setupCardAbilities() {
        this.reaction({
            when: {
                afterChallenge: (event, challenge) => (
                    !this.owner.faction.kneeled &&
                    challenge.challengeType === 'intrigue' &&
                    challenge.winner === this.owner &&
                    challenge.strengthDifference >= 5
                )
            },
            handler: () => {
                this.game.promptWithMenu(this.owner, this, {
                    activePrompt: {
                        menuTitle: 'Trigger Scheme plot?',
                        buttons: this.menuButtons()
                    },
                    source: this
                });
            }
        });
    }

    onDecksPrepared() {
        this.owner.createAdditionalPile('scheme plots', { title: 'Schemes', area: 'plots', isPrivate: true });
        var schemePartition = this.owner.plotDeck.partition(card => card.hasTrait('Scheme'));
        this.schemes = schemePartition[0];
        this.owner.plotDeck = _(schemePartition[1]);
        _.each(this.schemes, scheme => {
            this.owner.moveCard(scheme, 'scheme plots');
        });
    }<commit_msg>Add a manual way of triggering rains via a menu option<commit_after>const _ = require('underscore');

const AgendaCard = require('../../agendacard.js');

class TheRainsOfCastamere extends AgendaCard {
    constructor(owner, cardData) {
        super(owner, cardData);

        // TODO: This is a hack - should not be considered an interrupt but
        //       should fire approx at that timeframe.
        this['onPlotFlip:forcedinterrupt'] = () => this.onPlotFlip();

        this.registerEvents(['onDecksPrepared', 'onPlotFlip:forcedinterrupt']);
    }

    setupCardAbilities(ability) {
        this.reaction({
            when: {
                afterChallenge: (event, challenge) => (
                    !this.owner.faction.kneeled &&
                    challenge.challengeType === 'intrigue' &&
                    challenge.winner === this.owner &&
                    challenge.strengthDifference >= 5
                )
            },
            handler: this.trigger.bind(this)
        });

        this.action({
            title: 'Manually trigger',
            method: 'trigger',
            cost: ability.costs.kneelFactionCard()
        });
    }

    trigger() {
        this.game.promptWithMenu(this.owner, this, {
            activePrompt: {
                menuTitle: 'Trigger Scheme plot?',
                buttons: this.menuButtons()
            },
            source: this
        });        
    }

    onDecksPrepared() {
        this.owner.createAdditionalPile('scheme plots', { title: 'Schemes', area: 'plots', isPrivate: true });
        var schemePartition = this.owner.plotDeck.partition(card => card.hasTrait('Scheme'));
        this.schemes = schemePartition[0];
        this.owner.plotDeck = _(schemePartition[1]);
        _.each(this.schemes, scheme => {
            this.owner.moveCard(scheme, 'scheme plots');
        });
    }
{'fraction_non_alphanumeric': 0.12419036891016615, 'fraction_numerical': 0.0016896648831315122, 'mean_word_length': 1.812351543942993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '127863', 'n_tokens_mistral': 982, 'n_tokens_neox': 921, 'n_words': 184}