Exemplo n.º 1
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="group">Market Group the Blueprint will be a member of.</param>
        /// <param name="src">Source serializable blueprint.</param>
        internal Blueprint(MarketGroup group, SerializableBlueprint src)
            : base(group, src)
        {
            RunsPerCopy              = src.MaxProductionLimit;
            ProducesItem             = StaticItems.GetItemByID(src.ProduceItemID);
            ProductionTime           = src.ProductionTime;
            ResearchCopyTime         = src.ResearchCopyTime;
            ResearchMaterialTime     = src.ResearchMaterialTime;
            ResearchProductivityTime = src.ResearchProductivityTime;
            ResearchInventionTime    = src.InventionTime;
            ReverseEngineeringTime   = src.ReverseEngineeringTime;

            // Invented blueprints
            m_inventBlueprints = new Dictionary <int, double>(src.InventionTypeIDs?.Count ?? 0);
            if (src.InventionTypeIDs != null && src.InventionTypeIDs.Any())
            {
                m_inventBlueprints.AddRange(src.InventionTypeIDs);
            }

            // Materials prerequisites
            m_materialRequirements =
                new FastList <StaticRequiredMaterial>(src.ReqMaterial?.Count ?? 0);
            if (src.ReqMaterial == null)
            {
                return;
            }

            foreach (SerializableRequiredMaterial prereq in src.ReqMaterial)
            {
                m_materialRequirements.Add(new StaticRequiredMaterial(prereq));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="src">The source.</param>
        /// <exception cref="System.ArgumentNullException">src</exception>
        public Material(SerializableMaterialQuantity src)
        {
            src.ThrowIfNull(nameof(src));

            Item     = StaticItems.GetItemByID(src.ID);
            Quantity = src.Quantity;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize static masteries.
        /// </summary>
        internal static void Load()
        {
            MasteriesDatafile datafile = Util.DeserializeDatafile <MasteriesDatafile>(
                DatafileConstants.MasteriesDatafile);

            foreach (SerializableMasteryShip srcShip in datafile.MasteryShips)
            {
                Ship ship = StaticItems.GetItemByID(srcShip.ID) as Ship;
                if (ship != null)
                {
                    s_masteryShipsByID[ship.ID] = new MasteryShip(srcShip, ship);
                }
            }

            GlobalDatafileCollection.OnDatafileLoaded();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="group"></param>
        /// <param name="src"></param>
        internal Implant(MarketGroup group, SerializableItem src)
            : base(group, src)
        {
            // Gets the slot
            EvePropertyValue?slotProperty = Properties[DBConstants.ImplantSlotPropertyID];

            if (slotProperty == null)
            {
                return;
            }

            Slot = (ImplantSlots)(slotProperty.Value.Int64Value - 1);

            // Sets the implant bonus
            SetImplantBonus();

            // Adds itself to the implants slot
            StaticItems.GetImplants(Slot).Add(this);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="group"></param>
        /// <param name="src"></param>
        internal Implant(MarketGroup group, SerializableItem src)
            : base(group, src)
        {
            // Gets the slot
            var slotProperty = this.Properties[DBConstants.ImplantSlotPropertyID];

            m_implantSlot = (slotProperty == null ? ImplantSlots.None : (ImplantSlots)(slotProperty.Value.IValue - 1));

            // Get the bonus
            switch (m_implantSlot)
            {
            case ImplantSlots.Charisma:
                m_bonus = this.Properties[DBConstants.CharismaModifierPropertyID].Value.IValue;
                break;

            case ImplantSlots.Intelligence:
                m_bonus = this.Properties[DBConstants.IntelligenceModifierPropertyID].Value.IValue;
                break;

            case ImplantSlots.Memory:
                m_bonus = this.Properties[DBConstants.MemoryModifierPropertyID].Value.IValue;
                break;

            case ImplantSlots.Perception:
                m_bonus = this.Properties[DBConstants.PerceptionModifierPropertyID].Value.IValue;
                break;

            case ImplantSlots.Willpower:
                m_bonus = this.Properties[DBConstants.WillpowerModifierPropertyID].Value.IValue;
                break;

            default:
                break;
            }

            // Adds itself to the implants slot
            StaticItems.GetImplants(m_implantSlot).Add(this);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the material's name.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        private static string GetName(int id)
        {
            Item item = StaticItems.GetItemByID(id);

            return(item?.Name ?? String.Empty);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Format a property value as shown in EVE.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private String Format(string value)
        {
            float numericValue;

            if (!value.TryParseInv(out numericValue))
            {
                return(value);
            }

            try
            {
                // Format a value of Packaged Volume
                if (Name == DBConstants.PackagedVolumePropertyName)
                {
                    return($"{numericValue:N1} {Unit}");
                }

                // Format a value of Structure Volume
                if (ID == DBConstants.VolumePropertyID)
                {
                    return(numericValue <= 1000
                        ? $"{numericValue:N2} {Unit}"
                        : $"{numericValue:#,##0.0##} {Unit}");
                }

                // Format a value of Capacitor Capacity
                if (ID == DBConstants.CapacitorCapacityPropertyID)
                {
                    return($"{Math.Floor(numericValue):N0} {Unit}");
                }

                // Format a value of Ships Warp Speed
                if (ID == DBConstants.ShipWarpSpeedPropertyID)
                {
                    return($"{numericValue:N2} {Unit}");
                }

                switch (UnitID)
                {
                // Format a value of Mass
                case DBConstants.MassUnitID:
                    return(numericValue <= 1000
                            ? $"{numericValue:#,##0.0#} {Unit}"
                            : $"{numericValue:N0} {Unit}");

                // Format a value of Millseconds
                case DBConstants.MillsecondsUnitID:
                    return($"{numericValue / 1000:N2} {Unit}");

                // Format a value of Absolute Percentage
                case DBConstants.AbsolutePercentUnitID:
                    return($"{numericValue * 100} {Unit}");

                // Format a value of Inverse Absolute Percentage
                case DBConstants.InverseAbsolutePercentUnitID:
                    return($"{(1 - numericValue) * 100} {Unit}");

                // Format a value of Modifier Percentage
                case DBConstants.ModifierPercentUnitID:
                    return($"{(numericValue - 1) * 100:0.###} {Unit}");

                // Format a value of Inverse Modifier Percentage
                case DBConstants.InversedModifierPercentUnitID:
                    return($"{(1 - numericValue) * 100:0.###} {Unit}");

                // A reference to a group (groupID), it has been pre-transformed on XmlGenerator
                case DBConstants.GroupIDUnitID:
                    return(value);

                // A reference to an item or a skill (typeID)
                case DBConstants.TypeUnitID:
                    int id;
                    return((!value.TryParseInv(out id) || id == 0) ? string.Empty :
                           StaticItems.GetItemName(id));

                // Format a Sizeclass ("1=small 2=medium 3=l")
                case DBConstants.SizeclassUnitID:
                    int size;
                    value.TryParseInv(out size);
                    switch (size)
                    {
                    case 1:
                        return("Small");

                    case 2:
                        return("Medium");

                    case 3:
                        return("Large");

                    case 4:
                        return("Extra Large");

                    default:
                        return(EveMonConstants.UnknownText);
                    }

                // Format all other values (use of thousand and decimal separator)
                default:
                    return($"{numericValue:#,##0.###} {Unit}");
                }
            }
            catch (FormatException)
            {
                return("N/A");
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Format a property value as shown in EVE
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private string Format(string value)
        {
            if (float.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out m_value))
            {
                try
                {
                    // Format a value of Structure Volume
                    if (m_id == 161)
                    {
                        return(String.Format(CultureConstants.DefaultCulture, "{0:#,##0.0##} {1}", m_value, m_unit));
                    }

                    // Format a value of Capacitor Capacity
                    if (m_id == 482)
                    {
                        return(String.Format(CultureConstants.DefaultCulture, "{0:#,##0} {1}", Math.Floor(m_value), m_unit));
                    }

                    // Format a value of Ships Warp Speed
                    if (m_id == 1281)
                    {
                        return(String.Format(CultureConstants.DefaultCulture, "{0:0.0#} {1}", m_value, m_unit));
                    }

                    switch (m_unitID)
                    {
                    // Format a value of Mass
                    case 2:
                        if (m_value <= 1000)
                        {
                            return(String.Format(CultureConstants.DefaultCulture, "{0:#,##0.0#} {1}", m_value, m_unit));
                        }
                        else
                        {
                            return(String.Format(CultureConstants.DefaultCulture, "{0:#,##0} {1}", m_value, m_unit));
                        }

                    // Format a value of Millseconds
                    case 101:
                        return(String.Format(CultureConstants.DefaultCulture, "{0:#,##0.00} {1}", m_value / 1000, m_unit));

                    // Format a value of Absolute Percentage
                    case 127:
                        return(String.Format(CultureConstants.DefaultCulture, "{0} {1}", (m_value) * 100, m_unit));

                    // Format a value of Inverse Absolute Percentage
                    case 108:
                        return(String.Format(CultureConstants.DefaultCulture, "{0} {1}", (1 - m_value) * 100, m_unit));

                    // Format a value of Modifier Percentage
                    case 109:
                        return(String.Format(CultureConstants.DefaultCulture, "{0:0.###} {1}", (m_value - 1) * 100, m_unit));

                    // Format a value of Inverse Modifier Percentage
                    case 111:
                        return(String.Format(CultureConstants.DefaultCulture, "{0:0.###} {1}", (1 - m_value) * 100, m_unit));

                    // A reference to a group, it has been pre-transformed on XmlGenerator.
                    case 115:     // "groupID"
                        return(value);

                    // A reference to an item or a skill.
                    case 116:     // "typeID"
                        int id = Int32.Parse(value);
                        return(StaticItems.GetItemByID(id).Name);

                    // Format a Sizeclass
                    case 117:     // "1=small 2=medium 3=l"
                        int size = Int32.Parse(value);
                        switch (size)
                        {
                        case 1:
                            return("Small");

                        case 2:
                            return("Medium");

                        case 3:
                            return("Large");

                        case 4:
                            return("Extra Large");

                        default:
                            return("Unknown");
                        }

                    // Format all other values (use of thousand and decimal separator)
                    default:
                        return(String.Format(CultureConstants.DefaultCulture, "{0:#,##0.###} {1}", m_value, m_unit));
                    }
                }
                catch
                {
                    return("Error");
                }
            }
            return(value);
        }
Exemplo n.º 9
0
        private static string GetName(int id)
        {
            Item item = StaticItems.GetItemByID(id);

            return(item != null ? item.Name : String.Empty);
        }
Exemplo n.º 10
0
 public Material(SerializableMaterialQuantity src)
 {
     m_product  = StaticItems.GetItem(src.ID);
     m_quantity = src.Quantity;
 }