Search in sources :

Example 11 with MATERIAL

use of main.content.enums.entity.ItemEnums.MATERIAL in project Eidolons by IDemiurge.

the class ItemGenerator method init.

public void init() {
    // if (!basicMode)
    ContentGenerator.initMaterials();
    if (!isGenerationOn()) {
        return;
    }
    for (QUALITY_LEVEL q : ItemEnums.QUALITY_LEVEL.values()) {
        ConcurrentMap qMap = new ConcurrentMap<>();
        itemMaps.put(q, qMap);
        for (MATERIAL m : ItemEnums.MATERIAL.values()) {
            qMap.put(m, new ConcurrentMap<>());
        }
    }
    baseWeaponTypes.addAll(DataManager.getTypes(DC_TYPE.WEAPONS));
    baseArmorTypes.addAll(DataManager.getTypes(DC_TYPE.ARMOR));
    baseJewelryTypes.addAll(DataManager.getTypes(DC_TYPE.JEWELRY));
    baseItemTypes.addAll(DataManager.getTypes(DC_TYPE.ITEMS));
    // baseGarmentTypes.addAll(DataManager.getTypes(OBJ_TYPES.GARMENT));
    DataManager.setBaseGarmentTypes(baseGarmentTypes.toArray(new ObjType[baseGarmentTypes.size()]));
    DataManager.setBaseWeaponTypes(baseWeaponTypes.toArray(new ObjType[baseWeaponTypes.size()]));
    DataManager.setBaseArmorTypes(baseArmorTypes.toArray(new ObjType[baseArmorTypes.size()]));
    DataManager.setBaseJewelryTypes(baseJewelryTypes.toArray(new ObjType[baseJewelryTypes.size()]));
    DataManager.setBaseItemTypes(baseItemTypes.toArray(new ObjType[baseItemTypes.size()]));
    // basicGenerator = new ItemGenerator(true);
    try {
        // (isBasicMode() ? basicGenerator : defaultGenerator).
        generateItemObjTypes();
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    DataManager.setItemMaps(itemMaps);
}
Also used : ObjType(main.entity.type.ObjType) QUALITY_LEVEL(main.content.enums.entity.ItemEnums.QUALITY_LEVEL) ConcurrentMap(main.data.ConcurrentMap) MATERIAL(main.content.enums.entity.ItemEnums.MATERIAL)

Example 12 with MATERIAL

use of main.content.enums.entity.ItemEnums.MATERIAL in project Eidolons by IDemiurge.

the class UnitShop method buyNew.

public static boolean buyNew(String repertoire, Unit unit, ITEM_SLOT slot, int costLimit, boolean canExceed, OBJ_TYPE OBJ_TYPE_ENUM) {
    // choose instead of stumble
    WeightMap<ObjType> map = new WeightMap<>(new RandomWizard<ObjType>().constructWeightMap(repertoire, ObjType.class, OBJ_TYPE_ENUM));
    // TODO preconstruct more item types?
    if (map.isEmpty()) {
        return false;
    }
    ObjType baseType = getItem(map);
    MATERIAL materialType = chooseMaterialType(costLimit, unit, baseType, canExceed);
    ObjType itemType = null;
    if (materialType != null) {
        itemType = chooseQualityForItem(materialType, costLimit, unit, baseType, canExceed);
    } else {
        if (baseType.getOBJ_TYPE_ENUM() != DC_TYPE.ITEMS)
            return false;
        List<ObjType> types = DataManager.getUpgradedTypes(baseType);
        // types = (List<ObjType>) SortMaster.sortByValue(types, PARAMS.GOLD_COST, true);
        SortMaster.sortEntitiesByExpression(types, (type) -> -type.getIntParam(PARAMS.GOLD_COST));
        for (ObjType type : types) {
            if (!checkCost(type, unit)) {
                continue;
            }
            itemType = type;
            break;
        }
    }
    if (itemType == null) {
        // return buy(repertoire, unit, slot, OBJ_TYPE_ENUM);
        return false;
    }
    DC_HeroItemObj item = buy(itemType, unit);
    equip(unit, item, slot);
    return true;
}
Also used : ObjType(main.entity.type.ObjType) RandomWizard(main.system.auxiliary.RandomWizard) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) WeightMap(main.system.datatypes.WeightMap) MATERIAL(main.content.enums.entity.ItemEnums.MATERIAL)

Example 13 with MATERIAL

use of main.content.enums.entity.ItemEnums.MATERIAL 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

MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)13 QUALITY_LEVEL (main.content.enums.entity.ItemEnums.QUALITY_LEVEL)8 ObjType (main.entity.type.ObjType)8 ArrayList (java.util.ArrayList)3 EnumMaster (main.system.auxiliary.EnumMaster)3 DurabilityReductionEffect (eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect)1 ItemGenerator (eidolons.client.cc.logic.items.ItemGenerator)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 SHOP_LEVEL (main.content.CONTENT_CONSTS2.SHOP_LEVEL)1 ConcurrentMap (main.data.ConcurrentMap)1 Conditions (main.elements.conditions.Conditions)1 OrConditions (main.elements.conditions.OrConditions)1 StringComparison (main.elements.conditions.StringComparison)1 Ref (main.entity.Ref)1 RandomWizard (main.system.auxiliary.RandomWizard)1 WeightMap (main.system.datatypes.WeightMap)1