Exemple #1
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);
        }
Exemple #2
0
 static void ReSetSet()
 {
     Set = new Set(
         new Slot[] {
         new Slot()
         {
             Level = 4
         },
         new Slot()
         {
             Level = 4
         },
         new Slot()
         {
             Level = 4
         },
         new Slot()
         {
             Level = 4
         },
         new Slot()
         {
             Level = 4
         },
         new Slot()
         {
             Level = 3
         },
         new Slot()
         {
             Level = 1
         },
     },
         new Skill[] {
         new Skill()
         {
             Name = "滑走強化", Level = 1
         },
         new Skill()
         {
             Name = "体術", Level = 1
         },
         new Skill()
         {
             Name = "属性やられ耐性", Level = 1
         },
         new Skill()
         {
             Name = "属性解放/装填拡張", Level = 3
         },
         new Skill()
         {
             Name = "スタミナ奪取", Level = 1
         },
         new Skill()
         {
             Name = "オトモへの采配", Level = 2
         },
         new Skill()
         {
             Name = "飛燕", Level = 1
         },
         new Skill()
         {
             Name = "貫通弾・竜の一矢強化", Level = 1
         },
         new Skill()
         {
             Name = "追跡の達人", Level = 1
         }
     }
         );
 }
Exemple #3
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;
                }
            }
        }