Search in sources :

Example 11 with QUALITY_LEVEL

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);
}
Also used : EnumMaster(main.system.auxiliary.EnumMaster) ObjType(main.entity.type.ObjType) QUALITY_LEVEL(main.content.enums.entity.ItemEnums.QUALITY_LEVEL) ArrayList(java.util.ArrayList) MATERIAL(main.content.enums.entity.ItemEnums.MATERIAL)

Aggregations

QUALITY_LEVEL (main.content.enums.entity.ItemEnums.QUALITY_LEVEL)11 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)8 ObjType (main.entity.type.ObjType)7 ArrayList (java.util.ArrayList)3 EnumMaster (main.system.auxiliary.EnumMaster)3 ItemGenerator (eidolons.client.cc.logic.items.ItemGenerator)1 ConcurrentMap (main.data.ConcurrentMap)1 Conditions (main.elements.conditions.Conditions)1 OrConditions (main.elements.conditions.OrConditions)1 StringComparison (main.elements.conditions.StringComparison)1