Search in sources :

Example 11 with RandomWizard

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

Aggregations

RandomWizard (main.system.auxiliary.RandomWizard)11 ObjType (main.entity.type.ObjType)7 Ref (main.entity.Ref)3 Loop (main.system.auxiliary.Loop)3 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)2 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)2 ArrayList (java.util.ArrayList)2 DC_TYPE (main.content.DC_TYPE)2 CONTAINER_CONTENTS (main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS)2 CONTAINER_CONTENT_VALUE (main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENT_VALUE)2 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)2 InventoryTransactionManager (eidolons.ability.InventoryTransactionManager)1 DC_Effect (eidolons.ability.effects.DC_Effect)1 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 CharacterCreator (eidolons.client.cc.CharacterCreator)1 ItemGenerator (eidolons.client.cc.logic.items.ItemGenerator)1 ItemMaster (eidolons.client.cc.logic.items.ItemMaster)1 JEWELRY_ITEM_TRAIT (eidolons.content.DC_CONSTS.JEWELRY_ITEM_TRAIT)1 MAGICAL_ITEM_LEVEL (eidolons.content.DC_CONSTS.MAGICAL_ITEM_LEVEL)1 PARAMS (eidolons.content.PARAMS)1