use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitShop method chooseQualityForItem.
private static ObjType chooseQualityForItem(MATERIAL materialType, int costLimit, Unit unit, ObjType baseType, boolean canExceed) {
String allowed = unit.getProperty(PROPS.QUALITY_LEVEL_RANGE);
int minIndex = 0;
int maxIndex = 999;
if (allowed.contains(";")) {
minIndex = EnumMaster.getEnumConstIndex(QUALITY_LEVEL.class, allowed.split(";")[0]);
maxIndex = EnumMaster.getEnumConstIndex(QUALITY_LEVEL.class, allowed.split(";")[1]);
}
List<ObjType> types = new ArrayList<>();
for (QUALITY_LEVEL sub : DataManager.getItemMaps().keySet()) {
int index = EnumMaster.getEnumConstIndex(QUALITY_LEVEL.class, sub);
if (index > maxIndex)
continue;
if (index < minIndex)
continue;
ObjType type = DataManager.getItem(sub, materialType, baseType);
if (type.getIntParam(PARAMS.GOLD_COST) <= costLimit) {
return type;
} else if (canExceed)
types.add(type);
}
if (!canExceed)
return null;
SortMaster.sortEntitiesByExpression(types, (type) -> -type.getIntParam(PARAMS.GOLD_COST));
return types.get(0);
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitShop method buy.
private static boolean buy(String repertoire, Unit unit, ITEM_SLOT slot, OBJ_TYPE OBJ_TYPE_ENUM) {
// Map<ObjType, Integer>
List<ObjType> itemPool = new ArrayList<>();
// ++ add weight! choose from repertoire!
WeightMap<ObjType> map = new WeightMap<>(new RandomWizard<ObjType>().constructWeightMap(repertoire, ObjType.class, OBJ_TYPE_ENUM));
Loop.startLoop(map.size());
while (!Loop.loopEnded() && !map.isEmpty()) {
ObjType baseType = getItem(map);
map.remove(baseType);
if (baseType == null) {
// *empty*
return false;
}
for (ObjType type : DataManager.getTypes(OBJ_TYPE_ENUM)) {
if (!checkItemType(type, baseType)) {
continue;
}
if (!checkCanEquip(baseType, unit, slot)) {
continue;
}
if (!specialCheck(unit, type)) {
continue;
}
// TODO for potions/jewelry?
if (// for potions/ammo?
!checkQualityRange(type, unit)) {
continue;
}
itemPool.add(type);
}
try {
itemPool = (List<ObjType>) SortMaster.sortByValue(itemPool, PARAMS.GOLD_COST, true);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
DC_HeroItemObj item = null;
for (ObjType type : itemPool) {
// sort by cost? then go from top to bottom trying to buy...
if (!checkCost(type, unit)) {
continue;
}
item = buy(type, unit);
break;
}
if (item == null) {
continue;
}
equip(unit, item, slot);
return true;
}
return false;
// ++ sell TODO
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitTrainer method initXpItemPool.
private static WeightMap<ObjType> initXpItemPool(Unit trainee) {
if (StringMaster.isEmpty(getPlan(trainee)) || getPlan(trainee).contains(StringMaster.BASE_CHAR)) {
generateSkillPlan(trainee);
}
WeightMap<ObjType> pool = new WeightMap<>();
Map<ObjType, Integer> map = new RandomWizard<ObjType>().constructWeightMap(getPlan(trainee), ObjType.class, DC_TYPE.SKILLS);
for (ObjType type : map.keySet()) {
if (type == null)
continue;
if (trainee.checkProperty(PROPS.SKILLS, type.getName())) {
// TODO ++ exceptions
continue;
}
String reason = trainee.getGame().getRequirementsManager().check(trainee, type);
if (reason != null) {
continue;
}
pool.put(type, map.get(type));
// we really can't have weights here - must be more or less
// sequential, since it'll be skill trees!
// and i dont wanna override reqs
}
// random-pick
return pool;
}
use of main.entity.type.ObjType 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.entity.type.ObjType in project Eidolons by IDemiurge.
the class ClassTreeCondition method check.
@Override
public boolean check(Ref ref) {
ObjType type = DataManager.getType(className, DC_TYPE.CLASSES);
if (type == null) {
return true;
}
Unit hero = (Unit) ref.getSourceObj();
for (DC_FeatObj c : hero.getClasses()) {
if (c.getType().equals(type)) {
return true;
}
if (c.getProperty(G_PROPS.CLASS_GROUP).equalsIgnoreCase(type.getProperty(G_PROPS.CLASS_GROUP))) {
if (c.getIntParam(PARAMS.CIRCLE) >= type.getIntParam(PARAMS.CIRCLE)) {
return false;
}
}
}
return true;
}
Aggregations