Package transientlibs.bindedobjects.gamecontent

Source Code of transientlibs.bindedobjects.gamecontent.Group

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

package transientlibs.bindedobjects.gamecontent;

import transientlibs.bindedobjects.gamecontent.Creatures;
import java.util.ArrayList;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.core.datasets.LesserBindedValue;
import transientlibs.objects.creatures.CreatureSlot;
import transientlibs.tex.StringAnalyst;

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



public static ArrayList<Group> groups = new ArrayList<Group>();

    public ArrayList<CreatureSlot> creatures = new ArrayList<CreatureSlot>();


    public static Group lastGroup;
    public static CreatureSlot lastSlot;

public static void loadGroup (){

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

        StringAnalyst reader = new StringAnalyst();


        reader.openFile("groups.dat");

        while (!reader.eof) {


        reader.readRow();
        analyzeStringForGroups (reader);
        }

        reader.closeFile();
    }
}

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

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

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

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

        boolean withResult = false;

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

            groups.add (new Group ());
            lastGroup = groups.get(groups.size()-1);
            lastGroup.ID = analyst.getBinding (Binding.groupBinding);

            withResult = true;
        }

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

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

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

            lastSlot = new CreatureSlot();
            lastSlot.creature = Creatures.getCreatureByCode(analyst.getNextString());

            lastGroup.creatures.add(lastSlot);
        }

        if (nowStr.equals("position")) {
            lastSlot.screenCoords.x = analyst.getNextNumber();
            lastSlot.screenCoords.y = analyst.getNextNumber();
        }


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

}

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



    public static Group getGroupByID (int byID) {
        return groups.get(byID);
    }

    public static Group getGroupByCode (String byCode) {
        return groups.get(Binding.readBinding(Binding.groupBinding, byCode.toLowerCase()));
    }

}
TOP

Related Classes of transientlibs.bindedobjects.gamecontent.Group

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.