use of main.content.enums.entity.ItemEnums.QUALITY_LEVEL in project Eidolons by IDemiurge.
the class UnitShop method chooseMaterialType.
public static MATERIAL chooseMaterialType(int costLimit, Unit unit, ObjType baseType, boolean canExceed) {
if (baseType == null)
return null;
if (baseType.getOBJ_TYPE_ENUM() == DC_TYPE.JEWELRY)
return null;
if (baseType.getOBJ_TYPE_ENUM() == DC_TYPE.ITEMS)
return null;
QUALITY_LEVEL qualityLevel = QUALITY_LEVEL.DAMAGED;
String property = unit.getProperty(PROPS.ALLOWED_MATERIAL);
List<MATERIAL> list = property.isEmpty() ? getMaterialsForUnit(unit, baseType, costLimit, canExceed) : new EnumMaster<MATERIAL>().getEnumList(MATERIAL.class, property);
list.removeIf(material -> !ItemMaster.checkMaterial(baseType, material));
Collections.shuffle(list);
List<MATERIAL> materials = new ArrayList<>();
for (MATERIAL sub : list) {
// map .get(sub).get(baseType);
ObjType type = DataManager.getItem(qualityLevel, sub, baseType);
if (type.getIntParam(PARAMS.GOLD_COST) <= costLimit)
return sub;
else if (canExceed)
materials.add(sub);
}
if (!canExceed)
return null;
SortMaster.sortByExpression(materials, (type) -> -((MATERIAL) type).getCost());
return materials.get(0);
}
Aggregations