Search in sources :

Example 1 with AbilityObj

use of main.ability.AbilityObj in project Eidolons by IDemiurge.

the class TextParser method parseRef.

// perhaps I should refactor into method per parse_type!
private static String parseRef(String ref_substring, Ref ref) {
    if (ref == null) {
        return parseVarRef(ref_substring);
    }
    String value = StringMaster.cropRef(ref_substring);
    if (!StringMaster.isInteger(value)) {
        if (isAbilityParsing()) {
            return ref_substring;
        }
    }
    int id = 0;
    if (isActiveParsing()) {
        id = ref.getId(KEYS.ACTIVE);
    } else {
        try {
            id = ref.getId(KEYS.INFO);
        } catch (Exception e) {
        }
    }
    Game game = ref.getGame();
    // if (id == 0) {
    // if (game.isRunning()) {
    // id = game.getManager().getInfoObj().getId();
    // }
    // }
    // else if (CharacterCreator.isRunning())
    String replacement = ref_substring;
    Entity entity = ref.getInfoEntity();
    if (entity == null) {
        if (game.isSimulation() && !isBuffParsing() && !isAbilityParsing()) {
            entity = game.getTypeById(id);
        } else {
            entity = game.getObjectById(id);
        }
    }
    if (entity == null) {
        return ref_substring;
    }
    if (entity instanceof AbilityObj) {
        entity = entity.getType();
    }
    if (StringMaster.isInteger(value)) {
        int index = StringMaster.getInteger(value) - 1;
        String varProp = entity.getProperty(G_PROPS.VARIABLES);
        if (StringMaster.isEmpty(varProp)) {
            varProp = DEFAULT_VARS;
        }
        boolean containerFormula = false;
        if (!entity.getParam("FORMULA").isEmpty()) {
            // StringMaster.compare(varProp.replace(";", ""), "FORMULA",
            // true)) {
            varProp = entity.getParam("FORMULA");
            containerFormula = true;
        }
        List<String> openContainer = StringMaster.openContainer(varProp);
        if (openContainer.size() > index) {
            VALUE val = null;
            if (!containerFormula && !isBuffParsing()) {
                val = ContentManager.getValue(openContainer.get(index));
                replacement = entity.getValue(val);
            } else {
                replacement = openContainer.get(index);
            }
            if (containerFormula || val instanceof PARAMETER) {
                if (StringMaster.isInteger(replacement)) {
                    return replacement;
                }
                try {
                    if (isAbilityParsing()) // if (replacement.contains(",")) {
                    // // TODO all function names!
                    // if (replacement.toLowerCase().contains("min")
                    // || replacement.toLowerCase().contains(
                    // "max")) {
                    // // get the insides of the formula?
                    // // parts = replacement.split(regex);
                    // // parts[1] = parts[1].
                    // //
                    // // replacement = parts[0] + parts[1];
                    // return replacement.replace(",",
                    // StringMaster.COMMA_CODE);
                    // }
                    // } else
                    {
                        return replacement.replace(",", StringMaster.COMMA_CODE);
                    }
                    if (game.isSimulation()) {
                        replacement = new Formula(replacement).getInt(ref) + " (" + formatFormula(replacement) + ")";
                    } else {
                        replacement = new Formula(replacement).getInt(ref) + "";
                    }
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            } else {
                String result = new Property(true, replacement).getStr(ref);
                if (StringMaster.isEmpty(result)) {
                    replacement = new Parameter(replacement).getInt(ref) + "";
                } else {
                    replacement = result;
                }
            }
        }
    } else {
        if (!isAbilityParsing()) {
            if (StringMaster.isInteger(replacement)) {
                return replacement;
            }
            if (game.isSimulation() && !tooltipParsing) {
                Integer VAL = new Formula(replacement).getInt(ref);
                replacement = VAL + " (" + replacement + ")";
            } else {
                // TODO
                replacement = new Formula(replacement).getInt(ref) + "";
            }
        // props!
        }
    }
    return replacement;
}
Also used : Entity(main.entity.Entity) VALUE(main.content.VALUE) AbilityObj(main.ability.AbilityObj) Formula(main.system.math.Formula) Game(main.game.core.game.Game) Parameter(main.system.math.Parameter) Property(main.system.math.Property) PARAMETER(main.content.values.parameters.PARAMETER)

Example 2 with AbilityObj

use of main.ability.AbilityObj in project Eidolons by IDemiurge.

the class DeathMaster method unitDies.

public void unitDies(DC_ActiveObj activeObj, Obj _killed, Obj _killer, boolean leaveCorpse, boolean quietly) {
    if (_killed.isDead())
        return;
    String message = null;
    if (_killed == _killer) {
        // + _killed.getInfoString();
        message = _killed + " dies ";
    } else
        message = _killed + " killed by " + _killer + " with " + activeObj;
    SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
    _killed.setDead(true);
    BattleFieldObject killed = (BattleFieldObject) _killed;
    BattleFieldObject killer = (BattleFieldObject) _killer;
    Ref ref = Ref.getCopy(killed.getRef());
    ref.setSource(killer.getId());
    ref.setTarget(killed.getId());
    for (AbilityObj abil : killed.getPassives()) {
        abil.kill();
    }
    if (killed.getBuffs() != null) {
        for (Attachment attach : killed.getBuffs()) {
            if (!attach.isRetainAfterDeath()) {
                getState().getAttachmentsMap().get(killed).remove(attach);
                attach.remove();
            }
        }
    }
    if (!leaveCorpse) {
    // leave a *ghost*?
    // destroy items?
    } else {
        if (killed instanceof Unit) {
            try {
                getGame().getDroppedItemManager().dropDead((Unit) killed);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
        try {
            getGame().getGraveyardManager().unitDies(killed);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    // getGame().getBattleField().remove(killed); // TODO GRAVEYARD
    if (!quietly) {
        Ref REF = Ref.getCopy(killer.getRef());
        REF.setTarget(killed.getId());
        REF.setSource(killer.getId());
        if (activeObj != null)
            REF.setObj(KEYS.ACTIVE, activeObj);
        if (killed instanceof Unit) {
            getGame().getRules().getMoraleKillingRule().unitDied((Unit) killed, killer.getRef().getAnimationActive());
        }
        LogEntryNode node = game.getLogManager().newLogEntryNode(ENTRY_TYPE.DEATH, killed);
        if (killer.getRef().getAnimationActive() != null) {
            ANIM animation = killer.getRef().getAnimationActive().getAnimation();
            if (animation != null) {
                animation.addPhase(new AnimPhase(PHASE_TYPE.DEATH, killer, killed));
                node.setLinkedAnimation(animation);
            }
        }
        DC_SoundMaster.playEffectSound(SOUNDS.DEATH, killed);
        game.getLogManager().logDeath(killed, killer);
        getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED, REF));
        game.getLogManager().doneLogEntryNode();
    } else {
        GuiEventManager.trigger(GuiEventType.DESTROY_UNIT_MODEL, killed);
    }
// refreshAll();
}
Also used : AbilityObj(main.ability.AbilityObj) Ref(main.entity.Ref) AnimPhase(main.system.graphics.AnimPhase) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) Attachment(main.entity.obj.Attachment) Unit(eidolons.entity.obj.unit.Unit) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Example 3 with AbilityObj

use of main.ability.AbilityObj in project Eidolons by IDemiurge.

the class ContainerIconElement method getPageData.

@Override
protected List<List<SmallItem>> getPageData() {
    if (property == G_PROPS.STANDARD_PASSIVES || property == G_PROPS.PASSIVES) {
        iconSize = GuiManager.getSmallObjSize() / 2;
        pageSize = PAGE_SIZE_SMALL;
        Collection<SmallItem> fullList = new ArrayList<>();
        for (String subString : StringMaster.open(entity.getProperty(G_PROPS.CLASSIFICATIONS))) {
            CLASSIFICATIONS classif = new EnumMaster<CLASSIFICATIONS>().retrieveEnumConst(CLASSIFICATIONS.class, subString);
            if (classif != null) {
                if (classif.isDisplayed()) {
                    fullList.add(new SmallItem(classif, classif.getImagePath(), classif.getName(), classif.getToolTip()));
                }
            }
        }
        for (String subString : StringMaster.open(entity.getProperty(G_PROPS.STANDARD_PASSIVES))) {
            STANDARD_PASSIVES std_pas = new EnumMaster<STANDARD_PASSIVES>().retrieveEnumConst(STANDARD_PASSIVES.class, subString);
            if (std_pas != null) {
                fullList.add(new SmallItem(std_pas, std_pas.getImagePath(), std_pas.getName(), std_pas.getToolTip()));
            }
        }
        for (AbilityObj passive : entity.getPassives()) {
            if (passive == null) {
                continue;
            }
            if (passive.getProperty(G_PROPS.ABILITY_GROUP, true).equalsIgnoreCase(DISPLAYED_PASSIVES)) {
                fullList.add(new SmallItem(passive));
            }
        }
        return splitList(fullList);
    }
    return null;
}
Also used : AbilityObj(main.ability.AbilityObj) SmallItem(eidolons.swing.components.panels.page.small.SmallItem) ArrayList(java.util.ArrayList) STANDARD_PASSIVES(main.content.enums.entity.UnitEnums.STANDARD_PASSIVES) CLASSIFICATIONS(main.content.enums.entity.UnitEnums.CLASSIFICATIONS)

Example 4 with AbilityObj

use of main.ability.AbilityObj in project Eidolons by IDemiurge.

the class DC_FeatObj method applyRank.

private void applyRank() {
    Integer rank = getRank();
    if (rank == 0) {
        return;
    }
    Integer mod = rank * getRankFormulaMod();
    for (AbilityObj p : getPassives()) {
        // will affect AddParam effects?
        for (Ability a : p.getAbilities()) {
            for (Effect ef : a.getEffects()) {
                try {
                    ef.resetOriginalFormula();
                    ef.appendFormulaByMod(100 + mod);
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            // some exceptions?
            /*
                     * how widely will this be used?
					 * mostly on simple low-level skills...
					 * but also on auras I guess...
					 * the point is to make things flexible, deeply customizable, and viable for 
					 * no-magic heroes...
					 * 
					 * it's true that with the amount of Masteries/Skills I may not need this on lower
					 * levels, but at some point I will! 
					 * 
					 * how will the rank be saved into hero data? 
					 * >> (var)
					 * >> special prop 
					 * >> prop per rank #
					 */
            }
        }
    }
    for (PARAMETER attr : ContentManager.getAttributes()) {
        PARAMS param = (PARAMS) attr;
        Integer value = getIntParam(param, true);
        if (value <= 0) {
            continue;
        }
        value += Math.round(value * mod / 100);
        setParam(param, value);
    }
    // modifyHeroParameters();
    for (PARAMETER param : DC_ContentManager.getFeatModifyingParams()) {
        Integer value = getIntParam(param, true);
        if (value == 0) {
            continue;
        }
        value += Math.round(value * mod / 100);
        setParam(param, value);
    }
    Integer sdMod = rank * getIntParam(PARAMS.RANK_SD_MOD);
    setParam(PARAMS.SKILL_DIFFICULTY, getIntParam(PARAMS.SKILL_DIFFICULTY, true));
    modifyParamByPercent(PARAMS.SKILL_DIFFICULTY, sdMod);
    rankApplied = true;
}
Also used : Ability(main.ability.Ability) AbilityObj(main.ability.AbilityObj) Effect(main.ability.effects.Effect) PARAMS(eidolons.content.PARAMS) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

AbilityObj (main.ability.AbilityObj)4 PARAMETER (main.content.values.parameters.PARAMETER)2 PARAMS (eidolons.content.PARAMS)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 Unit (eidolons.entity.obj.unit.Unit)1 SmallItem (eidolons.swing.components.panels.page.small.SmallItem)1 ArrayList (java.util.ArrayList)1 Ability (main.ability.Ability)1 Effect (main.ability.effects.Effect)1 VALUE (main.content.VALUE)1 CLASSIFICATIONS (main.content.enums.entity.UnitEnums.CLASSIFICATIONS)1 STANDARD_PASSIVES (main.content.enums.entity.UnitEnums.STANDARD_PASSIVES)1 Entity (main.entity.Entity)1 Ref (main.entity.Ref)1 Attachment (main.entity.obj.Attachment)1 Game (main.game.core.game.Game)1 Event (main.game.logic.event.Event)1 ANIM (main.system.graphics.ANIM)1 AnimPhase (main.system.graphics.AnimPhase)1 Formula (main.system.math.Formula)1