// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   multiGen.java

package boggle.server;

import boggle.settings;
import java.io.*;

// Referenced classes of package boggle.server:
//            dictionaryException

public class multiGen extends Thread
{

    public static void main(String args[])
    {
        multiGen multigen = new multiGen();
        multigen.run();
        System.out.println(multigen.getResult());
    }

    public String getResult()
    {
        return error;
    }

    public void run()
    {
        String s = settings.getGameDirectory();
        File file = new File(s);
        if(!file.isAbsolute())
        {
            s = file.getAbsolutePath();
            file = new File(s);
        }
        try
        {
            s = file.getCanonicalPath();
        }
        catch(IOException _ex)
        {
            error += "multiGen: cannot find " + s;
            return;
        }
        if(!file.isDirectory())
        {
            error += "multiGen: " + s + " is not a directory";
            return;
        }
        if(!file.canWrite())
        {
            error += "multiGen: cannot write to " + s;
            return;
        }
        String as[] = new String[100];
        for(int i = 0; i < settings.getLanguages().length; i++)
        {
            File file1 = new File(file, settings.getLanguages()[i] + ".dict");
            System.out.println("multi using filename " + settings.getLanguages()[i] + ".dict");
            if(!file1.isFile() || !file1.canRead())
            {
                error += "multiGen: Failure: cannot find dictionary " + file1.getAbsolutePath();
                return;
            }
            for(int j = 0; j < settings.getGameNames().length; j++)
            {
                for(int k = 0; k < 100; k++)
                {
                    for(int l = 0; l < 10; l++)
                        as[k] = settings.getGameNames()[j] + k + "." + settings.getLanguages()[i];

                }

                for(int i1 = 0; i1 < 100; i1++)
                {
                    while(Thread.activeCount() >= settings.getMaxThreads()) 
                        try
                        {
                            synchronized(this)
                            {
                                Thread.sleep(settings.getPollTime() * 1000);
                            }
                        }
                        catch(InterruptedException _ex) { }
                    File file2 = new File(file, as[i1]);
                    if(!file2.exists())
                        try
                        {
                            gameGen gamegen = settings.getGameGen(j, file1, file2);
                            gamegen.setPriority(1);
                            gamegen.start();
                        }
                        catch(dictionaryException dictionaryexception)
                        {
                            error += "multiGen Error: " + dictionaryexception.getMessage();
                            System.out.println("multiGen: " + dictionaryexception.getMessage());
                            dictionaryexception.printStackTrace();
                        }
                }

            }

        }

    }

    public multiGen()
    {
        error = "";
    }

    private String error;
}
