Package transientlibs.bindedobjects.gamecontent

Source Code of transientlibs.bindedobjects.gamecontent.Domain

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package transientlibs.bindedobjects.gamecontent;

import java.util.ArrayList;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.core.datasets.LesserBindedValue;
import transientlibs.tex.StringAnalyst;

/**
*
* @author kibertoad
*/
public class Domain extends LesserBindedValue {


public static ArrayList<Domain> domains = new ArrayList<Domain>();

    public static Domain lastDomain;

public static void loadDomains (){

        if (StringAnalyst.isFileExist("domains.dat")) {

        StringAnalyst reader = new StringAnalyst();


        reader.openFile("domains.dat");

        while (!reader.eof) {


        reader.readRow();
        analyzeStringForDomains (reader);
        }

        reader.closeFile();
    }
}

          public static void analyzeStringForDomains (StringAnalyst analyst) {
        analyzeStringForDomains ("-NO-", analyst);
    }

public static void analyzeStringForDomains (String getString, StringAnalyst analyst) {

   if (!"-NO-".equals(getString)) {analyst.fullStr = getString;}

        analyst.getNextString();
        String nowStr = analyst.lastStr;

        boolean withResult = false;

        if (nowStr.equals("domain")) {

            domains.add (new Domain ());
            lastDomain = domains.get(domains.size()-1);
            lastDomain.ID = analyst.getBinding (Binding.domainBinding);

            //ReqList.lastReqList = lastDomain.trainReqs;

            withResult = true;

        }

    if (nowStr.equals("name")) {
            lastDomain.LName.value = analyst.getNextString();
            withResult = true;
        }

        if (nowStr.equals("desc")) {
            lastDomain.desc = analyst.restOfRow();
            withResult = true;
        }


        if ((withResult == false) && (nowStr.length()>2) && (!nowStr.startsWith("//"))) {
            Log.error("Unknown string: "+nowStr);        }

}

  @Override
    public String name (){
        return LName.value;
    }


    public static Domain getDomainByCode (String byCode) {
        return domains.get(Binding.readBinding(Binding.domainBinding, byCode.toLowerCase()));
    }

    public static Domain getDomainByID (int byID) {
        return domains.get(byID);
    }

}
TOP

Related Classes of transientlibs.bindedobjects.gamecontent.Domain

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.