Search in sources :

Example 1 with ITEM_RARITY

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

the class ContainerMaster method getItem.

public ObjType getItem(CONTAINER_CONTENTS c, int maxCost) {
    int random = RandomWizard.getRandomInt(100);
    ITEM_RARITY rarity = ITEM_RARITY.COMMON;
    for (ITEM_RARITY sub : ITEM_RARITY.values()) {
        if (sub.getChance() >= random) {
            rarity = sub;
            break;
        }
    }
    main.system.auxiliary.log.LogMaster.log(1, "getItem " + c + "; " + rarity + maxCost);
    ObjType type = preselectBaseType(c, rarity);
    main.system.auxiliary.log.LogMaster.log(1, "preselectBaseType " + type);
    if (type == null)
        return null;
    // base types!
    List<ObjType> pool = new ArrayList<>(getItemPool(c, rarity, type));
    main.system.auxiliary.log.LogMaster.log(1, "pool= " + pool);
    if (pool.isEmpty())
        return null;
    if (isRemoveBase(c, type))
        pool.removeIf(item -> !item.isGenerated());
    else {
        pool.size();
    }
    if (pool.isEmpty())
        return null;
    pool.removeIf(item -> item.getIntParam(PARAMS.GOLD_COST) > maxCost);
    if (pool.isEmpty())
        return null;
    if (pool.size() > 20) {
        SortMaster.sortEntitiesByExpression(pool, (item) -> item.getIntParam(PARAMS.GOLD_COST));
        pool.removeIf(item -> pool.indexOf(item) > pool.size() / 2);
    }
    main.system.auxiliary.log.LogMaster.log(1, "filtered pool= " + pool + " max cost: " + maxCost);
    if (pool.isEmpty())
        return null;
    ObjType baseType = new RandomWizard<ObjType>().getRandomListItem(pool);
    return baseType;
}
Also used : CONTAINER_ACTION(eidolons.game.module.dungeoncrawl.objects.ContainerMaster.CONTAINER_ACTION) InventoryDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource) java.util(java.util) CONTAINER_CONTENTS(main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS) JEWELRY_ITEM_TRAIT(eidolons.content.DC_CONSTS.JEWELRY_ITEM_TRAIT) DungeonMaster(eidolons.game.battlecraft.logic.dungeon.universal.DungeonMaster) PARAMS(eidolons.content.PARAMS) CONTAINER_CONTENT_VALUE(main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENT_VALUE) CoreEngine(main.system.launch.CoreEngine) GuiEventType(main.system.GuiEventType) WaitMaster(main.system.threading.WaitMaster) MAGICAL_ITEM_LEVEL(eidolons.content.DC_CONSTS.MAGICAL_ITEM_LEVEL) GuiEventManager(main.system.GuiEventManager) StringMaster(main.system.auxiliary.StringMaster) C_OBJ_TYPE(main.content.C_OBJ_TYPE) Ref(main.entity.Ref) Pair(org.apache.commons.lang3.tuple.Pair) CharacterCreator(eidolons.client.cc.CharacterCreator) Loop(main.system.auxiliary.Loop) ItemMaster(eidolons.client.cc.logic.items.ItemMaster) MATERIAL(main.content.enums.entity.ItemEnums.MATERIAL) G_PROPS(main.content.values.properties.G_PROPS) SortMaster(main.system.SortMaster) DC_TYPE(main.content.DC_TYPE) ItemGenerator(eidolons.client.cc.logic.items.ItemGenerator) ObjType(main.entity.type.ObjType) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) PROPS(eidolons.content.PROPS) ContainerDataSource(eidolons.libgdx.gui.panels.dc.inventory.container.ContainerDataSource) InventoryTransactionManager(eidolons.ability.InventoryTransactionManager) FilterMaster(main.system.entity.FilterMaster) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ITEM_RARITY(main.content.enums.entity.ItemEnums.ITEM_RARITY) RandomWizard(main.system.auxiliary.RandomWizard) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Entity(main.entity.Entity) DataManager(main.data.DataManager) QUALITY_LEVEL(main.content.enums.entity.ItemEnums.QUALITY_LEVEL) WEAPON_GROUP(main.content.enums.entity.ItemEnums.WEAPON_GROUP) Unit(eidolons.entity.obj.unit.Unit) OBJ_TYPE(main.content.OBJ_TYPE) ITEM_RARITY(main.content.enums.entity.ItemEnums.ITEM_RARITY) ObjType(main.entity.type.ObjType)

Aggregations

InventoryTransactionManager (eidolons.ability.InventoryTransactionManager)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 PROPS (eidolons.content.PROPS)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 Unit (eidolons.entity.obj.unit.Unit)1 DungeonMaster (eidolons.game.battlecraft.logic.dungeon.universal.DungeonMaster)1 CONTAINER_ACTION (eidolons.game.module.dungeoncrawl.objects.ContainerMaster.CONTAINER_ACTION)1 ContainerDataSource (eidolons.libgdx.gui.panels.dc.inventory.container.ContainerDataSource)1 InventoryDataSource (eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource)1 java.util (java.util)1 C_OBJ_TYPE (main.content.C_OBJ_TYPE)1 DC_TYPE (main.content.DC_TYPE)1 OBJ_TYPE (main.content.OBJ_TYPE)1 CONTAINER_CONTENTS (main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS)1