<commit_before>const Phase = require('./phase.js');
const SimpleStep = require('./simplestep.js');
const Challenge = require('../challenge.js');
const ChallengeFlow = require('./challenge/challengeflow.js');
const ActionWindow = require('./actionwindow.js');

class ChallengePhase extends Phase {
    constructor(game) {
        super(game, 'challenge');
        this.initialise([
            new SimpleStep(this.game, () => this.beginPhase()),
            new ActionWindow(this.game, 'Before challenge', 'challengeBegin'),
            new SimpleStep(this.game, () => this.promptForChallenge())
        ]);
    }

    beginPhase() {
        this.remainingPlayers = this.game.getPlayersInFirstPlayerOrder();
    }

    promptForChallenge() {
        if(this.remainingPlayers.length === 0) {
            return true;
        }

        var currentPlayer = this.remainingPlayers[0];
        this.game.promptWithMenu(currentPlayer, this, {
            activePrompt: {
                menuTitle: '',
                buttons: [
                    { text: 'Military', method: 'chooseChallengeType', arg: 'military' },
                    { text: 'Intrigue', method: 'chooseChallengeType', arg: 'intrigue' },
                    { text: 'Power', method: 'chooseChallengeType', arg: 'power' },
                    { text: 'Done', method: 'completeChallenges' }
                ]
            },
            waitingPromptTitle: 'Waiting for opponent to initiate challenge'
        });

        return false;<commit_msg>Add pre-challenge action window after first player completes challenges (#1880)<commit_after>const Phase = require('./phase.js');
const SimpleStep = require('./simplestep.js');
const Challenge = require('../challenge.js');
const ChallengeFlow = require('./challenge/challengeflow.js');
const ActionWindow = require('./actionwindow.js');

class ChallengePhase extends Phase {
    constructor(game) {
        super(game, 'challenge');
        this.initialise([
            new SimpleStep(this.game, () => this.beginPhase()),
            new SimpleStep(this.game, () => this.promptForChallenge())
        ]);
    }

    beginPhase() {
        this.remainingPlayers = this.game.getPlayersInFirstPlayerOrder();
    }

    promptForChallenge() {
        if(this.remainingPlayers.length === 0) {
            return true;
        }

        this.game.queueStep(new ActionWindow(this.game, 'Before challenge', 'challengeBegin'));

        var currentPlayer = this.remainingPlayers[0];
        this.game.promptWithMenu(currentPlayer, this, {
            activePrompt: {
                menuTitle: '',
                buttons: [
                    { text: 'Military', method: 'chooseChallengeType', arg: 'military' },
                    { text: 'Intrigue', method: 'chooseChallengeType', arg: 'intrigue' },
                    { text: 'Power', method: 'chooseChallengeType', arg: 'power' },
                    { text: 'Done', method: 'completeChallenges' }
                ]
            },
            waitingPromptTitle: 'Waiting for opponent to initiate challenge'
        });

        return false;
{'fraction_non_alphanumeric': 0.134107027724049, 'fraction_numerical': 0.0025789813023855577, 'mean_word_length': 2.308102345415778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2125088', 'n_tokens_mistral': 873, 'n_tokens_neox': 783, 'n_words': 170}