use of eidolons.ability.effects.oneshot.DealDamageEffect in project Eidolons by IDemiurge.
the class DamageCalculator method precalculateRawDamageForDisplay.
/**
* Calculates and creates Damage Objects of each DAMAGE_TYPE present for PhaseAnimations
*
* @param attack
* @return
*/
public static List<Damage> precalculateRawDamageForDisplay(Attack attack) {
List<Damage> list = new ArrayList<>();
list.add(DamageFactory.getDamageFromAttack(attack));
List<Effect> effects = new ArrayList<>();
if (attack.getWeapon().getSpecialEffects() != null) {
if (attack.getWeapon().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK) != null) {
effects.add(attack.getWeapon().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK));
}
}
if (attack.getAttacker().getSpecialEffects() != null) {
if (attack.getAttacker().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK) != null) {
effects.add(attack.getAttacker().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK));
}
}
for (Effect e : effects) {
// TODO ++ PARAM MOD
for (Effect dmgEffect : EffectFinder.getEffectsOfClass(e, DealDamageEffect.class)) {
int amount = dmgEffect.getFormula().getInt(attack.getRef());
list.add(DamageFactory.getDamageFromEffect((DealDamageEffect) dmgEffect, amount));
}
}
return list;
}
use of eidolons.ability.effects.oneshot.DealDamageEffect in project Eidolons by IDemiurge.
the class ForceRule method applyDamage.
public static void applyDamage(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
int damage = getDamage(force, target, target, target);
// attack.modifyParameter(PARAMS.BASE_DAMAGE, damage);
// if (target.getShield()!=null )
Ref ref = attack.getRef().getCopy();
ref.setTarget(target.getId());
new DealDamageEffect(new Formula(damage + ""), GenericEnums.DAMAGE_TYPE.BLUDGEONING).apply(ref);
}
use of eidolons.ability.effects.oneshot.DealDamageEffect in project Eidolons by IDemiurge.
the class FutureBuilder method getDamage.
public static int getDamage(DC_ActiveObj active, Obj targetObj, Effect e, Boolean min_max_normal) {
Integer damage;
Ref ref = active.getOwnerObj().getRef().getCopy();
ref.setTarget(targetObj.getId());
ref.setID(KEYS.ACTIVE, active.getId());
e.setRef(ref);
if (e instanceof DealDamageEffect) {
ref.setAmount(e.getFormula().getInt(ref));
if (((DealDamageEffect) e).getDamageType() != null) {
ref.setValue(KEYS.DAMAGE_TYPE, ((DealDamageEffect) e).getDamageType().toString());
}
damage = DamageCalculator.precalculateDamage(ref);
} else {
Attack attack = ((AttackEffect) e).initAttack();
// attack.setAttacked((DC_HeroObj) targetObj);
Map<String, Integer> _cache = getCache(min_max_normal);
damage = _cache.get(getCacheKey(active, targetObj));
if (damage == null) {
damage = DamageCalculator.precalculateDamage(attack, min_max_normal);
_cache.put(getCacheKey(active, targetObj), damage);
}
}
// active.toBase();
LogMaster.log(1, active.getName() + " on " + targetObj.getName() + " - damage precalculated: " + damage);
return damage;
}
use of eidolons.ability.effects.oneshot.DealDamageEffect in project Eidolons by IDemiurge.
the class BindingDamageEffect method applyThis.
@Override
public boolean applyThis() {
// Can be initialized() just once
GroupImpl group = ref.getGroup();
Effects effects = new Effects();
STANDARD_EVENT_TYPE event_type;
if (shareOrRedirect) {
// TODO splitMode!
event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
}
}
} else {
effects.add(new AlteringEffect(false, formula.getNegative().toString()));
event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
}
}
}
Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
/*
* ensure there is no deadlock
*/
conditions = new Conditions();
conditions.add(new NonTriggeredEventCondition());
KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
conditions.add(new GroupCondition(OBJ_REF, group));
// has the group...
Ref REF = Ref.getCopy(ref);
// REF.setTarget(null); // ???
new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
return true;
}
use of eidolons.ability.effects.oneshot.DealDamageEffect in project Eidolons by IDemiurge.
the class DealDamageEffectTest method dealDamageEffectTest.
@Test
public void dealDamageEffectTest() {
assertTrue(source != null);
assertTrue(target != null);
int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
Effect eff = new DealDamageEffect(new Formula("50"), GenericEnums.DAMAGE_TYPE.BLUDGEONING.getName(), DAMAGE_MODIFIER.UNBLOCKABLE);
Ref ref = new Ref(source);
ref.setTarget(target.getId());
ref.setID(KEYS.ACTIVE, source.getAction("Attack").getId());
eff.apply(ref);
Integer newToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
Integer newEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
assertTrue(newToughness < origToughness);
assertTrue(newEndurance < origEndurance);
}
Aggregations