use of main.system.math.Formula in project Eidolons by IDemiurge.
the class ForceRule method applyPush.
// TODO into PushEffect! With std knockdown on "landing" or damage!
public static void applyPush(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
DIRECTION d = DirectionMaster.getRelativeDirection(source, target);
if (attack.isSpell()) {
d = DirectionMaster.getRelativeDirection(attack.getRef().getTargetObj(), target);
// cell
}
int distance = getPushDistance(MathMaster.applyModIfNotZero(force, attack.getFinalModParam(PARAMS.FORCE_PUSH_MOD)), target);
if (distance == 0) {
if (isTestMode()) {
distance = 1;
} else {
return;
}
}
if (d.isDiagonal()) {
distance = (int) Math.round(Math.sqrt(distance));
if (distance == 0) {
d = d.rotate90(RandomWizard.random());
distance = 1;
}
}
// int weight = target.getIntParam(PARAMS.TOTAL_WEIGHT);
// if (distance == 0)
// distance = RandomWizard.chance(force * 100 / weight) ? 1 : 0; // TODO
int x_displacement = BooleanMaster.isTrue(d.growX) ? distance : -distance;
int y_displacement = BooleanMaster.isTrue(d.growY) ? distance : -distance;
if (!d.isDiagonal()) {
if (d.isVertical()) {
x_displacement = 0;
} else {
y_displacement = 0;
}
}
Ref ref = attack.getRef().getCopy();
ref.setTarget(target.getId());
new MoveEffect("target", new Formula("" + x_displacement), new Formula("" + y_displacement)).apply(ref);
// roll dexterity against Fall Down
// TODO knock vs push - which is 'critical'?
// maybe just apply a modifier, then calculate if push/knock?
// sometimes it'll be better to be 'weak', eh?
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DC_RequirementsManager method generateSpellRequirements.
// TODO preCheck upgrade
public Requirements generateSpellRequirements(Entity type, int mode) {
Requirements req = new Requirements();
String cost = (mode != NORMAL_MODE) ? HeroManager.getCost(type, getHero(), type.getOBJ_TYPE_ENUM(), PROPS.VERBATIM_SPELLS) : HeroManager.getCost(type, getHero());
Condition paramCondition = ConditionMaster.getParamCondition(1, PARAMS.XP, PARAMS.XP_COST);
((NumericCondition) paramCondition).setComparingValue(new Formula("" + cost));
Requirement xpReq = new Requirement(paramCondition, InfoMaster.getParamReasonString(type, PARAMS.XP, cost));
req.add(xpReq);
PARAMETER spellMastery = ContentManager.getSpellMasteryForSpell(type);
if (mode != NORMAL_MODE) {
req.add(new Requirement(ConditionMaster.getParamCondition(spellMastery.getName(), "1", true), InfoMaster.getSpellMasteryReason(spellMastery)));
if (mode != VERBATIM_MODE) {
req.add(getParamRequirements(PARAMS.MEMORY_REMAINING, PARAMS.SPELL_DIFFICULTY, type));
}
if (type.isUpgrade()) {
String base = type.getProperty(G_PROPS.BASE_TYPE);
req.add(new Requirement(ConditionMaster.getPropCondition(KEYS.SOURCE.toString(), PROPS.VERBATIM_SPELLS, base), InfoMaster.SPELL_BASE + base));
}
return req;
}
if (spellMastery != null) {
String amount = "" + new Formula("2*" + StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SPELL_DIFFICULTY)).getInt(type.getRef());
req.add(new Requirement(getTotalCondition(amount, spellMastery, PARAMS.INTELLIGENCE), // PARAMS.SPELL_DIFFICULTY)),
InfoMaster.getTotalReasonString(// getOrParamReasonString
amount, PARAMS.INTELLIGENCE, spellMastery)));
}
// req.add(new Requirement(new NotCondition(new
// NumericCondition(StringMaster.getValueRef(
// KEYS.MATCH, PARAMS.SPELL_DIFFICULTY), "0", true)),
// InfoMaster.UNDER_CONSTRUCTION));
Requirement unknownReq = new Requirement(new NotCondition(ConditionMaster.getPropCondition(PROPS.KNOWN_SPELLS, G_PROPS.NAME, KEYS.SOURCE.toString(), KEYS.MATCH.toString())), InfoMaster.SPELL_KNOWN);
req.add(unknownReq);
return req;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DC_RequirementsManager method generateItemRequirements.
private Requirements generateItemRequirements(Entity type, int mode) {
// str/agi/int req!
Requirement paramRequirements = getParamRequirements(PARAMS.GOLD, PARAMS.GOLD_COST, type);
((NumericCondition) paramRequirements.getCondition()).setComparingValue(new Formula("" + HeroManager.getCost(type, getHero())));
return new Requirements(paramRequirements);
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DC_RequirementsManager method modifyRankReq.
private Requirements modifyRankReq(Entity feat, Requirements reqs, String tip, Map<String, Condition> reqMap, Condition condition, int rank) {
if (condition instanceof Conditions) {
Conditions conditions = (Conditions) condition;
OrConditions orCondition = null;
String[] tipParts = null;
if (tip.contains(" or ")) {
orCondition = new OrConditions();
tipParts = tip.split(" or ");
}
String reqTip = tip;
int i = 0;
String prevValue = null;
for (Condition c : conditions) {
if (orCondition != null) {
if (reqTip.equals(tip)) {
reqTip = "";
}
Requirements modifiedReqs = modifyRankReq(feat, reqs, tipParts[i], new HashMap<>(), c, rank);
for (String t : modifiedReqs.getReqMap().keySet()) {
Condition c2 = modifiedReqs.getReqMap().get(t);
orCondition.add(c2);
// if (prevValue != null)
// if (!prevValue.equals(value))
reqTip += t + " or ";
}
i++;
// prevValue = value;
} else {
modifyRankReq(feat, reqs, reqTip, reqMap, c, rank);
}
}
if (orCondition != null) {
reqMap.put(StringMaster.cropLast(reqTip, 4), orCondition);
}
} else if (condition instanceof NumericCondition) {
NumericCondition numericCondition = (NumericCondition) condition;
Formula f = new Formula(numericCondition.getComparingValue().toString());
String originalValue = "" + f.getInt();
Integer mod = (rank + 1) * feat.getIntParam(PARAMS.RANK_SD_MOD);
if (tip.contains("Xp")) {
f.applyModifier(feat.getIntParam(PARAMS.RANK_XP_MOD));
} else {
f.applyFactor(mod);
}
String value = "" + f.getInt();
// }
if (// total...
tip.contains("otal ")) {
tip.replace(originalValue, value);
}
tip = tip.replace(originalValue, value);
LogMaster.log(1, tip + " for " + feat + " = " + value);
numericCondition.setComparingValue(new Formula(value));
reqs = new Requirements(new Requirement(numericCondition, tip));
reqMap.put(tip, condition);
}
return reqs;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DC_MathManager method evaluateSummonEnergyCost.
@Override
public Integer evaluateSummonEnergyCost(Entity obj, String s) {
// 5+5*level +(level^2 -1)
Formula formula = new Formula("4+ 5*{SOURCE_LEVEL}+{SOURCE_LEVEL}*{SOURCE_LEVEL}");
Integer cost = formula.getInt(obj.getRef());
return cost;
}
Aggregations