<commit_before>class IntroText extends Phaser.State {
    create(game) {
        game.stage.backgroundColor = "black";
        var style = {
            font: "32px Arial",
            fill: "black",
            wordWrap: false,
            //align: "center",
            //backgroundColor: "black"
        };
        bg = game.add.sprite(0, 0, "storyBackground");
        backstory = game.add.text(90, 64, '', style);
        displayBackstory();
    }
};

var wordDelay = 120;
var lineDelay = 400;
var content = [
    "Ivan, ",
    "You are terrible.",
    "You do not judge like your comrades.",
    "Americanski says you either take bribe",
    "  or never learn how to judge.",
    "You disgrace mother Russia!",
    "Interpretive dance serious business!",
    "We send you back to beginning, ",
    "  learn judging all over again.",
    "Then MAYBE you return for next Olympics.",
    "",
    "-- Minister of Cultural Emergencies"
];

var line = [];
var backstory;
var bg;

var wordIndex = 0;
var lineIndex = 0;

function displayBackstory() {

    music = game.add.audio('dark');
    music.play();
    music.volume += 50.0;

    nextLine();

}

function nextLine() {

    if (lineIndex === content.length) {
        //  We're finished
        stamp = game.add.sprite(0, 0, "stamp");
        stamp.x = 625;
        stamp.y = 500;

        game.time.events.loop(Phaser.Timer.SECOND * 3, function() {
            music.stop();
            game.state.start('dancing');
        }, this);
        return;
    }

    //  Split the current line on spaces, so one word per array element
    line = content[lineIndex].split(' ');

    //  Reset the word index to zero (the first word in the line)
    wordIndex = 0;

    //  Call the 'nextWord' function once for each word in the line (line.length)
    game.time.events.repeat(wordDelay, line.length, nextWord, this);

    //  Advance to the next line
    lineIndex++;

}

function nextWord() {

    //  Add the next word onto the text string, followed by a space
    backstory.text = backstory.text.concat(line[wordIndex] + " ");


    //  Advance the word index to the next word in the line
    wordIndex++;

    //  Last word?
    if (wordIndex === line.length) {
        //  Add a carriage return
        backstory.text = backstory.text.concat("\n");

        //  Get the next line after the lineDelay amount of ms has elapsed
        game.time.events.add(lineDelay, nextLine, this);
    }

}

export default IntroText;<commit_msg>WIP working on converting introtext<commit_after>class IntroText extends Phaser.State {
    constructor() {
        super();
        this.wordDelay = 120;
        this.lineDelay = 400;
        this.content = [
            "Ivan, ",
            "You are terrible.",
            "You do not judge like your comrades.",
            "Americanski says you either take bribe",
            "  or never learn how to judge.",
            "You disgrace mother Russia!",
            "Interpretive dance serious business!",
            "We send you back to beginning, ",
            "  learn judging all over again.",
            "Then MAYBE you return for next Olympics.",
            "",
            "-- Minister of Cultural Emergencies"
        ];

        this.line = [];

        this.wordIndex = 0;
        this.lineIndex = 0;
    }
    create() {
        this.game.stage.backgroundColor = "black";
        let style = {
            font: "32px Arial",
            fill: "black",
            wordWrap: false,
            //align: "center",
            //backgroundColor: "black"
        };
        this.game.add.sprite(0, 0, "storyBackground");
        this.backstory = this.game.add.text(90, 64, '', style);
        this.displayBackstory();
    }

    displayBackstory() {
        this.music = this.game.add.audio('dark');
        this.music.play();
        this.music.volume += 50.0;

        this.nextLine();

    }

    nextLine() {
        if (this.lineIndex === this.content.length) {
            //  We're finished
            this.game.add.sprite(625, 500, "stamp");

            this.game.time.events.loop(Phaser.Timer.SECOND * 3, function() {
                this.music.stop();
                this.game.state.start('dancing');
            }, this);
            return;
        }

        //  Split the current line on spaces, so one word per array element
        this.line = this.content[this.lineIndex].split(' ');

        //  Reset the word index to zero (the first word in the line)
        this.wordIndex = 0;

        //  Call the 'nextWord' function once for each word in the line (line.length)
        this.game.time.events.repeat(this.wordDelay, line.length, this.nextWord, this);

        //  Advance to the next line
        this.lineIndex++;

    }

    nextWord() {
        //  Add the next word onto the text string, followed by a space
        backstory.text = backstory.text.concat(this.line[this.wordIndex] + " ");

        //  Advance the word index to the next word in the line
        this.wordIndex++;

        //  Last word?
        if (this.wordIndex === line.length) {
            //  Add a carriage return
            backstory.text = backstory.text.concat("\n");

            //  Get the next line after the lineDelay amount of ms has elapsed
            this.game.time.events.add(this.lineDelay, this.nextLine, this);
        }

    }
};

export default IntroText;
{'fraction_non_alphanumeric': 0.1216065451840833, 'fraction_numerical': 0.010412792859799182, 'mean_word_length': 1.8919354838709677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5029788', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1532, 'n_words': 464}