Search in sources :

Example 51 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class UnitShop method chooseQualityForItem.

private static ObjType chooseQualityForItem(MATERIAL materialType, int costLimit, Unit unit, ObjType baseType, boolean canExceed) {
    String allowed = unit.getProperty(PROPS.QUALITY_LEVEL_RANGE);
    int minIndex = 0;
    int maxIndex = 999;
    if (allowed.contains(";")) {
        minIndex = EnumMaster.getEnumConstIndex(QUALITY_LEVEL.class, allowed.split(";")[0]);
        maxIndex = EnumMaster.getEnumConstIndex(QUALITY_LEVEL.class, allowed.split(";")[1]);
    }
    List<ObjType> types = new ArrayList<>();
    for (QUALITY_LEVEL sub : DataManager.getItemMaps().keySet()) {
        int index = EnumMaster.getEnumConstIndex(QUALITY_LEVEL.class, sub);
        if (index > maxIndex)
            continue;
        if (index < minIndex)
            continue;
        ObjType type = DataManager.getItem(sub, materialType, baseType);
        if (type.getIntParam(PARAMS.GOLD_COST) <= costLimit) {
            return type;
        } else if (canExceed)
            types.add(type);
    }
    if (!canExceed)
        return null;
    SortMaster.sortEntitiesByExpression(types, (type) -> -type.getIntParam(PARAMS.GOLD_COST));
    return types.get(0);
}
Also used : ObjType(main.entity.type.ObjType) QUALITY_LEVEL(main.content.enums.entity.ItemEnums.QUALITY_LEVEL) ArrayList(java.util.ArrayList)

Example 52 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class UnitShop method buy.

private static boolean buy(String repertoire, Unit unit, ITEM_SLOT slot, OBJ_TYPE OBJ_TYPE_ENUM) {
    // Map<ObjType, Integer>
    List<ObjType> itemPool = new ArrayList<>();
    // ++ add weight! choose from repertoire!
    WeightMap<ObjType> map = new WeightMap<>(new RandomWizard<ObjType>().constructWeightMap(repertoire, ObjType.class, OBJ_TYPE_ENUM));
    Loop.startLoop(map.size());
    while (!Loop.loopEnded() && !map.isEmpty()) {
        ObjType baseType = getItem(map);
        map.remove(baseType);
        if (baseType == null) {
            // *empty*
            return false;
        }
        for (ObjType type : DataManager.getTypes(OBJ_TYPE_ENUM)) {
            if (!checkItemType(type, baseType)) {
                continue;
            }
            if (!checkCanEquip(baseType, unit, slot)) {
                continue;
            }
            if (!specialCheck(unit, type)) {
                continue;
            }
            // TODO for potions/jewelry?
            if (// for potions/ammo?
            !checkQualityRange(type, unit)) {
                continue;
            }
            itemPool.add(type);
        }
        try {
            itemPool = (List<ObjType>) SortMaster.sortByValue(itemPool, PARAMS.GOLD_COST, true);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
        DC_HeroItemObj item = null;
        for (ObjType type : itemPool) {
            // sort by cost? then go from top to bottom trying to buy...
            if (!checkCost(type, unit)) {
                continue;
            }
            item = buy(type, unit);
            break;
        }
        if (item == null) {
            continue;
        }
        equip(unit, item, slot);
        return true;
    }
    return false;
// ++ sell TODO
}
Also used : ObjType(main.entity.type.ObjType) RandomWizard(main.system.auxiliary.RandomWizard) ArrayList(java.util.ArrayList) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) WeightMap(main.system.datatypes.WeightMap)

Example 53 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class UnitTrainer method initXpItemPool.

private static WeightMap<ObjType> initXpItemPool(Unit trainee) {
    if (StringMaster.isEmpty(getPlan(trainee)) || getPlan(trainee).contains(StringMaster.BASE_CHAR)) {
        generateSkillPlan(trainee);
    }
    WeightMap<ObjType> pool = new WeightMap<>();
    Map<ObjType, Integer> map = new RandomWizard<ObjType>().constructWeightMap(getPlan(trainee), ObjType.class, DC_TYPE.SKILLS);
    for (ObjType type : map.keySet()) {
        if (type == null)
            continue;
        if (trainee.checkProperty(PROPS.SKILLS, type.getName())) {
            // TODO ++ exceptions
            continue;
        }
        String reason = trainee.getGame().getRequirementsManager().check(trainee, type);
        if (reason != null) {
            continue;
        }
        pool.put(type, map.get(type));
    // we really can't have weights here - must be more or less
    // sequential, since it'll be skill trees!
    // and i dont wanna override reqs
    }
    // random-pick
    return pool;
}
Also used : ObjType(main.entity.type.ObjType) WeightMap(main.system.datatypes.WeightMap)

Example 54 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class UnitTrainer method generateSkillPlan.

private static void generateSkillPlan(Unit trainee) {
    /*
         * weights per mastery level and skill difficulty TODO
		 */
    String plan = getPlan(trainee).replace(StringMaster.BASE_CHAR, "");
    if (!plan.isEmpty()) {
        if (!plan.endsWith(";")) {
            // ++ syntax for cancelling [mastery] skills...
            plan += ";";
        }
    }
    for (PARAMETER mastery : ValuePages.MASTERIES) {
        Integer score = trainee.getIntParam(mastery);
        if (score <= 0) {
            continue;
        }
        List<ObjType> types = DataManager.toTypeList(DataManager.getTypesSubGroupNames(DC_TYPE.SKILLS, mastery.getName()), DC_TYPE.SKILLS);
        for (ObjType t : types) {
            if (plan.contains(t.getName())) {
                continue;
            }
            if (!WorkspaceMaster.checkTypeIsReadyForUse(t)) {
                continue;
            }
            int weight = Math.max(1, score - t.getIntParam(PARAMS.SKILL_DIFFICULTY));
            plan += t.getName() + StringMaster.wrapInParenthesis("" + weight) + StringMaster.CONTAINER_SEPARATOR;
        }
    }
    trainee.setProperty(PROPS.XP_PLAN, plan, true);
}
Also used : ObjType(main.entity.type.ObjType) PARAMETER(main.content.values.parameters.PARAMETER)

Example 55 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class ClassTreeCondition method check.

@Override
public boolean check(Ref ref) {
    ObjType type = DataManager.getType(className, DC_TYPE.CLASSES);
    if (type == null) {
        return true;
    }
    Unit hero = (Unit) ref.getSourceObj();
    for (DC_FeatObj c : hero.getClasses()) {
        if (c.getType().equals(type)) {
            return true;
        }
        if (c.getProperty(G_PROPS.CLASS_GROUP).equalsIgnoreCase(type.getProperty(G_PROPS.CLASS_GROUP))) {
            if (c.getIntParam(PARAMS.CIRCLE) >= type.getIntParam(PARAMS.CIRCLE)) {
                return false;
            }
        }
    }
    return true;
}
Also used : DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) ObjType(main.entity.type.ObjType) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

ObjType (main.entity.type.ObjType)354 ArrayList (java.util.ArrayList)42 Coordinates (main.game.bf.Coordinates)30 Ref (main.entity.Ref)25 Unit (eidolons.entity.obj.unit.Unit)24 OBJ_TYPE (main.content.OBJ_TYPE)18 PROPERTY (main.content.values.properties.PROPERTY)18 DC_TYPE (main.content.DC_TYPE)16 PARAMETER (main.content.values.parameters.PARAMETER)16 File (java.io.File)15 Entity (main.entity.Entity)12 XLinkedMap (main.data.XLinkedMap)11 EnumMaster (main.system.auxiliary.EnumMaster)11 DC_SpellObj (eidolons.entity.active.DC_SpellObj)9 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)9 Obj (main.entity.obj.Obj)9 QUALITY_LEVEL (main.content.enums.entity.ItemEnums.QUALITY_LEVEL)8 MusicList (main.music.entity.MusicList)8 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)6 C_OBJ_TYPE (main.content.C_OBJ_TYPE)6