Package transientlibs.bindedobjects.gamecontent

Source Code of transientlibs.bindedobjects.gamecontent.PersonalityTraits

/*
* 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 PersonalityTraits extends LesserBindedValue {

    public int oppositeTrait;


public static ArrayList<PersonalityTraits> personalityTraits = new ArrayList<PersonalityTraits>();

    public static PersonalityTraits lastPersonalityTrait;

public static void loadPersonalityTrait (){

        StringAnalyst reader = new StringAnalyst();


        reader.openFile("personality.dat");

        while (!reader.eof) {


        reader.readRow();
        analyzeStringForPersonalityTraits (reader);
        }

        reader.closeFile();
    }

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

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

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

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

        boolean withResult = false;

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

            personalityTraits.add (new PersonalityTraits ());
            lastPersonalityTrait = personalityTraits.get(personalityTraits.size()-1);
            lastPersonalityTrait.ID = analyst.getBinding (Binding.personalityTraitBinding);

            //ReqList.lastReqList = lastPersonalityTrait.trainReqs;

            withResult = true;

        }

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

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

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

            lastPersonalityTrait.oppositeTrait = analyst.getBinding(Binding.personalityTraitBinding);
            withResult = true;
        }


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

}

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



    public static PersonalityTraits getPersonalityTraitByCode (String byCode) {
        return personalityTraits.get(Binding.readBinding(Binding.personalityTraitBinding, byCode.toLowerCase()));
    }

    public static PersonalityTraits getPersonalityTraitByID (int byID) {
        return personalityTraits.get(byID);
    }

}
TOP

Related Classes of transientlibs.bindedobjects.gamecontent.PersonalityTraits

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.