Beispiel #1
0
        public static MagicItem ByName(string name)
        {
            MagicItem item = null;

            if (itemMap.TryGetValue(name, out item))
            {
                return(item);
            }
            return(null);
        }
Beispiel #2
0
 public TreasureItem(TreasureItem t)
 {
     _Name  = t._Name;
     _Value = t._Value;
     if (t.Spell != null)
     {
         _Spell = t.Spell;
     }
     if (t.MagicItem != null)
     {
         _MagicItem = t.MagicItem;
     }
 }
Beispiel #3
0
 public void CopyFrom(MagicItem magicItem)
 {
     if (magicItem == null)
     {
         return;
     }
     _DetailsID         = magicItem._DetailsID;
     _Name              = magicItem._Name;
     _Aura              = magicItem._Aura;
     _CL                = magicItem._CL;
     _Slot              = magicItem._Slot;
     _Price             = magicItem._Price;
     _Weight            = magicItem._Weight;
     _Description       = magicItem._Description;
     _Requirements      = magicItem._Requirements;
     _Cost              = magicItem._Cost;
     _Group             = magicItem._Group;
     _Source            = magicItem._Source;
     _FullText          = magicItem._FullText;
     _Destruction       = magicItem._Destruction;
     _MinorArtifactFlag = magicItem._MinorArtifactFlag;
     _MajorArtifactFlag = magicItem._MajorArtifactFlag;
     _Abjuration        = magicItem._Abjuration;
     _Conjuration       = magicItem._Conjuration;
     _Divination        = magicItem._Divination;
     _Enchantment       = magicItem._Enchantment;
     _Evocation         = magicItem._Evocation;
     _Necromancy        = magicItem._Necromancy;
     _Transmutation     = magicItem._Transmutation;
     _AuraStrength      = magicItem._AuraStrength;
     _WeightValue       = magicItem._WeightValue;
     _PriceValue        = magicItem._PriceValue;
     _CostValue         = magicItem._CostValue;
     _AL                = magicItem._AL;
     _Int               = magicItem._Int;
     _Wis               = magicItem._Wis;
     _Cha               = magicItem._Cha;
     _Ego               = magicItem._Ego;
     _Communication     = magicItem._Communication;
     _Senses            = magicItem._Senses;
     _Powers            = magicItem._Powers;
     _MagicItems        = magicItem._MagicItems;
     _DescHTML          = magicItem._DescHTML;
     _Mythic            = magicItem._Mythic;
     _LegendaryWeapon   = magicItem._LegendaryWeapon;
     _DBLoaderID        = magicItem._DBLoaderID;
 }
Beispiel #4
0
        public static List <MagicItem> LoadMagicItemsFromXml(string filename)
        {
            XElement last = null;

            try
            {
                List <MagicItem> magicItems = new List <MagicItem>();
    #if ANDROID
                XDocument doc = XDocument.Load(new StreamReader(CoreContext.Context.Assets.Open(filename)));
    #elif MONO
                XDocument doc = XDocument.Load(Path.Combine(XmlLoader <MagicItem> .AssemblyDir, filename));
    #else
                XDocument doc = XDocument.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filename));
    #endif

                foreach (var v in doc.Descendants("MagicItem"))
                {
                    last = v;
                    MagicItem m = new MagicItem();

                    m._DetailsID = v.ElementIntValue("id");

                    Debug.Assert(m._DetailsID != 0);

                    m._Name = v.ElementValue("Name");
                    if (v.ElementValue("CL") != "-")
                    {
                        m._CL = v.ElementIntValue("CL");
                    }
                    else
                    {
                        m._CL = 0;
                    }
                    m._Group      = v.ElementValue("Group");
                    m._Source     = v.ElementValue("Source");
                    m._MagicItems = v.ElementValue("MagicItems");

                    magicItems.Add(m);
                }
                return(magicItems);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #5
0
 public static bool TryByID(bool custom, int id, out MagicItem s)
 {
     s = ByID(custom, id);
     return(s != null);
 }
Beispiel #6
0
 public MagicItem(MagicItem m)
 {
     CopyFrom(m);
 }
Beispiel #7
0
        public List <Block> CreateBlocks(MagicItem item, bool showTitle)
        {
            List <Block> blocks = new List <Block>();

            if (showTitle)
            {
                blocks.Add(CreateHeaderParagraph(item.Name, item.Group));
            }


            Paragraph details = new Paragraph();

            details.Margin = new Thickness(0, 2, 0, 0);

            CreateItemIfNotNull(details.Inlines, "Aura ", true, item.Aura, " ", false);
            CreateItemIfNotNull(details.Inlines, "[", false, item.AuraStrength, "]; ", false);
            CreateItemIfNotNull(details.Inlines, "CL ", true, (item.CL == -1)?"Varies":PastTenseNumber(item.CL), "", true);
            CreateItemIfNotNull(details.Inlines, "Slot ", true, item.Slot, "; ", false);
            CreateItemIfNotNull(details.Inlines, "Price ", true, item.Price, "; ", false);
            CreateItemIfNotNull(details.Inlines, "Weight ", true, item.Weight, "", true);


            blocks.Add(details);

            if (NotNullString(item.DescHTML) || NotNullString(item.Description))
            {
                blocks.AddRange(CreateSectionHeader("DESCRIPTION"));

                if (NotNullString(item.DescHTML))
                {
                    blocks.AddRange(CreateFlowFromDescription(item.DescHTML));
                }
                else
                {
                    Paragraph description = new Paragraph();
                    description.Margin = new Thickness(0, 2, 0, 0);

                    string text = FixBodyString(item.Description);

                    CreateItemIfNotNull(description.Inlines, null, true, text, null, true);


                    blocks.Add(description);
                }
            }

            if (item.Requirements != null && item.Requirements.Length > 0 &&
                item.Cost != null && item.Cost.Length > 0)
            {
                blocks.AddRange(CreateSectionHeader("CONSTRUCTION"));

                Paragraph construction = new Paragraph();
                construction.Margin = new Thickness(0, 2, 0, 0);

                CreateItemIfNotNull(construction.Inlines, "Requirements ", true, item.Requirements, "; ", false);
                CreateItemIfNotNull(construction.Inlines, "Cost ", true, item.Cost, "", true);

                blocks.Add(construction);
            }

            if (NotNullString(item.Destruction))
            {
                blocks.AddRange(CreateSectionHeader("DESTRUCTION"));

                Paragraph desctruction = new Paragraph();
                desctruction.Margin = new Thickness(0, 2, 0, 0);


                CreateItemIfNotNull(desctruction.Inlines, null, false, FixBodyString(item.Destruction), null, true);


                blocks.Add(desctruction);
            }

            if (SourceInfo.GetSourceType(item.Source) != SourceType.Core)
            {
                Paragraph source = new Paragraph();
                source.Margin = new Thickness(0, 2, 0, 0);
                CreateItemIfNotNull(source.Inlines, "Source: ", SourceInfo.GetSource(item.Source));
                blocks.Add(source);
            }


            return(blocks);
        }
Beispiel #8
0
 public List <Block> CreateBlocks(MagicItem item)
 {
     return(CreateBlocks(item, true));
 }
Beispiel #9
0
        public static String CreateHtml(MagicItem item, bool showTitle)
        {
            StringBuilder blocks = new StringBuilder();

            blocks.CreateHtmlHeader();

            if (showTitle)
            {
                blocks.CreateHeader(item.Name, item.Group);
            }


            /*Paragraph details = new Paragraph();
             * details.Margin = new Thickness(0, 2, 0, 0);*/

            blocks.AppendOpenTag("p");
            blocks.CreateItemIfNotNull("Aura ", true, item.Aura, " ", false);
            blocks.CreateItemIfNotNull("[", false, item.AuraStrength, "]; ", false);
            blocks.CreateItemIfNotNull("CL ", true, item.CL.PastTense(), "", true);
            blocks.CreateItemIfNotNull("Slot ", true, item.Slot, "; ", false);
            blocks.CreateItemIfNotNull("Price ", true, item.Price, "; ", false);
            blocks.CreateItemIfNotNull("Weight ", true, item.Weight, "", true);
            blocks.AppendCloseTag("p");



            if (!String.IsNullOrEmpty(item.DescHTML) || !String.IsNullOrEmpty(item.Description))
            {
                blocks.CreateSectionHeader("DESCRIPTION");

                if (!String.IsNullOrEmpty(item.DescHTML) && item.DescHTML != "NULL")
                {
                    blocks.AppendOpenTagWithClass("p", "description");
                    blocks.Append(item.DescHTML);
                    blocks.AppendCloseTag("p");
                }
                else if (item.Description != "NULL")
                {
                    blocks.AppendOpenTagWithClass("p", "description");

                    blocks.CreateItemIfNotNull(null, true, item.Description, null, true);


                    blocks.AppendCloseTag("p");
                }
            }

            if (item.Requirements != null && item.Requirements.Length > 0 &&
                item.Cost != null && item.Cost.Length > 0)
            {
                blocks.CreateSectionHeader("CONSTRUCTION");


                blocks.AppendOpenTag("p");
                blocks.CreateItemIfNotNull("Requirements ", true, item.Requirements, "; ", false);
                blocks.CreateItemIfNotNull("Cost ", true, item.Cost, "", true);
                blocks.AppendCloseTag("p");
            }

            if (!String.IsNullOrEmpty(item.Destruction) && item.Destruction != "NULL")
            {
                blocks.CreateSectionHeader("DESTRUCTION");


                blocks.AppendOpenTag("p");

                blocks.CreateItemIfNotNull(null, false, item.Destruction, null, true);

                blocks.AppendCloseTag("p");
            }

            if (SourceInfo.GetSourceType(item.Source) != SourceType.Core)
            {
                blocks.CreateItemIfNotNull("Source: ", SourceInfo.GetSource(item.Source));
            }

            blocks.CreateHtmlFooter();

            return(blocks.ToString());
        }
Beispiel #10
0
 public static String CreateHtml(MagicItem item)
 {
     return(CreateHtml(item, true));
 }