Search in sources :

Example 1 with Cost

use of main.elements.costs.Cost 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 2 with Cost

use of main.elements.costs.Cost 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)

Example 3 with Cost

use of main.elements.costs.Cost in project Eidolons by IDemiurge.

the class ActionAnimation method drawCosts.

protected boolean drawCosts(AnimPhase phase) {
    int base = getDefaultIconMapOffsetY();
    boolean invert = false;
    Boolean edge;
    boolean positive;
    if (getTarget() == source || phase.isDrawOnSource()) {
        edge = game.getBattleField().getGrid().isOnEdgeY(source.getCoordinates());
        // TODO
        positive = BooleanMaster.isTrue(edge) || edge == null;
        base = getOffsetBase(positive);
        if (base < 0) {
            invert = true;
        }
    }
    if (getTarget().getCoordinates().isAdjacent(source.getCoordinates())) {
        if (PositionMaster.inLine(source, target)) {
            if (PositionMaster.isAbove(target, source)) {
                invert = true;
            }
            if (PositionMaster.isAbove(source, target)) {
                invert = false;
            }
        }
    }
    Costs costs = (Costs) phase.getArgs()[0];
    Map<Image, String> map = new XLinkedMap<>();
    for (Cost s : costs.getCosts()) {
        if (s.isPaidAlt()) {
            s = s.getAltCost();
        }
        Formula formula = s.getPayment().getAmountFormula();
        PARAMETER param = s.getPayment().getParamToPay();
        Image image = ImageManager.getValueIcon(param);
        if (image == null) {
            continue;
        }
        String string = "" + (-s.getPayment().getLastPaid());
        map.put(image, string);
        List<String> list = new ArrayList<>();
        list.add(string);
        getSubPhaseTooltipMap().put(image, list);
    }
    drawIconMap(map, false, true, base, invert);
    return true;
}
Also used : Costs(main.elements.costs.Costs) XLinkedMap(main.data.XLinkedMap) Cost(main.elements.costs.Cost) Formula(main.system.math.Formula) PARAMETER(main.content.values.parameters.PARAMETER)

Example 4 with Cost

use of main.elements.costs.Cost in project Eidolons by IDemiurge.

the class ChannelingRule method getChannelingCosts.

public static Costs getChannelingCosts(DC_SpellObj action, boolean activateOrResolve) {
    List<Cost> list = new ArrayList<>();
    for (PARAMS costParam : activateOrResolve ? costParamsActivate : costParamsResolve) {
        PARAMS payParam = DC_ContentManager.getPayParameterForCost(costParam);
        Cost cost = DC_CostsFactory.getCost(action, costParam, payParam);
        // int mod = 100;
        // cost.getPayment().getAmountFormula().applyModifier(mod);
        list.add(cost);
    }
    // Costs costs = getEntity().getCosts();
    // Costs channelingResolveCosts = new Costs(costs.getRequirements(), costs.getCosts());
    // Costs channelingActivateCosts = new Costs(costs.getRequirements(), costs
    // .getCost(PARAMS.C_N_OF_ACTIONS));
    // channelingResolveCosts.removeCost(PARAMS.C_N_OF_ACTIONS);
    CostRequirements reqs = action.getCosts().getRequirements();
    Costs costs = new Costs(reqs, list);
    if (!activateOrResolve)
        costs.removeRequirement(InfoMaster.COOLDOWN_REASON);
    return costs;
}
Also used : Costs(main.elements.costs.Costs) CostRequirements(main.elements.costs.CostRequirements) ArrayList(java.util.ArrayList) PARAMS(eidolons.content.PARAMS) Cost(main.elements.costs.Cost)

Example 5 with Cost

use of main.elements.costs.Cost in project Eidolons by IDemiurge.

the class DualAttackMaster method createDual.

private static DC_UnitAction createDual(DC_UnitAction main, DC_UnitAction offhand) {
    Costs costs = getDualCosts(main, offhand);
    // cooldown!
    ActiveAbility activateAttacks = new ActiveAbility(main.getTargeting(), new Effects(new ActivateEffect(main.getName(), true), new ActivateEffect(offhand.getName(), true)));
    Ability setCooldown = new ActiveAbility(new AutoTargeting(new PropCondition(G_PROPS.ACTION_TAGS, "Dual", false)), new ModifyValueEffect(PARAMS.C_COOLDOWN, MOD.SET, getCooldown(main.getOwnerObj())));
    Abilities abilities = new Abilities();
    abilities.add(activateAttacks);
    abilities.add(setCooldown);
    ObjType newType = new ObjType("Dual: " + main.getName() + " and " + offhand.getName(), DataManager.getType("Dual Attack", DC_TYPE.ACTIONS));
    for (Cost cost : costs.getCosts()) {
        PARAMETER p = cost.getCostParam();
        if (p == null)
            continue;
        newType.setParam(p, cost.getPayment().getAmountFormula().toString());
    }
    DC_UnitAction dual = new DC_UnitAction(newType, main.getOwner(), main.getGame(), new Ref(main.getOwnerObj()));
    dual.setAbilities(abilities);
    dual.setCosts(costs);
    dual.setTargeting(main.getTargeting());
    dual.getTargeter().setTargetingInitialized(true);
    dual.setConstructed(true);
    return dual;
}
Also used : ActiveAbility(main.ability.ActiveAbility) ActiveAbility(main.ability.ActiveAbility) Ability(main.ability.Ability) AutoTargeting(main.elements.targeting.AutoTargeting) Costs(main.elements.costs.Costs) Abilities(main.ability.Abilities) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects) PropCondition(main.elements.conditions.PropCondition) Cost(main.elements.costs.Cost) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) ActivateEffect(eidolons.ability.effects.oneshot.activation.ActivateEffect) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

Cost (main.elements.costs.Cost)8 Costs (main.elements.costs.Costs)6 PARAMETER (main.content.values.parameters.PARAMETER)5 ArrayList (java.util.ArrayList)3 CostImpl (main.elements.costs.CostImpl)2 Payment (main.elements.costs.Payment)2 Formula (main.system.math.Formula)2 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ActivateEffect (eidolons.ability.effects.oneshot.activation.ActivateEffect)1 PARAMS (eidolons.content.PARAMS)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 Abilities (main.ability.Abilities)1 Ability (main.ability.Ability)1 ActiveAbility (main.ability.ActiveAbility)1 Effects (main.ability.effects.Effects)1 XLinkedMap (main.data.XLinkedMap)1 PropCondition (main.elements.conditions.PropCondition)1 CostRequirements (main.elements.costs.CostRequirements)1 AutoTargeting (main.elements.targeting.AutoTargeting)1 Ref (main.entity.Ref)1