Search in sources :

Example 6 with PARAMETER

use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.

the class XML_Reader method createCustomTypeList.

public static List<ObjType> createCustomTypeList(String xml, OBJ_TYPE TYPE, Game game, boolean overwrite, boolean incompleteTypes, boolean wrap) {
    List<ObjType> types = new ArrayList<>();
    if (wrap) {
        xml = XML_Converter.wrap("wrapped", xml);
    }
    Document doc = XML_Converter.getDoc(xml);
    List<Node> nodes = XML_Converter.getNodeList(XML_Converter.getNodeList(doc).get(0));
    for (Node node : nodes) {
        // typeName = node.getNodeName();
        ObjType type = TypeBuilder.buildType(node, TYPE.toString());
        game.initType(type);
        if (incompleteTypes) {
            ObjType parent = DataManager.getType(type.getProperty(G_PROPS.PARENT_TYPE), type.getOBJ_TYPE_ENUM());
            if (parent != null) {
                type.setType(parent);
                for (PROPERTY prop : parent.getPropMap().keySet()) {
                    if (type.getProperty(prop).isEmpty()) {
                        type.setProperty(prop, parent.getProperty(prop));
                    }
                }
                for (PARAMETER param : parent.getParamMap().keySet()) {
                    if (type.getParam(param).isEmpty()) {
                        type.setParam(param, parent.getParam(param));
                    }
                }
            }
        }
        if (overwrite) {
            DataManager.overwriteType(type);
        }
        types.add(type);
    }
    return types;
}
Also used : ObjType(main.entity.type.ObjType) PROPERTY(main.content.values.properties.PROPERTY) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) PARAMETER(main.content.values.parameters.PARAMETER)

Example 7 with PARAMETER

use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.

the class XML_Writer method getTypeXML_Builder.

public static StringBuilder getTypeXML_Builder(Entity type, StringBuilder builder, Entity parent) {
    if (type.getName().isEmpty()) {
        return builder;
    }
    builder.append(openXML(type.getName()));
    builder.append("<params>");
    for (PARAMETER param : type.getParamMap().keySet()) {
        if (param == null) {
            continue;
        }
        String value = XML_Formatter.formatXmlTextContent(type.getParamMap().get(param), param);
        if (parent != null) {
            if (parent.getParam(param).equals(value)) {
                continue;
            }
        }
        if (!checkWriteValue(param, value, type.getOBJ_TYPE_ENUM())) {
            continue;
        }
        appendLeafNode(builder, StringMaster.capitalizeFirstLetter(param.getName()), value);
    }
    builder.append("</params>");
    builder.append("<props>");
    for (PROPERTY prop : type.getPropMap().keySet()) {
        String value = XML_Formatter.formatXmlTextContent(type.getPropMap().get(prop), prop);
        if (parent != null) {
            // don't duplicate
            if (parent.getProperty(prop).equals(value)) {
                continue;
            }
        }
        if (prop == null) {
            LogMaster.log(1, "null key! ; value = " + type.getPropMap().get(prop));
        }
        appendLeafNode(builder, StringMaster.capitalizeFirstLetter(prop.getName()), value);
    }
    builder.append("</props>");
    return builder.append(closeXML(type.getName()));
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) PARAMETER(main.content.values.parameters.PARAMETER)

Example 8 with PARAMETER

use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.

the class HeroObjectModifyingEffect method applyThis.

/**
 * Modstring format: valueName(value);valueName2(value2);... Use [mod],
 * [set], [remove] to change the default ADD function of modstring
 */
public boolean applyThis() {
    if (ref.getTargetObj().isDead() || ref.getSourceObj().isDead()) {
        removeEffects();
        return false;
    }
    if (game.isSimulation()) {
        if (!checkApplyInSimulation()) {
            return true;
        }
    }
    // what if the group has changed? perhaps there should be a map...
    if (prop) {
        if (propMap == null) {
            propMap = new RandomWizard<PROPERTY>().constructStringWeightMap(modString, PROPERTY.class);
        } else {
            LogMaster.log(1, "prop map " + propMap.toString());
        }
    } else if (// TODO support PROPERTY?
    map == null) {
        map = new RandomWizard<PARAMETER>().constructStringWeightMap(modString, PARAMETER.class);
    } else {
        LogMaster.log(0, "map " + map.toString());
    }
    List<? extends Obj> list = getObjectsToModify();
    LogMaster.log(0, "list " + list.toString());
    LogMaster.log(0, "effects " + effects.toString());
    for (Obj obj : list) {
        if (obj == null) {
            continue;
        }
        if (obj.isDead()) {
            // TODO clean up for owner is dead!
            continue;
        }
        Effect effect = effects.get(obj);
        if (effect != null) {
            // if (isPermanent() && isApplied())
            // continue;
            effect.applyThis();
            applied = true;
            continue;
        }
        Ref REF = ref.getCopy();
        REF.setTarget(obj.getId());
        // map = new MapMaster<PARAMETER, String>().constructVarMap(
        // modString, PARAMETER.class);
        Effects modEffects = new Effects();
        if (map != null) {
            EffectFinder.initParamModEffects(modEffects, map, ref);
        } else if (propMap != null) {
            EffectFinder.initPropModEffects(modEffects, propMap, ref);
        }
        applied = true;
        for (Effect e : modEffects.getEffects()) {
            e.resetOriginalFormula();
            e.appendFormulaByMod(getFormula().toString());
        }
        if (buff) {
            AddBuffEffect buffEffect = new AddBuffEffect(buffName, modEffects);
            // TODO LAYER?
            buffEffect.setForcedLayer(getModEffectLayer());
            modEffects.setForcedLayer(getModEffectLayer());
            if (isPermanent()) {
                buffEffect.setDuration(ContentManager.INFINITE_VALUE);
            }
            if (!game.isSimulation()) {
                effects.put(obj, buffEffect);
            }
            buffEffect.apply(REF);
        } else {
            if (!game.isSimulation()) {
                effects.put(obj, modEffects);
            }
            modEffects.apply(REF);
        }
    }
    return true;
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Ref(main.entity.Ref) RandomWizard(main.system.auxiliary.RandomWizard) PROPERTY(main.content.values.properties.PROPERTY) Obj(main.entity.obj.Obj) DC_Effect(eidolons.ability.effects.DC_Effect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Effect(main.ability.effects.Effect) Effects(main.ability.effects.Effects) PARAMETER(main.content.values.parameters.PARAMETER)

Example 9 with PARAMETER

use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.

the class DualAttackMaster method checkCostsCanMerge.

private static boolean checkCostsCanMerge(DC_UnitAction main, DC_UnitAction offhand) {
    Costs costsMain = main.getCosts();
    costsMain = DC_CostsFactory.getCostsForAction(main);
    Costs costsOffhand = offhand.getCosts();
    costsOffhand = DC_CostsFactory.getCostsForAction(offhand);
    for (Cost cost : costsMain.getCosts()) {
        PARAMETER p = cost.getPayment().getParamToPay();
        Cost cost2 = costsOffhand.getCost(p);
        Integer value1 = cost.getPayment().getAmountFormula().getInt();
        Integer value2 = (cost2 == null) ? 0 : cost2.getPayment().getAmountFormula().getInt();
        Boolean mode = getMinMaxOrAverage((PARAMS) p);
        if (!checkCost(value1, value2, mode))
            return false;
    }
    return true;
}
Also used : Costs(main.elements.costs.Costs) Cost(main.elements.costs.Cost) PARAMETER(main.content.values.parameters.PARAMETER)

Example 10 with PARAMETER

use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.

the class DualAttackMaster method getDualCosts.

private static Costs getDualCosts(DC_UnitAction main, DC_UnitAction offhand) {
    List<Cost> list = new ArrayList<>();
    Costs costsMain = main.getCosts();
    // if (costsMain == null)
    costsMain = DC_CostsFactory.getCostsForAction(main);
    Costs costsOffhand = offhand.getCosts();
    // if (costsOffhand == null)
    costsOffhand = DC_CostsFactory.getCostsForAction(offhand);
    for (Cost cost : costsMain.getCosts()) {
        PARAMETER p = cost.getPayment().getParamToPay();
        Cost cost2 = costsOffhand.getCost(p);
        Integer value1 = cost.getPayment().getAmountFormula().getInt();
        Integer value2 = (cost2 == null) ? 0 : cost2.getPayment().getAmountFormula().getInt();
        Boolean mode = getMinMaxOrAverage((PARAMS) p);
        Integer value = MathMaster.getTotalOrMinMax(mode, value1, value2);
        list.add(new CostImpl(new Payment(p, value), cost.getCostParam()));
    }
    Costs costsDual = new Costs(list);
    Integer focReq = 25;
    list.add(new CostImpl(new Payment(PARAMS.FOC_REQ, focReq)));
    return costsDual;
}
Also used : Costs(main.elements.costs.Costs) Payment(main.elements.costs.Payment) ArrayList(java.util.ArrayList) CostImpl(main.elements.costs.CostImpl) Cost(main.elements.costs.Cost) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

PARAMETER (main.content.values.parameters.PARAMETER)136 PROPERTY (main.content.values.properties.PROPERTY)22 ObjType (main.entity.type.ObjType)13 ArrayList (java.util.ArrayList)12 Formula (main.system.math.Formula)12 Ref (main.entity.Ref)9 VALUE (main.content.VALUE)7 Obj (main.entity.obj.Obj)7 PARAMS (eidolons.content.PARAMS)6 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)5 Cost (main.elements.costs.Cost)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)4 G_Panel (main.swing.generic.components.G_Panel)4 Node (org.w3c.dom.Node)4 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)3 HashMap (java.util.HashMap)3 DAMAGE_TYPE (main.content.enums.GenericEnums.DAMAGE_TYPE)3 Costs (main.elements.costs.Costs)3 Entity (main.entity.Entity)3 GraphicComponent (main.swing.generic.components.misc.GraphicComponent)3