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; } }
/// <summary> /// Adjusts the trap's level and attack data. /// </summary> /// <param name="delta">The level adjustment delta.</param> public void AdjustLevel(int delta) { fLevel += delta; fLevel = Math.Max(1, fLevel); if (fInitiative != int.MinValue) { Initiative += delta; fInitiative = Math.Max(1, fInitiative); } foreach (TrapAttack ta in fAttacks) { if (ta.Attack != null) { ta.Attack.Bonus += delta; ta.Attack.Bonus = Math.Max(1, ta.Attack.Bonus); } string hit_dmg = AI.ExtractDamage(ta.OnHit); if (hit_dmg != "") { DiceExpression exp = DiceExpression.Parse(hit_dmg); if (exp != null) { DiceExpression exp_adj = exp.Adjust(delta); if ((exp_adj != null) && (exp.ToString() != exp_adj.ToString())) { ta.OnHit = ta.OnHit.Replace(hit_dmg, exp_adj + " damage"); } } } string miss_dmg = AI.ExtractDamage(ta.OnMiss); if (miss_dmg != "") { DiceExpression exp = DiceExpression.Parse(miss_dmg); if (exp != null) { DiceExpression exp_adj = exp.Adjust(delta); if ((exp_adj != null) && (exp.ToString() != exp_adj.ToString())) { ta.OnMiss = ta.OnMiss.Replace(miss_dmg, exp_adj + " damage"); } } } string effect_dmg = AI.ExtractDamage(ta.Effect); if (effect_dmg != "") { DiceExpression exp = DiceExpression.Parse(effect_dmg); if (exp != null) { DiceExpression exp_adj = exp.Adjust(delta); if ((exp_adj != null) && (exp.ToString() != exp_adj.ToString())) { ta.Effect = ta.Effect.Replace(effect_dmg, exp_adj + " damage"); } } } } foreach (TrapSkillData tsd in fSkills) { tsd.DC += delta; } }