private static CharacterAttrib RemakeAttribute(CharacterAttrib objNewAttribute, XmlNode objCharacterNode) { string strAttributeLower = objNewAttribute.Abbrev.ToLowerInvariant(); if (strAttributeLower == "magadept") strAttributeLower = "mag"; int intMinValue = 1; int intMaxValue = 1; int intAugValue = 1; // This statement is wrapped in a try/catch since trying 1 div 2 results in an error with XSLT. try { intMinValue = Convert.ToInt32(Math.Ceiling((double)CommonFunctions.EvaluateInvariantXPath(objCharacterNode[strAttributeLower + "min"]?.InnerText.Replace("/", " div ").Replace('F', '0').Replace("1D6", "0").Replace("2D6", "0") ?? "1"))); } catch (XPathException) { intMinValue = 1; } catch (OverflowException) { intMinValue = 1; } catch (InvalidCastException) { intMinValue = 1; } try { intMaxValue = Convert.ToInt32(Math.Ceiling((double)CommonFunctions.EvaluateInvariantXPath(objCharacterNode[strAttributeLower + "max"]?.InnerText.Replace("/", " div ").Replace('F', '0').Replace("1D6", "0").Replace("2D6", "0") ?? "1"))); } catch (XPathException) { intMaxValue = 1; } catch (OverflowException) { intMaxValue = 1; } catch (InvalidCastException) { intMaxValue = 1; } try { intAugValue = Convert.ToInt32(Math.Ceiling((double)CommonFunctions.EvaluateInvariantXPath(objCharacterNode[strAttributeLower + "aug"]?.InnerText.Replace("/", " div ").Replace('F', '0').Replace("1D6", "0").Replace("2D6", "0") ?? "1"))); } catch (XPathException) { intAugValue = 1; } catch (OverflowException) { intAugValue = 1; } catch (InvalidCastException) { intAugValue = 1; } objNewAttribute.AssignLimits(intMinValue.ToString(), intMaxValue.ToString(), intAugValue.ToString()); return objNewAttribute; }
private static CharacterAttrib RemakeAttribute(CharacterAttrib objNewAttribute, XmlNode objCharacterNode, XPathNavigator nav) { string strAttributeLower = objNewAttribute.Abbrev.ToLowerInvariant(); int intMinValue = 1; int intMaxValue = 1; int intAugValue = 1; object xprEvaluateMinResult = null; object xprEvaluateMaxResult = null; object xprEvaluateAugResult = null; // This statement is wrapped in a try/catch since trying 1 div 2 results in an error with XSLT. try { xprEvaluateMinResult = nav.Evaluate(objCharacterNode[strAttributeLower + "min"]?.InnerText.Replace("/", " div ").Replace("F", "0").Replace("1D6", "0").Replace("2D6", "0")); } catch (XPathException) { } try { xprEvaluateMaxResult = nav.Evaluate(objCharacterNode[strAttributeLower + "max"]?.InnerText.Replace("/", " div ").Replace("F", "0").Replace("1D6", "0").Replace("2D6", "0")); } catch (XPathException) { } try { xprEvaluateAugResult = nav.Evaluate(objCharacterNode[strAttributeLower + "aug"]?.InnerText.Replace("/", " div ").Replace("F", "0").Replace("1D6", "0").Replace("2D6", "0")); } catch (XPathException) { } if (xprEvaluateMinResult != null) { intMinValue = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(xprEvaluateMinResult.ToString(), GlobalOptions.InvariantCultureInfo))); } if (xprEvaluateMaxResult != null) { intMaxValue = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(xprEvaluateMaxResult.ToString(), GlobalOptions.InvariantCultureInfo))); } if (xprEvaluateAugResult != null) { intAugValue = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(xprEvaluateAugResult.ToString(), GlobalOptions.InvariantCultureInfo))); } objNewAttribute.AssignLimits(intMinValue.ToString(), intMaxValue.ToString(), intAugValue.ToString()); return(objNewAttribute); }