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);
}
}
}
}
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;
}
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");
}
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;
}
Aggregations