Пример #1
0
        public override void load(SQLiteDataReader data)
        {
            op_stct2        out_name      = OPDataContainer.GetOP_Stct(data.GetValue(1) as string);
            List <op_stct2> out_marteials = new List <op_stct2>();

            for (int i = 2; i <= 7; i++)
            {
                var s = data.GetValue(i);

                if (s is System.DBNull == false)
                {
                    op_stct2 mat_temp = OPDataContainer.GetOP_Stct(s as string);
                    out_marteials.Add(mat_temp);
                }
            }

            var per_str     = data.GetValue(8) as long?;
            int out_percent = 0;

            if (per_str != null)
            {
                out_percent = (int)per_str;
            }

            OP_Recipe2 recp = new OP_Recipe2()
            {
                name      = out_name,
                materials = out_marteials,
                percent   = out_percent
            };

            op_recipes.Add(recp);
        }
        public OP_CompositionEngine()
        {
            OPData_Memory sqtest = new OPData_Memory("pso2_op_base.db");

            opdataContainer = new OPDataContainer(sqtest);

            RecipeData_Memory res = new RecipeData_Memory("pso2_op_base.db");

            recipeDataContainer = new RecipeDataContainer(res);
        }
        //slot_countより少ないop数の場合ゴミで埋める
        public static List <op_stct2> add_NULL_op(int slot_count, List <op_stct2> op)
        {
            if (slot_count == 0)
            {
                return(op);
            }

            int             d      = slot_count - op.Count();
            List <op_stct2> op_fix = op.Select(x => x).ToList();

            for (int i = 0; i < d; i++)
            {
                op_fix.Add(OPDataContainer.GetOP_Stct("none"));
            }

            return(op_fix);
        }
        public static List <OP_Recipe2> add_NULL_Recipe(int slot_count, List <OP_Recipe2> op)
        {
            if (slot_count == 0)
            {
                return(op);
            }

            int d = slot_count - op.Count();
            List <OP_Recipe2> op_fix = op.Select(x => x).ToList();

            for (int i = 0; i < d; i++)
            {
                var OP_none = RecipeDataContainer.GetOP_Recipes(OPDataContainer.GetOP_Stct("none"));
                op_fix.Add(OP_none[0]);
            }

            return(op_fix);
        }
        /// <summary>
        /// opに指定された素材と、確率を返す。
        /// percent_plusで成功確率を上げる
        /// </summary>
        /// <param name="op">素材</param>
        /// <param name="percent_Plus">確率上昇率</param>
        /// <returns>素材</returns>
        static public (int, List <op_stct2>) GetMaterials(op_stct2 op, int percent_Plus = 0)
        {
            var comArr = RecipeDataContainer.GetOP_Recipes(op);

            comArr = comArr.OrderBy(x => x.percent).ToList();

            if (comArr.Count == 0)
            {
                Console.WriteLine("Recepi Not Found:{0}", op.jp_name);
                return(GetMaterials(OPDataContainer.GetOP_Stct("none")));
            }

            OP_Recipe2 opc = comArr[0];

            foreach (OP_Recipe2 o in comArr)
            {
                opc = o;
                int p = o.percent + percent_Plus;
                if (p >= 100)
                {
                    break;
                }
            }

            List <op_stct2> op_s = new List <op_stct2>();

            foreach (op_stct2 name in opc.materials)
            {
                op_s.Add(name);
            }

            int output_p = opc.percent + percent_Plus;

            if (output_p > 100)
            {
                output_p = 100;
            }
            return(output_p, op_s);
        }
        /// <summary>
        /// targetで指定されたOPを合成するために必要な素材を推定する。
        /// </summary>
        /// <param name="target">ほしいOP</param>
        /// <param name="percent_plus">特殊能力成功確率上昇</param>
        /// <returns>
        /// 合成成功確率,必要な素材
        /// </returns>
        static public material SerchOP_materialBodys(op_stct2[] target, int percent_plus = 0)
        {
            List <List <op_stct2> > output_material_bodys = new List <List <op_stct2> >();

            List <OP_Recipe2>     output_target  = GetMaterials(target.ToList(), percent_plus);
            List <OP_Recipe_flag> need_materials = output_target.Select(x => new OP_Recipe_flag(x)).ToList();

            //1sでソール <= ソール+ソールみたいなのは次で無限ループになってしまう。

            if (target.Length == 1)
            {
                List <bool> commonOP = new List <bool>();
                foreach (OP_Recipe2 r in output_target)
                {
                    bool fg = true;

                    foreach (op_stct2 o in r.materials)
                    {
                        if (r.name.op_name != o.op_name)
                        {
                            fg = false;
                        }
                    }

                    commonOP.Add(fg);
                }

                if (commonOP.All(x => (x == true)))
                {
                    foreach (OP_Recipe2 r in output_target)
                    {
                        foreach ((op_stct2 x, int i) in r.materials.Select((x, i) => (x, i)))
                        {
                            if (output_material_bodys.Count < (i + 1))
                            {
                                output_material_bodys.Add(new List <op_stct2>());
                            }
                            output_material_bodys[i].Add(x);
                        }
                    }



                    return(new material()
                    {
                        //material_op = output_material_bodys.Select(x => add_NULL_op(target.Length, x)).ToList(),
                        material_op = output_material_bodys,
                        Recipes = output_target
                    });
                }
            }



            foreach (OP_Recipe_flag cmp in need_materials)
            {
                foreach (OP_stct_flag osf in cmp.materials)
                {
                    if (osf.flag == false)
                    {
                        int material_slot = 0;

                        bool loopa = true;
                        while (loopa == true)
                        {
                            if (output_material_bodys.Count > material_slot == false)
                            {
                                output_material_bodys.Add(new List <op_stct2>());
                            }

                            var isExist_OP = output_material_bodys[material_slot].Where(x => (x.op_name == osf.op_name)).ToList();
                            int slot_count = output_material_bodys[material_slot].Count();


                            if (isExist_OP.Count == 0)
                            {
                                //output_material_bodysの一番最初は素体なので、OPスロ数注意
                                if (material_slot == 0)
                                {
                                    if (slot_count <= target.Length)
                                    {
                                        //output_material_bodys[material_slot].Add(OP_Datas.options[osf.op_name]);
                                        output_material_bodys[material_slot].Add(OPDataContainer.GetOP_Stct(osf.op_name));

                                        List <op_stct2> dupOP = checkOP(output_material_bodys[material_slot]);


                                        if (dupOP.Count > 0)
                                        {
                                            output_material_bodys[material_slot].RemoveAt(output_material_bodys[material_slot].Count - 1);
                                        }
                                        else
                                        {
                                            loopa = false;
                                        }
                                    }
                                }
                                else
                                {
                                    output_material_bodys[material_slot].Add(OPDataContainer.GetOP_Stct(osf.op_name));
                                    List <op_stct2> dupOP = checkOP(output_material_bodys[material_slot]);

                                    if (dupOP.Count > 0)
                                    {
                                        output_material_bodys[material_slot].RemoveAt(output_material_bodys[material_slot].Count - 1);
                                    }
                                    else
                                    {
                                        loopa = false;
                                    }
                                }
                            }

                            if (loopa == true)
                            {
                                material_slot++;

                                //8スロ以上になったら
                                if (material_slot > 5)
                                {
                                    loopa = false;

                                    //op付不可なのでとりあえず空き配列でも返す

                                    return(new material()
                                    {
                                        material_op = new List <List <op_stct2> >(), Recipes = output_target
                                    });
                                }
                            }
                            else
                            {
                                //素材のOP数がほしいOP数と同数以上じゃないと同じOPにはならない
                                if (target.Length <= output_material_bodys[material_slot].Count)
                                {
                                    //ほしいOP構成と同じOP構成の素材ができたらmaterial_slot+1
                                    List <bool> isExist = new List <bool>();

                                    foreach (var t in target)
                                    {
                                        isExist.Add(false);
                                    }

                                    foreach ((var t, int i) in target.Select((val, i) => (val, i)))
                                    {
                                        foreach (var x in output_material_bodys[material_slot])
                                        {
                                            if (t.op_name == x.op_name)
                                            {
                                                isExist[i] = true;
                                            }
                                        }
                                    }

                                    //ほしいOP構成と同じOP構成の素材ができている場合
                                    if (isExist.All(x => (x == true)) == true)
                                    {
                                        output_material_bodys[material_slot].RemoveAt(output_material_bodys[material_slot].Count - 1);
                                        material_slot++;
                                        loopa = true;
                                    }
                                }


                                //素材の素材を作るのに必要な素材数を調べる
                                if (output_material_bodys.Count() > material_slot)
                                {
                                    List <op_stct2> all_matel = new List <op_stct2>();
                                    foreach (op_stct2 o in output_material_bodys[material_slot])
                                    {
                                        (int p, List <op_stct2> res_op) = GetMaterials(o);
                                        foreach (op_stct2 reo in res_op)
                                        {
                                            all_matel.Add(reo);
                                        }
                                    }

                                    List <op_stct2> next_dupOP  = checkOP(all_matel);
                                    List <int>      next_dupSer = seriseCount(next_dupOP);

                                    if (next_dupSer.Max() > 6)
                                    {
                                        output_material_bodys[material_slot].RemoveAt(output_material_bodys[material_slot].Count - 1);
                                        material_slot++;
                                        loopa = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }


            return(new material()
            {
                //material_op = output_material_bodys.Select(x => add_NULL_op(target.Length, x)).ToList(),
                material_op = output_material_bodys,
                Recipes = output_target
            });
        }
        public MainWindowData()
        {
            AllOPLists   = new ObservableCollection <op_stct2>();
            targetOPList = new ObservableCollection <op_stct2>();
            ItemAdd      = new ObservableCollection <PercentAdd>();
            CampaignAdd  = new ObservableCollection <PercentAdd>();

            //OPリスト追加
            foreach (op_stct2 o in OPDataContainer.GetAllOP())
            {
                AllOPLists.Add(o);
            }

            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 0, itemName = "なし"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 5, itemName = "+5%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 10, itemName = "+10%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 20, itemName = "+20%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 30, itemName = "+30%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 40, itemName = "+40%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 45, itemName = "+45%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 50, itemName = "+50%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 55, itemName = "+55%"
            });
            ItemAdd.Add(new PercentAdd()
            {
                addPercent = 60, itemName = "+60%"
            });

            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = 0, itemName = "なし"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = 5, itemName = "+5%"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = 10, itemName = "+10%"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = 15, itemName = "+15%"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = 18, itemName = "+18%"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = -1, itemName = "打撃力系"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = -2, itemName = "射撃力系"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = -3, itemName = "法撃力系"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = -4, itemName = "HP/PP系"
            });
            CampaignAdd.Add(new PercentAdd()
            {
                addPercent = -5, itemName = "特殊系"
            });
        }