<commit_before>var wordToSearch = "",
    wordArray = [],
    checkedLetters = "",
    button,
    errors = 0,
    displayedWord,
    description,
    letter,
    buttonText,
    message,
    lettersStat,
    guessedLetters,
    triedLetters,
    wrongLetters;

// TODO: Implement whole word guessing

var GameState = {
    preload: function () {
        this.load.image("hangingMan0", "assets/images/0.png");
        this.load.image("hangingMan1", "assets/images/1.png");
        this.load.image("hangingMan2", "assets/images/2.png");
        this.load.image("hangingMan3", "assets/images/3.png");
        this.load.image("hangingMan4", "assets/images/4.png");
        this.load.image("hangingMan5", "assets/images/5.png");
        this.load.image("button", "assets/images/button.png");

    },

    create: function () {
        errors = 0;
        triedLetters = "";
        wrongLetters = "";
        stats = JSON.parse(localStorage.getItem("stats")) || stats;
        this.game.stage.backgroundColor = "#ffffff";
        this.game.add.text(0, 0, "Played Games: " + stats.playedGames, { fontSize: 15 });
        this.game.add.text(0, 20, "Won Games: " + stats.wonGames, { fontSize: 15 });
        this.game.add.text(0, 40, "Lost Games: " + stats.lostGames, { fontSize: 15 });
        button = this.game.add.button(550, 40, "button", function() {
            var container = document.getElementById("container");
            var input = document.createElement("input");
            input.setAttribute("type", "text");
            input.setAttribute("id", "wordInput");            
            container.appendChild(input);
            input.focus();
            //button.onDownCallback.enabled = false;
            game.input.keyboard.onDownCallback = function(e) {
                if (e.keyCode == 13) {
                    var input = document.getElementById("wordInput");
                    var word = input.value;
                    if (word.toUpperCase() == wordToSearch) {
                        console.log("you win");
                    } else {
                        console.log("you lose");
                    }
                }
            } ;
        });
        button.scale.setTo(0.6, 1);
        button.anchor.x = 0.5;
        buttonText =  this.game.add.text(550, 45, "Guess word");
        buttonText.anchor.x = 0.5;
        lettersStat = this.game.add.text(0, 60, "Guessed Letters: " + stats.guessedLetters, { fontSize: 15 });
        guessedLetters = this.game.add.text(0, 200, "Wrong Letters: " + wrongLetters, { fontSize: 15 });
        message = this.game.add.text();
        message.anchor.x = 0.5;
        this.hangingMan = this.game.add.sprite(game.world.centerX, 0, "hangingMan0");<commit_msg>word guessing is fully done<commit_after>var wordToSearch = "",
    wordArray = [],
    checkedLetters = "",
    button,
    errors = 0,
    displayedWord,
    description,
    letter,
    buttonText,
    message,
    lettersStat,
    guessedLetters,
    triedLetters,
    wrongLetters;

// TODO: refactor by removing code repetition and renaming variables

var GameState = {
    preload: function () {
        this.load.image("hangingMan0", "assets/images/0.png");
        this.load.image("hangingMan1", "assets/images/1.png");
        this.load.image("hangingMan2", "assets/images/2.png");
        this.load.image("hangingMan3", "assets/images/3.png");
        this.load.image("hangingMan4", "assets/images/4.png");
        this.load.image("hangingMan5", "assets/images/5.png");
        this.load.image("button", "assets/images/button.png");

    },

    create: function () {
        errors = 0;
        triedLetters = "";
        wrongLetters = "";
        stats = JSON.parse(localStorage.getItem("stats")) || stats;
        this.game.stage.backgroundColor = "#ffffff";
        this.game.add.text(0, 0, "Played Games: " + stats.playedGames, { fontSize: 15 });
        this.game.add.text(0, 20, "Won Games: " + stats.wonGames, { fontSize: 15 });
        this.game.add.text(0, 40, "Lost Games: " + stats.lostGames, { fontSize: 15 });
        button = this.game.add.button(550, 40, "button", function() {
            var container = document.getElementById("container");
            var input = document.createElement("input");
            input.setAttribute("type", "text");
            input.setAttribute("id", "wordInput");            
            container.appendChild(input);
            input.focus();
            game.input.keyboard.onDownCallback = function(e) {
                if (e.keyCode == 13) {
                    var input = document.getElementById("wordInput");
                    var word = input.value;
                    input.remove();

                    if (word.toUpperCase() == wordToSearch) {
                        stats.guessedWords++;
                        stats.playedGames++;
                        stats.wonGames++;
                        var win = this.game.add.text(game.world.centerX, 150, "YOU WIN!", { fontSize: 30, backgroundColor: "#ffffff" });
                        win.anchor.x = 0.5;
                        game.state.states.GameState.addButton("New Game");
                    } else {
                        stats.playedGames++;                
                        stats.lostGames++;
                        var lose = this.game.add.text(game.world.centerX, 150, "YOU LOSE!", { fontSize: 30, backgroundColor: "#ffffff" });
                        lose.anchor.x = 0.5;
                        game.state.states.GameState.addButton("New Game");
                    }
                }
            } ;
        });
        button.scale.setTo(0.6, 1);
        button.anchor.x = 0.5;
        buttonText =  this.game.add.text(550, 45, "Guess word");
        buttonText.anchor.x = 0.5;
        lettersStat = this.game.add.text(0, 60, "Guessed Letters: " + stats.guessedLetters, { fontSize: 15 });
        lettersStat = this.game.add.text(0, 80, "Guessed Words: " + stats.guessedWords, { fontSize: 15 });
        guessedLetters = this.game.add.text(0, 200, "Wrong Letters: " + wrongLetters, { fontSize: 15 });
        message = this.game.add.text();
        message.anchor.x = 0.5;
        this.hangingMan = this.game.add.sprite(game.world.centerX, 0, "hangingMan0");
{'fraction_non_alphanumeric': 0.14816, 'fraction_numerical': 0.02288, 'mean_word_length': 1.9347417840375587, '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': '2173153', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1831, 'n_words': 331}