コード例 #1
0
 /// Create an Initiation Grade from an XmlNode.
 /// <param name="intGrade">Grade number.</param>
 /// <param name="blnTechnomancer">Whether or not the character is a Technomancer.</param>
 /// <param name="blnGroup">Whether or not a Group was used.</param>
 /// <param name="blnOrdeal">Whether or not an Ordeal was used.</param>
 /// <param name="blnSchooling">Whether or not Schooling was used.</param>
 public void Create(int intGrade, bool blnTechnomancer, bool blnGroup, bool blnOrdeal, bool blnSchooling)
 {
     _intGrade        = intGrade;
     _blnTechnomancer = blnTechnomancer;
     _blnGroup        = blnGroup;
     _blnOrdeal       = blnOrdeal;
     _blnSchooling    = blnSchooling;
     //TODO: I'm not happy with this.
     //KC 90: a Cyberadept who has Submerged may restore Resonance that has been lost to cyberware (and only cyberware) by an amount equal to half their Submersion Grade(rounded up).
     //To handle this, we ceiling the CyberwareEssence value up, as a non-zero loss of Essence removes a point of Resonance, and cut the submersion grade in half.
     //Whichever value is lower becomes the value of the improvement.
     if (intGrade > 0 && blnTechnomancer && _objCharacter.RESEnabled && !_objCharacter.Settings.SpecialKarmaCostBasedOnShownValue &&
         ImprovementManager.GetCachedImprovementListForValueOf(_objCharacter, Improvement.ImprovementType.CyberadeptDaemon).Count > 0)
     {
         decimal decNonCyberwareEssence = _objCharacter.BiowareEssence + _objCharacter.EssenceHole;
         int     intResonanceRecovered  = Math.Min(intGrade.DivAwayFromZero(2), (int)(
                                                       Math.Ceiling(decNonCyberwareEssence) == Math.Floor(decNonCyberwareEssence)
                 ? Math.Ceiling(_objCharacter.CyberwareEssence)
                 : Math.Floor(_objCharacter.CyberwareEssence)));
         // Cannot increase RES to be more than what it would be without any Essence loss.
         intResonanceRecovered = _objCharacter.Settings.ESSLossReducesMaximumOnly
             ? Math.Min(intResonanceRecovered, _objCharacter.RES.MaximumNoEssenceLoss() - intGrade - _objCharacter.RES.TotalMaximum)
                                 // +1 compared to normal because this Grade's effect has not been processed yet.
             : Math.Min(intResonanceRecovered, _objCharacter.RES.MaximumNoEssenceLoss() - intGrade + 1 - _objCharacter.RES.Value);
         ImprovementManager.CreateImprovement(_objCharacter, "RESBase", Improvement.ImprovementSource.CyberadeptDaemon,
                                              InternalId, Improvement.ImprovementType.Attribute, string.Empty, 0, intResonanceRecovered, 0, 1, 1);
         ImprovementManager.Commit(_objCharacter);
     }
 }
コード例 #2
0
        /// <summary>
        /// Create a Mentor Spirit from an XmlNode.
        /// </summary>
        /// <param name="xmlMentor">XmlNode to create the object from.</param>
        /// <param name="eMentorType">Whether this is a Mentor or a Paragon.</param>
        /// <param name="strForceValueChoice1">Name/Text for Choice 1.</param>
        /// <param name="strForceValueChoice2">Name/Text for Choice 2.</param>
        /// <param name="strForceValue">Force a value to be selected for the Mentor Spirit.</param>
        /// <param name="blnMentorMask">Whether the Mentor's Mask is enabled.</param>
        public void Create(XmlNode xmlMentor, Improvement.ImprovementType eMentorType, string strForceValue = "", string strForceValueChoice1 = "", string strForceValueChoice2 = "", bool blnMentorMask = false)
        {
            _blnMentorMask      = blnMentorMask;
            _eMentorType        = eMentorType;
            _objCachedMyXmlNode = null;
            xmlMentor.TryGetStringFieldQuickly("name", ref _strName);
            xmlMentor.TryGetStringFieldQuickly("source", ref _strSource);
            xmlMentor.TryGetStringFieldQuickly("page", ref _strPage);
            if (!xmlMentor.TryGetStringFieldQuickly("altnotes", ref _strNotes))
            {
                xmlMentor.TryGetStringFieldQuickly("notes", ref _strNotes);
            }
            if (xmlMentor.TryGetField("id", Guid.TryParse, out Guid guiTemp))
            {
                _sourceID = guiTemp;
            }

            // Build the list of advantages gained through the Mentor Spirit.
            if (!xmlMentor.TryGetStringFieldQuickly("altadvantage", ref _strAdvantage))
            {
                xmlMentor.TryGetStringFieldQuickly("advantage", ref _strAdvantage);
            }
            if (!xmlMentor.TryGetStringFieldQuickly("altdisadvantage", ref _strDisadvantage))
            {
                xmlMentor.TryGetStringFieldQuickly("disadvantage", ref _strDisadvantage);
            }

            _nodBonus = xmlMentor["bonus"];
            if (_nodBonus != null)
            {
                string strOldForce    = ImprovementManager.ForcedValue;
                string strOldSelected = ImprovementManager.SelectedValue;
                ImprovementManager.ForcedValue = strForceValue;
                if (!ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.MentorSpirit, _guiID.ToString("D"), _nodBonus, false, 1, DisplayNameShort(GlobalOptions.Language)))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                _strExtra = ImprovementManager.SelectedValue;
                ImprovementManager.ForcedValue   = strOldForce;
                ImprovementManager.SelectedValue = strOldSelected;
            }
            else if (!string.IsNullOrEmpty(strForceValue))
            {
                _strExtra = strForceValue;
            }
            _nodChoice1 = xmlMentor.SelectSingleNode("choices/choice[name = \"" + strForceValueChoice1 + "\"]/bonus");
            if (_nodChoice1 != null)
            {
                string strOldForce    = ImprovementManager.ForcedValue;
                string strOldSelected = ImprovementManager.SelectedValue;
                ImprovementManager.ForcedValue = strForceValueChoice1;
                if (!ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.MentorSpirit, _guiID.ToString("D"), _nodChoice1, false, 1, DisplayNameShort(GlobalOptions.Language)))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (string.IsNullOrEmpty(_strExtra))
                {
                    _strExtra = ImprovementManager.SelectedValue;
                }
                ImprovementManager.ForcedValue   = strOldForce;
                ImprovementManager.SelectedValue = strOldSelected;
            }
            else if (string.IsNullOrEmpty(_strExtra) && !string.IsNullOrEmpty(strForceValueChoice1))
            {
                _strExtra = strForceValueChoice1;
            }
            _nodChoice2 = xmlMentor.SelectSingleNode("choices/choice[name = \"" + strForceValueChoice2 + "\"]/bonus");
            if (_nodChoice2 != null)
            {
                string strOldForce    = ImprovementManager.ForcedValue;
                string strOldSelected = ImprovementManager.SelectedValue;
                ImprovementManager.ForcedValue = strForceValueChoice2;
                if (!ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.MentorSpirit, _guiID.ToString("D"), _nodChoice2, false, 1, DisplayNameShort(GlobalOptions.Language)))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (string.IsNullOrEmpty(_strExtra))
                {
                    _strExtra = ImprovementManager.SelectedValue;
                }
                ImprovementManager.ForcedValue   = strOldForce;
                ImprovementManager.SelectedValue = strOldSelected;
            }
            else if (string.IsNullOrEmpty(_strExtra) && !string.IsNullOrEmpty(strForceValueChoice2))
            {
                _strExtra = strForceValueChoice2;
            }
            if (_blnMentorMask)
            {
                ImprovementManager.CreateImprovement(_objCharacter, string.Empty, Improvement.ImprovementSource.MentorSpirit, _guiID.ToString("D"), Improvement.ImprovementType.AdeptPowerPoints, string.Empty, 1);
                ImprovementManager.CreateImprovement(_objCharacter, string.Empty, Improvement.ImprovementSource.MentorSpirit, _guiID.ToString("D"), Improvement.ImprovementType.DrainValue, string.Empty, -1);
                ImprovementManager.Commit(_objCharacter);
            }

            /*
             * if (string.IsNullOrEmpty(_strNotes))
             * {
             *  _strNotes = CommonFunctions.GetTextFromPDF($"{_strSource} {_strPage}", _strName);
             *  if (string.IsNullOrEmpty(_strNotes))
             *  {
             *      _strNotes = CommonFunctions.GetTextFromPDF($"{Source} {Page(GlobalOptions.Language)}", DisplayName(GlobalOptions.Language));
             *  }
             * }*/
        }
コード例 #3
0
        protected void RedlinerCheck()
        {
            string strSeekerImprovPrefix = "SEEKER";
            var    lstSeekerAttributes   = new List <string>();
            var    lstSeekerImprovements = new List <Improvement>();

            //Get attributes affected by redliner/cyber singularity seeker
            foreach (Improvement objLoopImprovement in _objCharacter.Improvements)
            {
                if (objLoopImprovement.ImproveType == Improvement.ImprovementType.Seeker)
                {
                    lstSeekerAttributes.Add(objLoopImprovement.ImprovedName);
                }
                else if ((objLoopImprovement.ImproveType == Improvement.ImprovementType.Attribute ||
                          objLoopImprovement.ImproveType == Improvement.ImprovementType.PhysicalCM) &&
                         objLoopImprovement.SourceName.Contains(strSeekerImprovPrefix))
                {
                    lstSeekerImprovements.Add(objLoopImprovement);
                }
            }

            //if neither contains anything, it is safe to exit
            if (lstSeekerImprovements.Count == 0 && lstSeekerAttributes.Count == 0)
            {
                _objCharacter.RedlinerBonus = 0;
                return;
            }

            //Calculate bonus from cyberlimbs
            int count = 0;

            foreach (Cyberware objCyberware in _objCharacter.Cyberware)
            {
                count += objCyberware.CyberlimbCount;
            }
            count = Math.Min(count / 2, 2);
            if (lstSeekerImprovements.Any(x => x.ImprovedName == "STR" || x.ImprovedName == "AGI"))
            {
                _objCharacter.RedlinerBonus = count;
            }
            else
            {
                _objCharacter.RedlinerBonus = 0;
            }

            for (int i = 0; i < lstSeekerAttributes.Count; i++)
            {
                Improvement objImprove =
                    lstSeekerImprovements.FirstOrDefault(
                        x =>
                        x.SourceName == strSeekerImprovPrefix + "_" + lstSeekerAttributes[i] &&
                        x.Value == (lstSeekerAttributes[i] == "BOX" ? count * -3 : count));
                if (objImprove != null)
                {
                    lstSeekerAttributes.RemoveAt(i);
                    lstSeekerImprovements.Remove(objImprove);
                    i--;
                }
            }
            //Improvement manager defines the functions we need to manipulate improvements
            //When the locals (someday) gets moved to this class, this can be removed and use
            //the local

            // Remove which qualites have been removed or which values have changed
            foreach (Improvement improvement in lstSeekerImprovements)
            {
                ImprovementManager.RemoveImprovements(_objCharacter, improvement.ImproveSource, improvement.SourceName);
            }

            // Add new improvements or old improvements with new values
            foreach (string attribute in lstSeekerAttributes)
            {
                if (attribute == "BOX")
                {
                    ImprovementManager.CreateImprovement(_objCharacter, attribute, Improvement.ImprovementSource.Quality,
                                                         strSeekerImprovPrefix + "_" + attribute, Improvement.ImprovementType.PhysicalCM,
                                                         Guid.NewGuid().ToString(), count * -3);
                }
                else
                {
                    ImprovementManager.CreateImprovement(_objCharacter, attribute, Improvement.ImprovementSource.Quality,
                                                         strSeekerImprovPrefix + "_" + attribute, Improvement.ImprovementType.Attribute,
                                                         Guid.NewGuid().ToString(), count, 1, 0, 0, count);
                }
            }
            ImprovementManager.Commit(_objCharacter);
        }