use of main.system.math.Formula in project Eidolons by IDemiurge.
the class ActivesConstructor method wrapEffects.
public static Effect wrapEffects(TARGETING_MODE mode, Effect effects, DC_ActiveObj entity) {
Formula radius = new Formula(entity.getParam(G_PARAMS.RADIUS));
Formula range = new Formula(entity.getParam(PARAMS.RANGE));
Boolean allyOrEnemyOnly = null;
if (entity.checkBool(GenericEnums.STD_BOOLS.NO_FRIENDLY_FIRE)) {
allyOrEnemyOnly = false;
}
if (entity.checkBool(GenericEnums.STD_BOOLS.NO_ENEMY_FIRE)) {
allyOrEnemyOnly = true;
}
boolean notSelf = entity.checkBool(GenericEnums.STD_BOOLS.NO_SELF_FIRE);
switch(mode) {
case SPRAY:
effects = new WaveEffect(effects, radius, range, allyOrEnemyOnly, true, false, entity.checkBool(GenericEnums.STD_BOOLS.APPLY_THRU) ? C_OBJ_TYPE.BF : C_OBJ_TYPE.BF_OBJ);
break;
case WAVE:
effects = new WaveEffect(effects, radius, range, allyOrEnemyOnly, true, true, // expanding
entity.checkBool(GenericEnums.STD_BOOLS.APPLY_THRU) ? C_OBJ_TYPE.BF : C_OBJ_TYPE.BF_OBJ);
// modifier?
break;
case RAY:
effects = new RayEffect(effects);
// ++ special conditions for allyOrEnemyOnly
break;
case DOUBLE:
break;
case MULTI:
break;
case TRIPPLE:
break;
case BLAST:
if (// ideally, I
entity.getIntParam(G_PARAMS.RADIUS) > 0) // shouldn't mix
// up targeting
// and effect
// wrapping
{
effects = new ZoneEffect(effects, radius, allyOrEnemyOnly, notSelf);
}
break;
case NOVA:
// TODO
effects = new Effects(new ZoneEffect(effects, radius, allyOrEnemyOnly, true));
break;
case SINGLE:
break;
case TRAP:
break;
default:
break;
}
return effects;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class ActivesConstructor method wrapEffects.
public static Effect wrapEffects(EFFECTS_WRAP wrap, Effect effects, Entity entity) {
Formula radius = new Formula(entity.getParam(G_PARAMS.RADIUS));
Boolean allyOrEnemyOnly = null;
if (entity.checkBool(GenericEnums.STD_BOOLS.NO_FRIENDLY_FIRE)) {
allyOrEnemyOnly = false;
}
if (entity.checkBool(GenericEnums.STD_BOOLS.NO_ENEMY_FIRE)) {
allyOrEnemyOnly = true;
}
boolean notSelf = entity.checkBool(GenericEnums.STD_BOOLS.NO_SELF_FIRE);
switch(wrap) {
case CHAIN:
break;
case CUSTOM_ZONE_CROSS:
break;
case CUSTOM_ZONE_STAR:
// };
break;
case ZONE:
effects = new Effects(new ZoneEffect(effects, radius, allyOrEnemyOnly, notSelf));
break;
case SINGLE_BUFF:
Effects buffEffects = new Effects();
if (effects instanceof Effects) {
for (Effect effect : (Effects) effects) {
if (effect instanceof AddBuffEffect) {
buffEffects.add(((AddBuffEffect) effect).getEffect());
} else {
buffEffects.add(effect);
}
}
} else {
buffEffects.add(effects);
}
String buffName = entity.getProperty(PROPS.BUFF_NAME);
if (buffName == null) {
}
effects = new AddBuffEffect(buffName, buffEffects);
break;
default:
break;
}
return effects;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DC_CostsFactory method getCost.
public static Cost getCost(Entity obj, PARAMS cost_param, PARAMS pay_param) {
String paramValue = obj.getParam(cost_param);
Formula formula;
boolean var;
int amount = StringMaster.getInteger(paramValue);
if (amount == 0) {
return null;
}
formula = new Formula(amount + "");
var = false;
Cost cost = new CostImpl(new Payment(pay_param, formula), cost_param);
cost.setVariable(var);
return cost;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class TextParser method parseRef.
// perhaps I should refactor into method per parse_type!
private static String parseRef(String ref_substring, Ref ref) {
if (ref == null) {
return parseVarRef(ref_substring);
}
String value = StringMaster.cropRef(ref_substring);
if (!StringMaster.isInteger(value)) {
if (isAbilityParsing()) {
return ref_substring;
}
}
int id = 0;
if (isActiveParsing()) {
id = ref.getId(KEYS.ACTIVE);
} else {
try {
id = ref.getId(KEYS.INFO);
} catch (Exception e) {
}
}
Game game = ref.getGame();
// if (id == 0) {
// if (game.isRunning()) {
// id = game.getManager().getInfoObj().getId();
// }
// }
// else if (CharacterCreator.isRunning())
String replacement = ref_substring;
Entity entity = ref.getInfoEntity();
if (entity == null) {
if (game.isSimulation() && !isBuffParsing() && !isAbilityParsing()) {
entity = game.getTypeById(id);
} else {
entity = game.getObjectById(id);
}
}
if (entity == null) {
return ref_substring;
}
if (entity instanceof AbilityObj) {
entity = entity.getType();
}
if (StringMaster.isInteger(value)) {
int index = StringMaster.getInteger(value) - 1;
String varProp = entity.getProperty(G_PROPS.VARIABLES);
if (StringMaster.isEmpty(varProp)) {
varProp = DEFAULT_VARS;
}
boolean containerFormula = false;
if (!entity.getParam("FORMULA").isEmpty()) {
// StringMaster.compare(varProp.replace(";", ""), "FORMULA",
// true)) {
varProp = entity.getParam("FORMULA");
containerFormula = true;
}
List<String> openContainer = StringMaster.openContainer(varProp);
if (openContainer.size() > index) {
VALUE val = null;
if (!containerFormula && !isBuffParsing()) {
val = ContentManager.getValue(openContainer.get(index));
replacement = entity.getValue(val);
} else {
replacement = openContainer.get(index);
}
if (containerFormula || val instanceof PARAMETER) {
if (StringMaster.isInteger(replacement)) {
return replacement;
}
try {
if (isAbilityParsing()) // if (replacement.contains(",")) {
// // TODO all function names!
// if (replacement.toLowerCase().contains("min")
// || replacement.toLowerCase().contains(
// "max")) {
// // get the insides of the formula?
// // parts = replacement.split(regex);
// // parts[1] = parts[1].
// //
// // replacement = parts[0] + parts[1];
// return replacement.replace(",",
// StringMaster.COMMA_CODE);
// }
// } else
{
return replacement.replace(",", StringMaster.COMMA_CODE);
}
if (game.isSimulation()) {
replacement = new Formula(replacement).getInt(ref) + " (" + formatFormula(replacement) + ")";
} else {
replacement = new Formula(replacement).getInt(ref) + "";
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
} else {
String result = new Property(true, replacement).getStr(ref);
if (StringMaster.isEmpty(result)) {
replacement = new Parameter(replacement).getInt(ref) + "";
} else {
replacement = result;
}
}
}
} else {
if (!isAbilityParsing()) {
if (StringMaster.isInteger(replacement)) {
return replacement;
}
if (game.isSimulation() && !tooltipParsing) {
Integer VAL = new Formula(replacement).getInt(ref);
replacement = VAL + " (" + replacement + ")";
} else {
// TODO
replacement = new Formula(replacement).getInt(ref) + "";
}
// props!
}
}
return replacement;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class UpkeepRule method subtractUpkeep.
public void subtractUpkeep(Unit unit, Obj payObj) {
for (PARAMETER p : ValuePages.UPKEEP_PARAMETERS) {
PARAMETER payParam = DC_ContentManager.getPayParamFromUpkeep(p);
int amount = new Formula(payObj.getParam(p)).getAppendedByModifier(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.UPKEEP_MOD)).getInt(unit.getRef());
if (amount <= 0) {
return;
}
unit.modifyParameter(payParam, -amount);
unit.getGame().getLogManager().log(payObj.getName() + "'s " + ContentManager.getBaseParameterFromCurrent(p).getName() + " upkeep paid: " + amount);
}
}
Aggregations