use of main.elements.conditions.Condition in project Eidolons by IDemiurge.
the class TurnSequenceConstructor method getTurnSequence.
public List<Action> getTurnSequence(Action action) {
Conditions conditions = (action.getTargeting().getFilter().getConditions());
FacingCondition condition = null;
FACING_SINGLE template = null;
DC_Obj target = action.getTarget();
Unit source = (Unit) action.getRef().getSourceObj();
for (Condition c : conditions) {
if (c instanceof FacingCondition) {
condition = (FacingCondition) c;
break;
}
List<Object> list = ClassMaster.getInstances(c, FacingCondition.class);
if (!list.isEmpty()) {
List<Action> front_sequence = getTurnSequence(FACING_SINGLE.IN_FRONT, source, target.getCoordinates());
List<Action> side_sequence = null;
if (action.getSource().hasBroadReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.BROAD_REACH)) // front_sequence.remove(front_sequence.size() - 1);
{
side_sequence = getTurnSequence(FACING_SINGLE.TO_THE_SIDE, source, target.getCoordinates());
}
List<Action> hind_sequence = null;
if (action.getSource().hasHindReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.HIND_REACH)) {
hind_sequence = getTurnSequence(FACING_SINGLE.BEHIND, source, target.getCoordinates());
}
return new ListMaster<Action>().getSmallest(front_sequence, hind_sequence, side_sequence);
}
}
// }
if (condition == null) {
return new ArrayList<>();
}
if (ArrayMaster.isNotEmpty(condition.getTemplate())) {
template = condition.getTemplate()[0];
}
return getTurnSequence(template, source, target.getCoordinates());
}
use of main.elements.conditions.Condition in project Eidolons by IDemiurge.
the class Filter method getObjects.
public Set<T> getObjects() {
if (isDebug()) {
ArrayList<Obj> list = new ArrayList<>(getFilteredObjectPool());
Set<Obj> set = new HashSet<>();
loop: for (Obj obj : list) {
for (Condition c : getConditions()) {
if (!match(c, obj.getId())) {
if (conditionDebugCache != null)
conditionDebugCache.put(obj.getId(), c);
continue loop;
}
}
set.add(obj);
}
return (Set<T>) new HashSet<>(set);
}
Collection<Obj> pool = getFilteredObjectPool();
Set<T> filteredSet = (Set<T>) new HashSet<>(pool);
ArrayList<Obj> list = new ArrayList<>(pool);
for (Condition c : getConditions()) {
for (Obj obj : list) {
if (!match(c, obj.getId())) {
filteredSet.remove(obj);
}
}
}
return filteredSet;
// TODO sort out; use cache
}
use of main.elements.conditions.Condition in project Eidolons by IDemiurge.
the class ModeEffect method addDispelOnHitTrigger.
private void addDispelOnHitTrigger() {
Effects effects = new Effects(new RemoveBuffEffect(addBuffEffect.getBuffTypeName()));
if (!mode.equals(STD_MODES.ALERT)) {
effects.add(InterruptRule.getEffect());
} else {
effects.add(AlertRule.getInterruptEffect());
}
if (mode.equals(STD_MODES.CHANNELING)) {
effects.add(new EffectImpl() {
@Override
public boolean applyThis() {
ChannelingRule.channelingInterrupted((Unit) getRef().getSourceObj());
return true;
}
});
}
// TODO
STANDARD_EVENT_TYPE event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
Condition conditions = (mode.equals(STD_MODES.ALERT)) ? InterruptRule.getConditionsAlert() : InterruptRule.getConditions();
addBuffEffect.addEffect(new DelayedEffect(event_type, effects, conditions));
}
use of main.elements.conditions.Condition in project Eidolons by IDemiurge.
the class PartyHelper method getPrincipleConditions.
public static Conditions getPrincipleConditions(Party party) {
Conditions principlesConditions = new Conditions();
for (Unit m : party.getMembers()) {
String principles = m.getProperty(G_PROPS.PRINCIPLES);
Condition principlesCondition = new PrinciplesCondition(principles, "{MATCH_" + G_PROPS.PRINCIPLES + "}", true);
principlesConditions.add(principlesCondition);
}
return principlesConditions;
}
use of main.elements.conditions.Condition in project Eidolons by IDemiurge.
the class AddBuffEffect method initRetainConditions.
private void initRetainConditions() {
if (ref.getActive() == null) {
return;
}
String prop = ref.getActive().getProperty(PROPS.RETAIN_CONDITIONS, false);
for (String s : StringMaster.open(prop)) {
RETAIN_CONDITIONS template = new EnumMaster<RETAIN_CONDITIONS>().retrieveEnumConst(RETAIN_CONDITIONS.class, s);
Condition condition;
if (template != null) {
condition = DC_ConditionMaster.getRetainConditionsFromTemplate(template, ref);
} else {
condition = ConditionMaster.toConditions(s);
}
if (condition != null) {
getRetainConditions().add(condition);
}
}
}
Aggregations