示例#1
0
文件: ItemDB.cs 项目: Reve/EVESharp
        public static Dictionary<string, ItemAttribute> GetAttributesForItem(int itemID)
        {
            MySqlDataReader reader = null;

            if (Database.Query(ref reader, "SELECT dgmattributetypes.attributeName, entity_attributes.attributeID, valueInt, valueFloat FROM entity_attributes LEFT JOIN dgmattributetypes ON dgmattributetypes.attributeID=entity_attributes.attributeID WHERE itemID=" + itemID) == false)
            {
                return null;
            }

            if (reader == null)
            {
                return null;
            }

            Dictionary<string, ItemAttribute> result = new Dictionary<string, ItemAttribute>();

            while (reader.Read())
            {
                ItemAttribute attrib = new ItemAttribute();

                attrib.attributeID = reader.GetInt32(1);
                attrib.intValue = (reader.IsDBNull(2) == true) ? 0 : reader.GetInt32(2);
                attrib.floatValue = (reader.IsDBNull(3) == true) ? 0.0f : reader.GetFloat(3);

                result.Add(reader.GetString(0), attrib);
            }

            reader.Close();

            return result;
        }
示例#2
0
        public void Set(string attribute, int value)
        {
            if (attributes.ContainsKey(attribute) == true)
            {
                attributes[attribute].intValue = value;
            }
            else
            {
                ItemAttribute attrib = new ItemAttribute();

                attrib.attributeID = ItemDB.GetAttributeIDForName(attribute);
                attrib.intValue = value;

                attributes.Add(attribute, attrib);
            }
        }
示例#3
0
        public void Set(string attribute, float value)
        {
            if (attributes.ContainsKey(attribute) == true)
            {
                attributes[attribute].floatValue = value;
            }
            else
            {
                ItemAttribute attrib = new ItemAttribute();

                attrib.attributeID = ItemDB.GetAttributeIDForName(attribute);
                attrib.floatValue  = value;

                attributes.Add(attribute, attrib);
            }
        }