use of main.system.math.Formula in project Eidolons by IDemiurge.
the class IlluminationRule method getLightEmissionEffect.
public LightEmittingEffect getLightEmissionEffect(DC_Obj source) {
LightEmittingEffect effect = effectCache.get(source);
if (effect == null) {
int value = getLightEmission(source);
if (value <= 0) {
return null;
}
Boolean circular = true;
if (source instanceof Unit)
circular = false;
else if (source.checkBool(GenericEnums.STD_BOOLS.SPECTRUM_LIGHT)) {
circular = false;
} else if (EntityCheckMaster.isOverlaying(source)) {
BattleFieldObject dc_Obj = (BattleFieldObject) source;
if (dc_Obj.getDirection() != null) {
circular = false;
}
}
effect = new LightEmittingEffect(("" + value), circular);
effect.setRef(new Ref(source));
effectCache.put(source, effect);
} else
effect.getEffects().setFormula(new Formula("" + getLightEmission(source)));
return effect;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DiseaseRule method getSpecialRoundEffects.
@Override
protected Effect getSpecialRoundEffects() {
// spread effects could go here! :)
ModifyValueEffect modifyValueEffect = new ModifyValueEffect(PARAMS.C_STAMINA, MOD.MODIFY_BY_CONST, getCounterRef() + "*" + STAMINA_PER_COUNTER);
modifyValueEffect.setMin_max_formula(new Formula("0"));
Effects effects = new Effects(modifyValueEffect);
return effects;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class FilterMaster method filter.
public static Collection<?> filter(Collection<?> list, String valueName, String value, OBJ_TYPE TYPE, boolean prop, boolean filterOut, Boolean strict_or_greater_less_equal) {
List<Object> filteredList = new ArrayList<>();
for (Object l : list) {
Entity entity;
if (l instanceof Entity) {
entity = (Entity) l;
} else {
entity = DataManager.getType(l.toString(), TYPE);
}
if (entity == null) {
continue;
}
boolean result;
if (prop) {
PROPERTY property = ContentManager.getPROP(valueName);
if (property.isContainer()) // if (!BooleanMaster.isFalse(strict_or_greater_less_equal))
{
result = entity.checkContainerProp(property, value, strict_or_greater_less_equal == null);
} else {
result = StringMaster.compareByChar(entity.getProperty(property), value, BooleanMaster.isTrue(strict_or_greater_less_equal));
}
// entity.checkProperty();
} else {
PARAMETER param = ContentManager.getPARAM(valueName);
int amount = new Formula(value).getInt(new Ref(entity));
if (strict_or_greater_less_equal == null) {
result = entity.getIntParam(param) == amount;
} else {
result = entity.checkParam(param, "" + amount);
if (!strict_or_greater_less_equal) {
result = !result;
}
}
}
if (filterOut) {
if (result) {
filteredList.add(l);
}
} else if (!result) {
filteredList.add(l);
}
}
for (Object l : filteredList) {
list.remove(l);
}
return list;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class SpectrumEffect method applyThis.
public boolean applyThis() {
if (range == null)
range = new Formula(rangeFormula).getInt(ref);
Integer backwardRange = 0;
Integer sidePenalty = 0;
if (vision) {
range = new Formula(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SIGHT_RANGE)).getInt(ref);
// TODO
backwardRange = null;
// will be taken from unit
sidePenalty = null;
}
if (ref.getObj(source) instanceof BattleFieldObject)
bfObj = ((BattleFieldObject) ref.getObj(source));
else {
// TODO
}
FACING_DIRECTION facing = bfObj.getFacing();
if (circular) {
backwardRange = range;
facing = FACING_DIRECTION.NORTH;
} else {
sidePenalty = 1;
}
List<Coordinates> coordinates = new ArrayList<>(getGame().getVisionMaster().getSightMaster().getSpectrumCoordinates(range, sidePenalty, backwardRange, bfObj, vision, facing));
// boolean x-ray ++ tall/short/etc
if (effects == null) {
initEffects();
}
for (Coordinates c : coordinates) {
// TODO WHAT IF IT'S ON A DIFFERENT Z-LEVEL?
// applyThrough = true; // ?
// if (!applyThrough)
// if (!(getGame().getObjectByCoordinate(c, true) instanceof
// DC_Cell))
// continue;
DequeImpl<? extends Obj> objects = new DequeImpl<>(getGame().getObjectsOnCoordinate(getGame().getDungeon().getZ(), c, null, true, applyThrough));
if (applyThrough) {
objects.addCast(getGame().getCellByCoordinate(c));
}
for (Obj o : objects) {
ref.setMatch(o.getId());
if (filterConditions != null) {
if (!filterConditions.preCheck(ref)) {
continue;
}
}
Integer target = o.getId();
// target = getGame().getCellByCoordinate(c).getId();
if (getGame().getObjectById(target) == null) {
continue;
}
for (Effect effect : effects.getEffects()) {
Ref REF = Ref.getCopy(ref);
REF.setTarget(target);
if (reductionForDistance != null) {
// for the first time
effect.resetOriginalFormula();
// to set original
effect.resetOriginalFormula();
String reduction = reductionForDistance;
if (reductionForDistanceModifier != null)
reduction += (reductionForDistanceModifier);
Formula effectFormula = effect.getFormula();
reduction = reduction.replace(X, effectFormula.toString());
int distance = PositionMaster.getDistance(REF.getSourceObj(), REF.getTargetObj());
reduction = reduction.replace("distance", distance + "");
effectFormula.append(reduction);
// TODO
Integer amount = effectFormula.getInt(ref);
if (amount < 0) {
effect.setAmount(amount);
}
effect.setAmount(amount);
}
effect.apply(REF);
}
}
}
return true;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class RestEffect method getRestedBuffEffect.
private Effect getRestedBuffEffect() {
Effects effects = new Effects();
effects.add(new ModifyValueEffect(PARAMS.STAMINA, MOD.MODIFY_BY_PERCENT, "25"));
effects.add(new ModifyValueEffect(PARAMS.ESSENCE, MOD.MODIFY_BY_PERCENT, "25"));
effects.add(new ModifyValueEffect(PARAMS.WILLPOWER, MOD.MODIFY_BY_PERCENT, "25"));
effects.add(new ModifyValueEffect(PARAMS.AGILITY, MOD.MODIFY_BY_PERCENT, "25"));
effects.add(new ModifyValueEffect(PARAMS.DEXTERITY, MOD.MODIFY_BY_PERCENT, "25"));
effects.add(new ModifyValueEffect(PARAMS.SPELLPOWER, MOD.MODIFY_BY_PERCENT, "25"));
effects.add(new ModifyValueEffect(PARAMS.STRENGTH, MOD.MODIFY_BY_PERCENT, "25"));
return new AddBuffEffect("Rested", effects, new Formula("10"));
}
Aggregations