示例#1
0
    public void Add(CraftMaterial material)
    {
        inventory.Add(material);

        if (material.type == CraftMaterial.itemType.Stone)
        {
            stoneCount++;
        }
        else if (material.type == CraftMaterial.itemType.Coal)
        {
            coalCount++;
        }
        else if (material.type == CraftMaterial.itemType.Iron)
        {
            ironCount++;
        }
        else if (material.type == CraftMaterial.itemType.Wood)
        {
            woodCount++;
        }
        else if (material.type == CraftMaterial.itemType.Torch)
        {
            torchCount++;
        }
        else if (material.type == CraftMaterial.itemType.Carbon)
        {
            carbonCount++;
        }
        else if (material.type == CraftMaterial.itemType.Can)
        {
            canCount++;
        }
        else if (material.type == CraftMaterial.itemType.Steel)
        {
            steelCount++;
        }
        else if (material.type == CraftMaterial.itemType.Wood)
        {
            woodCount++;
        }
        else if (material.type == CraftMaterial.itemType.MoonStone)
        {
            moonStoneCount++;
        }
        itemCounter.UpdatedeText();
    }
示例#2
0
        public void Load()
        {
            _crafts         = new Dictionary <uint, Craft>();
            _craftProducts  = new Dictionary <uint, CraftProduct>();
            _craftMaterials = new Dictionary <uint, List <CraftMaterial> >();
            _log.Info("Loading crafts...");

            using (var connection = SQLite.CreateConnection())
            {
                /* Crafts */
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM crafts";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new Craft();
                            template.Id              = reader.GetUInt32("id");
                            template.CastDelay       = reader.GetInt32("cast_delay");
                            template.ToolId          = reader.GetUInt32("tool_id", 0);
                            template.SkillId         = reader.GetUInt32("skill_id", 0);
                            template.WiId            = reader.GetUInt32("wi_id");
                            template.MilestoneId     = reader.GetUInt32("milestone_id", 0);
                            template.ReqDoodadId     = reader.GetUInt32("req_doodad_id", 0);
                            template.NeedBind        = reader.GetBoolean("need_bind");
                            template.AcId            = reader.GetUInt32("ac_id", 0);
                            template.ActabilityLimit = reader.GetInt32("actability_limit");
                            template.ShowUpperCraft  = reader.GetBoolean("show_upper_crafts");
                            template.RecommendLevel  = reader.GetInt32("recommend_level");
                            template.VisibleOrder    = reader.GetInt32("visible_order");
                            _crafts.Add(template.Id, template);
                        }
                    }
                }

                /* Craft products (item you get at the end) */
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM craft_products";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new CraftProduct();
                            template.Id              = reader.GetUInt32("id");
                            template.CraftId         = reader.GetUInt32("craft_id");
                            template.ItemId          = reader.GetUInt32("item_id");
                            template.Amount          = reader.GetInt32("amount", 1); //We always want to produce at least 1 item ?
                            template.Rate            = reader.GetInt32("rate");
                            template.ShowLowerCrafts = reader.GetBoolean("show_lower_crafts");
                            template.UseGrade        = reader.GetBoolean("use_grade");
                            template.ItemGradeId     = reader.GetUInt32("item_grade_id");

                            _craftProducts.Add(template.CraftId, template); // Using craftID so it's easier to find in the dictionary. Need to make sure results dont have duplicates later on. they do not in my db
                        }
                    }
                }

                /* Craft products (item you get at the end) */
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM craft_materials";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new CraftMaterial();
                            template.Id        = reader.GetUInt32("id");
                            template.CraftId   = reader.GetUInt32("craft_id");
                            template.ItemId    = reader.GetUInt32("item_id");
                            template.Amount    = reader.GetInt32("amount", 1); //We always want to cost at least 1 item ?
                            template.MainGrade = reader.GetBoolean("main_grade");

                            if (!_craftMaterials.ContainsKey(template.CraftId))
                            {
                                _craftMaterials.Add(template.CraftId, new List <CraftMaterial>());
                            }

                            _craftMaterials[template.CraftId].Add(template); // Using craftID so it's easier to find in the dictionary. Need to make sure results dont have duplicates later on. they do not in my db
                        }
                    }
                }
            }

            _log.Info("Loaded crafts", _crafts.Count);
        }
示例#3
0
        public SupersetInfo CreateSupersetModel(IList <IEquipment> equipments, IAbility[] desiredAbilities)
        {
            EquipmentType type            = equipments.FirstOrDefault()?.Type ?? EquipmentType.Charm; // No equipment probably means charm
            var           desiredSkillIDs = new HashSet <int>(desiredAbilities.Select(x => x.Skill.Id));

            int[] slots     = new int[CutoffSearchConstants.Slots];
            int   maxSkills = 0;

            foreach (IEquipment eq in equipments)
            {
                for (int i = 0; i < eq.Slots.Length; i++)
                {
                    if (slots[i] < eq.Slots[i])
                    {
                        slots[i] = eq.Slots[i];
                    }
                }

                int skillCount = 0;
                foreach (IAbility ability in eq.Abilities)
                {
                    if (!desiredSkillIDs.Contains(ability.Skill.Id))
                    {
                        continue;
                    }
                    skillCount += ability.Level;
                }
                if (skillCount > maxSkills)
                {
                    maxSkills = skillCount;
                }
            }

            IAbility[] abilities = equipments
                                   .SelectMany(x => x.Abilities)
                                   .GroupBy(x => x.Skill.Id)
                                   .Select(x => x.OrderByDescending(y => y.Level).First())
                                   .ToArray();

            string name     = $"{type} superset";
            var    nameDict = new Dictionary <string, string>()
            {
                { "EN", name }
            };
            var        craftMaterials = new CraftMaterial[0];
            IEvent     ev             = null;
            IEquipment equipment;

            if (type == EquipmentType.Charm)
            {
                equipment = new CharmLevel(-1, 0, nameDict, 0, slots, abilities, ev, craftMaterials);
            }
            else
            {
                var armorPieces            = equipments.Cast <IArmorPiece>().ToList();
                IArmorSetSkill[] setSkills = armorPieces
                                             .Where(x => x.ArmorSetSkills != null)
                                             .SelectMany(x => x.ArmorSetSkills)
                                             .Distinct()
                                             .ToArray();
                IArmorPiece firstArmor = armorPieces.First();
                equipment = new ArmorPiece(-1, nameDict, firstArmor.Type, 0, slots, abilities, setSkills, firstArmor.Defense, firstArmor.Resistances, firstArmor.Attributes, firstArmor.Assets, firstArmor.FullArmorSet, ev, craftMaterials);
            }
            var info = new SupersetInfo(equipment, maxSkills);

            return(info);
        }