示例#1
0
 public bool AddDecoration(Decoration decoration, int slot)
 {
     if (_Slots.Any(s => slot == s.Level && s.Decoration == null))
     {
         _Slots[_Slots.FindIndex(s => s.Level == slot && s.Decoration == null)]
         .Decoration = decoration;
         return(true);
     }
     return(false);
 }
示例#2
0
 static void ReadDecoration()
 {
     _DecorationList = new List <Decoration>();
     using (StreamReader streamReader = new StreamReader("mhw_decoration.csv"))
     {
         string data;
         while ((data = streamReader.ReadLine()) != null)
         {
             string[] splitData = data.Split(',');
             //ex.火炎珠【1】,火属性攻撃強化1,
             Decoration decoration = new Decoration()
             {
                 Name  = splitData[0].Split('【')[0],
                 Level = Convert.ToInt32(splitData[0].Split('【')[1].Replace("】", ""))
             };
             if (decoration.Level == 4)
             {
                 if (splitData[2] == "null" || splitData[2] == string.Empty)
                 {
                     decoration.Skills = new Skill[] {
                         new Skill()
                         {
                             Name  = splitData[1].Substring(0, splitData[1].Length - 1),
                             Level = Convert.ToInt32(splitData[1].Substring(splitData[1].Length - 1, 1))
                         }
                     };
                 }
                 else
                 {
                     decoration.Skills = new Skill[] {
                         new Skill()
                         {
                             Name = splitData[1].Substring(0, splitData[1].Length - 1), Level = 1
                         },
                         new Skill()
                         {
                             Name = splitData[2].Substring(0, splitData[2].Length - 1), Level = 1
                         }
                     };
                 }
             }
             else
             {
                 decoration.Skills = new Skill[] {
                     new Skill()
                     {
                         Name = splitData[1].Substring(0, splitData[1].Length - 1), Level = 1
                     }
                 };
             }
             _DecorationList.Add(decoration);
         }
     }
     _DecorationList = _DecorationList.OrderByDescending(dec => dec.Level).ToList();
 }
示例#3
0
        public void AddDecoration(Decoration decoration)
        {
            if (AddDecoration(decoration, decoration.Level))
            {
                return;
            }

            if (_Slots.Any(s => decoration.Level <= s.Level && s.Decoration == null))
            {
                _Slots[_Slots.FindIndex(s => s.Level >= decoration.Level && s.Decoration == null)]
                .Decoration = decoration;
            }
        }
示例#4
0
 public void ChangeDecoration(int slotIndex, Decoration decoration)
 {
     _Slots[slotIndex].Decoration = decoration;
 }
示例#5
0
        static bool FourSlotsCalculation(Skill skill, Set set, IEnumerable <Skill> searchSkillList, SetSearchCriteria setSearchCriteria, List <string> usedSkillList)
        {
            usedSkillList.Add(skill.Name);
            switch (setSearchCriteria)
            {
            case SetSearchCriteria.HH:
                searchSkillList = _DecorationList.Where(dec => dec.Level < 4 &&
                                                        Set.RemainingExpectation.Where(re => re.Level > 0)
                                                        .Select(re => re.Name)
                                                        .Intersect(dec.Skills.Select(s => s.Name))
                                                        .Any()).OrderByDescending(skill => _DecorationList.Where(dec => dec.Level != 4)
                                                                                  .Select(dec => dec.Skills[0].Name)
                                                                                  .ToList().IndexOf(skill.Name)).Select(dec => dec.Skills[0]);
                break;

            case SetSearchCriteria.HL:
                searchSkillList = _DecorationList.Where(dec => dec.Level < 4 &&
                                                        Set.RemainingExpectation.Where(re => re.Level > 0)
                                                        .Select(re => re.Name)
                                                        .Intersect(dec.Skills.Select(s => s.Name))
                                                        .Any()).OrderBy(dec => dec.Level).Select(dec => dec.Skills[0]);
                break;

            case SetSearchCriteria.LH:
                searchSkillList = _DecorationList.Where(dec => dec.Level < 4 &&
                                                        Set.RemainingExpectation.Where(re => re.Level > 0)
                                                        .Select(re => re.Name)
                                                        .Intersect(dec.Skills.Select(s => s.Name))
                                                        .Any()).OrderByDescending(dec => dec.Level).Select(dec => dec.Skills[0]);
                break;

            case SetSearchCriteria.LL:
                searchSkillList = _DecorationList.Where(dec => dec.Level < 4 &&
                                                        Set.RemainingExpectation.Where(re => re.Level > 0)
                                                        .Select(re => re.Name)
                                                        .Intersect(dec.Skills.Select(s => s.Name))
                                                        .Any()).OrderBy(dec => dec.Level).Select(dec => dec.Skills[0]);
                break;

            default:
                return(false);
            }
            //Find 4 slots decoration with other skills
            foreach (Skill subExpectedSkill in searchSkillList)
            {
                Decoration tempDecoration = _DecorationList
                                            .FirstOrDefault(dec => dec.Skills.Select(s => s.Name)
                                                            .SequenceEqual(new string[] { skill.Name, subExpectedSkill.Name }) ||
                                                            dec.Skills.Select(s => s.Name).Reverse()
                                                            .SequenceEqual(new string[] { skill.Name, subExpectedSkill.Name }));
                if (tempDecoration != null)
                {
                    Set.AddDecoration(tempDecoration);
                    return(true);
                }
            }
            //Put in the respective slot first
            if (set.RemainingSlots.Any(slot => slot.Level == _DecorationList.First(dec => dec.Level < 4 && dec.Skills[0].Name == skill.Name).Level))
            {
                set.AddDecoration(_DecorationList.First(dec => dec.Level < 4 && dec.Skills[0].Name == skill.Name));
                return(true);
            }


            //switching slot from the lower skill of a decoration
            foreach (Decoration decoration in set.SlotsWithDecoration
                     .Where(s => s.Decoration.Level == 4 &&
                            s.Decoration.Skills.Count() > 1 &&
                            s.Decoration.Skills[0].Name != skill.Name &&
                            !usedSkillList.Contains(s.Decoration.Skills[0].Name))
                     .Select(s => s.Decoration))
            {
                if (_LevelFourDecorationList
                    .Any(lfd => lfd.Skills.Select(s => s.Name).Contains(skill.Name) &&
                         lfd.Skills.Select(s => s.Name).Contains(decoration.Skills[1].Name)))
                {
                    if (set.RemainingSlots.All(slot => slot.Level == 4 && slot.Decoration != null))
                    {
                        return(false);
                    }
                    //Put the new decoration in
                    set.AddDecoration(_LevelFourDecorationList
                                      .First(lfd => lfd.Skills.Select(s => s.Name).Contains(skill.Name) &&
                                             lfd.Skills.Select(s => s.Name).Contains(decoration.Skills[1].Name)));
                    //Replace the old decoration with an empty one
                    set.ChangeDecoraiton(decoration.Name, null);
                    return(FourSlotsCalculation(decoration.Skills[0], set, searchSkillList, setSearchCriteria, usedSkillList));
                }
            }
            //switching slot from the higher skill of a decoration
            foreach (Decoration decoration in set.SlotsWithDecoration
                     .Where(s => s.Decoration.Level == 4 &&
                            s.Decoration.Skills.Count() > 1 &&
                            s.Decoration.Skills[1].Name != skill.Name &&
                            !usedSkillList.Contains(s.Decoration.Skills[0].Name))
                     .Select(s => s.Decoration))
            {
                if (_LevelFourDecorationList
                    .Any(lfd => lfd.Skills.Select(s => s.Name).Contains(skill.Name) &&
                         lfd.Skills.Select(s => s.Name).Contains(decoration.Skills[0].Name)))
                {
                    if (set.RemainingSlots.All(slot => slot.Level == 4 && slot.Decoration != null))
                    {
                        return(false);
                    }
                    //Put the new decoration in
                    set.AddDecoration(_LevelFourDecorationList
                                      .First(lfd => lfd.Skills.Select(s => s.Name).Contains(skill.Name) &&
                                             lfd.Skills.Select(s => s.Name).Contains(decoration.Skills[0].Name)));
                    //Replace the old decoration with an empty one
                    set.ChangeDecoraiton(decoration.Name, null);
                    return(FourSlotsCalculation(decoration.Skills[0], set, searchSkillList, setSearchCriteria, usedSkillList));
                }
            }
            return(false);
        }
示例#6
0
        static void SearchWithCondition(Set Set, SetSearchCriteria setSearchCriteria)
        {
            //Sort the skill expectation in ascending order
            //Start with the lowest skills
            //Initial an attempting cache dictionary
            Dictionary <Skill, bool> remainingExpectationDic = new Dictionary <Skill, bool>();

            RefreshRemainingExpectationDictionary(remainingExpectationDic, Set.RemainingExpectation);
            List <Decoration> plausibleDecoration = new List <Decoration>();

            //Get all plausible decorations from the expectation skill
            foreach (Skill skill in Set.Expectation)
            {
                plausibleDecoration.AddRange(_DecorationList.Where(dec => dec.Skills.Select(s => s.Name).Contains(skill.Name)));
            }

            while (remainingExpectationDic.Any(re => re.Key.Level > 0))
            {
                bool fourSlotsflag = false;
                RefreshRemainingExpectationDictionary(remainingExpectationDic, Set.RemainingExpectation);
                //Skill expectedSkill = Set.RemainingExpectation.Where(r => r.Level > 0).First();
                IEnumerable <Skill> searchSkillList = new List <Skill>();
                Skill expectedSkill = new Skill();
                switch (setSearchCriteria)
                {
                case SetSearchCriteria.HH:
                    expectedSkill = remainingExpectationDic.OrderBy(re => re.Value)
                                    .ThenBy(re => _DecorationList.Where(dec => dec.Level != 4)
                                            .Select(dec => dec.Skills[0].Name)
                                            .ToList().IndexOf(re.Key.Name))
                                    .FirstOrDefault(re => re.Key.Level > 0).Key;
                    break;

                case SetSearchCriteria.HL:
                    expectedSkill = remainingExpectationDic.OrderBy(re => re.Value)
                                    .ThenBy(re => _DecorationList.Where(dec => dec.Level != 4)
                                            .Select(dec => dec.Skills[0].Name)
                                            .ToList().IndexOf(re.Key.Name))
                                    .FirstOrDefault(re => re.Key.Level > 0).Key;
                    break;

                case SetSearchCriteria.LH:
                    expectedSkill = remainingExpectationDic.OrderBy(re => re.Value)
                                    .ThenByDescending(re => _DecorationList.Where(dec => dec.Level != 4)
                                                      .Select(dec => dec.Skills[0].Name)
                                                      .ToList().IndexOf(re.Key.Name))
                                    .FirstOrDefault(re => re.Key.Level > 0).Key;
                    break;

                case SetSearchCriteria.LL:
                    expectedSkill = remainingExpectationDic.OrderBy(re => re.Value)
                                    .ThenByDescending(re => _DecorationList.Where(dec => dec.Level != 4)
                                                      .Select(dec => dec.Skills[0].Name)
                                                      .ToList().IndexOf(re.Key.Name))
                                    .FirstOrDefault(re => re.Key.Level > 0).Key;

                    break;
                }
                //Find level four decoration if possible and check if the expected skill has a level four decoration
                if (expectedSkill != null &&
                    _LevelFourDecorationList.Any(dec => dec.Skills.Select(s => s.Name).Any(s => s == expectedSkill.Name)) &&
                    Set.RemainingSlots.Any(slot => slot.Level == 4 && slot.Decoration == null))
                {
                    //Find 4 slots decoration with itself first if 3 or more skill points required
                    //and if this skill has a 3 skill points worth level 4 decoration
                    if (expectedSkill.Level >= 3 &&
                        _DecorationList.Any(dec => dec.Level == 4 &&
                                            dec.Skills.Count() == 1 &&
                                            dec.Skills[0].Name == expectedSkill.Name &&
                                            dec.Name.Contains("III")
                                            ))
                    {
                        Set.AddDecoration(_DecorationList.First(dec => dec.Level == 4 &&
                                                                dec.Skills.Count() == 1 &&
                                                                dec.Skills[0].Name == expectedSkill.Name &&
                                                                dec.Name.Contains("III")));
                        fourSlotsflag = true;
                        continue;
                    }
                    //2 or more skill points required
                    //and if this skill has a 2 skill points worth level 4 decoration
                    else if (expectedSkill.Level >= 2)
                    {
                        Decoration tempDecoration = _DecorationList
                                                    .FirstOrDefault(dec => dec.Level == 4 &&
                                                                    dec.Skills.Count() == 1 &&
                                                                    dec.Skills[0].Name == expectedSkill.Name);
                        if (tempDecoration != null)
                        {
                            Set.AddDecoration(tempDecoration);
                            fourSlotsflag = true;
                            continue;
                        }
                    }
                    try
                    {
                        fourSlotsflag = FourSlotsCalculation(expectedSkill, Set, searchSkillList, setSearchCriteria, new List <string>());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                        break;
                    }
                    //Find with <3 slot
                    if (!fourSlotsflag)
                    {
                        Decoration tempDecoration = _DecorationList
                                                    .FirstOrDefault(dec => dec.Skills[0].Name == expectedSkill.Name &&
                                                                    dec.Level < 4);
                        if (tempDecoration != null)
                        {
                            Set.AddDecoration(tempDecoration);
                            fourSlotsflag = true;
                        }
                    }

                    if (!fourSlotsflag)
                    {
                        remainingExpectationDic[expectedSkill] = false;
                        fourSlotsflag = true;
                    }
                }
                else if (Set.RemainingSlots.Count() > 0 && expectedSkill != null)
                {
                    //Find with <3 slot
                    Decoration tempDecoration = _DecorationList
                                                .FirstOrDefault(dec => dec.Skills[0].Name == expectedSkill.Name &&
                                                                dec.Level < 4);
                    if (tempDecoration != null && Set.RemainingSlots.Any(re => re.Level >= tempDecoration.Level))
                    {
                        Set.AddDecoration(tempDecoration);
                        fourSlotsflag = true;
                    }
                }
                if (!fourSlotsflag || expectedSkill == null)
                {
                    break;
                }
            }
        }