API Docs for:
Show:

File: gameplay\spell-casting\spell-effects\Components.js

/**
 A component class which allows an entity to be affected by various effects.
 @class SpellEffects
 @constructor
 */
function SpellEffects(){
    //Movement spell effects.
    this._movementSpeedSpellEffects = new LinkedList();
    this._jumpPowerSpellEffects = new LinkedList();
    
    //Health spell effects.
    this._resistanceSpellEffects = new LinkedList();
    this._shieldSpellEffects = new LinkedList();
    this._damageOverTimeSpellEffects = new LinkedList();
    this._healingOverTimeSpellEffects = new LinkedList();
    
    //Attack spell effects.
    this._attackSpeedSpellEffects = new LinkedList();
    this._attackEnchantSpellEffect = null;
}

SpellEffects.prototype = {
    constructor : SpellEffects,
    _componentIdentifier : 0,
    
    /**
     @method applySpellEffect
     @param spellEffect {MovementSpeedSpellEffect|JumpPowerSpellEffect|ResistanceSpellEffect|ShieldSpellEffect|DamageOverTimeSpellEffect|HealingOverTimeSpellEffect|AttackSpeedSpellEffect|AttackEnchantSpellEffect} Only one attack enchant can be active at a time, other spell effects stack.
     */
    applySpellEffect : function(spellEffect){
        switch(spellEffect.constructor){
            case MovementSpeedSpellEffect : this._movementSpeedSpellEffects.insert(0, spellEffect);
                break;
            case JumpPowerSpellEffect : this._jumpPowerSpellEffects.insert(0, spellEffect);
                break;
            case ResistanceSpellEffect : this._resistanceSpellEffects.insert(0, spellEffect);
                break;
            case ShieldSpellEffect : this._shieldSpellEffects.insert(0, spellEffect);
                break;
            case DamageOverTimeSpellEffect : this._damageOverTimeSpellEffects.insert(0, spellEffect);
                break;
            case HealingOverTimeSpellEffect : this._healingOverTimeSpellEffects.insert(0, spellEffect);
                break;
            case AttackSpeedSpellEffect : this._attackSpeedSpellEffects.insert(0, spellEffect);
                break;
            case AttackEnchantSpellEffect : this._attackEnchantSpellEffect = spellEffect;
                break;
        }
    },
    
    /**
     Removes all spell effects.
     @method clearSpellEffects
     */
    clearSpellEffects: function(){
        this._movementSpeedSpellEffects.clear();
        this._jumpPowerSpellEffects.clear();
        this._resistanceSpellEffects.clear();
        this._shieldSpellEffects.clear();
        this._damageOverTimeSpellEffects.clear();
        this._healingOverTimeSpellEffects.clear();
        this._attackSpeedSpellEffects.clear();
        this._attackEnchantSpellEffect = null;
    },
    
    /**
     @method getMovementSpeedSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getMovementSpeedSpellEffects : function(){
        return this._movementSpeedSpellEffects;
    },
    
    /**
     @method getJumpPowerSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getJumpPowerSpellEffects : function(){
        return this._jumpPowerSpellEffects;
    },
    
    /**
     @method getResistanceSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getResistanceSpellEffects : function(){
        return this._resistanceSpellEffects;
    },
    
    /**
     @method getShieldSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getShieldSpellEffects : function(){
        return this._shieldSpellEffects;
    },
    
    /**
     @method getDamageOverTimeSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getDamageOverTimeSpellEffects : function(){
        return this._damageOverTimeSpellEffects;
    },
    
    /**
     @method getHealingOverTimeSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getHealingOverTimeSpellEffects : function(){
        return this._healingOverTimeSpellEffects;
    },
    
    /**
     @method getAttackSpeedSpellEffects
     @return {LinkedList} A list holding spell effects.
     */
    getAttackSpeedSpellEffects : function(){
        return this._attackSpeedSpellEffects;
    },
    
    /**
     @method getAttackEnchantSpellEffect
     @return {AttackEnchantSpellEffect|Null} Returns a direct reference to an attack enchant, if present, otherwise returns null.
     */
    getAttackEnchantSpellEffect : function(){
        return this._attackEnchantSpellEffect;
    }
};