use of eidolons.ability.conditions.special.CanActCondition in project Eidolons by IDemiurge.
the class TossItemEffect method applyThis.
/*
* size? from hand?
*
* interrupt?
*/
@Override
public boolean applyThis() {
Unit source = (Unit) ref.getSourceObj();
Ref REF = ref.getCopy();
conditions = new OrConditions(DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_ITEM), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_WEAPON));
if (!new SelectiveTargeting(conditions).select(REF)) {
ref.getActive().setCancelled(true);
return false;
}
DC_HeroItemObj item = (DC_HeroItemObj) REF.getTargetObj();
conditions = new Conditions(// ++ Max distance?
new DistanceCondition(ref.getActive().getIntParam(PARAMS.RANGE, false) + ""), // new NumericCondition("{match_c_n_of_actions}", "1"),
new CanActCondition(KEYS.MATCH), new NotCondition(ConditionMaster.getSelfFilterCondition()), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.ANY_ALLY));
// non-immobile, ++facing?
if (!new SelectiveTargeting(conditions).select(REF)) {
ref.getActive().setCancelled(true);
return false;
}
Unit unit = (Unit) REF.getTargetObj();
boolean result = roll(source, unit, item);
if (item instanceof DC_QuickItemObj) {
DC_QuickItemObj quickItem = (DC_QuickItemObj) item;
source.removeQuickItem(quickItem);
if (result) {
unit.addQuickItem(quickItem);
} else {
dropped(item, unit);
}
} else {
source.unequip(item, null);
if (result) {
// TODO equip in hand if
unit.addItemToInventory(item);
} else // possible? spend AP?
{
dropped(item, unit);
}
}
// ref.getObj(KEYS.ITEM);
unit.modifyParameter(PARAMS.C_N_OF_ACTIONS, -1);
return true;
}
Aggregations