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);
}
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;
}
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);
}
Aggregations