Package transientlibs.bindedobjects.core.datasets

Source Code of transientlibs.bindedobjects.core.datasets.Action

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

import transientlibs.tex.ActList;
import transientlibs.tex.Branch;
import transientlibs.tex.ReqList;
import transientlibs.tex.BranchList;
import transientlibs.tex.TexBlock;
import transientlibs.preui.objects.gui.elements.InfoGroup;
import java.util.ArrayList;


import transientlibs.bindedobjects.core.datasets.BindedValue;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.core.loaders.ActionLoader;
import transientlibs.processors.misc.Detonator;
import transientlibs.processors.misc.HoverInfoProcessor;
import transientlibs.preui.objects.gui.interfaces.IAnimation;
import transientlibs.preui.objects.gui.interfaces.IImage;

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

    public ReqList reqsToActivate = new ReqList();
    public static ReqList globalReqs = new ReqList();
    public static ReqList globalActivationReq = new ReqList();
    public static ActList globalActs = new ActList();
    public static ArrayList<String> globalTags = new ArrayList<String>();
    public static String globalGroup = "-";
    public int chanceToDraw = 100; //default
    public int adjustedChanceToDraw = 100; //after all bonuses
    public IAnimation unitAnimation = null;
    public Branch eval = null;
    public BranchList tex = null;
    public static ReqList mainReqList;
    public static ActList mainActList;
    //public static ArrayList<Action> actions = new ArrayList<Action>();
    public static Action lastAction;
    public boolean isSelectable = true;
    public boolean stopAutomatically = true;
    //public String group = "-";
    public IImage image;
   
    public static BindedValueContainer<Action> container = new BindedValueContainer<Action>(Binding.actionBinding);

    public static void loadActions (){
        ActionLoader loader = new ActionLoader (container);
        loader.loadAllActions();
    }
   
    @Override
    public void fillInfo(InfoGroup infoTable) {
        //infoTable.addOption(TexBlock.transformText(desc));
        reEvaluate();
        Detonator.INSTANCE.hoverInfoProcessor.fillActionInfo(this, infoTable);
    }

    @Override
    public void fillInfo(InfoGroup infoTable, HoverInfoProcessor processor) {
        //fillInfo (infoTable);
        reEvaluate();
        processor.fillActionInfo(this, infoTable);
    }

    public void fullProcessing() {

        reEvaluate();

        if ((reqs.isFulfilled())
                && (reqsToActivate.isFulfilled())) {

            acts.process();
        }
    }

    @Override
    public void reEvaluate() {
        if (eval != null) {
            //Log.info("Eval time!");
            eval.processSilently();
        }
    }

    public static ArrayList<Action> getTagActions(String checkGroup) {
        ArrayList<Action> result = new ArrayList<Action>();

        for (Action a : container.elements) {

            if ((a.hasTag(checkGroup)) && (a.reqs.isFulfilled())) {
                result.add(a);
                a.reEvaluate();
            }
        }

        return result;

    }

    public static ArrayList<Action> getGroupActions(String checkGroup) {
        ArrayList<Action> result = new ArrayList<Action>();

        for (Action a : container.elements) {

            if ((a.group.equals(checkGroup)) && (a.reqs.isFulfilled())) {
                result.add(a);
                a.reEvaluate();
            }
        }

        return result;
    }



    //public static Action getActionByID(int byID) {
    //    return Action.actions.get(byID);
    //}
   
        public static Action getActionByID (int getCode) {
        //return creatures.get(byID);
        /*
        for (Action a : actions) {
            if (a.ID == getCode) {
                return a;
            }
        }

        return null;       
        */
           
            return container.getByID(getCode);
    }

    public static Action getActionByCode(String byCode) {
        //return Action.actions.get(Binding.readBinding(Binding.actionBinding, byCode.toLowerCase()));
        //return getActionByID(Binding.readBinding(Binding.actionBinding, byCode.toLowerCase()));
        return container.getByCode(byCode);
    }

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



    @Override
    public String getDesc() {
        reEvaluate();
        return TexBlock.transformText(desc);
    }
}
TOP

Related Classes of transientlibs.bindedobjects.core.datasets.Action

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.