use of main.system.auxiliary.RandomWizard 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;
}
Aggregations