Package transientlibs.bindedobjects.core.datasets

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

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

import java.io.File;
import java.util.ArrayList;

import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.Binding;

import transientlibs.bindedobjects.core.datasets.LesserBindedValue;
import transientlibs.bindedobjects.core.loaders.ItemsLoader;
import transientlibs.bindedobjects.gamecontent.CombatEffect;
import transientlibs.processors.misc.Detonator;
import transientlibs.preui.objects.gui.interfaces.IImage;
import transientlibs.objects.primitives.Int;
import transientlibs.tex.ActList;
import transientlibs.tex.ReqList;
import transientlibs.tex.StringAnalyst;

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

    public int itemType; //defined in itemgroups
    public boolean isStackable = true;
    public Int keepLimit = new Int(100000); //item limit
    public CombatEffect stats = null;
    public IImage image;
    public IImage largeImage;
    public ArrayList<Action> relatedActions = new ArrayList<Action>();
    public static BindedValueContainer<Items> container = new BindedValueContainer<Items>(Binding.itemBinding);

    public ItemGroups getGroup() {
        return ItemGroups.getItemGroupsByID(itemType);
    }

    public static void loadItems() {
        ItemsLoader loader = new ItemsLoader(container);
        loader.loadAllItems();
    }

    public static Items getItemByCode(String byCode) {
        //return items.get(Binding.readBinding(Binding.itemBinding, byCode.toLowerCase()));
        //return getItemByID(Binding.readBinding(Binding.itemBinding, byCode.toLowerCase()));
        return container.getByCode(byCode);
    }

    public static Items getItemByID(int getCode) {
        return container.getByID(getCode);

        /*
         for (Items l : items) {
         if (l.ID == getCode) {
         return l;
         }
         }

         return null;
         */
    }

    public static ArrayList<Items> getAllItemsByGroup(String itemGroup) {

        /*
         ArrayList<Items> list = new ArrayList<Items>();

         for (Items l : items) {
         if (l.group == null ? itemGroup == null : l.group.equals(itemGroup)) {
         list.add(l);
         }
         }

         return list;
         */

        return container.getListByGroup(itemGroup);
    }

    public static ArrayList<Items> getAllItemsByType(String itemGroup) {

        Log.info("All items: " + container.elements.size());

        int byType = Binding.getBinding(Binding.itemTypeBinding, itemGroup);
        ArrayList<Items> list = new ArrayList<Items>();

        for (Items l : container.elements) {
            if (l.itemType == byType) {
                list.add(l);
            }

            Log.info("Has type: " + l.itemType);
            Log.info("need: " + byType);
        }

        Log.info("Hits for " + itemGroup + ": " + list.size());
        return list;
    }
}
TOP

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

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.