Search in sources :

Example 41 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class Entity method toBase.

public void toBase() {
    setBeingReset(true);
    // TODO DRY!
    if (getMaster() != null) {
        if (getResetter() != null) {
            getResetter().toBase();
            setBeingReset(false);
            return;
        }
    }
    getPropCache().clear();
    // TODO [OPTIMIZED] no need to clear
    getIntegerMap(false).clear();
    // type's map?
    if (modifierMaps != null) {
        // remember? For interesting spells or log
        modifierMaps.clear();
    }
    // info...
    if (!type.checkProperty(G_PROPS.DISPLAYED_NAME)) {
        setProperty(G_PROPS.DISPLAYED_NAME, getName(), true);
    }
    if (this.owner != getOriginalOwner()) {
        LogMaster.log(LogMaster.CORE_DEBUG, getName() + ": original owner restored!");
    }
    this.owner = getOriginalOwner();
    HashSet<PARAMETER> params = new HashSet<>(getParamMap().keySet());
    params.addAll(type.getParamMap().keySet());
    for (PARAMETER p : params) {
        if (p == null) {
            continue;
        }
        if (p.isDynamic()) {
            if (p.isWriteToType()) {
                getType().setParam(p, getParam(p), true);
            }
            continue;
        }
        String baseValue = getType().getParam(p);
        String value = getParam(p);
        getValueCache().put(p, value);
        if (!value.equals(baseValue)) {
            String amount = getType().getParam(p);
            putParameter(p, amount);
            if (game.isStarted() && !game.isSimulation()) {
                if (p.isDynamic()) {
                    fireParamEvent(p, amount, CONSTRUCTED_EVENT_TYPE.PARAM_MODIFIED);
                }
            }
        }
    }
    HashSet<PROPERTY> props = new HashSet<>(getPropMap().keySet());
    props.addAll(type.getPropMap().keySet());
    for (PROPERTY p : props) {
        if (p.isDynamic()) {
            if (p.isWriteToType()) {
                getType().setProperty(p, getProperty(p));
            }
            continue;
        }
        String baseValue = getType().getProperty(p);
        if (TextParser.isRef(baseValue)) {
            baseValue = new Property(baseValue).getStr(ref);
            if ((baseValue) == null) {
                baseValue = getType().getProperty(p);
            }
        }
        String value = getProperty(p);
        getValueCache().put(p, value);
        if (!value.equals(baseValue)) {
            putProperty(p, baseValue);
        } else {
            putProperty(p, baseValue);
        }
    }
    // resetStatus();
    setDirty(false);
    setBeingReset(false);
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) Property(main.system.math.Property) PARAMETER(main.content.values.parameters.PARAMETER)

Example 42 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class PropertyPage method getComponent.

@Override
protected EntityValueComponent getComponent(VALUE v) {
    if (v instanceof PARAMETER) {
        ParamElement pElement = new ParamElement(v);
        pElement.setEntity(entity);
        return pElement;
    }
    PROPERTY p = (PROPERTY) v;
    if (isIconContainer(p)) {
        ContainerIconElement containerIconElement = new ContainerIconElement(p);
        X = STD_COMP_IMAGES.ARROW_3_RIGHT.getImg().getWidth(null) / 2 + (VISUALS.INFO_PANEL.getImage().getWidth(null) - ValueInfoPage.INNER_WIDTH) / 2;
        containerIconElement.setEntity(entity);
        return containerIconElement;
    }
    if (isWrappedText(p)) {
        X = (VISUALS.INFO_PANEL.getImage().getWidth(null) - ValueInfoPage.INNER_WIDTH) / 2;
        ContainerTextElement containerTextElement = new ContainerTextElement(p);
        containerTextElement.setEntity(entity);
        containerTextElement.refresh();
        return containerTextElement;
    }
    PropertyElement propertyElement = new PropertyElement(p);
    propertyElement.setEntity(entity);
    return propertyElement;
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) PARAMETER(main.content.values.parameters.PARAMETER)

Example 43 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class FilterMaster method filter.

public static Collection<?> filter(Collection<?> list, String valueName, String value, OBJ_TYPE TYPE, boolean prop, boolean filterOut, Boolean strict_or_greater_less_equal) {
    List<Object> filteredList = new ArrayList<>();
    for (Object l : list) {
        Entity entity;
        if (l instanceof Entity) {
            entity = (Entity) l;
        } else {
            entity = DataManager.getType(l.toString(), TYPE);
        }
        if (entity == null) {
            continue;
        }
        boolean result;
        if (prop) {
            PROPERTY property = ContentManager.getPROP(valueName);
            if (property.isContainer()) // if (!BooleanMaster.isFalse(strict_or_greater_less_equal))
            {
                result = entity.checkContainerProp(property, value, strict_or_greater_less_equal == null);
            } else {
                result = StringMaster.compareByChar(entity.getProperty(property), value, BooleanMaster.isTrue(strict_or_greater_less_equal));
            }
        // entity.checkProperty();
        } else {
            PARAMETER param = ContentManager.getPARAM(valueName);
            int amount = new Formula(value).getInt(new Ref(entity));
            if (strict_or_greater_less_equal == null) {
                result = entity.getIntParam(param) == amount;
            } else {
                result = entity.checkParam(param, "" + amount);
                if (!strict_or_greater_less_equal) {
                    result = !result;
                }
            }
        }
        if (filterOut) {
            if (result) {
                filteredList.add(l);
            }
        } else if (!result) {
            filteredList.add(l);
        }
    }
    for (Object l : filteredList) {
        list.remove(l);
    }
    return list;
}
Also used : Entity(main.entity.Entity) Formula(main.system.math.Formula) Ref(main.entity.Ref) PROPERTY(main.content.values.properties.PROPERTY) ArrayList(java.util.ArrayList) PARAMETER(main.content.values.parameters.PARAMETER)

Example 44 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class EntityResetter method toBase.

public void toBase() {
    getPropCache().clear();
    // TODO [OPTIMIZED] no need to clear
    getEntity().getIntegerMap(false).clear();
    // type's map?
    if (getEntity().getModifierMaps() != null) {
        // remember? For interesting spells or log
        getEntity().getModifierMaps().clear();
    }
    // info...
    if (!getType().checkProperty(G_PROPS.DISPLAYED_NAME)) {
        getEntity().setProperty(G_PROPS.DISPLAYED_NAME, getName(), true);
    }
    if (this.getEntity().getOwner() != getEntity().getOriginalOwner()) {
        LogMaster.log(LogMaster.CORE_DEBUG, getName() + ": original owner restored!");
    }
    getEntity().setOwner(getEntity().getOriginalOwner());
    HashSet<PARAMETER> params = new HashSet<>(getEntity().getParamMap().keySet());
    params.addAll(getType().getParamMap().keySet());
    for (PARAMETER p : params) {
        if (p == null) {
            continue;
        }
        if (p.isDynamic()) {
            if (p.isWriteToType()) {
                getType().setParam(p, getParam(p), true);
            }
            continue;
        }
        String baseValue = getType().getParam(p);
        String value = getParam(p);
        getEntity().getValueCache().put(p, value);
        if (!value.equals(baseValue)) {
            String amount = getType().getParam(p);
            if (getEntity().isTypeLinked()) {
                getType().getParamMap().put(p, value);
            }
            getEntity().getParamMap().put(p, amount);
            if (game.isStarted() && !game.isSimulation()) {
                if (p.isDynamic()) {
                    getEntity().fireParamEvent(p, amount, CONSTRUCTED_EVENT_TYPE.PARAM_MODIFIED);
                }
            }
        }
    }
    HashSet<PROPERTY> props = new HashSet<>(getEntity().getPropMap().keySet());
    props.addAll(getType().getPropMap().keySet());
    for (PROPERTY p : props) {
        if (p.isDynamic()) {
            if (p.isWriteToType()) {
                getType().setProperty(p, getProperty(p));
            }
            continue;
        }
        String baseValue = getType().getProperty(p);
        if (TextParser.isRef(baseValue)) {
            baseValue = new Property(baseValue).getStr(getRef());
            if ((baseValue) == null) {
                baseValue = getType().getProperty(p);
            }
        }
        String value = getProperty(p);
        getEntity().getValueCache().put(p, value);
        if (!value.equals(baseValue)) {
            if (getEntity().isTypeLinked()) {
                getType().getPropMap().put(p, value);
            }
            getEntity().getPropMap().put(p, baseValue);
        } else {
            // TODO ???
            if (getEntity().isTypeLinked()) {
                getType().getPropMap().put(p, value);
            }
            getEntity().getPropMap().put(p, baseValue);
        }
    }
    resetStatus();
    getEntity().setDirty(false);
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) Property(main.system.math.Property) PARAMETER(main.content.values.parameters.PARAMETER) HashSet(java.util.HashSet)

Example 45 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class TreeControlPanel method setProperty.

// private static void setProp(boolean alt, ObjType selectedType) {
// 
// }
private static boolean setProperty(boolean alt, ObjType selectedType) {
    String name;
    String containerString = "Lore;Description;Flavor;Image;Actives;Passives;Attribute Bonuses;Parameter Bonuses;";
    // TODO v-flow buttons one-click!
    List<String> listData = StringMaster.openContainer(containerString);
    name = new ListChooser(SELECTION_MODE.SINGLE, listData, true).choose();
    if (name == null) {
        return false;
    }
    // name = new ButtonChoicePanel(SELECTION_MODE.SINGLE,
    // listData).choose();
    PROPERTY prop = ContentManager.getPROP(name);
    String value = null;
    if (alt) {
        value = new TextEditor().launch(selectedType.getProperty(prop));
    } else if (DC_ContentManager.getEditorMap() != null) {
        if (DC_ContentManager.getEditorMap().get(name) != null) {
            value = DC_ContentManager.getEditorMap().get(name).launch(value, name);
        }
    } else if (prop == G_PROPS.IMAGE) {
        value = new ImageChooser().launch(selectedType.getImagePath(), "");
    // tableMouse.getEditor(prop)
    } else {
        value = new TextEditor().launch(selectedType.getProperty(prop));
    }
    if (value != null) {
        selectedType.setProperty(prop, value);
    }
    return true;
// TableMouseListener
// if ()
}
Also used : TextEditor(main.swing.generic.components.editors.TextEditor) ImageChooser(main.swing.generic.components.editors.ImageChooser) PROPERTY(main.content.values.properties.PROPERTY) ListChooser(main.swing.generic.components.editors.lists.ListChooser)

Aggregations

PROPERTY (main.content.values.properties.PROPERTY)57 PARAMETER (main.content.values.parameters.PARAMETER)23 ObjType (main.entity.type.ObjType)17 OBJ_TYPE (main.content.OBJ_TYPE)6 ArrayList (java.util.ArrayList)5 VALUE (main.content.VALUE)5 Ref (main.entity.Ref)5 DC_TYPE (main.content.DC_TYPE)4 Node (org.w3c.dom.Node)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)3 Unit (eidolons.entity.obj.unit.Unit)3 XLinkedMap (main.data.XLinkedMap)3 Obj (main.entity.obj.Obj)3 EnumMaster (main.system.auxiliary.EnumMaster)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)2 File (java.io.File)2 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 MOD_PROP_TYPE (main.ability.effects.Effect.MOD_PROP_TYPE)2