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;
}
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;
}
Aggregations