Package transientlibs.bindedobjects.gamecontent

Source Code of transientlibs.bindedobjects.gamecontent.Looks

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.bindedobjects.gamecontent;

import transientlibs.objects.creatures.LookType;
import transientlibs.objects.general.Node;
import transientlibs.tex.StringAnalyst;
import java.util.ArrayList;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.datasets.BindedValue;
import transientlibs.bindedobjects.core.Binding;

/**
*
* @author kibertoad
*/
public class Looks extends BindedValue {

    public int frequency;


    public static ArrayList<ArrayList<Looks>> looks = new ArrayList<ArrayList<Looks>>();
    public static ArrayList<LookType> lookTypes = new ArrayList<LookType>();
    public static Looks lastLooks;
    public static int lastLookGroup;

    public static final int typeStage = 1;
    public static final int valueStage = 2;
    public static int currentStage = 1;

    public static void loadLooks() {

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

        StringAnalyst reader = new StringAnalyst();
        boolean withResult = false;

        reader.openFile("looks.dat");

        while (!reader.eof) {


            reader.readRow(); //reader.getNextString(); reader.getNextString();
            analyzeStringForLooks(reader);
        }

        //outputAll (lookTypes);
        //outputAll (looks.get(0));
        //outputAll (looks.get(1));
        //outputAll (looks.get(2));

        //outputAll (lookTypes);



        reader.closeFile();
         }
    }

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

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

        boolean withResult = false;

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

        analyst.checkForAliases();

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

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

            currentStage = typeStage;

            lookTypes.add(new LookType());
            LookType.lastLookType = lookTypes.get(lookTypes.size() - 1);
            LookType.lastLookType.ID = analyst.getBinding(Binding.lookTypeBinding);
            LookType.lastLookType.LName.value = analyst.lastStr;

            looks.add(new ArrayList<Looks>());

            withResult = true;



        }

        int nowType;
        ArrayList<Looks> nowGroup;


        nowType = Binding.safeReadBinding(Binding.lookTypeBinding, nowStr);

        //if known look group name is the first word, add new
        if (nowType != -1) {

          //  Log.info("New looks classifier found");

            currentStage = valueStage;

            nowGroup = looks.get(nowType);

            nowGroup.add(new Looks());

            lastLooks = nowGroup.get(nowGroup.size() - 1);
            lastLooks.ofType = nowType;
            lastLooks.frequency = 10;
            lastLooks.ID = analyst.getListBinding(Binding.lookList, nowType);

            withResult = true;

            //nowGroup = looks.get(lastLookGroup)
        }

        if (nowStr.equals("name")) {
            //Log.info("current stage: "+currentStage);
            if (currentStage == valueStage) {lastLooks.LName.value = analyst.restOfRow();}
            else LookType.lastLookType.LName.value = analyst.restOfRow();

            withResult = true;
        }

        if (nowStr.equals("freq")) {
            lastLooks.frequency = analyst.getNextNumber();

            withResult = true;
        }

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

    }

    public static String returnLookName (int lookType, int lookID) {
        return looks.get(lookType).get(lookID).LName.value;
    }


}
TOP

Related Classes of transientlibs.bindedobjects.gamecontent.Looks

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.