use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class CostImpl method pay.
@Override
public boolean pay(Ref ref) {
setRef(ref);
ref.setID(KEYS.PAYEE, ref.getId(key));
Obj payee = ref.getGame().getObjectById(ref.getId(key));
boolean result = true;
if (altCosts != null) {
if (!canBePaid(ref, true)) {
paidAlt = true;
return altCosts.pay(ref);
}
}
for (Payment payment : toPay) {
result &= payment.pay(payee, ref);
}
paidAlt = false;
return result;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class ShapeEffect method initTargeting.
@Override
public void initTargeting() {
// init unit group
Coordinates baseCoordinate = getBaseCoordinate();
int base_width = radius.getInt(ref);
int distance = this.distance.getInt(ref);
coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
DequeImpl<Obj> objects = new DequeImpl<>();
objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
Filter.filter(objects, targetType);
if (allyOrEnemyOnly != null) {
if (allyOrEnemyOnly) {
FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
} else {
FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
}
}
if (notSelf) {
FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
}
if (targetType.equals(DC_TYPE.TERRAIN)) {
// C_TYPE equals if contains() !
objects.addAll(game.getCellsForCoordinates(coordinates));
}
targeting = new AutoTargeting(new GroupImpl(objects));
setFilteringConditions(new Conditions());
targeting.setConditions(getFilteringConditions());
}
use of main.entity.obj.Obj 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;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class HeroObjectModifyingEffect method getIdList.
protected List<Integer> getIdList(Unit hero) {
List<Integer> list = new ArrayList<>();
if (hero == null) {
return list;
}
switch(type) {
case ACTIONS:
for (ACTION_TYPE a : ActionEnums.ACTION_TYPE.values()) {
if (hero.getActionMap().get(a) != null) {
for (DC_UnitAction action : hero.getActionMap().get(a)) {
list.add(action.getId());
}
}
}
break;
case ARMOR:
list = new ArrayList<>(new ListMaster<Integer>().getList(hero.getArmor().getId()));
break;
case ITEMS:
for (Obj i : hero.getQuickItems()) // if (i.getOBJ_TYPE_ENUM() != OBJ_TYPES.WEAPONS)
// non-weapon QI???
{
list.add(i.getId());
}
break;
case SPELLS:
for (Obj i : hero.getSpells()) {
list.add(i.getId());
}
// hero.getGame().getManager().getSpells(hero)
break;
case WEAPONS:
Integer id = null;
if (hero.getActiveWeapon(true) != null) {
id = hero.getActiveWeapon(true).getId();
}
Integer id2 = 0;
if (hero.getActiveWeapon(false) != null) {
id2 = hero.getActiveWeapon(false).getId();
}
list = new ArrayList<>(new ListMaster<Integer>().getList(id2, id));
List<? extends Obj> l = new ArrayList<>(hero.getQuickItems());
for (Obj i : l) {
if (i.getOBJ_TYPE_ENUM() == DC_TYPE.WEAPONS) {
list.add(i.getId());
}
}
break;
}
// ListMaster.removeNullElements(list);
FilterMaster.filter(list, conditions, game);
return list;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class CastNewSpellEffect method applyThis.
// TODO spellpower/mastery mods!!!
@Override
public boolean applyThis() {
ObjType type = DataManager.getType(spelltype, DC_TYPE.SPELLS);
Ref REF = new Ref(ref.getGame(), ref.getSource());
Obj obj = game.createSpell(type, ref.getSourceObj().getOwner(), REF);
DC_SpellObj spell = (DC_SpellObj) obj;
spell.setFree(free);
spell.setQuietMode(true);
if (group) {
REF.setGroup(ref.getGroup());
return spell.activatedOn(REF);
}
if (chooseTarget) {
spell.getTargeting().select(REF);
} else {
REF.setTarget(ref.getId(target_key));
}
return spell.activatedOn(REF);
}
Aggregations