Inheritance: MonoBehaviour
示例#1
0
        public void AddOrUpdate(string staticName, string scope, string name, string description, int? usesConfigurationOfOtherSet, bool alwaysShareConfig, bool changeStaticName = false, string newStaticName = "")
        {
            var ct = GetAttributeSetByStaticName(staticName);

            if (ct == null)
            {
                ct = new AttributeSet()
                {
                    AppID = Context.AppId,
                    StaticName = Guid.NewGuid().ToString(),// staticName,
                    Scope = scope == "" ? null : scope,
                    UsesConfigurationOfAttributeSet = usesConfigurationOfOtherSet,
                    AlwaysShareConfiguration = alwaysShareConfig
                };
                Context.SqlDb.AddToAttributeSets(ct);
            }

            ct.Name = name;
            ct.Description = description;
            ct.Scope = scope;
            if (changeStaticName) // note that this is a very "deep" change
                ct.StaticName = newStaticName;
            ct.ChangeLogIDCreated = Context.Versioning.GetChangeLogId(Context.UserName);

            // save first, to ensure it has an Id
            Context.SqlDb.SaveChanges();

            //var fullApi = new BetaFullApi(Context.ZoneId, Context.AppId, Context);
            //fullApi.Metadata_AddOrUpdate(Constants.AssignmentObjectTypeIdFieldProperties, ct.AttributeSetID, "@All", newValues);
        }
        public CardboardOverlayView(Context context, AttributeSet attrs)
            : base(context, attrs)
        {
            setOrientation(HORIZONTAL);

            LayoutParams @params = new LayoutParams(
              LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
            @params.setMargins(0, 0, 0, 0);

            leftView = new CardboardOverlayEyeView(context, attrs);
            leftView.setLayoutParams(@params);
            addView(leftView);

            rightView = new CardboardOverlayEyeView(context, attrs);
            rightView.setLayoutParams(@params);
            addView(rightView);

            // Set some reasonable defaults.
            setDepthOffset(0.016f);
            setColor(Color.rgb(150, 255, 180));
            setVisibility(View.VISIBLE);

            textFadeAnimation = new AlphaAnimation(1.0f, 0.0f);
            textFadeAnimation.setDuration(5000);
        }
示例#3
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        LblErr.Text = "";
        LblOk.Text = "";

        try
        {
            var o1 = new AttributeSet();
            var man = new AttributeSetsManager();
            if (base.CurrentId == 0)
            {
                form2obj(o1);
                o1 = man.Insert(o1);
            }
            else
            {
                o1 = man.GetByKey(base.CurrentId);  //precarico i campi esistenti e nn gestiti dal form
                form2obj(o1);
                man.Update(o1);
            }
            Grid1.DataBind();
            Grid2.DataBind();
            LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG"));
            MultiView1.ActiveViewIndex = 0;
        }
        catch (Exception e1)
        {
            LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
        }
        finally
        {
        }
    }
示例#4
0
 public void AttributeSetShouldBeMakeANameTileMappping()
 {
     var firstTile = new TileAttribute("first", new StringTile("1"));
     var secondTile = new TileAttribute("second", new StringTile("2"));
     var set = new AttributeSet("TILE", new List<TileAttribute> { firstTile, secondTile });
     Assert.That(set.Count, Is.EqualTo(2));
 }
示例#5
0
文件: Attribute.cs 项目: ewcasas/DVTK
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="tag">The tag of this instance.</param>
 /// <param name="vr">The VR of this instance.</param>
 /// <param name="parent">The parent of this instance.</param>
 public Attribute(Tag tag, VR vr, AttributeSet parent)
 {
     this.tag = tag;
     this.vr = vr;
     this.parent = parent;
     this.parent.Add(this);
 }
示例#6
0
 public void ContainsOnTileAttributesShouldReturnTrueForExistingName()
 {
     var firstTile = new TileAttribute("first", new StringTile("1"));
     var secondTile = new TileAttribute("second", new StringTile("2"));
     var set = new AttributeSet("TILE", new List<TileAttribute> { firstTile, secondTile });
     Assert.That(set.HasDefinitionFor("first"));
 }
示例#7
0
		protected internal override View onCreateView (string name, AttributeSet attrs)
		{
			Assembly calling = Assembly.GetCallingAssembly ();
			if (calling.GetType ("android.widget." + name) != null)
				return createView (name, "android.widget.", attrs);
			return base.onCreateView (name, attrs);
		}
示例#8
0
        /// <summary>
        /// Get a List of all Attributes in specified AttributeSet
        /// </summary>
        /// <param name="attributeSet">Reference to an AttributeSet</param>
        /// <param name="includeTitleAttribute">Specify whether TitleAttribute should be included</param>
        public List<Attribute> GetAttributes(AttributeSet attributeSet, bool includeTitleAttribute = true)
        {
            var items = Context.SqlDb.AttributesInSets.Where(a => a.AttributeSetID == attributeSet.AttributeSetID);
            if (!includeTitleAttribute)
                items = items.Where(a => !a.IsTitle);

            return items.Select(a => a.Attribute).ToList();
        }
 /// <summary>
 /// Creates a new instance according to attributes decorating the derived class
 /// </summary>
 protected PmcCategoryDefinitionBase()
 {
     var attrSet = new AttributeSet(GetType(), typeof (PmcAttributeBase));
     Name = attrSet.Single<PmcCategoryNameAttribute>().Value;
     Help = attrSet.Optional(new PmcCategoryHelpAttribute(string.Empty)).Value;
     Type = attrSet.Optional(new PmcCategoryTypeAttribute(PerformanceCounterCategoryType.Unknown)).Type;
     IsPredefined = attrSet.Optional(new PmcCategoryPredefinedAttribute(false)).IsPredefined;
 }
		/// <summary>
		/// This ctor is used mostly when FloatingControler is inflated from xml layout
		/// </summary>
		/// <param name="context">
		///            The context for which the view is being inflated. If it is not an Activity the
		///            exception may be thrown. </param>
		/// <param name="attrs">
		///            Attributes given in xml declaration of FloatingControler </param>
		public FloatingController(Context context, AttributeSet attrs) : base(context, attrs)
		{

			TypedArray array = context.Theme.obtainStyledAttributes(attrs, R.styleable.FloatingControler, 0, 0);

			initializeControl(array);
			array.recycle();
		}
示例#11
0
 /// <summary>
 /// Creates a new instance of the class using the attributes decorating it.
 /// </summary>
 protected LogEventBase()
 {
     var attrSet = new AttributeSet(GetType(), typeof(EventAttributeBase));
     CategoryId = attrSet.Optional(new EventCategoryIdAttribute(0)).Value;
     EventId = attrSet.Optional(new EventIdAttribute(0)).Value;
     Source = attrSet.Single<EventSourceAttribute>().Value;
     Type = attrSet.Optional(new EventTypeAttribute(EventLogEntryType.Information)).Value;
     Message = attrSet.Optional(new EventMessageAttribute(String.Empty)).Value;
     LogName = attrSet.Single<EventLogNameAttribute>().Value;
 }
示例#12
0
 public void FlattenShouldAddExistingAttributesToNewSet()
 {
     var firstSet = new AttributeSet("TILE", new TileAttribute("first", new StringTile("1")));
     var secondSet = new AttributeSet("TILE", new TileAttribute("second", new StringTile("1")));
     Assert.That(firstSet.Count, Is.EqualTo(1));
     Assert.That(secondSet.Count, Is.EqualTo(1));
     firstSet.Merge(secondSet);
     Assert.That(firstSet.Count, Is.EqualTo(2));
     Assert.That(secondSet.Count, Is.EqualTo(1));
 }
 public virtual void insertString(int offs, string str, AttributeSet a)
 {
   if (str == null)
     return;
   if (this.maxlen < 0)
     base.insertString(offs, str, a);
   char[] chArray = String.instancehelper_toCharArray(str);
   StringBuffer stringBuffer = new StringBuffer();
   stringBuffer.append(chArray, 0, Math.min(this.maxlen, chArray.Length));
   base.insertString(offs, stringBuffer.toString(), a);
 }
示例#14
0
        /// <summary>
        /// Create a xml import. The data stream passed will be imported to memory, and checked 
        /// for errors. If no error could be found, the data can be persisted to the repository.
        /// </summary>
        /// <param name="zoneId">ID of 2SexyContent zone</param>
        /// <param name="applicationId">ID of 2SexyContent application</param>
        /// <param name="contentTypeId">ID of 2SexyContent type</param>
        /// <param name="dataStream">Xml data stream to import</param>
        /// <param name="languages">Languages that can be imported (2SexyContent languages enabled)</param>
        /// <param name="documentLanguageFallback">Fallback document language</param>
        /// <param name="entityClear">How to handle entities already in the repository</param>
        /// <param name="resourceReference">How value references to files and pages are handled</param>
        public XmlImport(int zoneId, int applicationId, int contentTypeId, Stream dataStream, IEnumerable<string> languages, string documentLanguageFallback, EntityClearImport entityClear, ResourceReferenceImport resourceReference)
        {
            Entities = new List<ImportEntity>();
            ErrorProtocol = new ImportErrorProtocol();

            _appId = applicationId;
            _zoneId = zoneId;
            _contentType = EavDataController.Instance(zoneId, applicationId).AttribSet.GetAttributeSet(contentTypeId);
            _languages = languages;
            _documentLanguageFallback = documentLanguageFallback;
            _entityClear = entityClear;
            _resourceReference = resourceReference;

            ValidateAndImportToMemory(dataStream);
        }
 public void AttribDelete(string name)
 {
     try
     {
         attSets = doc.AttributeSets;
         attSet  = attSets[name];
         foreach (Inventor.Attribute att in attSet)
         {
             att.Delete();
         }
         attSets[name].Delete();
     }
     catch
     {
     }
 }
示例#16
0
        // requires: All slots in this are null or non-constants
        // effects: Returns the non-null slots of this
        internal AttributeSet GetNonNullSlots()
        {
            AttributeSet attributes = new AttributeSet(MemberPath.EqualityComparer);

            foreach (ProjectedSlot projectedSlot in m_projectedSlots)
            {
                // null means 'unused' slot -- we ignore those
                if (projectedSlot != null)
                {
                    MemberProjectedSlot projectedVar = projectedSlot as MemberProjectedSlot;
                    Debug.Assert(projectedVar != null, "Projected slot must not be a constant");
                    attributes.Add(projectedVar.MemberPath);
                }
            }
            return(attributes);
        }
示例#17
0
        public ConfirmablesTest(ITestOutputHelper output) : base(output)
        {
            _localNodeId = Id.Of(1);

            _localNode = Config.NodeMatching(_localNodeId);

            _remoteNode2 = Config.NodeMatching(Id.Of(2));

            _remoteNode3 = Config.NodeMatching(Id.Of(3));

            _set = AttributeSet.Named("test-set");

            _tracked = _set.AddIfAbsent(Attribute <string> .From("test-attr", "test-value"));

            _consumables = new Confirmables(_localNode, Config.AllOtherNodes(_localNodeId));
        }
示例#18
0
        public void TileAttributesShouldThrowExceptionOnNonExistingName()
        {
            var firstTile  = new TileAttribute("first", new StringTile("1"));
            var secondTile = new TileAttribute("second", new StringTile("2"));
            var set        = new AttributeSet("TILE", new List <TileAttribute> {
                firstTile, secondTile
            });

            try
            {
                Assert.That(set["nonexisting"], Is.Not.Null);
                Assert.Fail("Expected exception");
            } catch (TileException Te)
            {
                Assert.That(Te.Message, Is.EqualTo(TileException.AttributeNotFound("nonexisting", "TILE").Message));
            }
        }
示例#19
0
        public View(Context context, AttributeSet attrs)
        {
            WinUI.Name = this.GetType().Name;
            WinUI.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            WinUI.VerticalContentAlignment   = VerticalAlignment.Stretch;

            this.mContext = context;

            //Get attributes and set this view's options
            setId(Convert.ToInt32(attrs.getIdAttribute()));
            //setId((int)attrs.getAttributeUnsignedIntValue(Util.nspace, "id", 0));

            //FOR IMPLEMENTING GRAVITY: if((grav | top) == grav) - means it contains top param. replace top with others (bottom, center, etc) to determine gravity
            LoadViewAttributeSet(attrs);

            CreateWinUI(context, attrs);
        }
示例#20
0
        /// <summary>
        /// Parse Xml file into dictionary of relative paths and attributes.
        /// <para>Optionally writes structure to project folder (defaults to true).</para>
        /// </summary>
        /// <param name="xmlFilePath">Path to the Xml template file.</param>
        /// <param name="write">If the structure should be written to disk.</param>
        /// <returns></returns>
        public static Dictionary <string, AttributeSet> PaseXML(string xmlFilePath, bool write = true)
        {
            // Take reference to project and directory to ensure it doesn't change mid method.
            var    project          = Strings.CurrentProject;
            string projectDirectory = Strings.ProjectDirectory;

            // Read Xml file.
            var doc = new XmlDocument();

            try
            {
                doc.Load(xmlFilePath);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error");
                return(null);
            }

            // Skip to root node.
            var root = doc.ChildNodes[0];

            // Create list to hold unique paths and template ids.
            var paths = new Dictionary <string, AttributeSet>();

            // Itterate through XML and populate list.
            foreach (XmlNode node in root.ChildNodes)
            {
                var nodeDir = node.Attributes[Strings.Attributes[XmlAttributeName.Name]].Value;
                paths.Add(nodeDir, AttributeSet.FromXmlNode(node));

                var children = node.ChildNodes;
                foreach (XmlNode child in children)
                {
                    AddPathsFromXmlNode(child, ref paths);
                }
            }

            // Write parsed structure to disk if requested.
            if (write)
            {
                WriteStructure(project, projectDirectory, paths);
            }

            return(paths);
        }
示例#21
0
        // Computes accuracy.
        public void AccuracyRating(AttributeSet attrs)
        {
            Accuracy = attrs["+# Accuracy Rating"][0];
            // Local weapon accuracy bonus.
            if (Local.ContainsKey("+# to Accuracy Rating"))
            {
                Accuracy += Local["+# to Accuracy Rating"][0];
            }
            float incAcc = 0;

            // Local weapon accuracy bonus.
            if (Local.ContainsKey("#% increased Accuracy Rating"))
            {
                incAcc += Local["#% increased Accuracy Rating"][0];
            }
            // Gems & global bonuses.
            if (attrs.ContainsKey("+# to Accuracy Rating"))
            {
                Accuracy += attrs["+# to Accuracy Rating"][0];
            }
            if (attrs.ContainsKey("#% increased Accuracy Rating"))
            {
                incAcc += attrs["#% increased Accuracy Rating"][0];
            }
            if (attrs.ContainsKey("#% reduced Accuracy Rating"))
            {
                incAcc += attrs["#% reduced Accuracy Rating"][0];
            }
            foreach (var attr in attrs.Matches(ReIncreasedAccuracyRatingWithWeaponType))
            {
                Match      m = ReIncreasedAccuracyRatingWithWeaponType.Match(attr.Key);
                WeaponType weaponType;
                if (WithWeaponType.TryGetValue(m.Groups[2].Value, out weaponType) && Nature.Is(weaponType))
                {
                    incAcc += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                }
            }
            if (Compute.IsDualWielding && attrs.ContainsKey("#% increased Accuracy Rating while Dual Wielding"))
            {
                incAcc += attrs["#% increased Accuracy Rating while Dual Wielding"][0];
            }
            if (incAcc != 0)
            {
                Accuracy = IncreaseValueByPercentage(Accuracy, incAcc);
            }
        }
示例#22
0
        public IServiceDefinition BuildUpService(object serviceInstance = null, Type declaringType = null, IPackage package = null)
        {
            var service = serviceInstance as Service ?? new Service(_serviceDependenciesFactory);

            if (declaringType == null)
            {
                declaringType = (serviceInstance ?? service).GetType();
            }

            var serviceDefinition = new ServiceDefinition(service, _requestRouter, _nameManager, _fluentBuilder, package, declaringType);

            var attributes = new AttributeSet(declaringType);

            _elementConfiguror.Configure(serviceDefinition, attributes);

            return(serviceDefinition);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static bool FindParentFeature(AssemblyDocument ParentDocument,
                                             PartFeature partFeature,
                                             out PartFeature asmFeature,
                                             out ComponentOccurrence occurrence)
        {
            asmFeature = null;
            occurrence = null;

            try
            {
                AttributeSet set = partFeature.AttributeSets[_AttributeSet];

                Byte[] contextData = set["ContextData"].Value as Byte[];

                int keyContext = ParentDocument.ReferenceKeyManager.LoadContextFromArray(ref contextData);


                Byte[] refKey1 = set["AsmFeatureRefKey"].Value as Byte[];

                object MatchType1;

                asmFeature = ParentDocument.ReferenceKeyManager.BindKeyToObject(ref refKey1,
                                                                                keyContext,
                                                                                out MatchType1) as PartFeature;


                Byte[] refKey2 = set["OccurrenceRefKey"].Value as Byte[];

                object MatchType2;

                occurrence = ParentDocument.ReferenceKeyManager.BindKeyToObject(ref refKey2,
                                                                                keyContext,
                                                                                out MatchType2) as ComponentOccurrence;

                if (asmFeature != null && occurrence != null)
                {
                    return(true);
                }

                return(false);
            }
            catch
            {
                return(false);
            }
        }
示例#24
0
        IPackageDefinition IPackageBuilder.BuildUpPackage(object packageInstance, Type declaringType)
        {
            var package = packageInstance as Runtime.Package ?? new Runtime.Package(_packageDependenciesFactory);

            if (declaringType == null)
            {
                declaringType = (packageInstance ?? package).GetType();
            }

            var packageDefinition = new PackageDefinition(package, _fluentBuilder, _nameManager);

            var attributes = new AttributeSet(declaringType);

            _elementConfiguror.Configure(packageDefinition, attributes);

            return(packageDefinition);
        }
示例#25
0
        IModuleDefinition IModuleBuilder.BuildUpModule(object moduleInstance, Type declaringType)
        {
            var module = moduleInstance as Module ?? new Module(_moduleDependenciesFactory);

            if (declaringType == null)
            {
                declaringType = (moduleInstance ?? module).GetType();
            }

            var moduleDefinition = new ModuleDefinition(module, _fluentBuilder);

            var attributes = new AttributeSet(declaringType);

            _elementConfiguror.Configure(moduleDefinition, attributes);

            return(moduleDefinition);
        }
        public AttributeSet AttribSetAdd(object ob, string nameAttSet)
        {
            PartFeature pf;

            if (ob is PartFeature)
            {
                pf      = ob as PartFeature;
                attSets = pf.AttributeSets;
                if (attSets.NameIsUsed[nameAttSet])
                {
                    AttribDelete(nameAttSet);
                }
                attSet = attSets.Add(nameAttSet);
                return(attSet);
            }
            return(null);
        }
示例#27
0
        /**
         * Creates or retrieves a ColorStateList that always returns a single color.
         */
        /*public static ColorStateList valueOf(int color)
         * {
         *  // TODO: should we collect these eventually?
         *  lock(sCache)
         *  {
         *      WeakReference<ColorStateList> ref1 = sCache.get(color);
         *
         *      ColorStateList csl1;
         *      ref1.TryGetTarget(out csl1);
         *
         *      ColorStateList csl = ref1 != null ? csl1 : null;
         *      if (csl != null)
         *      {
         *          return csl;
         *      }
         *
         *      csl = new ColorStateList(EMPTY, new int[] { color });
         *      sCache.put(color, new WeakReference<ColorStateList>(csl));
         *      return csl;
         *  }
         * }*/

        /**
         * Create a ColorStateList from an XML document, given a set of {@link Resources}.
         */
        public static ColorStateList createFromXml(Resources r, XmlPullParser parser)
        {
            AttributeSet attrs = Xml.asAttributeSet(parser);

            int type;

            while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT)
            {
            }

            if (type != XmlPullParser.START_TAG)
            {
                throw new Exception("No start tag found");
            }

            return(createFromXmlInner(r, parser, attrs));
        }
示例#28
0
        public void AddInformation()
        {
            PartDocument oPartDocument;

            oPartDocument = (PartDocument)m_inventorApplication.ActiveDocument;
            PartComponentDefinition oPartCompDef;

            oPartCompDef = oPartDocument.ComponentDefinition;

            AttributeSets atr = m_selectiFeature.AttributeSets;
            int           insertPlane;
            int           insertFace;

            this.GetInsertFace(oPartCompDef, m_selectFace, out insertPlane, out insertFace);
            m_insertFace = oPartCompDef.Features.ExtrudeFeatures["拉伸1"].Faces[insertFace];
            AttributeSet abs = atr["MyAttribSet"];

            Inventor.Attribute internalname = abs["InternalName"];
            Inventor.Attribute footprint    = abs["Footprint"];
            Inventor.Attribute pointX       = abs["PointX"];
            Inventor.Attribute pointY       = abs["PointY"];
            Inventor.Attribute pointZ       = abs["PointZ"];
            TransientGeometry  oTransGeo;

            oTransGeo = m_inventorApplication.TransientGeometry;
            m_Point   = oTransGeo.CreatePoint(pointX.Value, pointY.Value, pointZ.Value);
            Inventor.Attribute indexname = abs["IndexName"];
            m_indexname = indexname.Value;
            Inventor.Attribute codename = abs["CodeName"];
            m_codename = codename.Value;
            Inventor.Attribute codenumber = abs["CodeNumber"];
            m_codenumber      = codenumber.Value;
            m_connectToaccess = new ConnectToAccess(m_filepath, m_filename, m_codename, m_indexname, m_codenumber);
            string sql = @"select 生产厂家 from Outlines where Outlines.标准='" + m_indexname + "'";

            string [] result = new string[25];
            m_connectToaccess.GetInformation(sql, "生产厂家", out result);
            int i = 0;

            while (result[i] != null)
            {
                m_insertOutlineForm.listBoxName.Items.Add(result[i]);
                i++;
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sequenceItem">
        /// The SequenceItem instance containing the DICOM attributes to construct this instance with.
        /// </param>
        /// <param name="parentContentItem">The parent Content Item.</param>
        /// <param name="position">The ordinal position of the associated Sequence Item in it's contained Content Sequence Item.</param>
        public ContentItemWithValueTypeNum(AttributeSet attributeSet, ContentItem parentContentItem, uint position) :
            base(attributeSet, parentContentItem, position)
        {
            DvtkHighLevelInterface.Dicom.Other.Attribute attribute = attributeSet["0x0040A300"];

            if (attribute.Exists)
            {
                if (attribute.VR == VR.SQ)
                {
                    if (attribute.ItemCount > 0)
                    {
                        this.measuredValue = new MeasuredValue(attribute.GetItem(1));
                    }
                }
            }

            this.numericValueQualifier = ConceptCode.CreateConceptCode(attributeSet, "0x0040A301", numericValueQualifierContext);
        }
示例#30
0
 private void ManaRegen(AttributeSet def, float mana)
 {
     if (mana > 0)
     {
         float manaRegen = PercentOfValue(RoundValue(mana, 0), 1.75f);
         // manaRegen += ClarityManaRegenerationPerSecond; // Clarity provides flat mana regeneration bonus.
         float incManaRegen = 0;
         if (Global.ContainsKey("#% increased Mana Regeneration Rate"))
         {
             incManaRegen += Global["#% increased Mana Regeneration Rate"][0];
         }
         manaRegen = IncreaseValueByPercentage(manaRegen, incManaRegen);
         def["Mana Regeneration per Second: #"] = new List <float>()
         {
             RoundValue(manaRegen, 1)
         };
     }
 }
示例#31
0
        public void DoesExist_returnsTrue()
        {
            Inventor.Application app = ApplicationShim.Instance();
            var      path            = app.DesignProjectManager.ActiveDesignProject.TemplatesPath;
            Document doc             = app.Documents.Add(DocumentTypeEnum.kPartDocumentObject, path + "Standard.ipt", true);

            //create the test attribute
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");


            var result = AttributeShim.AttributeSetExists(doc, "testSet");

            try
            {
                Assert.IsTrue(result);
            }
            finally { doc.Close(true); }
        }
示例#32
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="dvtkDataAttribute">The encapsulated DvtkData attribute.</param>
        /// <param name="parentAttributeSet">The AttributeSet this instance is part of.</param>
        public ValidAttribute(TagSequence tagSequence, DvtkData.Dimse.Attribute dvtkDataAttribute, AttributeSet parentAttributeSet)
        {
            // Sanity check.
            if (dvtkDataAttribute == null)
            {
                throw new ArgumentException("Internal error: dvtkDataAttribute may not be null.");
            }

            // Sanity check.
            if (parentAttributeSet == null)
            {
                throw new ArgumentException("Internal error: parentAttributeSet may not be null.");
            }

            TagSequence = tagSequence;
            this.dvtkDataAttribute = dvtkDataAttribute;
            this.parentAttributeSet = parentAttributeSet;
        }
示例#33
0
        private void parseViewTag(XmlPullParser parser, View view, AttributeSet attrs)
        {
            int type;

            //The below will be activated in the final version of Astoria.
            //TypedArray ta = mContext.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ViewTag);
            //int key = ta.getResourceId(com.android.internal.R.styleable.ViewTag_id, 0);
            //string value = ta.getText(com.android.internal.R.styleable.ViewTag_value);
            //view.setTag(key, value);
            //ta.recycle();

            int currentDepth = parser.getDepth();

            while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT)
            {
                // Empty
            }
        }
        public void GetExisting_works()
        {
            var doc = tests.TestUtilities.CreatePartDocument();

            //create the test Attribute
            var          test         = "test string";
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");

            Inventor.Attribute attribute = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, test);

            var result = AttributeShim.GetAttributeValue(doc, "testSet", "testAttribute");

            try
            {
                Assert.AreEqual(result, test);
            }
            finally { doc.Close(true); }
        }
示例#35
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sequenceItem">
        /// The SequenceItem instance containing the DICOM attributes to construct this instance with.
        /// </param>
        /// <param name="parentContentItem">The parent Content Item.</param>
        /// <param name="position">The ordinal position of the associated Sequence Item in it's contained Content Sequence Item.</param>
        public ContentItemWithValueTypeNum(AttributeSet attributeSet, ContentItem parentContentItem, uint position)
            : base(attributeSet, parentContentItem, position)
        {
            DvtkHighLevelInterface.Dicom.Other.Attribute attribute = attributeSet["0x0040A300"];

            if (attribute.Exists)
            {
                if (attribute.VR == VR.SQ)
                {
                    if (attribute.ItemCount > 0)
                    {
                        this.measuredValue  = new MeasuredValue(attribute.GetItem(1));
                    }
                }
            }

            this.numericValueQualifier = ConceptCode.CreateConceptCode(attributeSet, "0x0040A301", numericValueQualifierContext);
        }
示例#36
0
        object IFluentBuilder.Register(Type type, Func <Type, object> factory)
        {
            if (!_types.Add(type))
            {
                return(null);
            }

            var attributes = new AttributeSet(type);

            if (attributes.IsPackage != null)
            {
                return(BuildPackage(null, type, factory, null));
            }
            if (attributes.IsModule != null)
            {
                return(BuildModule(type, factory));
            }
            if (attributes.IsPage != null)
            {
                return(BuildPage(type, factory));
            }
            if (attributes.IsLayout != null)
            {
                return(BuildLayout(type, factory));
            }
            if (attributes.IsRegion != null)
            {
                return(BuildRegion(type, factory));
            }
            if (attributes.IsComponent != null)
            {
                return(BuildComponent(type, factory));
            }
            if (attributes.IsService != null)
            {
                return(BuildService(type, factory));
            }
            if (attributes.IsDataProvider != null)
            {
                return(BuildDataProvider(type, factory));
            }

            return(null);
        }
示例#37
0
        private void EnergyShieldRegen(AttributeSet def, float es)
        {
            if (es > 0)
            {
                def["Maximum Energy Shield: #"] = new List <float>()
                {
                    RoundValue(es, 0)
                };

                float esRecharge = RoundValue(es, 0) / 5; // By default, energy shield recharges at a rate equal to a fifth of the character's maximum energy shield per second.
                if (Global.ContainsKey("#% increased Energy Shield Recharge Rate"))
                {
                    esRecharge = esRecharge * (1 + Global["#% increased Energy Shield Recharge Rate"][0] / 100);
                }
                def["Energy Shield Recharge per Second: #"] = new List <float>()
                {
                    RoundValue(esRecharge, 1)
                };

                float esDelay      = 2; // By default, the delay period for energy shield to begin to recharge is 2 seconds.
                float esOccurrence = 0;
                if (Global.ContainsKey("#% faster start of Energy Shield Recharge"))
                {
                    esOccurrence += Global["#% faster start of Energy Shield Recharge"][0];
                }
                if (Global.ContainsKey("#% slower start of Energy Shield Recharge"))
                {
                    esOccurrence -= Global["#% slower start of Energy Shield Recharge"][0];
                }
                esDelay = esDelay * 100 / (100 + esOccurrence); // 200 / (100 + r)
                if (esOccurrence != 0)
                {
                    def["Energy Shield Recharge Occurrence modifier: " + (esOccurrence > 0 ? "+" : "") + "#%"] = new List <float>()
                    {
                        esOccurrence
                    }
                }
                ;
                def["Energy Shield Recharge Delay: #s"] = new List <float>()
                {
                    RoundValue(esDelay, 1)
                };
            }
        }
示例#38
0
        public List <AttributeSet> GetAllAttributeSet()
        {
            List <AttributeSet> AttributeList = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[GetAllAttributeSet]";
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                AttributeList = new List <AttributeSet>();
                                while (sdr.Read())
                                {
                                    AttributeSet attributeSetObj = new AttributeSet();
                                    {
                                        attributeSetObj.ID   = (sdr["ID"].ToString() != "" ? int.Parse(sdr["ID"].ToString()) : attributeSetObj.ID);
                                        attributeSetObj.Name = sdr["Name"].ToString();
                                    }
                                    AttributeList.Add(attributeSetObj);
                                }
                            }//if
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(AttributeList);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Use: Read attribute and returns its value in out parameter.
        //      Returns true if attribute exists, false otherwise
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static bool ReadAttribute(object target,
                                         string setName,
                                         string attName,
                                         out object value,
                                         out ValueTypeEnum type)
        {
            value = null;
            type  = ValueTypeEnum.kIntegerType;

            try
            {
                AttributeSets sets = AdnInventorUtilities.GetProperty(target, "AttributeSets") as AttributeSets;

                if (sets == null)
                {
                    return(false);
                }

                if (!sets.get_NameIsUsed(setName))
                {
                    return(false);
                }

                AttributeSet set = sets[setName];

                if (!set.get_NameIsUsed(attName))
                {
                    return(false);
                }

                Inventor.Attribute att = set[attName];

                type = att.ValueType;

                value = att.Value;

                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#40
0
        public ConfirmingDistributorTest(ITestOutputHelper output) : base(output)
        {
            _localNodeId = Id.Of(1);

            _localNode = Config.NodeMatching(_localNodeId);

            _set = AttributeSet.Named("test-set");

            _tracked = _set.AddIfAbsent(Attribute <string> .From("test-attr", "test-value"));

            _channelProvider = new MockManagedOutboundChannelProvider(_localNodeId, Config);

            var pool = new ConsumerByteBufferPool(ElasticResourcePool <IConsumerByteBuffer, string> .Config.Of(10), Properties.OperationalBufferSize());

            var outboundStream = TestWorld.ActorFor <IOperationalOutboundStream>(
                () => new OperationalOutboundStreamActor(_localNode, _channelProvider, pool));

            _confirmingDistributor = new ConfirmingDistributor(Application, _localNode, outboundStream.Actor, Config);
        }
示例#41
0
        //
        // - Methods -
        //

        /// <summary>
        /// Create a ConceptCode instance, if the specified Sequence Attribute is present in the
        /// supplied Attribute Set and the Sequence Attribute contains at least one Sequence Item.
        /// </summary>
        /// <param name="attributeSet">
        /// The Attribute Set in which the Sequence Attribute may be present.
        /// </param>
        /// <param name="tag">The Tag of the Sequence Attribute.</param>
        /// <returns>
        /// The created ConceptCode instance if the first Sequence Item exists.
        /// Null otherwise.
        /// </returns>
        internal static ConceptCode CreateConceptCode(AttributeSet attributeSet, String tag, string context)
        {
            ConceptCode conceptCode = null;

            DvtkHighLevelInterface.Dicom.Other.Attribute attribute = attributeSet[tag];

            if (attribute.Exists)
            {
                if (attribute.VR == VR.SQ)
                {
                    if (attribute.ItemCount > 0)
                    {
                        conceptCode = new ConceptCode(attribute.GetItem(1), context);
                    }
                }
            }

            return(conceptCode);
        }
        /// <summary>
        /// Check if the given match dataset is found in the local dataset using the default Tag Type list.
        /// A check is made to see if all the attributes in the given match dataset are present in the local
        /// dataset. In addition to the base match we need to try to match attributes from the
        /// Request Attributes Sequence (if present) or Scheduled Procedure Step Sequence (if present).
        /// </summary>
        /// <param name="matchDataset">Match dataset to check.</param>
        /// <returns>Boolean indicating if the match attributes are present in the local dataset.</returns>
        public override bool IsFoundIn(AttributeSet matchDataset)
        {
            bool isFoundIn = base.IsFoundIn(matchDataset);

            if (isFoundIn == false)
            {
                // check if the Request Attributes Sequence is available in the match dataset
                DvtkData.Dimse.Attribute requestAttributesSequence = matchDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE);
                if (requestAttributesSequence != null)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue;
                    if (sequenceOfItems.Sequence.Count == 1)
                    {
                        // set up a temporary tag list to check the relevant tags in the Request Attributes Sequence
                        TagTypeList itemTagTypeList = new TagTypeList();
                        itemTagTypeList.Add(new TagType(Tag.SCHEDULED_PROCEDURE_STEP_DESCRIPTION, TagTypeEnum.TagOptional));
                        itemTagTypeList.Add(new TagType(Tag.SCHEDULED_ACTION_ITEM_CODE_SEQUENCE, TagTypeEnum.TagOptional));
                        itemTagTypeList.Add(new TagType(Tag.SCHEDULED_PROCEDURE_STEP_ID, TagTypeEnum.TagOptional));

                        DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                        // check if found in item
                        isFoundIn = base.IsFoundIn(itemTagTypeList, item);
                    }
                }

                // check if the Scheduled Procedure Step Sequence is available in the match dataset
                DvtkData.Dimse.Attribute scheduledProcedureStepSequence = matchDataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE);
                if (scheduledProcedureStepSequence != null)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue;
                    if (sequenceOfItems.Sequence.Count == 1)
                    {
                        DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                        // check if found in item - use default tag list
                        isFoundIn = base.IsFoundIn(item);
                    }
                }
            }

            return(isFoundIn);
        }
示例#43
0
 public static void AppendAttributeValues(this Import.ImportEntity importEntity, AttributeSet attributeSet, Dictionary<string, object> values, string valuesLanguage, bool valuesReadOnly, bool resolveHyperlink)
 {
     foreach (var value in values)
     {
         // Handle special attributes (for example of the system)
         if (value.Key == "IsPublished")
         {
             importEntity.IsPublished = value.Value is bool ? (bool)value.Value : true;
             continue;
         }
         // Handle content-type attributes
         var attribute = attributeSet.GetAttribute(value.Key);
         if (attribute == null)
         {
             throw new ArgumentException("Attribute '" + value.Key + "' does not exist.");
         }
         importEntity.AppendAttributeValue(value.Key, value.Value.ToString(), attribute.Type, valuesLanguage, valuesReadOnly, resolveHyperlink);
     }
 }
示例#44
0
        /// <summary>
        /// This static function will return boolean value indicating if the specified Attribute
        /// exists in the provided object. If the object is not attribute capable, the function
        /// will throw a system exception.
        /// </summary>
        /// <param name="obj">Object</param>
        /// <param name="attributeSetName">AttributeSet name as a string</param>
        /// <param name="attributeName">Attribute name as a string</param>
        public static bool AttributeExists(this object obj, string attributeSetName, string attributeName)
        {
            dynamic temp = (dynamic)obj;

            if (!ObjectIsAttributeCapable(obj))
            {
                return(false);
            }

            if (!AttributeSetExists(obj, attributeSetName))
            {
                return(false);
            }

            AttributeSets attributeSets = temp.AttributeSets;
            AttributeSet  attributeSet  = attributeSets[attributeSetName];

            return(attributeSet.NameIsUsed[attributeName]);
        }
        /// <summary>
        /// Copy from the given source Dataset into the local Dataset as defined by the
        /// default Tag Type list. In addition to the base copy we need to copy attributes from the
        /// Request Attributes Sequence (if present).
        /// </summary>
        /// <param name="sourceDataset">Source Dataset used to populate the local Dataset.</param>
        public override void CopyFrom(AttributeSet sourceDataset)
        {
            // perform base copy
            base.CopyFrom(sourceDataset);

            // check if the Request Attributes Sequence is available in the source dataset
            DvtkData.Dimse.Attribute requestAttributesSequence = sourceDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE);
            if (requestAttributesSequence != null)
            {
                SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // copy item attributes too
                    base.CopyFrom(item);
                }
            }
        }
示例#46
0
        private void LifeRegen(AttributeSet def, float life, float es)
        {
            float lifeRegen     = 0;
            float lifeRegenFlat = 0;

            if (Global.ContainsKey("#% of Life Regenerated per second"))
            {
                lifeRegen += Global["#% of Life Regenerated per second"][0];
            }
            if (Global.ContainsKey("# Life Regenerated per second"))
            {
                lifeRegenFlat += Global["# Life Regenerated per second"][0];
            }

            if (VaalPact)
            {
                lifeRegen = 0;
            }

            if (ZealotsOath)
            {
                if (es > 0 && lifeRegen + lifeRegenFlat > 0)
                {
                    def["Energy Shield Regeneration per Second: #"] = new List <float>()
                    {
                        RoundValue(PercentOfValue(RoundValue(es, 0), lifeRegen), 1) + lifeRegenFlat
                    }
                }
                ;
            }
            else
            {
                if (!ChaosInoculation && lifeRegen + lifeRegenFlat > 0)
                {
                    def["Life Regeneration per Second: #"] = new List <float>()
                    {
                        RoundValue(PercentOfValue(RoundValue(life, 0), lifeRegen), 1) + lifeRegenFlat
                    }
                }
                ;
            }
        }
        /// <summary>
        /// returns the names of the attributes
        /// </summary>
        /// <returns></returns>
        public String[] getAttributeNames()
        {
            LinkedList <string> values = new LinkedList <string>();

            //SortedDictionary<uint, double>.Enumerator enumerator = dict.GetEnumerator();
            for (uint i = 0; i < AttributeSet.GetAttributeCount(); i++)
            {
                if (!isNominal(i))
                {
                    values.AddLast(AttributeSet.GetAttributeDisplayName(i, false));
                }
                else
                {
                    if (!isTarget(i))
                    {
                        for (uint j = 0; j < AttributeSet.GetAttributeStateCount(i); j++)
                        {
                            StateValue value = new StateValue();
                            value.SetIndex(j);
                            object valuea = AttributeSet.UntokenizeAttributeValue(i, value);
                            string name;
                            if (valuea == null)
                            {
                                name = "NULL";
                            }
                            else
                            {
                                name = valuea.ToString();
                                if (name.Equals(""))
                                {
                                    name = "NULL";
                                }
                            }
                            values.AddLast(AttributeSet.GetAttributeDisplayName(i, false) + "." + name);
                        }
                    }
                }
            }
            string[] output = new string[values.Count];
            values.CopyTo(output, 0);
            return(output);
        }
示例#48
0
文件: Convert.cs 项目: ewcasas/DVTK
        /// <summary>
        /// Convert the first value of a specified attribute to a String.
        /// </summary>
        /// <param name="attributeSet">The Attribute Set containing the DICOM Attribute.</param>
        /// <param name="tag">The tag of the attribute.</param>
        /// <returns>
        /// If the associated DICOM attribute is not present, null is returned.
        /// If the associated DICOM attribute is present and has no values, "" is returned.
        /// If the associated DICOM attribute is present and has values, the first value is returned.
        /// </returns>
        public static String FirstAttributeValueToString(AttributeSet attributeSet, String tag)
        {
            String stringForFirstAttributeValue = null;

            DvtkHighLevelInterface.Dicom.Other.Attribute attribute = attributeSet[tag];

            if (attribute.Exists)
            {
                if (attribute.Values.Count == 0)
                {
                    stringForFirstAttributeValue = "";
                }
                else
                {
                    stringForFirstAttributeValue = Convert.ToTrimmedString(attribute.Values[0], attribute.VR);
                }
            }

            return (stringForFirstAttributeValue);
        }
示例#49
0
 public virtual void insertString(int i, string s, AttributeSet attributes)
 {
   base.insertString(i, s, attributes);
   if (s == null)
     return;
   if (String.instancehelper_equals(s, (object) "-"))
   {
     if (i == 0)
     {
       if (String.instancehelper_length(s) < 2)
         return;
     }
   }
   try
   {
     Integer.parseInt(((AbstractDocument) this).getText(0, ((AbstractDocument) this).getLength()));
     return;
   }
   catch (NumberFormatException ex)
   {
   }
   ((AbstractDocument) this).remove(i, String.instancehelper_length(s));
 }
 public XslArticleGeneratorLoader(AttributeSet validAttributes)
 {
     this.validAttributes = validAttributes;
 }
示例#51
0
        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <param name="parentAttributeSetToCloneTo">
        /// The AttributeSet the new cloned Attribute wil become part of.
        /// </param>
        /// <returns>The created deep copy of this instance.</returns>
        internal override Attribute Clone(AttributeSet parentAttributeSetToCloneTo)
        {
            //
            // Clone the attribute without values.
            //

            TagSequence newTagSequence = parentAttributeSetToCloneTo.TagSequence.Clone();

            Tag lastTagCurrentAttribute = TagSequence.Tags[TagSequence.Tags.Count - 1] as Tag;
            newTagSequence.Add(lastTagCurrentAttribute);

            ValidAttribute cloneAttribute = new ValidAttribute(newTagSequence, new DvtkData.Dimse.Attribute(lastTagCurrentAttribute.AsUInt32, (DvtkData.Dimse.VR)this.VR), parentAttributeSetToCloneTo);

            //
            // Add the values or items to the cloned attribute.
            //

            Values currentValues = this.Values;
            Values cloneValues = cloneAttribute.Values;

            if (currentValues.IsImplementedWithCollection)
            {
                Object[] collectionAsArray = new Object[currentValues.CollectionImplementation.Count];

                currentValues.CollectionImplementation.CopyTo(collectionAsArray, 0);

                cloneValues.Add(collectionAsArray);
            }
            else if (currentValues.IsImplementedWithString)
            {
                cloneValues.Add(currentValues.StringImplementation);
            }
            else if ((currentValues.Attribute.VR == VR.OB) || (currentValues.Attribute.VR == VR.OF) || (currentValues.Attribute.VR == VR.OW))
            {
                cloneValues.Add(currentValues);
            }
            else if (this.VR == VR.UN)
            {
                cloneValues.ByteArrayImplementation = currentValues.ByteArrayImplementation;
            }
            else if (this.VR == VR.SQ)
            {
                for (int index = 1; index <= this.ItemCount; index++)
                {
                    // The AddItem will take care that the item is cloned.
                    cloneAttribute.AddItem(this.GetItem(index));
                }
            }
            else
            {
                // Do nothing.
            }

            //
            // Set the Name of the attribute.
            //

            cloneAttribute.Name = Name;

            return(cloneAttribute);
        }
示例#52
0
            // Computes critical strike chance and multiplier.
            public void CriticalStrike(AttributeSet attrs)
            {
                // Critical chance.
                if (ResoluteTechnique) CriticalChance = 0;
                else
                {
                    if (CriticalChance > 0)
                    {
                        float incCC = 0;
                        if (attrs.ContainsKey("#% increased Critical Strike Chance"))
                            incCC += attrs["#% increased Critical Strike Chance"][0];
                        if (attrs.ContainsKey("#% increased Global Critical Strike Chance"))
                            incCC += attrs["#% increased Global Critical Strike Chance"][0];
                        if (IsWieldingStaff && attrs.ContainsKey("#% increased Global Critical Strike Chance while wielding a Staff"))
                            incCC += attrs["#% increased Global Critical Strike Chance while wielding a Staff"][0];
                        if (Nature.Is(DamageSource.Spell))
                        {
                            if (attrs.ContainsKey("#% increased Critical Strike Chance for Spells"))
                                incCC += attrs["#% increased Critical Strike Chance for Spells"][0];
                            if (attrs.ContainsKey("#% increased Global Critical Strike Chance for Spells"))
                                incCC += attrs["#% increased Global Critical Strike Chance for Spells"][0];
                        }
                        else // Attack
                        {
                            foreach (var attr in attrs.Matches(ReIncreasedCriticalChanceWithWeaponType))
                            {
                                Match m = ReIncreasedCriticalChanceWithWeaponType.Match(attr.Key);
                                if (WithWeaponType.ContainsKey(m.Groups[2].Value) && Nature.Is(WithWeaponType[m.Groups[2].Value]))
                                    incCC += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                            }
                            if (IsDualWielding && attrs.ContainsKey("#% increased Weapon Critical Strike Chance while Dual Wielding"))
                                incCC += attrs["#% increased Weapon Critical Strike Chance while Dual Wielding"][0];
                        }
                        // Form specific.
                        foreach (var attr in attrs.Matches(ReIncreasedCriticalChanceForm))
                        {
                            Match m = ReIncreasedCriticalChanceForm.Match(attr.Key);
                            if (DamageNature.Forms.ContainsKey(m.Groups[2].Value) && Nature.Is(DamageNature.Forms[m.Groups[2].Value]))
                                incCC += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                        }
                        if (incCC > 0)
                            CriticalChance = IncreaseValueByPercentage(CriticalChance, incCC);

                        // Critical chance can not be less than 5% nor more than 95%.
                        // @see http://pathofexile.gamepedia.com/Critical_Strike
                        if (CriticalChance < 5) CriticalChance = 5;
                        else if (CriticalChance > 95) CriticalChance = 95;

                        float incCM = 0;
                        if (attrs.ContainsKey("#% increased Critical Strike Multiplier"))
                            incCM += attrs["#% increased Critical Strike Multiplier"][0];
                        if (attrs.ContainsKey("#% increased Global Critical Strike Multiplier"))
                            incCM += attrs["#% increased Global Critical Strike Multiplier"][0];
                        if (IsWieldingStaff && attrs.ContainsKey("#% increased Global Critical Strike Multiplier while wielding a Staff"))
                            incCM += attrs["#% increased Global Critical Strike Multiplier while wielding a Staff"][0];
                        if (Nature.Is(DamageSource.Spell))
                        {
                            if (attrs.ContainsKey("#% increased Critical Strike Multiplier for Spells"))
                                incCM += attrs["#% increased Critical Strike Multiplier for Spells"][0];
                            if (attrs.ContainsKey("#% increased Global Critical Strike Multiplier for Spells"))
                                incCM += attrs["#% increased Global Critical Strike Multiplier for Spells"][0];
                        }
                        else // Attack
                        {
                            foreach (var attr in attrs.Matches(ReIncreasedCriticalMultiplierWithWeaponType))
                            {
                                Match m = ReIncreasedCriticalMultiplierWithWeaponType.Match(attr.Key);
                                if (WithWeaponType.ContainsKey(m.Groups[2].Value) && Nature.Is(WithWeaponType[m.Groups[2].Value]))
                                    incCM += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                            }
                            if (IsDualWielding && attrs.ContainsKey("#% increased Weapon Critical Strike Multiplier while Dual Wielding"))
                                incCM += attrs["#% increased Weapon Critical Strike Multiplier while Dual Wielding"][0];
                        }
                        // Form specific.
                        foreach (var attr in attrs.Matches(ReIncreasedCriticalMultiplierForm))
                        {
                            Match m = ReIncreasedCriticalMultiplierForm.Match(attr.Key);
                            if (DamageNature.Forms.ContainsKey(m.Groups[2].Value) && Nature.Is(DamageNature.Forms[m.Groups[2].Value]))
                                incCM += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                        }
                        if (incCM > 0)
                            CriticalMultiplier = IncreaseValueByPercentage(CriticalMultiplier, incCM);
                    }
                }
            }
示例#53
0
 /// <summary>
 /// Deletes this instance from the AttributeSet it is contained in.
 /// </summary>
 /// <remarks>
 /// <b>Don't use this instance anymore after calling this method!</b>
 /// </remarks>
 public override void Delete()
 {
     if (this.parentAttributeSet != null)
     {
         this.parentAttributeSet.DvtkDataAttributeSet.Remove(this.dvtkDataAttribute);
         TagSequence = new TagSequence();
         this.parentAttributeSet = null;
     }
 }
示例#54
0
 // Computes accuracy.
 public void AccuracyRating(AttributeSet attrs)
 {
     Accuracy = attrs["+# Accuracy Rating"][0];
     // Local weapon accuracy bonus.
     if (Local.ContainsKey("+# to Accuracy Rating"))
         Accuracy += Local["+# to Accuracy Rating"][0];
     float incAcc = 0;
     // Local weapon accuracy bonus.
     if (Local.ContainsKey("#% increased Accuracy Rating"))
         incAcc += Local["#% increased Accuracy Rating"][0];
     // Gems & global bonuses.
     if (attrs.ContainsKey("+# to Accuracy Rating"))
         Accuracy += attrs["+# to Accuracy Rating"][0];
     if (attrs.ContainsKey("#% increased Accuracy Rating"))
         incAcc += attrs["#% increased Accuracy Rating"][0];
     if (attrs.ContainsKey("#% reduced Accuracy Rating"))
         incAcc += attrs["#% reduced Accuracy Rating"][0];
     foreach (var attr in attrs.Matches(ReIncreasedAccuracyRatingWithWeaponType))
     {
         Match m = ReIncreasedAccuracyRatingWithWeaponType.Match(attr.Key);
         if (Nature.Is(WithWeaponType[m.Groups[2].Value]))
             incAcc += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
     }
     if (IsDualWielding && attrs.ContainsKey("#% increased Accuracy Rating while Dual Wielding"))
         incAcc += attrs["#% increased Accuracy Rating while Dual Wielding"][0];
     if (incAcc != 0)
         Accuracy = IncreaseValueByPercentage(Accuracy, incAcc);
 }
示例#55
0
            // Computes attacks or casts per second.
            public void AttackSpeed(AttackSkill skill, AttributeSet attrs)
            {
                if (Nature.Is(DamageSource.Attack))
                {
                    // If gem has own Attacks per Second, use it instead of weapon one.
                    if (skill.Local.ContainsKey("Attacks per Second: #"))
                    {
                        APS = skill.Local["Attacks per Second: #"][0];
                        // Apply local increased attack speed of weapon.
                        if (Local.ContainsKey("#% increased Attack Speed"))
                            APS = IncreaseValueByPercentage(APS, Local["#% increased Attack Speed"][0]);
                    }

                    float incAS = 0;
                    if (attrs.ContainsKey("#% increased Attack Speed"))
                        incAS += attrs["#% increased Attack Speed"][0];
                    if (attrs.ContainsKey("#% reduced Attack Speed"))
                        incAS -= attrs["#% reduced Attack Speed"][0];
                    if (attrs.ContainsKey("#% increased Attack and Cast Speed"))
                        incAS += attrs["#% increased Attack and Cast Speed"][0];
                    if (attrs.ContainsKey("#% reduced Attack and Cast Speed"))
                        incAS -= attrs["#% reduced Attack and Cast Speed"][0];
                    foreach (var attr in attrs.MatchesAny(new Regex[] { ReIncreasedAttackSpeedWithWeaponHandOrType, ReIncreasedAttackSpeedType }))
                    {
                        Match m = ReIncreasedAttackSpeedWithWeaponHandOrType.Match(attr.Key);
                        if (m.Success)
                        {
                            if (WithWeaponHand.ContainsKey(m.Groups[2].Value) && Nature.Is(WithWeaponHand[m.Groups[2].Value]))
                                incAS += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                            else if (WithWeaponType.ContainsKey(m.Groups[2].Value) && Nature.Is(WithWeaponType[m.Groups[2].Value]))
                                incAS += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                        }
                        else
                        {
                            m = ReIncreasedAttackSpeedType.Match(attr.Key);
                            if (m.Success)
                            {
                                // XXX: Not sure there are any mods with WeaponType here (Melee string in mod is DamageForm now, maybe Unarmed should be form as well).
                                if (Weapon.Types.ContainsKey(m.Groups[2].Value) && Nature.Is(Weapon.Types[m.Groups[2].Value]))
                                    incAS += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                                else
                                    if (DamageNature.Forms.ContainsKey(m.Groups[2].Value) && Nature.Is(DamageNature.Forms[m.Groups[2].Value]))
                                        incAS += m.Groups[1].Value == "increased" ? attr.Value[0] : -attr.Value[0];
                            }
                        }
                    }
                    if (IsDualWielding && attrs.ContainsKey("#% increased Attack Speed while Dual Wielding"))
                        incAS += attrs["#% increased Attack Speed while Dual Wielding"][0];
                    if (incAS != 0)
                        APS = IncreaseValueByPercentage(APS, incAS);

                    float moreAS = 0;
                    if (attrs.ContainsKey("#% more Attack Speed"))
                        moreAS += attrs["#% more Attack Speed"][0];
                    if (attrs.ContainsKey("#% less Attack Speed"))
                        moreAS -= attrs["#% less Attack Speed"][0];
                    foreach (var attr in attrs.Matches(ReMoreAttackSpeedType))
                    {
                        Match m = ReMoreAttackSpeedType.Match(attr.Key);
                        if (m.Success)
                        {
                            // XXX: Not sure there are any mods with WeaponType here (Melee string in mod is DamageForm now, maybe Unarmed should be form as well).
                            if (Weapon.Types.ContainsKey(m.Groups[2].Value) && Nature.Is(Weapon.Types[m.Groups[2].Value]))
                                moreAS += m.Groups[1].Value == "more" ? attr.Value[0] : -attr.Value[0];
                            else if (DamageNature.Forms.ContainsKey(m.Groups[2].Value) && Nature.Is(DamageNature.Forms[m.Groups[2].Value]))
                                moreAS += m.Groups[1].Value == "more" ? attr.Value[0] : -attr.Value[0];
                        }
                    }
                    if (moreAS != 0)
                        APS = IncreaseValueByPercentage(APS, moreAS);

                    APS = RoundHalfDownEvenValue(APS, 2);
                }
                else // Spell (use Cast Time directly).
                {
                    float incCS = 0;
                    if (attrs.ContainsKey("#% increased Cast Speed"))
                        incCS += attrs["#% increased Cast Speed"][0];
                    if (attrs.ContainsKey("#% reduced Cast Speed"))
                        incCS -= attrs["#% reduced Cast Speed"][0];
                    if (attrs.ContainsKey("#% increased Attack and Cast Speed"))
                        incCS += attrs["#% increased Attack and Cast Speed"][0];
                    if (attrs.ContainsKey("#% reduced Attack and Cast Speed"))
                        incCS -= attrs["#% reduced Attack and Cast Speed"][0];
                    if (IsDualWielding && attrs.ContainsKey("#% increased Cast Speed while Dual Wielding"))
                        incCS += attrs["#% increased Cast Speed while Dual Wielding"][0];
                    if (incCS != 0)
                        CastTime = RoundValue(CastTime / ((100 + incCS) / 100), 3);

                    float moreCS = 0;
                    if (attrs.ContainsKey("#% more Cast Speed"))
                        moreCS += attrs["#% more Cast Speed"][0];
                    if (attrs.ContainsKey("#% less Cast Speed"))
                        moreCS -= attrs["#% less Cast Speed"][0];
                    if (moreCS != 0)
                        CastTime = FloorValue(CastTime / ((100 + moreCS) / 100), 3);

                    APS = RoundValue(1 / CastTime, 2);
                }
            }
示例#56
0
            public AttackSource(string name, AttackSkill skill, Weapon weapon)
            {
                Name = name;

                if (weapon == null) // Spells get damage from gem local attributes.
                {
                    Nature = new DamageNature(skill.Nature);

                    foreach (var attr in skill.Local)
                    {
                        Damage damage = Damage.Create(skill.Nature, attr);
                        if (damage != null) Deals.Add(damage);
                    }

                    if (skill.Gem.Attributes.ContainsKey("Cast Time: # sec"))
                    {
                        CastTime = skill.Gem.Attributes["Cast Time: # sec"][0];
                        APS = 1 / CastTime;
                    }
                    else
                        APS = CastTime = 1; // Spell without Cast Time has cast time of 1 second.

                    if (skill.Gem.Attributes.ContainsKey("Critical Strike Chance: #%"))
                        CriticalChance = skill.Gem.Attributes["Critical Strike Chance: #%"][0];
                    else
                        CriticalChance = 0; // Spell without Critical Strike Chance has none.

                    Local = new AttributeSet(); // No local weapon attributes.
                }
                else
                {
                    if ((skill.Nature.WeaponType & weapon.Nature.WeaponType) == 0) // Skill can't be used.
                        // Override weapon type and form of skill with actual weapon (client shows damage of unuseable skills as well).
                        Nature = new DamageNature(skill.Nature) { Form = weapon.Nature.Form, WeaponHand = weapon.Hand, WeaponType = weapon.Nature.WeaponType };
                    else // Narrow down weapon type and form of skill gem to actual weapon (e.g. Frenzy).
                        Nature = new DamageNature(skill.Nature)
                        {
                            Form = skill.Nature.ChooseWeaponForm(weapon.Nature), // XXX: Choose between melee or projectile form according to weapon.
                            WeaponHand = weapon.Hand,
                            WeaponType = skill.Nature.WeaponType & weapon.Nature.WeaponType
                        };

                    // XXX: If source has no form, but skill has form defined, then force form of skill.
                    // This happens in form transition from melee to projectile with skills like Spectral Throw.
                    if (Nature.Form == DamageForm.Any && skill.Nature.Form != DamageForm.Any)
                        Nature.Form = skill.Nature.Form;

                    foreach (Damage damage in weapon.Deals)
                        Deals.Add(new Damage(damage) { Form = Nature.Form, Source = Nature.Source, WeaponHand = Nature.WeaponHand, WeaponType = Nature.WeaponType });

                    foreach (Damage.Added added in weapon.Added)
                        if (weapon.Is(added.Hand)) // Added damage may require specific hand.
                            added.Apply(this, 100);

                    APS = weapon.Attributes["Attacks per Second: #"][0];

                    if (weapon.Attributes.ContainsKey("Critical Strike Chance: #%"))
                        CriticalChance = weapon.Attributes["Critical Strike Chance: #%"][0];
                    else
                        CriticalChance = 0; // Weapon without Critical Strike Chance has none.

                    Local = weapon.Attributes;
                }
            }
示例#57
0
            // Return list group of this attack.
            public ListGroup ToListGroup()
            {
                AttributeSet props = new AttributeSet();

                props.Add(IsDamageOnUse() ? "Damage per Use: #" : "Damage per Second: #", new List<float> { RoundHalfDownValue(DamagePerSecond(), 1) });

                if (Nature.Is(DamageSource.Attack))
                {
                    props.Add("Chance to Hit: #%", new List<float> { RoundValue(ChanceToHit(), 0) });
                    props.Add("Attacks per Second: #", new List<float> { RoundHalfDownValue(AttacksPerSecond(), 1) });
                }
                else
                    props.Add("Casts per Second: #", new List<float> { RoundHalfDownValue(AttacksPerSecond(), 1) });

                foreach (AttackSource source in Sources)
                {
                    string sourcePrefix = source.Name.Length == 0 ? "" : source.Name + " ";

                    foreach (DamageType type in DamageTypes)
                    {
                        Damage damage = source.Deals.Find(d => d.Is(type));
                        if (damage != null)
                            props.Add(sourcePrefix + damage.ToAttribute(), damage.ToValue());
                    }

                    if (source.Nature.Is(DamageSource.Attack))
                        props.Add(sourcePrefix + "Accuracy Rating: #", new List<float> { RoundValue(source.Accuracy, 0) });

                    if (source.CriticalChance > 0)
                    {
                        // XXX: Different rounding style for spells and attacks. Really?
                        props.Add(sourcePrefix + "Critical Strike Chance: #%", new List<float> { Nature.Is(DamageSource.Spell) ? RoundValue(source.CriticalChance, 1) : RoundHalfDownValue(source.CriticalChance, 1) });
                        props.Add(sourcePrefix + "Critical Strike Multiplier: #%", new List<float> { RoundValue(source.CriticalMultiplier, 0) });
                    }
                }

                return new ListGroup(Name + (IsUseable ? "" : " (Unuseable)"), props);
            }
示例#58
0
        // Initializes structures.
        public static void Initialize(SkillTree skillTree, ItemAttributes itemAttrs)
        {
            Items = itemAttrs.Equip.ToList();

            MainHand = new Weapon(WeaponHand.Main, Items.Find(i => i.Class == ItemClass.MainHand));
            OffHand = new Weapon(WeaponHand.Off, Items.Find(i => i.Class == ItemClass.OffHand));

            // If main hand weapon has Counts as Dual Wielding modifier, then clone weapon to off hand.
            // @see http://pathofexile.gamepedia.com/Wings_of_Entropy
            if (MainHand.Attributes.ContainsKey("Counts as Dual Wielding"))
                OffHand = MainHand.Clone(WeaponHand.Off);

            IsDualWielding = MainHand.IsWeapon() && OffHand.IsWeapon();
            if (IsDualWielding)
            {
                // Set dual wielded bit on weapons.
                MainHand.Hand |= WeaponHand.DualWielded;
                OffHand.Hand |= WeaponHand.DualWielded;
            }
            IsWieldingShield = MainHand.Is(WeaponType.Shield) || OffHand.Is(WeaponType.Shield);
            IsWieldingStaff = MainHand.Is(WeaponType.Staff);

            Level = skillTree.Level;
            if (Level < 1) Level = 1;
            else if (Level > 100) Level = 100;

            Global = new AttributeSet();

            Tree = new AttributeSet(skillTree.SelectedAttributesWithoutImplicit);
            Global.Add(Tree);

            // Keystones.
            Acrobatics = Tree.ContainsKey("#% Chance to Dodge Attacks. #% less Armour and Energy Shield, #% less Chance to Block Spells and Attacks");
            AvatarOfFire = Tree.ContainsKey("Deal no Non-Fire Damage");
            BloodMagic = Tree.ContainsKey("Removes all mana. Spend Life instead of Mana for Skills");
            ChaosInoculation = Tree.ContainsKey("Maximum Life becomes #, Immune to Chaos Damage");
            IronGrip = Tree.ContainsKey("The increase to Physical Damage from Strength applies to Projectile Attacks as well as Melee Attacks");
            IronReflexes = Tree.ContainsKey("Converts all Evasion Rating to Armour. Dexterity provides no bonus to Evasion Rating");
            NecromanticAegis = Tree.ContainsKey("All bonuses from an equipped Shield apply to your Minions instead of you");
            ResoluteTechnique = Tree.ContainsKey("Never deal Critical Strikes");
            VaalPact = Tree.ContainsKey("Life Leech applies instantly at #% effectiveness. Life Regeneration has no effect.");
            ZealotsOath = Tree.ContainsKey("Life Regeneration applies to Energy Shield instead of Life");

            Equipment = new AttributeSet();
            foreach (ItemAttributes.Attribute attr in itemAttrs.NonLocalMods)
                Equipment.Add(attr.TextAttribute, new List<float>(attr.Value));

            if (NecromanticAegis && OffHand.IsShield())
            {
                // Remove all bonuses of shield from equipment set.
                // @see http://pathofexile.gamepedia.com/Necromantic_Aegis
                foreach (var attr in OffHand.Attributes)
                    Equipment.Remove(attr);
                // Remove all bonuses from shield itself.
                OffHand.Attributes.Clear();
            }

            Global.Add(Equipment);

            CoreAttributes();

            Implicit = new AttributeSet(SkillTree.ImplicitAttributes(Global, Level));
            Global.Add(Implicit);

            // Innate dual wielding bonuses.
            // @see http://pathofexile.gamepedia.com/Dual_wielding
            if (IsDualWielding)
            {
                Global["#% more Attack Speed"] = new List<float>() { 10 };
                Global["#% more Physical Damage with Weapons"] = new List<float>() { 20 };
            }
        }
示例#59
0
        // Computes defensive statistics.
        public static List<ListGroup> Defense()
        {
            AttributeSet ch = new AttributeSet();
            AttributeSet def = new AttributeSet();

            // Difficulty.
            bool difficultyNormal = true;
            bool difficultyCruel = false;
            bool difficultyMerciless = false;
            // Bandits.
            bool banditNormalKraityn = false; // +8% to all elemental resistances
            bool banditNormalAlira = false; // +40 Mana
            bool banditNormalOak = false; // +40 Life
            bool banditCruelKraityn = false; // +8% Attack Speed
            bool banditCruelAlira = false; // +4% Cast Speed
            bool banditCruelOak = false; // +18% Physical Damage
            bool banditMercilessKraityn = false; // +1 Max Frenzy Charge
            bool banditMercilessAlira = false; // +1 Max Power Charge
            bool banditMercilessOak = false; // +1 Max Endurance Charge

            float life;
            if (ChaosInoculation)
                life = Global["Maximum Life becomes #, Immune to Chaos Damage"][0];
            else
            {
                life = Global["+# to maximum Life"][0];
                if (banditNormalOak) // Bandit.
                    life += 40;
                if (Global.ContainsKey("#% increased maximum Life"))
                    life = IncreaseValueByPercentage(life, Global["#% increased maximum Life"][0]);
            }
            ch["Life: #"] = new List<float>() { RoundValue(life, 0) };

            float mana = Global["+# to maximum Mana"][0];
            float incMana = 0;
            if (banditNormalAlira) // Bandit.
                mana += 40;
            if (Global.ContainsKey("#% increased maximum Mana"))
                incMana = Global["#% increased maximum Mana"][0];

            float es = 0;
            float incES = 0;
            // Add maximum shield from tree.
            if (Global.ContainsKey("+# to maximum Energy Shield"))
                es += Global["+# to maximum Energy Shield"][0];
            // Add maximum shield from items.
            if (Global.ContainsKey("Energy Shield: #"))
                es += Global["Energy Shield: #"][0];
            // Increase % maximum shield from tree, items and intelligence.
            if (Global.ContainsKey("#% increased maximum Energy Shield"))
                incES += Global["#% increased maximum Energy Shield"][0];

            float moreES = 0;
            // More % maximum shield from tree and items.
            if (Global.ContainsKey("#% more maximum Energy Shield"))
                moreES += Global["#% more maximum Energy Shield"][0];

            float lessArmourAndES = 0;
            if (Acrobatics)
                lessArmourAndES += Global["#% Chance to Dodge Attacks. #% less Armour and Energy Shield, #% less Chance to Block Spells and Attacks"][1];

            // Equipped Shield bonuses.
            float incArmourShield = 0;
            float incESShield = 0;
            float incDefencesShield = 0;
            if (Global.ContainsKey("#% increased Armour from equipped Shield"))
                incArmourShield += Global["#% increased Armour from equipped Shield"][0];
            if (Global.ContainsKey("#% increased Energy Shield from equipped Shield"))
                incESShield += Global["#% increased Energy Shield from equipped Shield"][0];
            if (Global.ContainsKey("#% increased Defences from equipped Shield"))
                incDefencesShield += Global["#% increased Defences from equipped Shield"][0];
            float shieldArmour = 0;
            float shieldEvasion = 0;
            float shieldES = 0;
            if (incDefencesShield > 0 || incArmourShield > 0 || incESShield > 0)
            {
                List<float> value = OffHand.GetValues("Armour: #");
                if (value.Count > 0)
                    shieldArmour += PercentOfValue(value[0], incArmourShield + incDefencesShield);

                value = OffHand.GetValues("Evasion Rating: #");
                if (value.Count > 0)
                    shieldEvasion += PercentOfValue(value[0], incDefencesShield);

                value = OffHand.GetValues("Energy Shield: #");
                if (value.Count > 0)
                    shieldES += PercentOfValue(value[0], incESShield + incDefencesShield);
            }

            // ( Mana * %mana increases ) + ( ES * ( %ES increases + %mana increases ) * ( %ES more ) )
            // ES to Mana conversion mod (old Eldritch Battery).
            if (Global.ContainsKey("Converts all Energy Shield to Mana"))
            {
                es = IncreaseValueByPercentage(es, incES + incMana);
                es += shieldES;
                if (moreES > 0)
                    es = IncreaseValueByPercentage(es, moreES);
                if (lessArmourAndES > 0)
                    es = IncreaseValueByPercentage(es, -lessArmourAndES);

                mana = IncreaseValueByPercentage(mana, incMana) + es;
                es = 0;
            }
            else
            {
                mana = IncreaseValueByPercentage(mana, incMana);
                es = IncreaseValueByPercentage(es, incES);
                es += shieldES;
                if (moreES > 0)
                    es = IncreaseValueByPercentage(es, moreES);
                if (lessArmourAndES > 0)
                    es = IncreaseValueByPercentage(es, -lessArmourAndES);
            }

            if (BloodMagic)
                mana = 0;

            ch["Mana: #"] = new List<float>() { RoundValue(mana, 0) };
            ch["Maximum Energy Shield: #"] = new List<float>() { RoundValue(es, 0) };

            // Evasion Rating from level, tree and items.
            float evasion = Global["Evasion Rating: #"][0];
            if (Global.ContainsKey("+# to Evasion Rating"))
                evasion += Global["+# to Evasion Rating"][0];
            // Increase % from dexterity, tree and items.
            float incEvasion = Global["#% increased Evasion Rating"][0];
            float incEvasionAndArmour = 0;
            if (Global.ContainsKey("#% increased Evasion Rating and Armour"))
                incEvasionAndArmour += Global["#% increased Evasion Rating and Armour"][0];

            float armour = 0;
            float armourProjectile = 0;
            // Armour from items.
            if (Global.ContainsKey("Armour: #"))
                armour += Global["Armour: #"][0];
            if (Global.ContainsKey("+# to Armour"))
                armour += Global["+# to Armour"][0];
            float incArmour = 0;
            float incArmourProjectile = 0;
            if (Global.ContainsKey("#% increased Armour"))
                incArmour += Global["#% increased Armour"][0];
            if (Global.ContainsKey("#% increased Armour against Projectiles"))
                incArmourProjectile += Global["#% increased Armour against Projectiles"][0];
            // Enable armour against projectile calculations once there is some Armour against Projectiles modifier.
            if (incArmourProjectile != 0)
                armourProjectile = armour;

            // Final Armour = Base Evasion * ( 1 + % increased Evasion Rating + % increased Armour + % increased Evasion Rating and Armour )
            //              + Base Armour  * ( 1 + % increased Armour                              + % increased Evasion Rating and Armour )
            // @see http://pathofexile.gamepedia.com/Iron_Reflexes
            if (IronReflexes)
            {
                // Substract "#% increased Evasion Rating" from Dexterity (it's not being applied).
                incEvasion -= Implicit["#% increased Evasion Rating"][0];
                armour = IncreaseValueByPercentage(armour, incArmour + incEvasionAndArmour) + IncreaseValueByPercentage(evasion, incEvasion + incArmour + incEvasionAndArmour);
                armour += shieldArmour + shieldEvasion;
                if (armourProjectile > 0)
                {
                    armourProjectile = IncreaseValueByPercentage(armourProjectile, incArmour + incArmourProjectile + incEvasionAndArmour) + IncreaseValueByPercentage(evasion, incEvasion + incArmour + incEvasionAndArmour);
                    armourProjectile += shieldArmour + shieldEvasion;
                }
                evasion = 0;
            }
            else
            {
                evasion = IncreaseValueByPercentage(evasion, incEvasion + incEvasionAndArmour) + shieldEvasion;
                armour = IncreaseValueByPercentage(armour, incArmour + incEvasionAndArmour) + shieldArmour;
                if (armourProjectile > 0)
                    armourProjectile = IncreaseValueByPercentage(armourProjectile, incArmour + incArmourProjectile + incEvasionAndArmour) + shieldArmour;
            }
            if (lessArmourAndES > 0)
            {
                armour = IncreaseValueByPercentage(armour, -lessArmourAndES);
                if (armourProjectile > 0)
                    armourProjectile = IncreaseValueByPercentage(armourProjectile, -lessArmourAndES);
            }

            if (armour > 0)
            {
                def["Armour: #"] = new List<float>() { RoundValue(armour, 0) };
                def["Estimated Physical Damage reduction: #%"] = new List<float>() { RoundValue(PhysicalDamageReduction(Level, RoundValue(armour, 0)), 0) };
            }
            if (armourProjectile > 0)
            {
                def["Armour against Projectiles: #"] = new List<float>() { RoundValue(armourProjectile, 0) };
                def["Estimated Physical Damage reduction against Projectiles: #%"] = new List<float>() { RoundValue(PhysicalDamageReduction(Level, RoundValue(armourProjectile, 0)), 0) };
            }
            if (evasion > 0)
                def["Evasion Rating: #"] = new List<float>() { RoundValue(evasion, 0) };
            float chanceToEvade = ChanceToEvade(Level, RoundValue(evasion, 0));
            if (chanceToEvade > 0)
            {
                // Arrow Dancing keystone.
                float chanceToEvadeMelee = chanceToEvade, chanceToEvadeProjectile = chanceToEvade;

                if (Global.ContainsKey("#% less chance to Evade Melee Attacks"))
                    chanceToEvadeMelee = IncreaseValueByPercentage(chanceToEvadeMelee, -Global["#% less chance to Evade Melee Attacks"][0]);
                if (Global.ContainsKey("#% more chance to Evade Melee Attacks"))
                    chanceToEvadeMelee = IncreaseValueByPercentage(chanceToEvadeMelee, Global["#% more chance to Evade Melee Attacks"][0]);
                if (Global.ContainsKey("#% less chance to Evade Projectile Attacks"))
                    chanceToEvadeProjectile = IncreaseValueByPercentage(chanceToEvadeProjectile, -Global["#% less chance to Evade Projectile Attacks"][0]);
                if (Global.ContainsKey("#% more chance to Evade Projectile Attacks"))
                    chanceToEvadeProjectile = IncreaseValueByPercentage(chanceToEvadeProjectile, Global["#% more chance to Evade Projectile Attacks"][0]);
                // Chance cannot be less than 5% and more than 95%.
                if (chanceToEvadeMelee < 5f) chanceToEvadeMelee = 5f;
                else if (chanceToEvadeMelee > 95f) chanceToEvadeMelee = 95f;
                if (chanceToEvadeProjectile < 5f) chanceToEvadeProjectile = 5f;
                else if (chanceToEvadeProjectile > 95f) chanceToEvadeProjectile = 95f;

                if (chanceToEvadeMelee == chanceToEvadeProjectile)
                    def["Estimated chance to Evade Attacks: #%"] = new List<float>() { RoundValue(chanceToEvadeMelee, 0) };
                else
                {
                    def["Estimated chance to Evade Melee Attacks: #%"] = new List<float>() { RoundValue(chanceToEvadeMelee, 0) };
                    def["Estimated chance to Evade Projectile Attacks: #%"] = new List<float>() { RoundValue(chanceToEvadeProjectile, 0) };
                }
            }

            // Dodge Attacks and Spells.
            float chanceToDodgeAttacks = 0;
            float chanceToDodgeSpells = 0;
            if (Acrobatics)
                chanceToDodgeAttacks += Global["#% Chance to Dodge Attacks. #% less Armour and Energy Shield, #% less Chance to Block Spells and Attacks"][0];
            if (Global.ContainsKey("#% additional chance to Dodge Attacks"))
                chanceToDodgeAttacks += Global["#% additional chance to Dodge Attacks"][0];
            if (Global.ContainsKey("#% Chance to Dodge Spell Damage"))
                chanceToDodgeSpells += Global["#% Chance to Dodge Spell Damage"][0];
            if (chanceToDodgeAttacks > 0)
                def["Chance to Dodge Attacks: #%"] = new List<float>() { chanceToDodgeAttacks };
            if (chanceToDodgeSpells > 0)
                def["Chance to Dodge Spells: #%"] = new List<float>() { chanceToDodgeSpells };

            // Energy Shield Recharge per Second.
            // @see http://pathofexile.gamepedia.com/Energy_shield
            if (es > 0)
            {
                def["Maximum Energy Shield: #"] = new List<float>() { RoundValue(es, 0) };

                float esRecharge = RoundValue(es, 0) / 3; // By default, energy shield recharges at a rate equal to a third of the character's maximum energy shield per second.
                def["Energy Shield Recharge per Second: #"] = new List<float>() { RoundValue(esRecharge, 1) };
                float esDelay = 6; // By default, the delay period for energy shield to begin to recharge is 6 seconds.
                float esOccurrence = 0;
                if (Global.ContainsKey("#% faster start of Energy Shield Recharge"))
                    esOccurrence += Global["#% faster start of Energy Shield Recharge"][0];
                if (Global.ContainsKey("#% slower start of Energy Shield Recharge"))
                    esOccurrence -= Global["#% slower start of Energy Shield Recharge"][0];
                esDelay = esDelay * 100 / (100 + esOccurrence);
                if (esOccurrence != 0)
                    def["Energy Shield Recharge Occurrence modifier: " + (esOccurrence > 0 ? "+" : "") + "#%"] = new List<float>() { esOccurrence };
                def["Energy Shield Recharge Delay: #s"] = new List<float>() { RoundValue(esDelay, 1) };
            }

            // Life Regeneration.
            float lifeRegen = 0;
            float lifeRegenFlat = 0;
            if (Global.ContainsKey("#% of Life Regenerated per Second"))
                lifeRegen += Global["#% of Life Regenerated per Second"][0];
            if (Global.ContainsKey("# Life Regenerated per second"))
                lifeRegenFlat += Global["# Life Regenerated per second"][0];

            if (VaalPact)
                lifeRegen = 0;

            if (ZealotsOath)
            {
                if (es > 0 && lifeRegen + lifeRegenFlat > 0)
                    def["Energy Shield Regeneration per Second: #"] = new List<float>() { RoundValue(PercentOfValue(RoundValue(es, 0), lifeRegen), 1) + lifeRegenFlat };
            }
            else
            {
                if (! ChaosInoculation && lifeRegen + lifeRegenFlat > 0)
                    def["Life Regeneration per Second: #"] = new List<float>() { RoundValue(PercentOfValue(RoundValue(life, 0), lifeRegen), 1) + lifeRegenFlat };
            }

            // Mana Regeneration.
            if (mana > 0)
            {
                float manaRegen = PercentOfValue(RoundValue(mana, 0), 1.75f);
                // manaRegen += ClarityManaRegenerationPerSecond; // Clarity provides flat mana regeneration bonus.
                float incManaRegen = 0;
                if (Global.ContainsKey("#% increased Mana Regeneration Rate"))
                    incManaRegen += Global["#% increased Mana Regeneration Rate"][0];
                manaRegen = IncreaseValueByPercentage(manaRegen, incManaRegen);
                def["Mana Regeneration per Second: #"] = new List<float>() { RoundValue(manaRegen, 1) };
            }

            // Character attributes.
            ch["Strength: #"] = Global["+# to Strength"];
            ch["Dexterity: #"] = Global["+# to Dexterity"];
            ch["Intelligence: #"] = Global["+# to Intelligence"];

            // Shield, Staff and Dual Wielding detection.
            bool hasShield = OffHand.IsShield();

            // Resistances.
            float maxResistFire = 75;
            float maxResistCold = 75;
            float maxResistLightning = 75;
            float maxResistChaos = 75;
            float resistFire = 0;
            float resistCold = 0;
            float resistLightning = 0;
            float resistChaos = 0;
            // Penalties to resistances at difficulty levels.
            if (difficultyCruel)
                resistFire = resistCold = resistLightning = resistChaos = -20;
            else if (difficultyMerciless)
                resistFire = resistCold = resistLightning = resistChaos = -60;
            if (banditNormalKraityn) // Bandit.
            {
                resistFire += 8;
                resistCold += 8;
                resistLightning += 8;
            }
            if (Global.ContainsKey("+#% to Fire Resistance"))
                resistFire += Global["+#% to Fire Resistance"][0];
            if (Global.ContainsKey("+#% to Cold Resistance"))
                resistCold += Global["+#% to Cold Resistance"][0];
            if (Global.ContainsKey("+#% to Lightning Resistance"))
                resistLightning += Global["+#% to Lightning Resistance"][0];
            if (Global.ContainsKey("+#% to Chaos Resistance"))
                resistChaos += Global["+#% to Chaos Resistance"][0];
            if (Global.ContainsKey("+#% to Fire and Cold Resistances")) // Two-Stone Ring.
            {
                float value = Global["+#% to Fire and Cold Resistances"][0];
                resistFire += value;
                resistCold += value;
            }
            if (Global.ContainsKey("+#% to Fire and Lightning Resistances")) // Two-Stone Ring.
            {
                float value = Global["+#% to Fire and Lightning Resistances"][0];
                resistFire += value;
                resistLightning += value;
            }
            if (Global.ContainsKey("+#% to Cold and Lightning Resistances")) // Two-Stone Ring.
            {
                float value = Global["+#% to Cold and Lightning Resistances"][0];
                resistCold += value;
                resistLightning += value;
            }
            if (Global.ContainsKey("+#% to all Elemental Resistances"))
            {
                float value = Global["+#% to all Elemental Resistances"][0];
                resistFire += value;
                resistCold += value;
                resistLightning += value;
            }
            if (hasShield && Global.ContainsKey("+#% Elemental Resistances while holding a Shield"))
            {
                float value = Global["+#% Elemental Resistances while holding a Shield"][0];
                resistFire += value;
                resistCold += value;
                resistLightning += value;
            }
            if (Global.ContainsKey("+#% to maximum Fire Resistance"))
                maxResistFire += Global["+#% to maximum Fire Resistance"][0];
            if (Global.ContainsKey("+#% to maximum Cold Resistance"))
                maxResistCold += Global["+#% to maximum Cold Resistance"][0];
            if (Global.ContainsKey("+#% to maximum Lightning Resistance"))
                maxResistLightning += Global["+#% to maximum Lightning Resistance"][0];
            if (ChaosInoculation)
                maxResistChaos = resistChaos = 100;
            def["Fire Resistance: #% (#%)"] = new List<float>() { MaximumValue(resistFire, maxResistFire), resistFire };
            def["Cold Resistance: #% (#%)"] = new List<float>() { MaximumValue(resistCold, maxResistCold), resistCold };
            def["Lightning Resistance: #% (#%)"] = new List<float>() { MaximumValue(resistLightning, maxResistLightning), resistLightning };
            def["Chaos Resistance: #% (#%)"] = new List<float>() { MaximumValue(resistChaos, maxResistChaos), resistChaos };

            // Chance to Block Attacks and Spells.
            // Block chance is capped at 75%. The chance to block spells is also capped at 75%.
            // @see http://pathofexile.gamepedia.com/Blocking
            float maxChanceBlockAttacks = 75;
            float maxChanceBlockSpells = 75;
            float maxChanceBlockProjectiles = 75;
            float chanceBlockAttacks = 0;
            float chanceBlockSpells = 0;
            float chanceBlockProjectiles = 0;
            if (Global.ContainsKey("+#% to maximum Block Chance"))
            {
                maxChanceBlockAttacks += Global["+#% to maximum Block Chance"][0];
                maxChanceBlockSpells += Global["+#% to maximum Block Chance"][0];
                maxChanceBlockProjectiles += Global["+#% to maximum Block Chance"][0];
            }
            if (hasShield)
            {
                List<float> values = OffHand.GetValues("Chance to Block: #%");
                if (values.Count > 0) chanceBlockAttacks += values[0];
            }
            else if (IsWieldingStaff)
            {
                List<float> values = MainHand.GetValues("#% Chance to Block");
                if (values.Count > 0) chanceBlockAttacks += values[0];
            }
            else if (IsDualWielding)
                chanceBlockAttacks += 15; // When dual wielding, the base chance to block is 15% no matter which weapons are used.
            if (hasShield && Global.ContainsKey("#% additional Chance to Block with Shields"))
                chanceBlockAttacks += Global["#% additional Chance to Block with Shields"][0];
            if (IsWieldingStaff && Global.ContainsKey("#% additional Block Chance With Staves"))
                chanceBlockAttacks += Global["#% additional Block Chance With Staves"][0];
            if (IsDualWielding && Global.ContainsKey("#% additional Chance to Block while Dual Wielding"))
                chanceBlockAttacks += Global["#% additional Chance to Block while Dual Wielding"][0];
            if ((IsDualWielding || hasShield) && Global.ContainsKey("#% additional Chance to Block while Dual Wielding or holding a Shield"))
                chanceBlockAttacks += Global["#% additional Chance to Block while Dual Wielding or holding a Shield"][0];
            if (Global.ContainsKey("#% of Block Chance applied to Spells"))
                chanceBlockSpells = PercentOfValue(chanceBlockAttacks, Global["#% of Block Chance applied to Spells"][0]);
            if (hasShield && Global.ContainsKey("#% additional Chance to Block Spells with Shields"))
                chanceBlockSpells += Global["#% additional Chance to Block Spells with Shields"][0];
            if (Global.ContainsKey("+#% additional Block Chance against Projectiles"))
                chanceBlockProjectiles = chanceBlockAttacks + Global["+#% additional Block Chance against Projectiles"][0];
            if (Acrobatics)
            {
                float lessChanceBlock = Global["#% Chance to Dodge Attacks. #% less Armour and Energy Shield, #% less Chance to Block Spells and Attacks"][2];
                chanceBlockAttacks = IncreaseValueByPercentage(chanceBlockAttacks, -lessChanceBlock);
                chanceBlockSpells = IncreaseValueByPercentage(chanceBlockSpells, -lessChanceBlock);
            }
            if (chanceBlockAttacks > 0)
                def["Chance to Block Attacks: #%"] = new List<float>() { MaximumValue(RoundValue(chanceBlockAttacks, 0), maxChanceBlockAttacks) };
            if (chanceBlockSpells > 0)
                def["Chance to Block Spells: #%"] = new List<float>() { MaximumValue(RoundValue(chanceBlockSpells, 0), maxChanceBlockSpells) };
            if (chanceBlockProjectiles > 0)
                def["Chance to Block Projectile Attacks: #%"] = new List<float>() { MaximumValue(RoundValue(chanceBlockProjectiles, 0), maxChanceBlockProjectiles) };

            // Elemental stataus ailments.
            float igniteAvoidance = 0;
            float chillAvoidance = 0;
            float freezeAvoidance = 0;
            float shockAvoidance = 0;
            if (Global.ContainsKey("#% chance to Avoid being Ignited"))
                igniteAvoidance += Global["#% chance to Avoid being Ignited"][0];
            if (Global.ContainsKey("#% chance to Avoid being Chilled"))
                chillAvoidance += Global["#% chance to Avoid being Chilled"][0];
            if (Global.ContainsKey("#% chance to Avoid being Frozen"))
                freezeAvoidance += Global["#% chance to Avoid being Frozen"][0];
            if (Global.ContainsKey("#% chance to Avoid being Shocked"))
                shockAvoidance += Global["#% chance to Avoid being Shocked"][0];
            if (Global.ContainsKey("#% chance to Avoid Elemental Status Ailments"))
            {
                float value = Global["#% chance to Avoid Elemental Status Ailments"][0];
                igniteAvoidance += value;
                chillAvoidance += value;
                freezeAvoidance += value;
                shockAvoidance += value;
            }
            if (Global.ContainsKey("Cannot be Ignited"))
                igniteAvoidance = 100;
            if (Global.ContainsKey("Cannot be Chilled"))
                chillAvoidance = 100;
            if (Global.ContainsKey("Cannot be Frozen"))
                freezeAvoidance = 100;
            if (Global.ContainsKey("Cannot be Shocked"))
                shockAvoidance = 100;
            if (igniteAvoidance > 0)
                def["Ignite Avoidance: #%"] = new List<float>() { igniteAvoidance };
            if (chillAvoidance > 0)
                def["Chill Avoidance: #%"] = new List<float>() { chillAvoidance };
            if (freezeAvoidance > 0)
                def["Freeze Avoidance: #%"] = new List<float>() { freezeAvoidance };
            if (shockAvoidance > 0)
                def["Shock Avoidance: #%"] = new List<float>() { shockAvoidance };

            List<ListGroup> groups = new List<ListGroup>();
            groups.Add(new ListGroup(L10n.Message("Character"), ch));
            groups.Add(new ListGroup(L10n.Message("Defense"), def));

            return groups;
        }
示例#60
0
            // Copy constructor.
            Weapon(Weapon weapon)
            {
                Item = weapon.Item;
                Nature = new DamageNature(weapon.Nature);
                Attributes = new AttributeSet(weapon.Attributes);

                foreach (Damage damage in weapon.Deals)
                    Deals.Add(new Damage(damage));
                Added = weapon.Added;
            }