コード例 #1
0
ファイル: Move.cs プロジェクト: mikefunchess/ProblemSolving
 public Move(GamePiece MoveFrom, GamePiece MoveTo)
 {
     this.MoveFrom = MoveFrom;
     this.MoveTo = MoveTo;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: mikefunchess/ProblemSolving
        private void button2_Click(object sender, EventArgs e)
        {
            //48, 40 are the starting coordinates of a1.
            //add 48 to each in order to move to the next square.
            //MessageBox.Show(Move_enter.Text);
            string move = Move_enter.Text;

            if (move.Length >= 4 && move.Length <= 5)
            {

                GamePiece start = new GamePiece();
                start.Row = (move[0] - 'a');
                start.Col = (int)Char.GetNumericValue(move[1]) - 1;

                GamePiece end = new GamePiece();
                end.Row = move[2] - 'a';
                if (move.Length == 5)
                {
                    if (move[3] == '1' && move[4] == '0')
                    {
                        end.Col = 9;
                    }
                }
                else
                {
                    end.Col = (int)Char.GetNumericValue(move[3]) - 1;
                }

                Move playerMove = new Move(start, end);

                if (logic.MakePlayerMove(playerMove))
                {
                    MakeMove(playerMove);
                    Move logicMove = logic.GetNextMove();
                    logic.MakeComputerMove(logicMove);
                    MakeMove(logicMove);
                }
                else
                {
                    MessageBox.Show("Invalid Move");
                }
            }
            else if (move.Length == 6)
            {
                GamePiece start = new GamePiece();
                start.Row = (move[0] - 'a');
                start.Col = 9;

                GamePiece end = new GamePiece();
                end.Row = move[3] - 'a';
                end.Col = 9;

                Move playerMove = new Move(start, end);

                if (logic.MakePlayerMove(playerMove))
                {
                    MakeMove(playerMove);
                    Move logicMove = logic.GetNextMove();
                    logic.MakeComputerMove(logicMove);
                    MakeMove(logicMove);
                }
                else
                {
                    MessageBox.Show("Invalid Move");
                }
            }

            Move_enter.Text = "";
        }