Package transientlibs.bindedobjects.gamecontent

Source Code of transientlibs.bindedobjects.gamecontent.Motivations

/*
* 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.objects.creatures.Motivation;
import transientlibs.objects.creatures.Motivation.MotivationType;
import transientlibs.tex.StringAnalyst;

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


public static ArrayList<Motivations> motivations = new ArrayList<Motivations>();

public MotivationType motivationType;

public static Motivations lastMotivation;

public Domain domain;

public ArrayList<Activity> relatedActivities = new ArrayList<Activity>();


public static void loadMotivation (){

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

        StringAnalyst reader = new StringAnalyst();


        reader.openFile("motivations.dat");

        while (!reader.eof) {


        reader.readRow();
        analyzeStringForMotivations (reader);
        }

        reader.closeFile();
    }
}

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

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

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

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

        boolean withResult = false;

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

            motivations.add (new Motivations ());
            lastMotivation = motivations.get(motivations.size()-1);
            lastMotivation.ID = analyst.getBinding (Binding.motivationBinding);

            //ReqList.lastReqList = lastMotivation.trainReqs;

            withResult = true;

        }

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

    //if (nowStr.equals("fear")) {
//            lastMotivation.LName.value = analyst.getNextString();
//            withResult = true;
//        }


    if (nowStr.equals("wish")) {
            lastMotivation.motivationType = MotivationType.wish;
            withResult = true;
        }

    if (nowStr.equals("fear")) {
            lastMotivation.motivationType = MotivationType.fear;
            withResult = true;
        }


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

        if (nowStr.equals("domain")) {
            lastMotivation.domain = Domain.getDomainByID(analyst.getBinding(Binding.domainBinding));
            withResult = true;
        }

        if (nowStr.equals("activity")) {
            lastMotivation.relatedActivities.add(Activity.getActivityByID(analyst.readBinding(Binding.activityBinding)));
            withResult = true;
        }


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

}



}
TOP

Related Classes of transientlibs.bindedobjects.gamecontent.Motivations

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.