use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class UnitTrainer method generateSkillPlan.
private static void generateSkillPlan(Unit trainee) {
/*
* weights per mastery level and skill difficulty TODO
*/
String plan = getPlan(trainee).replace(StringMaster.BASE_CHAR, "");
if (!plan.isEmpty()) {
if (!plan.endsWith(";")) {
// ++ syntax for cancelling [mastery] skills...
plan += ";";
}
}
for (PARAMETER mastery : ValuePages.MASTERIES) {
Integer score = trainee.getIntParam(mastery);
if (score <= 0) {
continue;
}
List<ObjType> types = DataManager.toTypeList(DataManager.getTypesSubGroupNames(DC_TYPE.SKILLS, mastery.getName()), DC_TYPE.SKILLS);
for (ObjType t : types) {
if (plan.contains(t.getName())) {
continue;
}
if (!WorkspaceMaster.checkTypeIsReadyForUse(t)) {
continue;
}
int weight = Math.max(1, score - t.getIntParam(PARAMS.SKILL_DIFFICULTY));
plan += t.getName() + StringMaster.wrapInParenthesis("" + weight) + StringMaster.CONTAINER_SEPARATOR;
}
}
trainee.setProperty(PROPS.XP_PLAN, plan, true);
}
use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class UnitTrainingMaster method getSpellXpPercentage.
public static Integer getSpellXpPercentage(Unit unit) {
Integer mastery = 0;
for (PARAMETER m : ValuePages.MASTERIES) {
mastery += (unit.getIntParam(m));
}
Integer spellMastery = 0;
for (PARAMETER m : ValuePages.MASTERIES_MAGIC_SCHOOLS) {
spellMastery += (unit.getIntParam(m));
}
return Math.round(new Float(spellMastery) / mastery * 100);
}
use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class SkillPointCondition method check.
@Override
public boolean check(Ref ref) {
Entity match = ref.getMatchObj();
if (match == null) {
match = ref.getType("match");
}
if (match == null) {
return false;
}
PARAMETER masteryParam = ContentManager.getPARAM(match.getProperty(G_PROPS.MASTERY));
if (masteryParam == null) {
masteryParam = ContentManager.getMastery(match.getProperty(G_PROPS.MASTERY));
}
Integer amount = match.getIntParam(PARAMS.SKILL_DIFFICULTY);
if (rank) {
amount = amount * match.getIntParam(PARAMS.RANK_SD_MOD) / 100;
}
pointsRequired = amount - DC_MathManager.getFreeMasteryPoints((Unit) ref.getSourceObj(), masteryParam);
return pointsRequired <= 0;
}
use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class LogManager method logValueMod.
public void logValueMod(PARAMETER param, Number i, Obj obj) {
Integer amount = StringMaster.getInteger(i.toString());
if (amount.toString().equals("0")) {
return;
}
PARAMETER baseParameter = ContentManager.getBaseParameterFromCurrent(param);
if (baseParameter == null) {
return;
}
boolean positive = !amount.toString().contains("-");
String string = positive ? " gains " : " loses ";
if (!obj.getOwner().isMe()) {
positive = !positive;
}
String prefix = (positive) ? StringMaster.MESSAGE_PREFIX_SUCCESS : StringMaster.MESSAGE_PREFIX_FAIL;
String s = (obj.getNameIfKnown()) + string + " " + amount.toString().replace("-", "") + " " + baseParameter.getShortName();
log(prefix + s);
}
use of main.content.values.parameters.PARAMETER 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;
}
Aggregations