Search in sources :

Example 6 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class CostImpl method pay.

@Override
public boolean pay(Ref ref) {
    setRef(ref);
    ref.setID(KEYS.PAYEE, ref.getId(key));
    Obj payee = ref.getGame().getObjectById(ref.getId(key));
    boolean result = true;
    if (altCosts != null) {
        if (!canBePaid(ref, true)) {
            paidAlt = true;
            return altCosts.pay(ref);
        }
    }
    for (Payment payment : toPay) {
        result &= payment.pay(payee, ref);
    }
    paidAlt = false;
    return result;
}
Also used : ActiveObj(main.entity.obj.ActiveObj) Obj(main.entity.obj.Obj)

Example 7 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class ShapeEffect method initTargeting.

@Override
public void initTargeting() {
    // init unit group
    Coordinates baseCoordinate = getBaseCoordinate();
    int base_width = radius.getInt(ref);
    int distance = this.distance.getInt(ref);
    coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
    DequeImpl<Obj> objects = new DequeImpl<>();
    objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
    Filter.filter(objects, targetType);
    if (allyOrEnemyOnly != null) {
        if (allyOrEnemyOnly) {
            FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
        } else {
            FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
        }
    }
    if (notSelf) {
        FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
    }
    if (targetType.equals(DC_TYPE.TERRAIN)) {
        // C_TYPE equals if contains() !
        objects.addAll(game.getCellsForCoordinates(coordinates));
    }
    targeting = new AutoTargeting(new GroupImpl(objects));
    setFilteringConditions(new Conditions());
    targeting.setConditions(getFilteringConditions());
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) DequeImpl(main.system.datatypes.DequeImpl) Conditions(main.elements.conditions.Conditions)

Example 8 with Obj

use of main.entity.obj.Obj 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 Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class HeroObjectModifyingEffect method getIdList.

protected List<Integer> getIdList(Unit hero) {
    List<Integer> list = new ArrayList<>();
    if (hero == null) {
        return list;
    }
    switch(type) {
        case ACTIONS:
            for (ACTION_TYPE a : ActionEnums.ACTION_TYPE.values()) {
                if (hero.getActionMap().get(a) != null) {
                    for (DC_UnitAction action : hero.getActionMap().get(a)) {
                        list.add(action.getId());
                    }
                }
            }
            break;
        case ARMOR:
            list = new ArrayList<>(new ListMaster<Integer>().getList(hero.getArmor().getId()));
            break;
        case ITEMS:
            for (Obj i : hero.getQuickItems()) // if (i.getOBJ_TYPE_ENUM() != OBJ_TYPES.WEAPONS)
            // non-weapon QI???
            {
                list.add(i.getId());
            }
            break;
        case SPELLS:
            for (Obj i : hero.getSpells()) {
                list.add(i.getId());
            }
            // hero.getGame().getManager().getSpells(hero)
            break;
        case WEAPONS:
            Integer id = null;
            if (hero.getActiveWeapon(true) != null) {
                id = hero.getActiveWeapon(true).getId();
            }
            Integer id2 = 0;
            if (hero.getActiveWeapon(false) != null) {
                id2 = hero.getActiveWeapon(false).getId();
            }
            list = new ArrayList<>(new ListMaster<Integer>().getList(id2, id));
            List<? extends Obj> l = new ArrayList<>(hero.getQuickItems());
            for (Obj i : l) {
                if (i.getOBJ_TYPE_ENUM() == DC_TYPE.WEAPONS) {
                    list.add(i.getId());
                }
            }
            break;
    }
    // ListMaster.removeNullElements(list);
    FilterMaster.filter(list, conditions, game);
    return list;
}
Also used : Obj(main.entity.obj.Obj) ArrayList(java.util.ArrayList) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ACTION_TYPE(main.content.enums.entity.ActionEnums.ACTION_TYPE)

Example 10 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class CastNewSpellEffect method applyThis.

// TODO spellpower/mastery mods!!!
@Override
public boolean applyThis() {
    ObjType type = DataManager.getType(spelltype, DC_TYPE.SPELLS);
    Ref REF = new Ref(ref.getGame(), ref.getSource());
    Obj obj = game.createSpell(type, ref.getSourceObj().getOwner(), REF);
    DC_SpellObj spell = (DC_SpellObj) obj;
    spell.setFree(free);
    spell.setQuietMode(true);
    if (group) {
        REF.setGroup(ref.getGroup());
        return spell.activatedOn(REF);
    }
    if (chooseTarget) {
        spell.getTargeting().select(REF);
    } else {
        REF.setTarget(ref.getId(target_key));
    }
    return spell.activatedOn(REF);
}
Also used : Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) Obj(main.entity.obj.Obj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj)

Aggregations

Obj (main.entity.obj.Obj)127 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)34 DC_Obj (eidolons.entity.obj.DC_Obj)30 Coordinates (main.game.bf.Coordinates)27 Unit (eidolons.entity.obj.unit.Unit)24 ArrayList (java.util.ArrayList)19 Ref (main.entity.Ref)15 DC_SpellObj (eidolons.entity.active.DC_SpellObj)14 BuffObj (main.entity.obj.BuffObj)13 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)12 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)11 ActiveObj (main.entity.obj.ActiveObj)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)9 PassiveAbilityObj (main.ability.PassiveAbilityObj)9 ObjType (main.entity.type.ObjType)8 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)7 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)7 PARAMETER (main.content.values.parameters.PARAMETER)7 Conditions (main.elements.conditions.Conditions)6 MicroObj (main.entity.obj.MicroObj)6