use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.
the class VampirismEffect method applyThis.
@Override
public boolean applyThis() {
if (conditions == null) {
initConditions();
}
// TODO Auto-generated method stub
// endurance damage; modify endurance only? above base?
// if (triggerEffect!=null) triggerEffect.apply(ref); else {
Targeting targeting = new FixedTargeting(KEYS.SOURCE);
Effects effects = new Effects();
if (restoreEndurance) {
ModifyValueEffect effect = new ModifyValueEffect(PARAMS.C_ENDURANCE, code, formula.toString());
if (!restoreEnduranceAboveBase) {
effect.setMaxParam(PARAMS.ENDURANCE);
}
effects.add(effect);
}
if (restoreToughness) {
ModifyValueEffect effect = new ModifyValueEffect(PARAMS.C_TOUGHNESS, code, formula.toString());
if (!restoreToughnessAboveBase) {
effect.setMaxParam(PARAMS.TOUGHNESS);
}
effects.add(effect);
}
if (fromEnduranceDamage) {
ActiveAbility ability = new ActiveAbility(targeting, effects);
new AddTriggerEffect(// TODO
STANDARD_EVENT_TYPE.UNIT_IS_DEALT_ENDURANCE_DAMAGE, // damage?
conditions, ability).apply(ref);
}
if (fromToughnessDamage) {
}
return true;
}
use of main.elements.targeting.Targeting 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.Targeting in project Eidolons by IDemiurge.
the class ReasonMaster method getReasonsCannotTarget.
public static List<FILTER_REASON> getReasonsCannotTarget(Action action, boolean useConditionResultCache, Boolean checkMiscOrOnly, FILTER_REASON searchedReason) {
Ref REF = action.getRef().getCopy();
REF.setMatch(action.getRef().getTarget());
Targeting targeting = action.getActive().getTargeting();
if (targeting == null) {
targeting = TargetingMaster.findTargeting(action.getActive());
}
if (targeting == null) {
return new ArrayList<>();
}
Conditions conditions = targeting.getFilter().getConditions();
// conditions.preCheck(REF);
List<FILTER_REASON> reasons = new ArrayList<>();
for (Condition c : conditions) {
FILTER_REASON reason = getReason(c);
if (searchedReason != null) {
if (reason != searchedReason) {
continue;
}
}
if (checkMiscOrOnly == null) {
if (reason != FILTER_REASON.OTHER) {
continue;
}
} else if (!checkMiscOrOnly) {
if (reason == FILTER_REASON.OTHER) {
continue;
}
}
boolean result = c.isTrue();
if (!useConditionResultCache) {
result = c.preCheck(REF);
} else {
// LogMaster.log(0, c + " uses cached result " + result);
}
if (!result) {
if (reason != null) {
reasons.add(reason);
}
}
}
return reasons;
}
use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.
the class BindingDamageEffect method applyThis.
@Override
public boolean applyThis() {
// Can be initialized() just once
GroupImpl group = ref.getGroup();
Effects effects = new Effects();
STANDARD_EVENT_TYPE event_type;
if (shareOrRedirect) {
// TODO splitMode!
event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
}
}
} else {
effects.add(new AlteringEffect(false, formula.getNegative().toString()));
event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
}
}
}
Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
/*
* ensure there is no deadlock
*/
conditions = new Conditions();
conditions.add(new NonTriggeredEventCondition());
KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
conditions.add(new GroupCondition(OBJ_REF, group));
// has the group...
Ref REF = Ref.getCopy(ref);
// REF.setTarget(null); // ???
new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
return true;
}
use of main.elements.targeting.Targeting 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;
}
Aggregations