Exemplo n.º 1
0
        /// <summary>
        /// P部。
        /// </summary>
        /// <param name="line"></param>
        private static void ReadP(string line, CsaKifu csaKifuData)
        {
            if (line.Length < 2)
            {
                goto gt_EndMethod;
            }

            // 3通りあります。
            // (1)2文字目が「I」の場合。
            // (2)2文字目が「1」~「9」の場合。
            // (3)2文字目が「+」「-」の場合。
            switch (line[1])
            {
            case 'I': Util_Csa.ReadP_1(line); break;

            case '1':     //thru
            case '2':     //thru
            case '3':     //thru
            case '4':     //thru
            case '5':     //thru
            case '6':     //thru
            case '7':     //thru
            case '8':     //thru
            case '9': Util_Csa.ReadP_2(line, csaKifuData); break;

            case '+':     //thru
            case '-': Util_Csa.ReadP_3(line); break;

            default:
                break;
            }

gt_EndMethod:
            ;
        }
Exemplo n.º 2
0
        public static CsaKifu ReadFile(string filepath)
        {
            CsaKifuImpl csaKifuData = new CsaKifuImpl();

            if (!File.Exists(filepath))
            {
                MessageBox.Show($@"ファイルがありません。
ファイルパス=[{filepath}]", "エラー");

                goto gt_EndMethod;
            }

            string[] allLines = File.ReadAllLines(filepath);

            int phase = 0;

            foreach (string line in allLines)
            {
                if (line.Length < 1)
                {
                    goto gt_EndLoop1;
                }

gt_Continue1:
                ;

                switch (phase)
                {
                case 0:
                    //
                    // V,N,$部
                    //
                    switch (line[0])
                    {
                    case 'V': Util_Csa.ReadV(line, csaKifuData); break;

                    case 'N': Util_Csa.ReadN(line, csaKifuData); break;

                    case '$': break;        // 対局情報は無視します。

                    case '\'': break;       // コメントは無視します。

                    default:
                        phase = 1;
                        goto gt_Continue1;
                    }
                    break;

                case 1:
                    //
                    // P部
                    //
                    switch (line[0])
                    {
                    case 'P': Util_Csa.ReadP(line, csaKifuData); break;

                    case '\'': break;        // コメントは無視します。

                    default:
                        phase = 2;
                        goto gt_Continue1;
                    }
                    break;

                case 2:
                    //
                    // ±部
                    //
                    switch (line[0])
                    {
                    case '+':        //thru
                    case '-': Util_Csa.ReadPlaceMinus_FirstSengo(line, csaKifuData); phase = 3; break;

                    case '\'': break;        // コメントは無視します。

                    default:
                        phase = 3;        //本当はエラーのはず。
                        goto gt_Continue1;
                    }
                    break;

                case 3:
                    //
                    // 指し手の±部、T部
                    //
                    switch (line[0])
                    {
                    case '+':
                    case '-': Util_Csa.ReadPlaceMinusMove(line, csaKifuData); break;

                    case 'T': Util_Csa.ReadT(line, csaKifuData); break;

                    case '\'': break;        // コメントは無視します。

                    default:
                        phase = 4;
                        goto gt_Continue1;
                    }
                    break;

                case 4:
                    //
                    // %部
                    //
                    switch (line[0])
                    {
                    case '%': Util_Csa.ReadFinishedStatus(line, csaKifuData); break;

                    case '\'': break;        // コメントは無視します。

                    default:
                        phase = 5;
                        goto gt_Next1;
                    }
                    break;

                default:
                    break;
                }


gt_EndLoop1:
                ;
            }
gt_Next1:
            ;

gt_EndMethod:
            ;
            return(csaKifuData);
        }