use of main.entity.Ref in project Eidolons by IDemiurge.
the class PassiveAbilityObj method kill.
// @Override
// public boolean activate() {
// boolean result = true;
//
//
// return result;
// }
@Override
public boolean kill() {
Ref REF = Ref.getCopy(ref);
if (isDead()) {
return false;
}
if (!game.fireEvent(new Event(STANDARD_EVENT_TYPE.PASSIVE_BEING_REMOVED, REF))) {
return false;
}
setDead(true);
game.getManager().attachmentRemoved(this, ownerObj);
game.fireEvent(new Event(STANDARD_EVENT_TYPE.PASSIVE_REMOVED, REF));
applied = false;
return super.kill();
}
use of main.entity.Ref 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.entity.Ref in project Eidolons by IDemiurge.
the class ReasonMaster method getReasonsCannotActivate.
public static List<String> getReasonsCannotActivate(Action action) {
// action.getActive().getCosts().getReasons()
Ref REF = action.getRef().getCopy();
REF.setMatch(action.getRef().getTarget());
REF.setID(KEYS.PAYEE, action.getSource().getId());
return getReasonsCannotActivate(action.getActive(), REF);
// Map<String, Condition> reqs =
// action.getActive().getCosts().getRequirements().getReqMap();
// for (Condition c : reqs.values()) {
// if (!c.preCheck(REF)) {
// reasons.add
// (new MapMaster<String, Condition>().getKeyForValue(reqs, c));
// }
// }
//
// return reasons;
}
use of main.entity.Ref 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.entity.Ref in project Eidolons by IDemiurge.
the class ReasonMaster method getReasonsCannotActivate.
public static List<String> getReasonsCannotActivate(DC_ActiveObj action) {
Ref REF = action.getRef().getCopy();
REF.setMatch(action.getRef().getTarget());
REF.setID(KEYS.PAYEE, action.getOwnerObj().getId());
return getReasonsCannotActivate(action, REF);
}
Aggregations