Search in sources :

Example 1 with CONTAINER_CONTENTS

use of main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS 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)

Example 2 with CONTAINER_CONTENTS

use of main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS in project Eidolons by IDemiurge.

the class ContainerMaster method initContents.

public void initContents(BattleFieldObject obj) {
    String contents = "";
    RandomWizard<CONTAINER_CONTENTS> wizard = new RandomWizard<>();
    String prop = obj.getProperty(PROPS.CONTAINER_CONTENTS);
    if (test_mode)
        prop = "Food(10);";
    Map<CONTAINER_CONTENTS, Integer> map = wizard.constructWeightMap(prop, CONTAINER_CONTENTS.class);
    prop = obj.getProperty(PROPS.CONTAINER_CONTENT_VALUE);
    RandomWizard<CONTAINER_CONTENT_VALUE> wizard_ = new RandomWizard<>();
    Map<CONTAINER_CONTENT_VALUE, Integer> typeMap = wizard_.constructWeightMap(prop, CONTAINER_CONTENT_VALUE.class);
    List<CONTAINER_CONTENT_VALUE> itemValueList = new ArrayList<>();
    Integer maxCost = obj.getIntParam(PARAMS.GOLD_TOTAL);
    int totalCost = 0;
    // size prop!
    int maxGroups = 2;
    Loop overLoop = new Loop(maxGroups);
    while (overLoop.continues()) {
        CONTAINER_CONTENT_VALUE rarity = wizard_.getObjectByWeight(typeMap);
        if (rarity == null)
            rarity = CONTAINER_CONTENT_VALUE.COMMON;
        if (noDuplicates)
            typeMap.remove(rarity);
        if (totalCost + rarity.getGoldCost() > maxCost)
            break;
        itemValueList.add(rarity);
        totalCost += rarity.getGoldCost();
    }
    float randomization = (isRandomizationOn()) ? new Random().nextFloat() + 0.5f : 1;
    for (CONTAINER_CONTENT_VALUE rarity : itemValueList) {
        maxCost = Math.round(randomization * Math.min(totalCost, rarity.getGoldCost()));
        CONTAINER_CONTENTS c = wizard.getObjectByWeight(map);
        if (noDuplicates)
            map.remove(c);
        Integer maxItems = c.getMaxItems();
        Integer cost = 0;
        int items = 0;
        Loop loop = new Loop(maxItems * 3);
        while (cost < maxCost && items <= maxItems) {
            if (!loop.continues())
                break;
            int max = Math.round((maxCost - cost) * 1.2f);
            ObjType item = getItem(c, max);
            if (item == null)
                if (c == CONTAINER_CONTENTS.FOOD)
                    continue;
            main.system.auxiliary.log.LogMaster.log(1, c + " rarity  " + rarity + " = " + item + "; total : " + cost);
            if (item == null)
                continue;
            contents += item.getName() + StringMaster.SEPARATOR;
            cost += item.getIntParam(PARAMS.GOLD_COST);
            items++;
        }
    }
    if (contents.isEmpty()) {
        main.system.auxiliary.log.LogMaster.log(1, ">> " + obj + " has contents: " + contents + itemValueList);
    } else
        main.system.auxiliary.log.LogMaster.log(1, ">> " + obj + " has contents: " + contents + itemValueList);
    obj.setProperty(PROPS.INVENTORY, contents);
}
Also used : CONTAINER_CONTENT_VALUE(main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENT_VALUE) Loop(main.system.auxiliary.Loop) CONTAINER_CONTENTS(main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS) ObjType(main.entity.type.ObjType) RandomWizard(main.system.auxiliary.RandomWizard)

Aggregations

CONTAINER_CONTENTS (main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENTS)2 CONTAINER_CONTENT_VALUE (main.content.enums.entity.DungeonObjEnums.CONTAINER_CONTENT_VALUE)2 ObjType (main.entity.type.ObjType)2 Loop (main.system.auxiliary.Loop)2 RandomWizard (main.system.auxiliary.RandomWizard)2 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