<commit_before>package org.nbgames.yaya.gamedef;

import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.nbgames.core.NbGames;
import org.nbgames.core.json.JsonHelper;
import org.nbgames.yaya.YayaController;
import org.nbgames.yaya.api.GameLoader;
import org.openide.util.Lookup;
import se.trixon.almond.FileHelper;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public enum GameDef {

    INSTANCE;
    private LinkedList<GameType> mGameTypes;

    public String dump() {
        StringBuilder stringBuilder = new StringBuilder();

        for (GameType gameType : mGameTypes) {
            stringBuilder.append(gameType.dump());
        }

        return stringBuilder.toString();
    }

    public String[] getIdArray() {
        String[] result = new String[mGameTypes.size()];

        for (int i = 0; i < result.length; i++) {
            result[i] = mGameTypes.get(i).getId();
        }

        return result;
    }

    public String getIdForIndex(int index) {
        return mGameTypes.get(index).getId();
    }

    public int getIndexForId(String id) {
        int index = -1;

        for (int i = 0; i < getIdArray().length; i++) {
            if (id.equalsIgnoreCase(getIdArray()[i])) {
                index = i;
                break;
            }
        }

        return index;
    }

    public String getTitle(String id) {
        for (GameType gameType : mGameTypes) {
            if (gameType.getId().equalsIgnoreCase(id)) {
                return gameType.getTitle();
            }
        }
        // TODO Throw something?
        return "";
    }

    public String[] getTitleArray() {
        String[] result = new String[mGameTypes.size()];

        for (int i = 0; i < result.length; i++) {
            result[i] = mGameTypes.get(i).getTitle();
        }

        return result;
    }<commit_msg>Loads default game if previous game is uninstalled.<commit_after>package org.nbgames.yaya.gamedef;

import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.nbgames.core.NbGames;
import org.nbgames.core.json.JsonHelper;
import org.nbgames.yaya.YayaController;
import org.nbgames.yaya.api.GameLoader;
import org.openide.util.Lookup;
import se.trixon.almond.FileHelper;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public enum GameDef {

    INSTANCE;
    private LinkedList<GameType> mGameTypes;

    public String dump() {
        StringBuilder stringBuilder = new StringBuilder();

        for (GameType gameType : mGameTypes) {
            stringBuilder.append(gameType.dump());
        }

        return stringBuilder.toString();
    }

    public String[] getIdArray() {
        String[] result = new String[mGameTypes.size()];

        for (int i = 0; i < result.length; i++) {
            result[i] = mGameTypes.get(i).getId();
        }

        return result;
    }

    public String getIdForIndex(int index) {
        return mGameTypes.get(index).getId();
    }

    public int getIndexForId(String id) {
        int index = -1;

        for (int i = 0; i < getIdArray().length; i++) {
            if (id.equalsIgnoreCase(getIdArray()[i])) {
                index = i;
                break;
            }
        }

        if (index == -1) {
            index = getIndexForId("default");
        }

        return index;
    }

    public String getTitle(String id) {
        for (GameType gameType : mGameTypes) {
            if (gameType.getId().equalsIgnoreCase(id)) {
                return gameType.getTitle();
            }
        }
        // TODO Throw something?
        return "";
    }

    public String[] getTitleArray() {
        String[] result = new String[mGameTypes.size()];

        for (int i = 0; i < result.length; i++) {
            result[i] = mGameTypes.get(i).getTitle();
        }

        return result;
    }
{'fraction_non_alphanumeric': 0.12469196648595367, 'fraction_numerical': 0.0022178413011335633, 'mean_word_length': 2.186028257456829, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, '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': '5711924', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1212, 'n_words': 270}