Search in sources :

Example 6 with GroupImpl

use of main.entity.group.GroupImpl in project Eidolons by IDemiurge.

the class MultiTargeting method select.

@SuppressWarnings("unchecked")
@Override
public boolean select(Ref ref) {
    boolean result = true;
    int i = 0;
    if (nOfTargets != null && targeting != null) {
        int number = nOfTargets.getInt(ref);
        targetings = new Targeting[number];
        refs = new Ref[targetings.length];
        Arrays.fill(targetings, targeting);
        ignoreGroupTargeting = false;
    }
    ArrayList<Integer> IDs = new ArrayList<>(targetings.length);
    for (Targeting targeting : targetings) {
        Ref REF = Ref.getCopy(ref);
        if (noDuplicates) {
            for (Integer id : IDs) {
                if (// ?
                id != null) {
                    targeting.getFilter().getDynamicExceptions().add(id);
                }
            }
        }
        result &= targeting.select(REF);
        ref.setTarget(REF.getTarget());
        refs[i] = REF;
        IDs.add(REF.getTarget());
        i++;
    }
    if (!result) {
        return false;
    }
    Collection<Integer> ids = new ArrayList<>();
    for (Ref REF : refs) {
        ids.add(REF.getTarget());
    }
    GroupImpl group = new GroupImpl(ref.getGame(), ids, ignoreGroupTargeting);
    ref.setGroup(group);
    return result;
}
Also used : Ref(main.entity.Ref) GroupImpl(main.entity.group.GroupImpl) ArrayList(java.util.ArrayList)

Example 7 with GroupImpl

use of main.entity.group.GroupImpl in project Eidolons by IDemiurge.

the class CoordinateTargeting method select.

public boolean select(Ref ref) {
    DC_Obj obj = (DC_Obj) ref.getObj(key);
    DIRECTION used_direction = direction;
    if (unitDirection != null) {
        Unit unit = (Unit) obj;
        used_direction = DirectionMaster.getDirectionByFacing(unit.getFacing(), unitDirection);
    }
    Coordinates coordinate = obj.getCoordinates().getAdjacentCoordinate(used_direction);
    List<BattleFieldObject> objects = obj.getGame().getMaster().getObjectsOnCoordinate(coordinate, false);
    if (objects.size() == 0) {
        ref.setTarget(obj.getGame().getCellByCoordinate(coordinate).getId());
    } else if (objects.size() == 1) {
        ref.setTarget(objects.get(0).getId());
    } else {
        ref.setGroup(new GroupImpl(new ArrayList<>(objects)));
    }
    return true;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) UNIT_DIRECTION(main.game.bf.Coordinates.UNIT_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

GroupImpl (main.entity.group.GroupImpl)7 Ref (main.entity.Ref)4 ArrayList (java.util.ArrayList)3 Conditions (main.elements.conditions.Conditions)3 Obj (main.entity.obj.Obj)3 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)2 Effects (main.ability.effects.Effects)2 RefCondition (main.elements.conditions.RefCondition)2 AutoTargeting (main.elements.targeting.AutoTargeting)2 Coordinates (main.game.bf.Coordinates)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)1 AlteringEffect (eidolons.ability.effects.oneshot.misc.AlteringEffect)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Unit (eidolons.entity.obj.unit.Unit)1 ActiveAbility (main.ability.ActiveAbility)1