Search in sources :

Example 26 with DC_HeroItemObj

use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.

the class InventoryTransactionManager method equipOriginalItems.

public static void equipOriginalItems(Unit to, Obj from) {
    for (Obj i : to.getGame().getDroppedItemManager().getDroppedItems(to.getGame().getCellByCoordinate(to.getCoordinates()))) {
        if (i.getRef().getSourceObj() == from) {
            ITEM_SLOT slot = null;
            if (i.getOBJ_TYPE_ENUM() == DC_TYPE.ARMOR) {
                slot = ItemEnums.ITEM_SLOT.ARMOR;
            } else {
                if (from.getRef().getObj(KEYS.WEAPON) == i) {
                    slot = ItemEnums.ITEM_SLOT.MAIN_HAND;
                } else if (from.getRef().getObj(KEYS.OFFHAND) == i) {
                    slot = ItemEnums.ITEM_SLOT.OFF_HAND;
                }
            }
            if (slot == null) {
                if (i instanceof DC_WeaponObj) {
                    DC_WeaponObj weaponObj = (DC_WeaponObj) i;
                    if (weaponObj.getWeaponClass() == ItemEnums.WEAPON_CLASS.MAIN_HAND_ONLY || weaponObj.getWeaponClass() == ItemEnums.WEAPON_CLASS.TWO_HANDED || weaponObj.getWeaponClass() == ItemEnums.WEAPON_CLASS.DOUBLE) {
                        slot = ItemEnums.ITEM_SLOT.MAIN_HAND;
                    } else if (to.getMainWeapon() != null) {
                        slot = ItemEnums.ITEM_SLOT.OFF_HAND;
                    } else {
                        slot = ItemEnums.ITEM_SLOT.MAIN_HAND;
                    }
                }
            }
            // ITEM_SLOT.MAIN_HAND;
            to.getGame().getDroppedItemManager().pickedUp(i);
            i.setRef(to.getRef());
            // equip() !
            if (slot == null) {
                to.getQuickItems().add((DC_QuickItemObj) i);
            } else {
                to.equip((DC_HeroItemObj) i, slot);
            }
        }
    }
}
Also used : ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) Obj(main.entity.obj.Obj) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj)

Example 27 with DC_HeroItemObj

use of eidolons.entity.item.DC_HeroItemObj 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)

Example 28 with DC_HeroItemObj

use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.

the class UnitResetter method resetObjects.

public void resetObjects() {
    if (ExplorationMaster.isExplorationOn()) {
        if (!getEntity().isDirty()) {
            return;
        }
    }
    getEntity().setBeingReset(true);
    Chronos.mark(toString() + " OBJECTS APPLY");
    applyBackground();
    resetAttributes();
    resetMasteryScores();
    if (getEntity().getSkills() != null) {
        resetRanks(getEntity().getSkills(), PROPS.SKILLS);
        for (DC_FeatObj feat : getEntity().getSkills()) {
            feat.apply();
        }
    }
    if (getEntity().getClasses() != null) {
        resetRanks(getEntity().getClasses(), PROPS.CLASSES);
        for (DC_FeatObj feat : getEntity().getClasses()) {
            feat.apply();
        }
    }
    if (getEntity().getMainWeapon() != null) {
        getEntity().getMainWeapon().apply();
    } else if (getEntity().getNaturalWeapon() != null) {
        getEntity().getNaturalWeapon().apply();
    }
    if (getEntity().getOffhandWeapon() != null) {
        getEntity().getOffhandWeapon().apply();
    // if (checkDualWielding())
    // DC_Formulas.MAIN_HAND_DUAL_ATTACK_MOD
    } else if (getEntity().getOffhandNaturalWeapon() != null) {
        getEntity().getOffhandNaturalWeapon().apply();
    }
    if (getEntity().getArmor() != null) {
        getEntity().getArmor().apply();
    }
    resetQuickSlotsNumber();
    for (DC_HeroItemObj item : getEntity().getQuickItems()) {
        item.apply();
    }
    for (DC_HeroItemObj item : getEntity().getJewelry()) {
        item.apply();
    }
    // Chronos.logTimeElapsedForMark(toString() + " OBJECTS APPLY");
    // Chronos.mark(toString() + " activate PASSIVES");
    getInitializer().initSpells(game.isSimulation());
    getEntity().activatePassives();
    // Chronos.logTimeElapsedForMark(toString() + " activate PASSIVES");
    getEntity().setDirty(false);
    getEntity().setBeingReset(false);
    if (game.isSimulation() || getType().isModel()) {
        // initSpellbook(); //in afterEffect()
        return;
    }
    // Chronos.mark(toString() + " init ACTIVES");
    getInitializer().initActives();
// Chronos.logTimeElapsedForMark(toString() + " init ACTIVES");
}
Also used : DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj)

Example 29 with DC_HeroItemObj

use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.

the class BfObjInitializer method initContainedItems.

public DequeImpl<? extends DC_HeroItemObj> initContainedItems(PROPS prop, DequeImpl<? extends DC_HeroItemObj> list, boolean quick) {
    if (StringMaster.isEmpty(getProperty(prop))) {
        if (list == null) {
            return new DequeImpl<>();
        }
        if (list.isEmpty() || game.isSimulation()) {
            return new DequeImpl<>();
        }
    }
    if (list == null || (!game.isSimulation() && getEntity().isItemsInitialized())) {
        setProperty(prop, StringMaster.constructContainer(StringMaster.convertToIdList(list)));
    } else {
        List<String> idList = new ArrayList<>();
        Collection<DC_HeroItemObj> items = new ArrayList<>();
        for (String subString : StringMaster.open(getProperty(prop))) {
            ObjType type = DataManager.getType(subString, DC_ContentManager.getTypeForProperty(prop));
            // || !StringMaster.isInteger(subString)
            DC_HeroItemObj item = null;
            if (game.isSimulation()) {
                item = (DC_HeroItemObj) getGame().getSimulationObj(getEntity(), type, prop);
            }
            if (item == null) {
                if (type == null) {
                    item = (DC_HeroItemObj) game.getObjectById(StringMaster.getInteger(subString));
                } else {
                    item = ItemFactory.createItemObj(type, getEntity().getOriginalOwner(), getGame(), getRef(), quick);
                }
                if (item != null) {
                    if (!game.isSimulation()) {
                        idList.add(item.getId() + "");
                    } else {
                        getGame().addSimulationObj(getEntity(), type, item, prop);
                    }
                }
            }
            if (item == null) {
                LogMaster.log(1, getName() + " has null items in item container " + prop);
            } else {
                items.add(item);
            }
        }
        list = new DequeImpl<>(items);
        if (!game.isSimulation()) {
            setProperty(prop, StringMaster.constructContainer(idList));
        }
    }
    if (list == null) {
        return new DequeImpl<>();
    }
    return list;
}
Also used : ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DequeImpl(main.system.datatypes.DequeImpl)

Aggregations

DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)29 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)7 Obj (main.entity.obj.Obj)6 Ref (main.entity.Ref)5 ObjType (main.entity.type.ObjType)5 DC_JewelryObj (eidolons.entity.item.DC_JewelryObj)3 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)3 Unit (eidolons.entity.obj.unit.Unit)3 ArrayList (java.util.ArrayList)3 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)2 Coordinates (main.game.bf.Coordinates)2 RandomWizard (main.system.auxiliary.RandomWizard)2 WeightMap (main.system.datatypes.WeightMap)2 CanActCondition (eidolons.ability.conditions.special.CanActCondition)1 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 DC_SpellObj (eidolons.entity.active.DC_SpellObj)1 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)1 DC_Cell (eidolons.entity.obj.DC_Cell)1