use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.
the class CampEffect method applyThis.
@Override
public boolean applyThis() {
/*
restore fully, dispel all timed buffs, apply bonus
*/
List<Unit> allies = getGame().getMetaMaster().getPartyManager().getParty().getMembers();
if (allies.isEmpty())
getGame().getMetaMaster().getPartyManager().getParty().addMember(getGame().getMetaMaster().getPartyManager().getParty().getLeader());
// mystery fix
for (Unit sub : new LinkedList<>(allies)) {
DC_HeroItemObj item = sub.getItemFromInventory("Food");
if (item != null) {
sub.removeFromInventory(item);
continue;
}
DC_QuickItemObj qitem = sub.getQuickItem("Food");
if (item != null) {
sub.removeQuickItem(qitem);
continue;
}
allies.remove(sub);
continue;
// remove
}
if (allies.isEmpty()) {
FloatingTextMaster.getInstance().createFloatingText(TEXT_CASES.REQUIREMENT, "You need food supplies to camp!", ref.getSourceObj());
return false;
}
Effects restorationEffects = new Effects();
restorationEffects.add(new ModifyValueEffect(PARAMS.C_ENDURANCE, MOD.SET_TO_PERCENTAGE, "125", true));
restorationEffects.add(new ModifyValueEffect(PARAMS.C_FOCUS, MOD.SET_TO_PERCENTAGE, "70", true));
restorationEffects.add(new ModifyValueEffect(PARAMS.C_ESSENCE, MOD.SET_TO_PERCENTAGE, "100", true));
restorationEffects.add(new ModifyValueEffect(PARAMS.C_STAMINA, MOD.SET_TO_PERCENTAGE, "125", true));
restorationEffects.add(new ModifyValueEffect(PARAMS.C_TOUGHNESS, MOD.SET_TO_PERCENTAGE, "100", true));
for (Unit sub : allies) {
Ref REF = sub.getRef().getTargetingRef(sub);
restorationEffects.apply(REF);
}
float time = 20;
getGame().getDungeonMaster().getExplorationMaster().getTimeMaster().playerRests(time);
// applyRested();
for (Unit sub : allies) {
}
return true;
}
use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.
the class ModifyCounterEffect method applyThis.
@Override
public boolean applyThis() {
Ref REF = Ref.getCopy(ref);
Integer amount = formula.getInt(ref);
// MODIFY_BY_CONST Counter: {ACTIVE_PARAMS.BLEEDING_MOD}/100*(20-({TARGET_C_TOUGHNESS}*100/{TARGET_TOUGHNESS})*10/100)
if (getResistanceMod() != null) {
amount = MathMaster.applyMod(amount, getResistanceMod());
}
int mod = 0;
if (ref.getTargetObj() instanceof DC_HeroItemObj) {
try {
mod = ref.getSourceObj().getIntParam(DC_ContentManager.getCoatingAppliedModParam(CounterMaster.findCounterConst(counterName)));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
Integer modValue = MathMaster.addFactor(amount, mod);
REF.setAmount(modValue);
REF.setValue(KEYS.STRING, counterName);
new Event(STANDARD_EVENT_TYPE.COUNTER_BEING_MODIFIED, REF).fire();
boolean result = false;
switch(modtype) {
case MODIFY_BY_CONST:
result = ref.getTargetObj().modifyCounter(counterName, modValue);
break;
case MODIFY_BY_PERCENT:
result = ref.getTargetObj().modifyCounter(counterName, modValue);
break;
case SET:
result = ref.getTargetObj().setCounter(counterName, modValue);
break;
default:
break;
}
if (CoreEngine.isPhaseAnimsOn())
if (result) {
try {
getAnimation().addPhaseArgs(PHASE_TYPE.COUNTER, counterName, modtype, modValue);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
} else {
return false;
}
REF.setAmount(ref.getTargetObj().getCounter(counterName));
return new Event(STANDARD_EVENT_TYPE.COUNTER_MODIFIED, REF).fire();
}
use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.
the class UnitShop method equip.
private static void equip(Unit unit, DC_HeroItemObj item, ITEM_SLOT slot) {
if (slot != null) {
if (!unit.equip(item, slot)) {
LogMaster.log(1, unit.getName() + " failed to equip " + item.getName());
}
} else {
if (item instanceof DC_JewelryObj) {
unit.addJewelryItem((DC_JewelryObj) item);
} else {
if (item instanceof DC_QuickItemObj) {
unit.getQuickItems().add((DC_QuickItemObj) item);
} else {
DC_HeroItemObj itemObj = ItemFactory.createItemObj(item.getType(), unit.getOriginalOwner(), unit.getGame(), unit.getRef(), true);
unit.getQuickItems().add((DC_QuickItemObj) itemObj);
}
}
}
}
use of eidolons.entity.item.DC_HeroItemObj 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
}
use of eidolons.entity.item.DC_HeroItemObj in project Eidolons by IDemiurge.
the class SwapItemManager method removeType.
@Override
public void removeType(Entity type, PROPERTY p) {
if (!hasOperations()) {
return;
}
DC_HeroItemObj item = (DC_HeroItemObj) ObjUtilities.findObjByType(type, getHero().getInventory());
getHero().removeFromInventory(item);
// getHero().setInventory(null);
getHero().getGame().getDroppedItemManager().drop(item, getHero());
operationDone(OPERATIONS.DROP, type.getName());
CharacterCreator.getHeroManager().update(getHero());
}
Aggregations