Exemplo n.º 1
0
        public double Trigger(EnchantmentParameters ep)
        {
            Character charAttacker = getCharByAccessString(ep, attacker.ToString());
            Character charDefender = getCharByAccessString(ep, defender.ToString());

            if (charAttacker.enchantmentLayersDeep > 0)
            {
                return(0);
            }
            charAttacker.enchantmentLayersDeep++;
            double?an = attackValue.Calculate(ep);
            double?dn = defenceValue.Calculate(ep);

            if (an != null && dn != null)
            {
                double a = (double)an;
                double d = (double)dn;

                Weapon save = charAttacker.CombatStuff.CombatWeapon;

                string selectedWepforcalc = EnchantmentUtilities.checkForVariable(selectedWeap, this);
                charAttacker.CombatStuff.CombatWeapon = Utilities.GetWeaponByName(selectedWepforcalc);

                AttackOutcome outcome = CombatScripts.RunCombat(charAttacker, charDefender, a, d, null);
                CombatScripts.applyAttackOutcome(outcome);

                charAttacker.CombatStuff.CombatWeapon = save;
            }
            charAttacker.enchantmentLayersDeep--;
            return(0.0);
        }
        public double Trigger(EnchantmentParameters ep)
        {
            double?pot = potency.Calculate(ep);
            double?len = length.Calculate(ep);
            double?det = deterioration.Calculate(ep);

            if (pot != null && len != null && det != null)
            {
                double p = (double)pot;
                double l = (double)len;
                double d = (double)det;

                Character charToEffect = getCharByAccessString(ep, target.ToString());
                if (charToEffect.CombatStuff == null ||
                    charToEffect.CombatStuff.CombatName == "" ||
                    !CombatHolder._inCombatChars.Any(A => A.CombatStuff.CombatName == charToEffect.CombatStuff.CombatName))
                {
                    return(0.0);
                }
                EffectHolder.EffectType efftype;
                bool parsedType = Enum.TryParse(EnchantmentUtilities.checkForVariable(effectType, this), out efftype);
                if (effectType != null && effectType != "" && !parsedType)
                {
                    MessageBox.Show("Invalid effect Type");
                    return(0.0);
                }
                EffectHolder.EffectTag efftag;
                bool parsedTag = Enum.TryParse(EnchantmentUtilities.checkForVariable(effectTag, this), out efftag);
                if (effectTag != null && effectTag != "" && !parsedTag)
                {
                    MessageBox.Show("Invalid effect tag");
                    return(0.0);
                }
                Utilities.DamageType?damtype;
                Utilities.DamageType tempdamtype;
                bool parsedDam = Enum.TryParse(EnchantmentUtilities.checkForVariable(damageType, this), out tempdamtype);
                damtype = tempdamtype;
                if (EnchantmentUtilities.checkForVariable(damageType, this) == "")
                {
                    damtype = null;
                }
                if (damageType != null && damageType != "" && !parsedDam)
                {
                    MessageBox.Show("Invalid damage Type");
                    return(0.0);
                }
                Effect e = new Effect(efftype, p, (int)l, d);
                e.effectTag = efftag;

                Utilities.forceTypesToConformToTag(e);

                e.damageType = damtype;

                EffectHolder.CreateEffect(e, charToEffect, false);
            }
            return(0.0);
        }
Exemplo n.º 3
0
        public double Trigger(EnchantmentParameters ep)
        {
            double?valn = valueToReturn.Calculate(ep);

            if (valn == null)
            {
                return(0);
            }
            return((double)valn);
        }
Exemplo n.º 4
0
        public double Trigger(EnchantmentParameters ep)
        {
            double?dn = setTo.Calculate(ep);

            if (dn == null)
            {
                return(0);
            }
            double d = (double)dn;

            GetVariables()[varName][1] = d;
            return(0.0);
        }
        public double?Calculate(EnchantmentParameters ep)
        {
            switch (operation)
            {
            case EnchantmentUtilities.MathTypes.Add:
                return(left.Calculate(ep) + right.Calculate(ep));

            case EnchantmentUtilities.MathTypes.Divide:
                return(left.Calculate(ep) / right.Calculate(ep));

            case EnchantmentUtilities.MathTypes.Multiply:
                return(left.Calculate(ep) * right.Calculate(ep));

            case EnchantmentUtilities.MathTypes.Subtract:
                return(left.Calculate(ep) - right.Calculate(ep));

            case EnchantmentUtilities.MathTypes.EqualTo:
                double?lequal = left.Calculate(ep);
                double?requal = right.Calculate(ep);
                if (lequal == requal)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }

            case EnchantmentUtilities.MathTypes.GreaterThan:
                double?lgreater  = left.Calculate(ep);
                double?rlessthan = right.Calculate(ep);
                if (lgreater > rlessthan)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            return(0);
        }