Exemple #1
0
        public static void BunkaiMoveUmv()
        {
            PureMemory.umv_ss = PureMemory.kifu_moveArray[PureMemory.kifu_endTeme];

            // 駒がないところを指していることがないか?
            PureMemory.umv_ms_t1 = AbstractConvMove.GetDstMasu_WithoutErrorCheck((int)PureMemory.umv_ss);
            PureMemory.umv_km_t1 = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma(PureMemory.umv_ms_t1);
            PureMemory.umv_ks_t1 = Med_Koma.KomaToKomasyurui(PureMemory.umv_km_t1);// 成っているかもしれない☆
            Debug.Assert(Conv_Masu.IsBanjoOrError(PureMemory.umv_ms_t1), "error Undo-Begin-6");
            Debug.Assert(Conv_Koma.IsOk(PureMemory.umv_km_t1), "error Undo-Begin-7");


            if (!AbstractConvMove.IsUtta(PureMemory.umv_ss))                                                  // 指す
            {
                PureMemory.umv_ms_t0 = AbstractConvMove.GetSrcMasu_WithoutErrorCheck((int)PureMemory.umv_ss); // 戻し先。
                Debug.Assert(Conv_Masu.IsBanjo(PureMemory.umv_ms_t0), "error Undo-Begin-21 #金魚 戻し先が盤上でない?");

                PureMemory.umv_mk_t0 = Motigoma.Yososu;
                if (AbstractConvMove.IsNatta(PureMemory.umv_ss))                               // 成っていたとき
                {
                    PureMemory.umv_ks_t0 = Conv_Komasyurui.ToNarazuCase(PureMemory.umv_ks_t1); // 成る前
                }
                else
                {
                    PureMemory.umv_ks_t0 = PureMemory.umv_ks_t1;// 成る前、あるいは、成っていない、あるいは もともと にわとり☆
                }
                PureMemory.umv_km_t0 = Med_Koma.KomasyuruiAndTaikyokusyaToKoma(PureMemory.umv_ks_t0, PureMemory.kifu_teban);
                Debug.Assert(Conv_Koma.IsOk(PureMemory.umv_km_t0), "error Undo-Begin-9 #羊");
                Debug.Assert(Conv_Masu.IsBanjoOrError(PureMemory.umv_ms_t0), "error Undo-Begin-8 #颪");
            }
            else// 打つ
            {
                PureMemory.umv_ms_t0 = Conv_Masu.masu_error;
                PureMemory.umv_km_t0 = Piece.Yososu;
                PureMemory.umv_ks_t0 = Komasyurui.Yososu;
                PureMemory.umv_mk_t0 = Med_Koma.KomasyuruiAndTaikyokusyaToMotiKoma(PureMemory.umv_ks_t1, PureMemory.kifu_teban);
            }


            PureMemory.umv_ks_c = PureMemory.kifu_toraretaKsAr[PureMemory.kifu_endTeme];

            if (Komasyurui.Yososu != PureMemory.umv_ks_c)
            {
                PureMemory.umv_km_c = Med_Koma.KomasyuruiAndTaikyokusyaToKoma(PureMemory.umv_ks_c, PureMemory.kifu_aiteban);
                PureMemory.umv_mk_c = Med_Koma.BanjoKomaToMotiKoma(PureMemory.umv_km_c);
                Debug.Assert(Conv_Koma.IsOk(PureMemory.umv_km_c), "error Undo-Begin-10 #竜巻");
            }
            else
            {
                PureMemory.umv_km_c = Piece.Yososu;
                PureMemory.umv_mk_c = Motigoma.Yososu;
            }
        }
Exemple #2
0
        public static Json_Val ToJsonVal(IMoveHalf light)
        {
            Json_Obj obj = new Json_Obj();


            RO_Star koma = Util_Starlightable.AsKoma(light.Now);


            // プレイヤーサイド
            obj.Add(new Json_Prop("pside", Conv_Playerside.ToSankaku(koma.Pside)));// ▲△

            // マス
            obj.Add(new Json_Prop("masu", Conv_SyElement.ToMasuNumber(koma.Masu)));// ▲△

            // 駒の種類。歩、香、桂…。
            obj.Add(new Json_Prop("syurui", Conv_Komasyurui.ToStr_Ichimoji(Util_Komahaiyaku184.Syurui(koma.Haiyaku))));// ▲△

            return(obj);
        }
Exemple #3
0
        /// <summary>
        /// 指し手情報を分解するぜ☆(^~^)
        /// 駒を動かす方を手番、相手を相手番と考えるぜ☆(^~^)
        /// </summary>
        public static void BunkaiMoveDmv(Move ss)
        {
            //
            // 動かす駒を t0 と呼ぶとする。
            //      移動元を t0、移動先を t1 と呼ぶとする。
            // 取られる駒を c と呼ぶとする。
            //      取られる駒の元位置は t1 、駒台は 3 と呼ぶとする。
            //

            // 変数をグローバルに一時退避
            // 移動先升
            PureMemory.dmv_ms_t1 = AbstractConvMove.GetDstMasu_WithoutErrorCheck((int)ss);
            // あれば、移動先の相手の駒(取られる駒; capture)
            PureMemory.dmv_km_c = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma(PureMemory.kifu_aiteban, PureMemory.dmv_ms_t1);
            PureMemory.dmv_ks_c = Med_Koma.KomaToKomasyurui(PureMemory.dmv_km_c);
            PureMemory.dmv_mk_c = Med_Koma.BanjoKomaToMotiKoma(PureMemory.dmv_km_c);

            if (AbstractConvMove.IsUtta(ss))
            {
                // 打
                PureMemory.dmv_ms_t0 = Conv_Masu.masu_error;

                // 指し手から「持駒」を判別
                PureMemory.dmv_mks_t0 = AbstractConvMove.GetUttaKomasyurui(ss);
                PureMemory.dmv_mk_t0  = Med_Koma.MotiKomasyuruiAndTaikyokusyaToMotiKoma(PureMemory.dmv_mks_t0, PureMemory.kifu_teban);
                // 「持駒」から「駒」へ変換
                PureMemory.dmv_km_t0 = Med_Koma.MotiKomasyuruiAndTaikyokusyaToKoma(PureMemory.dmv_mks_t0, PureMemory.kifu_teban);

                // 持ち駒は t0 も t1 も同じ。
                PureMemory.dmv_km_t1 = PureMemory.dmv_km_t0;
                PureMemory.dmv_ks_t0 = Med_Koma.MotiKomasyuruiToKomasyrui(PureMemory.dmv_mks_t0); //おまとめ☆(^~^)
                PureMemory.dmv_ks_t1 = PureMemory.dmv_ks_t0;                                      //追加
                //#if DEBUG
                //                if (!gky.ky.motiKomas.sindanMK.HasMotiKoma(mk_t0))
                //                {
                //                    CommandK.Ky(isSfen, "ky", gky, syuturyoku);
                //                    Util_Machine.Flush(syuturyoku);
                //                }
                //#endif
                Debug.Assert(PureMemory.gky_ky.motigomaItiran.yomiMotigomaItiran.HasMotigoma(PureMemory.dmv_mk_t0),
                             $"持っていない駒を打つのか☆(^~^)!? mks_src=[{ PureMemory.dmv_mks_t0 }] mk_utu=[{ PureMemory.dmv_mk_t0 }]");
            }
            else
            {
                // 指し
                PureMemory.dmv_ms_t0  = AbstractConvMove.GetSrcMasu_WithoutErrorCheck((int)ss);
                PureMemory.dmv_km_t0  = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma(PureMemory.dmv_ms_t0);
                PureMemory.dmv_ks_t0  = Med_Koma.KomaToKomasyurui(PureMemory.dmv_km_t0);//移動元の駒の種類
                PureMemory.dmv_mks_t0 = MotigomaSyurui.Yososu;
                PureMemory.dmv_mk_t0  = Motigoma.Yososu;
                if (AbstractConvMove.IsNatta(ss)) // 駒が成るケース
                {
                    PureMemory.dmv_ks_t1 = Conv_Komasyurui.ToNariCase(PureMemory.dmv_ks_t0);
                    PureMemory.dmv_km_t1 = Med_Koma.KomasyuruiAndTaikyokusyaToKoma(PureMemory.dmv_ks_t1, PureMemory.kifu_teban);
                }
                else // 駒が成らないケース
                {
                    PureMemory.dmv_km_t1 = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma(PureMemory.dmv_ms_t0);
                    PureMemory.dmv_ks_t1 = PureMemory.dmv_ks_t0;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// ************************************************************************************************************************
        /// 駒ボタンの描画はここに書きます。
        /// ************************************************************************************************************************
        /// </summary>
        /// <param name="g1"></param>
        public void Paint(Graphics g1, MainGui_Csharp mainGui)
        {
            if (!this.Visible)
            {
                goto gt_EndMethod;
            }

            //----------
            // 背景
            //----------
            if (mainGui.FigTumandeiruKoma == this.Finger)                //>>>>> 駒をつまんでいる時
            {
                g1.FillRectangle(Brushes.Brown, this.Bounds);            // 駒の背景は茶色。
            }
            else if (mainGui.Shape_PnlTaikyoku.MovedKoma == this.Finger) //>>>>> 駒を移動した時
            {
                g1.FillRectangle(Brushes.DarkKhaki, this.Bounds);        // 駒の背景はカーキ。
            }
            else if (this.Light)                                         //>>>>> マウスカーソルが当たっている時
            {
            }

            // この駒について。
            RO_Star koma = Util_Starlightable.AsKoma(mainGui.Model_Manual.GuiSkyConst.StarlightIndexOf(this.Finger).Now);

            if (true)
            {
                //----------
                // 駒画像
                //----------
                StringBuilder sb = new StringBuilder();
                sb.Append(Path.Combine(mainGui.EngineConf.DataDirectory, "img/koma/"));
                sb.Append(Conv_Komasyurui.ToStr_ImageName(koma.Komasyurui));
                sb.Append(".png");
                Image img = Image.FromFile(sb.ToString());

                if (koma.Pside == Playerside.P2)
                {
                    // 画像を180度回転させたい☆
                    img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                }
                else
                {
                }

                g1.DrawImage(img, this.Bounds);
            }
            else
            {
                /*
                 * //----------
                 * // 配役画像
                 * //----------
                 * StringBuilder sb = new StringBuilder();
                 * sb.Append(Path.Combine(mainGui.EngineConf.DataDirectory, "img/mobility/"));
                 * sb.Append((int)koma.Haiyaku);//配役番号
                 * sb.Append(".png");
                 * Image img = Image.FromFile(sb.ToString());
                 *
                 * if (koma.Pside == Playerside.P2)
                 * {
                 *  // 画像を180度回転させたい☆
                 *  img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                 * }
                 * else
                 * {
                 * }
                 *
                 * g1.DrawImage(img, this.Bounds);
                 */
            }


            /*
             * // 枠線
             * if(false)
             * {
             *  Pen pen;
             *  if (this.Light)
             *  {
             *      pen = Pens.Yellow;
             *  }
             *  else
             *  {
             *      pen = Pens.Black;
             *  }
             *
             *  g1.DrawRectangle(pen, this.Bounds);
             * }
             */

            /*
             * // 文字
             * if(false)
             * {
             *  if (koma.Pside == Playerside.P1)
             *  {
             *      //----------
             *      // 先手
             *      //----------
             *      //
             *      // ただ描画するだけ☆
             *      //
             *
             *      this.PaintText(g1, koma, this.Bounds.Location);
             *  }
             *  else
             *  {
             *      //----------
             *      // 後手
             *      //----------
             *      //
             *      // 180度回転させて描画するために、大掛かりになっています。
             *      //
             *
             *      //string moji = siteiSk.KomaDoors[this.KomaHandle].Text_Label;
             *
             *      //----------
             *      // 使用するフォント
             *      //----------
             *      //Font fnt = new Font(FontFamily.GenericSerif, 20.0f);
             *
             *      //----------
             *      // 文字の大きさにあった白紙(b)
             *      //----------
             *      Graphics bG;
             *      Bitmap bImg;
             *      {
             *          int w;
             *          int h;
             *          {
             *              //----------
             *              // 文字の大きさを調べるための白紙(a)
             *              //----------
             *              Bitmap aImg = new Bitmap(1, 1);
             *
             *              //imgのGraphicsオブジェクトを取得
             *              Graphics aG = Graphics.FromImage(aImg);
             *
             *              //文字列を描画したときの大きさを計算する
             *              w = 48;
             *              h = 48;
             *              //w = (int)aG.MeasureString(moji, fnt).Width;
             *              //h = (int)fnt.GetHeight(aG);
             *
             *              //if (w == 0 || h == 0)
             *              //{
             *              //    Logger.Trace($"moji=[{moji}]");
             *              //}
             *
             *              //if (w < 1)
             *              //{
             *              //    w = 1;
             *              //}
             *
             *              //if (h < 1)
             *              //{
             *              //    h = 1;
             *              //}
             *
             *              aG.Dispose();
             *              aImg.Dispose();
             *          }
             *
             *          bImg = new Bitmap(w, h);
             *      }
             *
             *      // 文字描画
             *      bG = Graphics.FromImage(bImg);
             *
             *      this.PaintText(bG, koma, new Point(0, 0)); //bG.DrawString(moji, fnt, Brushes.Black, 0, 0);
             *
             *      //----------
             *      // 回転軸座標
             *      //----------
             *      float x = (float)this.Bounds.X + (float)this.Bounds.Width / 2;
             *      float y = (float)this.Bounds.Y + (float)this.Bounds.Height / 2;
             *
             *      //----------
             *      // 回転
             *      //----------
             *
             *      // 180度で回転するための座標を計算
             *      //ラジアン単位に変換
             *      float d = 180.0f / (180.0f / (float)Math.PI);
             *      //新しい座標位置を計算する
             *      float x1 = x + bImg.Width * (float)Math.Cos(d);
             *      float y1 = y + bImg.Width * (float)Math.Sin(d);
             *      float x2 = x - bImg.Height * (float)Math.Sin(d);
             *      float y2 = y + bImg.Height * (float)Math.Cos(d);
             *      //PointF配列を作成
             *      PointF[] destinationPoints = {new PointF(x + (float)this.Bounds.Width / 2, y + (float)this.Bounds.Height / 2),
             *                  new PointF(x1 + (float)this.Bounds.Width / 2, y1 + (float)this.Bounds.Height / 2),
             *                  new PointF(x2 + (float)this.Bounds.Width / 2, y2 + (float)this.Bounds.Height / 2)};
             *
             *      //画像を描画
             *      g1.DrawImage(bImg, destinationPoints);
             *
             *      //リソースを解放する
             *      bImg.Dispose();
             *      bG.Dispose();
             *      //fnt.Dispose();
             *  }
             * }
             */


            //// フィンガー番号
            //if (false)
            //{
            //    g1.DrawString(this.Finger.ToString(), new Font(FontFamily.GenericSerif, 10.0f), Brushes.Black, this.Bounds.Location);
            //}

            ////----------
            //// デバッグ用
            ////----------
            //if (true)
            //{
            //    string moji = siteiSk.KomaDoors[this.Handle].SrcOkiba.ToString();

            //    g1.DrawString(moji, new Font(FontFamily.GenericSerif, 12.0f), Brushes.Red, this.Bounds.Location);
            //}

gt_EndMethod:
            ;
        }