Search in sources :

Example 1 with CanActCondition

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;
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Ref(main.entity.Ref) CanActCondition(eidolons.ability.conditions.special.CanActCondition) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

CanActCondition (eidolons.ability.conditions.special.CanActCondition)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)1 Unit (eidolons.entity.obj.unit.Unit)1 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)1 Ref (main.entity.Ref)1