예제 #1
0
        /// <summary>
        /// 「0」→「1一」。
        /// </summary>
        /// <param name="hMasu"></param>
        /// <returns></returns>
        public static string Handle_To_Label(int hMasu)
        {
            string result;

            if (0 <= hMasu && hMasu < ConstShogi.BAN_SIZE)
            {
                SyElement masu = Conv_MasuHandle.ToMasu(hMasu);
                int       suji;
                Util_MasuNum.TryMasuToSuji(masu, out suji);
                int dan;
                Util_MasuNum.TryMasuToDan(masu, out dan);

                StringBuilder sb = new StringBuilder();
                sb.Append(Conv_Int.ToArabiaSuji(suji));
                sb.Append(Conv_Int.ToKanSuji(dan));
                result = sb.ToString();
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("エラー");
                sb.Append("(");
                sb.Append(hMasu);
                sb.Append(")");
                result = sb.ToString();
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 距離の近さ
        /// </summary>
        /// <returns></returns>
        public static int GetKyori(int masuNumber, SyElement genzai)
        {
            //
            // とりあえず おおざっぱに計算します。
            //

            int mokuhyoDan;

            Util_MasuNum.TryMasuToDan(masuNumber, out mokuhyoDan);

            int mokuhyoSuji;

            Util_MasuNum.TryMasuToSuji(masuNumber, out mokuhyoSuji);

            int genzaiDan;

            Util_MasuNum.TryMasuToDan(genzai, out genzaiDan);

            int genzaiSuji;

            Util_MasuNum.TryMasuToSuji(genzai, out genzaiSuji);

            int kyori = Math.Abs(mokuhyoDan - genzaiDan) + Math.Abs(mokuhyoSuji - genzaiSuji);

            return(kyori);
        }
예제 #3
0
        /// <summary>
        /// ************************************************************************************************************************
        /// 局面に合わせて、駒ボタンのx,y位置を変更します
        /// ************************************************************************************************************************
        /// </summary>
        /// <param name="btnKoma">駒</param>
        public static void Redraw_KomaLocation(
            Finger figKoma,
            MainGui_Csharp mainGui
            )
        {
            RO_Star koma = Util_Starlightable.AsKoma(mainGui.Model_Manual.GuiSkyConst.StarlightIndexOf(figKoma).Now);

            Shape_BtnKoma btnKoma = Conv_Koma_InGui.FingerToKomaBtn(figKoma, mainGui);

            // マスと駒の隙間(パディング)
            int padX = 2;
            int padY = 2;

            int suji;
            int dan;

            Util_MasuNum.TryMasuToSuji(koma.Masu, out suji);
            Util_MasuNum.TryMasuToDan(koma.Masu, out dan);

            switch (Conv_SyElement.ToOkiba(koma.Masu))
            {
            case Okiba.ShogiBan:
                btnKoma.SetBounds(new Rectangle(
                                      mainGui.Shape_PnlTaikyoku.Shogiban.SujiToX(suji) + padX,
                                      mainGui.Shape_PnlTaikyoku.Shogiban.DanToY(dan) + padY,
                                      btnKoma.Bounds.Width,
                                      btnKoma.Bounds.Height
                                      ));
                break;

            case Okiba.Sente_Komadai:
                btnKoma.SetBounds(new Rectangle(
                                      mainGui.Shape_PnlTaikyoku.KomadaiArr[0].SujiToX(suji) + padX,
                                      mainGui.Shape_PnlTaikyoku.KomadaiArr[0].DanToY(dan) + padY,
                                      btnKoma.Bounds.Width,
                                      btnKoma.Bounds.Height
                                      ));
                break;

            case Okiba.Gote_Komadai:
                btnKoma.SetBounds(new Rectangle(
                                      mainGui.Shape_PnlTaikyoku.KomadaiArr[1].SujiToX(suji) + padX,
                                      mainGui.Shape_PnlTaikyoku.KomadaiArr[1].DanToY(dan) + padY,
                                      btnKoma.Bounds.Width,
                                      btnKoma.Bounds.Height
                                      ));
                break;

            case Okiba.KomaBukuro:
                btnKoma.SetBounds(new Rectangle(
                                      mainGui.Shape_PnlTaikyoku.KomadaiArr[2].SujiToX(suji) + padX,
                                      mainGui.Shape_PnlTaikyoku.KomadaiArr[2].DanToY(dan) + padY,
                                      btnKoma.Bounds.Width,
                                      btnKoma.Bounds.Height
                                      ));
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// 2駒関係[KK]用。
        /// フィーチャーベクターの調査項目インデックス。該当なければ-1。
        /// </summary>
        /// <param name="pside">プレイヤーサイド</param>
        /// <param name="komasyurui">盤上の種類</param>
        /// <param name="masu">盤上の駒の升</param>
        /// <returns></returns>
        public static int ToKIndex_From_PsideBanjoKomasyuruiMasu(SkyConst src_Sky, Playerside pside)
        {
            // 調査項目番号(K1、K2等)
            int result;

            SyElement masu;

            {
                Finger  figK1  = Util_Sky_FingersQuery.InOkibaPsideKomasyuruiNow(src_Sky, Okiba.ShogiBan, pside, PieceType.K).ToFirst();
                RO_Star komaK1 = Util_Starlightable.AsKoma(src_Sky.StarlightIndexOf(figK1).Now);
                masu = komaK1.Masu;
            }

            if (Okiba.ShogiBan != Conv_SyElement.ToOkiba(masu))
            {
                // 盤上でなければ。
                result = -1;
                goto gt_EndMethod;
            }

            int kSuji;

            Util_MasuNum.TryMasuToSuji(masu, out kSuji);
            int kDan;

            Util_MasuNum.TryMasuToDan(masu, out kDan);


            int p1;

            Conv_FvKoumoku522.Converter_K1_to_P(Playerside.P1, kDan, kSuji, out p1);


            result = p1;

gt_EndMethod:
            ;
            return(result);
        }
예제 #5
0
        /// <summary>
        /// ************************************************************************************************************************
        /// HTML出力。(これは作者のホームページ用に書かれています)
        /// ************************************************************************************************************************
        /// </summary>
        public static string CreateHtml(MainGui_Csharp mainGui)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<div style=\"position:relative; left:0px; top:0px; border:solid 1px black; width:250px; height:180px;\">");

            // 後手の持ち駒
            sb.AppendLine("    <div style=\"position:absolute; left:0px; top:2px; width:30px;\">");
            sb.AppendLine("        △後手");
            sb.AppendLine("        <div style=\"margin-top:10px; width:30px;\">");
            sb.Append("            ");

            SkyConst siteiSky = mainGui.Model_Manual.GuiSkyConst;

            siteiSky.Foreach_Starlights((Finger finger, IMoveHalf ml, ref bool toBreak) =>
            {
                RO_Star koma = Util_Starlightable.AsKoma(ml.Now);


                if (Conv_SyElement.ToOkiba(koma.Masu) == Okiba.Gote_Komadai)
                {
                    sb.Append(Util_Komasyurui14.Fugo[(int)Util_Komahaiyaku184.Syurui(koma.Haiyaku)]);
                }
            });

            sb.AppendLine("        </div>");
            sb.AppendLine("    </div>");

            // 将棋盤
            sb.AppendLine("    <div style=\"position:absolute; left:30px; top:2px; width:182px;\">");
            sb.AppendLine("        <table>");
            for (int dan = 1; dan <= 9; dan++)
            {
                sb.Append("        <tr>");
                for (int suji = 9; 1 <= suji; suji--)
                {
                    bool isSpace = true;

                    siteiSky.Foreach_Starlights((Finger finger, IMoveHalf ml, ref bool toBreak) =>
                    {
                        RO_Star koma2 = Util_Starlightable.AsKoma(ml.Now);


                        int suji2;
                        Util_MasuNum.TryMasuToSuji(koma2.Masu, out suji2);

                        int dan2;
                        Util_MasuNum.TryMasuToDan(koma2.Masu, out dan2);

                        if (
                            Conv_SyElement.ToOkiba(koma2.Masu) == Okiba.ShogiBan && //盤上
                            suji2 == suji &&
                            dan2 == dan
                            )
                        {
                            if (Playerside.P2 == koma2.Pside)
                            {
                                sb.Append("<td><span class=\"koma2x\">");
                                sb.Append(Util_Komasyurui14.Fugo[(int)Util_Komahaiyaku184.Syurui(koma2.Haiyaku)]);
                                sb.Append("</span></td>");
                                isSpace = false;
                            }
                            else
                            {
                                sb.Append("<td><span class=\"koma1x\">");
                                sb.Append(Util_Komasyurui14.Fugo[(int)Util_Komahaiyaku184.Syurui(koma2.Haiyaku)]);
                                sb.Append("</span></td>");
                                isSpace = false;
                            }
                        }
                    });

                    if (isSpace)
                    {
                        sb.Append("<td> </td>");
                    }
                }

                sb.AppendLine("</tr>");
            }
            sb.AppendLine("        </table>");
            sb.AppendLine("    </div>");

            // 先手の持ち駒
            sb.AppendLine("    <div style=\"position:absolute; left:215px; top:2px; width:30px;\">");
            sb.AppendLine("        ▲先手");
            sb.AppendLine("        <div style=\"margin-top:10px; width:30px;\">");
            sb.Append("            ");

            siteiSky.Foreach_Starlights((Finger finger, IMoveHalf ml, ref bool toBreak) =>
            {
                RO_Star koma = Util_Starlightable.AsKoma(ml.Now);

                if (Conv_SyElement.ToOkiba(koma.Masu) == Okiba.Sente_Komadai)
                {
                    sb.Append(Util_Komasyurui14.Fugo[(int)Util_Komahaiyaku184.Syurui(koma.Haiyaku)]);
                }
            });

            sb.AppendLine("        </div>");
            sb.AppendLine("    </div>");

            //
            sb.AppendLine("</div>");

            return(sb.ToString());
        }
예제 #6
0
        /// <summary>
        /// 将棋盤、駒台に筋があります。
        /// </summary>
        /// <param name="masu"></param>
        /// <returns>該当なければ-1</returns>
        public static bool TryMasuToDan(SyElement masu, out int result)
        {
            int masuNumber = Conv_SyElement.ToMasuNumber(masu);

            return(Util_MasuNum.TryMasuToDan(masuNumber, out result));
        }