Beispiel #1
0
        /// <summary>
        /// Creates a copy of the PowerAttack.
        /// </summary>
        /// <returns>Returns the copy.</returns>
        public PowerAttack Copy()
        {
            PowerAttack pa = new PowerAttack();

            pa.Bonus   = fBonus;
            pa.Defence = fDefence;

            return(pa);
        }
Beispiel #2
0
        public PowerAttack Copy()
        {
            PowerAttack powerAttack = new PowerAttack()
            {
                Bonus   = this.fBonus,
                Defence = this.fDefence
            };

            return(powerAttack);
        }
Beispiel #3
0
 public void AdjustLevel(int delta)
 {
     this.fLevel += delta;
     this.fLevel  = Math.Max(1, this.fLevel);
     if (this.fInitiative != -2147483648)
     {
         Trap initiative = this;
         initiative.Initiative = initiative.Initiative + delta;
         this.fInitiative      = Math.Max(1, this.fInitiative);
     }
     foreach (TrapAttack fAttack in this.fAttacks)
     {
         if (fAttack.Attack != null)
         {
             PowerAttack attack = fAttack.Attack;
             attack.Bonus         = attack.Bonus + delta;
             fAttack.Attack.Bonus = Math.Max(1, fAttack.Attack.Bonus);
         }
         string str = AI.ExtractDamage(fAttack.OnHit);
         if (str != "")
         {
             DiceExpression diceExpression = DiceExpression.Parse(str);
             if (diceExpression != null)
             {
                 DiceExpression diceExpression1 = diceExpression.Adjust(delta);
                 if (diceExpression1 != null && diceExpression.ToString() != diceExpression1.ToString())
                 {
                     fAttack.OnHit = fAttack.OnHit.Replace(str, string.Concat(diceExpression1, " damage"));
                 }
             }
         }
         string str1 = AI.ExtractDamage(fAttack.OnMiss);
         if (str1 != "")
         {
             DiceExpression diceExpression2 = DiceExpression.Parse(str1);
             if (diceExpression2 != null)
             {
                 DiceExpression diceExpression3 = diceExpression2.Adjust(delta);
                 if (diceExpression3 != null && diceExpression2.ToString() != diceExpression3.ToString())
                 {
                     fAttack.OnMiss = fAttack.OnMiss.Replace(str1, string.Concat(diceExpression3, " damage"));
                 }
             }
         }
         string str2 = AI.ExtractDamage(fAttack.Effect);
         if (str2 == "")
         {
             continue;
         }
         DiceExpression diceExpression4 = DiceExpression.Parse(str2);
         if (diceExpression4 == null)
         {
             continue;
         }
         DiceExpression diceExpression5 = diceExpression4.Adjust(delta);
         if (diceExpression5 == null || !(diceExpression4.ToString() != diceExpression5.ToString()))
         {
             continue;
         }
         fAttack.Effect = fAttack.Effect.Replace(str2, string.Concat(diceExpression5, " damage"));
     }
     foreach (TrapSkillData fSkill in this.fSkills)
     {
         TrapSkillData dC = fSkill;
         dC.DC = dC.DC + delta;
     }
 }
Beispiel #4
0
        public void ExtractAttackDetails()
        {
            if (this.fAttack != null)
            {
                return;
            }
            if (!this.fDetails.Contains("vs"))
            {
                return;
            }
            string str = this.fDetails;

            string[] strArrays  = new string[] { ";" };
            string[] strArrays1 = str.Split(strArrays, StringSplitOptions.RemoveEmptyEntries);
            this.fDetails = "";
            string[] strArrays2 = strArrays1;
            for (int i = 0; i < (int)strArrays2.Length; i++)
            {
                string str1 = strArrays2[i].Trim();
                bool   flag = false;
                int    num  = str1.IndexOf("vs");
                if (num != -1 && this.fAttack == null)
                {
                    string str2 = str1.Substring(0, num);
                    string str3 = str1.Substring(num);
                    int    num1 = str2.LastIndexOfAny("1234567890".ToCharArray());
                    if (num1 != -1)
                    {
                        int         num2        = 0;
                        DefenceType defenceType = DefenceType.AC;
                        bool        flag1       = false;
                        bool        flag2       = false;
                        if (str3.Contains("AC"))
                        {
                            defenceType = DefenceType.AC;
                            flag2       = true;
                        }
                        if (str3.Contains("Fort"))
                        {
                            defenceType = DefenceType.Fortitude;
                            flag2       = true;
                        }
                        if (str3.Contains("Ref"))
                        {
                            defenceType = DefenceType.Reflex;
                            flag2       = true;
                        }
                        if (str3.Contains("Will"))
                        {
                            defenceType = DefenceType.Will;
                            flag2       = true;
                        }
                        if (flag2)
                        {
                            try
                            {
                                num1  = Math.Max(0, num1 - 2);
                                num2  = int.Parse(str2.Substring(num1));
                                flag1 = true;
                            }
                            catch
                            {
                                flag1 = false;
                            }
                        }
                        if (flag1 && flag2)
                        {
                            this.fAttack = new PowerAttack()
                            {
                                Bonus   = num2,
                                Defence = defenceType
                            };
                            flag = true;
                        }
                    }
                }
                if (!flag)
                {
                    if (this.fDetails != "")
                    {
                        CreaturePower creaturePower = this;
                        creaturePower.fDetails = string.Concat(creaturePower.fDetails, "; ");
                    }
                    CreaturePower creaturePower1 = this;
                    creaturePower1.fDetails = string.Concat(creaturePower1.fDetails, str1);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Parses the power details field to find the attack data (+N vs Defence).
        /// </summary>
        public void ExtractAttackDetails()
        {
            if (fAttack != null)
            {
                return;
            }

            if (!fDetails.Contains("vs"))
            {
                return;
            }

            string[] sections = fDetails.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            fDetails = "";

            foreach (string section in sections)
            {
                string str = section.Trim();

                bool added_attack = false;

                int index = str.IndexOf("vs");
                if ((index != -1) && (fAttack == null))
                {
                    string prefix = str.Substring(0, index);
                    string suffix = str.Substring(index);

                    string digits = "1234567890";
                    int    start  = prefix.LastIndexOfAny(digits.ToCharArray());
                    if (start != -1)
                    {
                        int         bonus         = 0;
                        DefenceType defence       = DefenceType.AC;
                        bool        found_bonus   = false;
                        bool        found_defence = false;

                        if (suffix.Contains("AC"))
                        {
                            defence       = DefenceType.AC;
                            found_defence = true;
                        }
                        if (suffix.Contains("Fort"))
                        {
                            defence       = DefenceType.Fortitude;
                            found_defence = true;
                        }
                        if (suffix.Contains("Ref"))
                        {
                            defence       = DefenceType.Reflex;
                            found_defence = true;
                        }
                        if (suffix.Contains("Will"))
                        {
                            defence       = DefenceType.Will;
                            found_defence = true;
                        }

                        if (found_defence)
                        {
                            try
                            {
                                start = Math.Max(0, start - 2);
                                string bonus_str = prefix.Substring(start);
                                bonus       = int.Parse(bonus_str);
                                found_bonus = true;
                            }
                            catch
                            {
                                found_bonus = false;
                            }
                        }

                        if (found_bonus && found_defence)
                        {
                            fAttack         = new PowerAttack();
                            fAttack.Bonus   = bonus;
                            fAttack.Defence = defence;

                            added_attack = true;
                        }
                    }
                }

                if (!added_attack)
                {
                    if (fDetails != "")
                    {
                        fDetails += "; ";
                    }

                    fDetails += str;
                }
            }
        }