use of main.elements.targeting.FixedTargeting in project Eidolons by IDemiurge.
the class AbilityImpl method activatedOn.
@Override
public boolean activatedOn(Ref ref) {
setRef(ref);
// preCheck if targeting is overridden
if (!(targeting instanceof AutoTargeting)) {
if (!(targeting instanceof FixedTargeting)) {
if (isForcePresetTargeting() || targeting == null) {
if (ref.getTarget() != null || ref.getGroup() != null) {
// without targeting.select()
return resolve();
} else {
// inconsistent data
return false;
}
}
}
}
boolean selectResult = targeting.select(ref);
ActiveObj a = ref.getActive();
if (selectResult) {
if (a != null) {
a.setCancelled(null);
}
return resolve();
} else {
if (a != null) {
if (a.isCancelled() != null) {
a.setCancelled(true);
}
}
return false;
}
}
use of main.elements.targeting.FixedTargeting in project Eidolons by IDemiurge.
the class PathChoiceMaster method getChoices.
List<Choice> getChoices(ActionPath path, Coordinates c_coordinate, Coordinates targetCoordinate, FACING_DIRECTION c_facing) {
Chronos.mark("Finding choices for " + path);
pathBuilder.adjustUnit();
List<Choice> choices = new ArrayList<>();
for (Coordinates c : getDefaultCoordinateTargets(path, c_coordinate)) {
Choice stdMoveChoice = constructStdMoveChoice(c, c_coordinate, c_facing);
if (stdMoveChoice != null) {
choices.add(stdMoveChoice);
}
}
Chronos.mark("Finding custom choices for " + path);
List<Choice> specialChoices = new ArrayList<>();
if (ListMaster.isNotEmpty(moveActions)) {
for (DC_ActiveObj a : moveActions) {
if (!a.canBeActivated()) {
if (firstStep) {
if (!ReasonMaster.checkReasonCannotActivate(a, PARAMS.C_N_OF_ACTIONS.getName())) {
// exception for AP TODO
continue;
}
}
}
if (path.hasAction(a)) {
if (a.getIntParam(PARAMS.COOLDOWN) >= 0) {
continue;
}
}
Targeting targeting = a.getTargeting();
Collection<Obj> objects = null;
if (targeting instanceof FixedTargeting) {
Targeting t = a.getAbilities().getTargeting();
if (t != null) {
objects = t.getFilter().getObjects(a.getRef());
}
Effect e = a.getAbilities().getEffects().getEffects().get(0);
e.setRef(unit.getRef());
if (e instanceof SelfMoveEffect) {
try {
Coordinates coordinates = ((SelfMoveEffect) e).getCoordinates();
if (coordinates != null) {
objects = new ArrayList<>(Arrays.asList(unit.getGame().getCellByCoordinate(coordinates)));
}
} catch (Exception ex) {
main.system.ExceptionMaster.printStackTrace(ex);
}
}
} else {
pathBuilder.adjustUnit();
objects = targeting.getFilter().getObjects(a.getRef());
}
if (objects != null) {
List<Choice> choicesForAction = new ArrayList<>();
for (Object obj : objects) {
if (obj instanceof DC_Cell) {
Coordinates coordinates = ((DC_Cell) obj).getCoordinates();
// if (a.getName().equals("Clumsy Leap"))
if (PositionMaster.getDistance(coordinates, c_coordinate) > Math.max(1, a.getIntParam(PARAMS.RANGE))) {
continue;
}
if (PositionMaster.getDistance(coordinates, targetCoordinate) > PositionMaster.getDistance(c_coordinate, targetCoordinate)) {
// TODO will this not eliminate good
continue;
}
// choices?
Ref ref = unit.getRef().getCopy();
ref.setTarget(((DC_Cell) obj).getId());
Choice choice = new Choice(coordinates, c_coordinate, new Action(a, ref));
choicesForAction.add(choice);
}
}
Chronos.mark("Filter custom choices for " + a);
specialChoices.addAll(filterSpecialMoveChoices(choicesForAction, a, c_coordinate, path));
Chronos.logTimeElapsedForMark("Filter custom choices for " + a);
}
// if (choices.size() > 1)
}
}
Chronos.logTimeElapsedForMark("Finding custom choices for " + path);
choices.addAll(specialChoices);
Chronos.mark("Sort choices");
sortChoices(choices);
Chronos.logTimeElapsedForMark("Sort choices");
// resetUnit();// TODO is that right?
Chronos.logTimeElapsedForMark("Finding choices for " + path);
// Chronos.logTimeElapsedForMark("Sorting choices for " + path);
return choices;
}
use of main.elements.targeting.FixedTargeting in project Eidolons by IDemiurge.
the class AbilityConstructor method constructAbility.
private static Ability constructAbility(Node node) {
Effect effects = null;
Targeting targeting = null;
for (Node NODE : XML_Converter.getNodeList(node)) {
if (NODE.getNodeName().equals(EFFECTS) || NODE.getNodeName().contains(EFFECTS)) {
effects = constructEffects(NODE);
}
if (NODE.getNodeName().equals(TARGETING) || NODE.getNodeName().contains(TARGETING)) {
targeting = constructTargeting(NODE);
}
}
if (effects == null) {
LogMaster.log(1, "null abil effects!");
effects = new Effects();
}
if (targeting == null) {
LogMaster.log(1, "null abil targeting!");
targeting = new FixedTargeting();
}
Ability abil = null;
if (node.getNodeName().equals(ACTIVE_ABILITY)) {
abil = new ActiveAbility(targeting, effects);
} else if (node.getNodeName().equals(ONESHOT_ABILITY)) {
abil = new OneshotAbility(targeting, effects);
} else if (node.getNodeName().equals(PASSIVE_ABILITY)) {
abil = new PassiveAbility(targeting, effects);
}
abil.setXml(XML_Converter.getStringFromXML(node));
return abil;
}
use of main.elements.targeting.FixedTargeting in project Eidolons by IDemiurge.
the class WaitEffect method getAbility.
protected Ability getAbility(Ref ref) {
Effect effect = new Effects(new RemoveBuffEffect(getBuffName()));
Ability ability = new ActiveAbility(new FixedTargeting(KEYS.SOURCE), effect);
ability.setRef(ref);
return ability;
}
use of main.elements.targeting.FixedTargeting in project Eidolons by IDemiurge.
the class BindingSpellEffect method applyThis.
@Override
public boolean applyThis() {
// TODO Auto-generated method stub
Effects effects = null;
if (!shareOrRedirect) {
effects = new Effects(new CustomTargetEffect(new FixedTargeting(KEYS.TARGET2), new DuplicateEffect(true)), new CustomTargetEffect(new FixedTargeting(KEYS.TARGET), new InterruptEffect()));
}
Effect EFFECT = new DuplicateSpellEffect(KEYS.TARGET.name(), false, true);
EFFECT.setTargetGroup(ref.getGroup());
effects = new Effects(EFFECT);
Event.STANDARD_EVENT_TYPE event_type = Event.STANDARD_EVENT_TYPE.SPELL_RESOLVED;
conditions.add(ConditionMaster.getPropCondition("EVENT_SPELL", G_PROPS.SPELL_TAGS, SpellEnums.SPELL_TAGS.MIND_AFFECTING.name()));
return false;
}
Aggregations