use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class UpkeepRule method enactUpkeepFail.
public void enactUpkeepFail(UPKEEP_FAIL_ACTION ufa, Ref ref) {
Obj targetObj = ref.getTargetObj();
if (targetObj instanceof BuffObj) {
BuffObj buffObj = (BuffObj) targetObj;
ref.setTarget(buffObj.getBasis().getId());
new RemoveBuffEffect(targetObj.getName()).apply(ref);
ref.getGame().getLogManager().log(targetObj.getName() + " " + BUFF_DISPELLED_STRING);
return;
}
ref.getGame().getLogManager().log(targetObj.getName() + " " + ufa.getLogString());
// TODO enemy string should be different!
Effect e = getFailEffects(ufa);
e.apply(ref);
}
use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class DC_CounterRule method applyEffects.
protected void applyEffects(Unit unit) {
Effect effects = getWrappedEffects(unit);
effects.apply(Ref.getSelfTargetingRefCopy(unit));
if (effects instanceof AddBuffEffect) {
((AddBuffEffect) effects).getBuff().setCounterRef(getCounterName());
}
// TODO animation?
// startContinuousAnimation();
// playAddAnimation();
// playIntensifyAnimation();
// playTickAnimation();
}
use of main.ability.effects.Effect 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.ability.effects.Effect in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getSelfSpellPriority.
@Override
public int getSelfSpellPriority(Action action) {
Effects effects = null;
if (action instanceof AiQuickItemAction)
effects = EffectFinder.getEffectsFromSpell(((DC_QuickItemAction) action.getActive()).getItem().getActives().get(0));
else
effects = EffectFinder.getEffectsFromSpell(action.getActive());
if (effects.getEffects().isEmpty())
return 0;
setBasePriority(getUnitPriority(getUnit(), false));
for (Effect e : effects) {
addEffectPriority(action, e);
}
return priority;
}
use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class PriorityManagerImpl method initRollMap.
private void initRollMap(DC_ActiveObj spell, List<Effect> effects) {
rollMap = new ConcurrentMap<>();
List<RollEffect> rollEffects = EffectFinder.getRollEffects(spell);
for (RollEffect roll : rollEffects) {
for (Effect e : effects) {
Effect effect = roll.getEffect();
if (effect instanceof Effects) {
Effects rolledEffects = (Effects) effect;
for (Effect e1 : rolledEffects.getEffects()) {
rollMap.put(e1, roll);
}
break;
}
if (effect == e) {
rollMap.put(e, roll);
break;
}
}
}
}
Aggregations