示例#1
0
文件: Choice.cs 项目: zombisaur/iggy
        public Choice(SelectRule rule, Character character)
        {
            this.rule = rule;
            this.character = character;
            this.options = new ObservableCollection<RuleElement>();

            FillItems();
            if (this.rule.Filter != null)
            {
                this.rule.Filter.FilterChanged += OnFilterChanged;
            }
        }
示例#2
0
        public RuleElement(XElement element)
        {
            this.xml      = element;
            this.fullname = Identifier.Get(element.Attribute(XNames.Name).Value + " " + element.Attribute(XNames.Type).Value);
            this.name     = Identifier.Get(element.Attribute(XNames.Name).Value);
            this.type     = Identifier.Get(element.Attribute(XNames.Type).Value);
            this.id       = Identifier.Get(element.Attribute(XNames.InternalID).Value);

            XAttribute attribute = element.Attribute(XNames.Source);

            if (attribute != null)
            {
                this.source = element.Attribute(XNames.Source).Value;
            }

            string description = "";

            foreach (XNode node in element.Nodes())
            {
                if (node.NodeType == System.Xml.XmlNodeType.Element)
                {
                    var subElement = (XElement)node;
                    if (subElement.Name == XNames.Category)
                    {
                        string[] split = subElement.Value.Trim().Split(',');
                        this.category = new Identifier[split.Length];
                        for (int i = 0; i < split.Length; i++)
                        {
                            category[i] = Identifier.Get(split[i]);
                        }
                    }
                    else if (subElement.Name == XNames.Specific)
                    {
                        this.specifics[subElement.Attribute(XNames.Name).Value] = subElement.Value;
                    }
                    else if (subElement.Name == XNames.Flavor)
                    {
                        this.flavor = subElement.Value;
                    }
                    else if (subElement.Name == XNames.PrintPrereqs)
                    {
                        this.printPrereqs = subElement.Value;
                    }
                    else if (subElement.Name == XNames.Prereqs)
                    {
                        this.preReqs = subElement.Value.Trim().Split(',');
                    }
                    else if (subElement.Name == XNames.Rules)
                    {
                        foreach (XElement ruleElement in subElement.Elements())
                        {
                            if (ruleElement.Name == XNames.Grant)
                            {
                                this.rules.Add(GrantRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.TextString)
                            {
                                this.rules.Add(TextStringRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.StatAdd)
                            {
                                this.rules.Add(StatAddRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.Select)
                            {
                                this.rules.Add(SelectRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.Replace)
                            {
                                this.rules.Add(ReplaceRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.Modify)
                            {
                                this.rules.Add(ModifyRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.Drop)
                            {
                                this.rules.Add(DropRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.Suggest)
                            {
                                this.rules.Add(SuggestRule.New(this, ruleElement));
                            }
                            else if (ruleElement.Name == XNames.StatAlias)
                            {
                                this.rules.Add(StatAliasRule.New(this, ruleElement));
                            }
                            else
                            {
                                throw new NotSupportedException("Unsupported rule name: " + ruleElement.Name.ToString());
                            }
                        }
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported element name: " + subElement.Name.ToString());
                    }
                }
                else if (node.NodeType == System.Xml.XmlNodeType.Text)
                {
                    description += node.ToString(SaveOptions.DisableFormatting);
                }
            }

            this.description = description.Trim();
        }