Search in sources :

Example 1 with RandomWizard

use of main.system.auxiliary.RandomWizard in project Eidolons by IDemiurge.

the class HeroObjectModifyingEffect method applyThis.

/**
 * Modstring format: valueName(value);valueName2(value2);... Use [mod],
 * [set], [remove] to change the default ADD function of modstring
 */
public boolean applyThis() {
    if (ref.getTargetObj().isDead() || ref.getSourceObj().isDead()) {
        removeEffects();
        return false;
    }
    if (game.isSimulation()) {
        if (!checkApplyInSimulation()) {
            return true;
        }
    }
    // what if the group has changed? perhaps there should be a map...
    if (prop) {
        if (propMap == null) {
            propMap = new RandomWizard<PROPERTY>().constructStringWeightMap(modString, PROPERTY.class);
        } else {
            LogMaster.log(1, "prop map " + propMap.toString());
        }
    } else if (// TODO support PROPERTY?
    map == null) {
        map = new RandomWizard<PARAMETER>().constructStringWeightMap(modString, PARAMETER.class);
    } else {
        LogMaster.log(0, "map " + map.toString());
    }
    List<? extends Obj> list = getObjectsToModify();
    LogMaster.log(0, "list " + list.toString());
    LogMaster.log(0, "effects " + effects.toString());
    for (Obj obj : list) {
        if (obj == null) {
            continue;
        }
        if (obj.isDead()) {
            // TODO clean up for owner is dead!
            continue;
        }
        Effect effect = effects.get(obj);
        if (effect != null) {
            // if (isPermanent() && isApplied())
            // continue;
            effect.applyThis();
            applied = true;
            continue;
        }
        Ref REF = ref.getCopy();
        REF.setTarget(obj.getId());
        // map = new MapMaster<PARAMETER, String>().constructVarMap(
        // modString, PARAMETER.class);
        Effects modEffects = new Effects();
        if (map != null) {
            EffectFinder.initParamModEffects(modEffects, map, ref);
        } else if (propMap != null) {
            EffectFinder.initPropModEffects(modEffects, propMap, ref);
        }
        applied = true;
        for (Effect e : modEffects.getEffects()) {
            e.resetOriginalFormula();
            e.appendFormulaByMod(getFormula().toString());
        }
        if (buff) {
            AddBuffEffect buffEffect = new AddBuffEffect(buffName, modEffects);
            // TODO LAYER?
            buffEffect.setForcedLayer(getModEffectLayer());
            modEffects.setForcedLayer(getModEffectLayer());
            if (isPermanent()) {
                buffEffect.setDuration(ContentManager.INFINITE_VALUE);
            }
            if (!game.isSimulation()) {
                effects.put(obj, buffEffect);
            }
            buffEffect.apply(REF);
        } else {
            if (!game.isSimulation()) {
                effects.put(obj, modEffects);
            }
            modEffects.apply(REF);
        }
    }
    return true;
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Ref(main.entity.Ref) RandomWizard(main.system.auxiliary.RandomWizard) PROPERTY(main.content.values.properties.PROPERTY) Obj(main.entity.obj.Obj) DC_Effect(eidolons.ability.effects.DC_Effect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Effect(main.ability.effects.Effect) Effects(main.ability.effects.Effects) PARAMETER(main.content.values.parameters.PARAMETER)

Example 2 with RandomWizard

use of main.system.auxiliary.RandomWizard 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 3 with RandomWizard

use of main.system.auxiliary.RandomWizard in project Eidolons by IDemiurge.

the class LocationBuilder method getRandomCoordinate.

private Coordinates getRandomCoordinate(ROOM_TYPE roomType) {
    // TODO totally random? a fair start...
    boolean corner = false;
    boolean center = false;
    ROOM_TYPE[] adjacentRoomRequired = null;
    switch(roomType) {
        case DEATH_ROOM:
        case GUARD_ROOM:
            adjacentRoomRequired = new ROOM_TYPE[] { ROOM_TYPE.TREASURE_ROOM, ROOM_TYPE.THRONE_ROOM, ROOM_TYPE.EXIT_ROOM };
            break;
        case SECRET_ROOM:
        case TREASURE_ROOM:
            corner = true;
            break;
    }
    Coordinates c = null;
    if (adjacentRoomRequired != null) {
        Loop.startLoop(500);
        while (!Loop.loopEnded()) {
            MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
            if (Arrays.asList(adjacentRoomRequired).contains(block.getRoomType())) {
                List<Coordinates> list = CoordinatesMaster.getAdjacentToSquare(block.getCoordinates());
                c = new RandomWizard<Coordinates>().getRandomListItem(list);
                if (c.isInvalid()) {
                    continue;
                }
                if (helper.getUsedCoordinates().contains(c)) {
                    continue;
                }
                return c;
            }
        }
        return null;
    }
    Loop.startLoop(100);
    while (!Loop.loopEnded()) {
        c = CoordinatesMaster.getRandomCoordinate(getDungeon().getCellsX(), getDungeon().getCellsY());
        if (helper.getUsedCoordinates().contains(c)) {
            continue;
        }
        // add the outer walls to usedCoordinates?
        if (corner) {
            if (Math.min(plan.getBorderX() - c.x, c.x) + Math.min(plan.getBorderY() - c.y, c.y) > 6) {
                continue;
            }
        }
        break;
    }
    return c;
}
Also used : RandomWizard(main.system.auxiliary.RandomWizard) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 4 with RandomWizard

use of main.system.auxiliary.RandomWizard in project Eidolons by IDemiurge.

the class LocationSpawner method getCreepGroupForBlock.

private Wave getCreepGroupForBlock(int preferredPower, Dungeon dungeon, MapBlock block, int min, int max) {
    // alt? vielleicht fur einige spezielle orte...
    String property = dungeon.getProperty(PROPS.ENCOUNTERS);
    int mod = block.getSpawningPriority();
    if (mod == 0) {
        mod = 100;
    }
    Wave wave;
    List<ObjType> list = DataManager.toTypeList(property, DC_TYPE.ENCOUNTERS);
    Collections.shuffle(list);
    ObjType type = null;
    for (ObjType t : list) {
        type = t;
        if (EncounterMaster.getPower(type, false) < min * mod / 100) {
            continue;
        }
        if (EncounterMaster.getPower(type, false) > max * mod / 100) {
            continue;
        }
        break;
    }
    if (type == null) {
        type = new RandomWizard<ObjType>().getObjectByWeight(property, ObjType.class);
    }
    wave = new Wave(type, game, new Ref(game), game.getPlayer(false));
    wave.setPreferredPower(preferredPower * mod / 100);
    wave.setBlock(block);
    return wave;
}
Also used : Wave(eidolons.game.battlecraft.logic.battle.arena.Wave) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) RandomWizard(main.system.auxiliary.RandomWizard)

Example 5 with RandomWizard

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

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