Пример #1
0
        public void Cell_Click(Position pos)
        {
            MyList<Position> moves, attacks,castlings, inmoveattacks;
            Figure fig = Field.GetFigureAt(pos);
            if (!isHighlighted())
            {
                if (Hightlight(pos, out moves, out attacks, out castlings, out inmoveattacks))
                {
                    foreach (Position move in moves)
                    {
                        view.CellMove(move);
                    }
                    view.CellMove(pos);
                    foreach (Position move in attacks)
                    {
                        view.CellAttack(move);
                    }
                    foreach (Position castle in castlings)
                    {
                        view.CellCastling(castle);
                    }
                    foreach (Position attack in inmoveattacks)
                    {
                        view.CellAttack(attack);
                    }
                }

            }
            else
            {
                if (isCorrectMove(pos))
                {
                    view.AddToLog(Field.GetFigureAt(highlightedfigurepos).GetImage() + " " + highlightedfigurepos.ToString() + "-" + pos.ToString());
                    Move(pos);
                    view.DrawField();
                }

                if (isCorrectCastling(pos))
                {
                    view.AddToLog(Field.GetFigureAt(highlightedfigurepos).GetImage() + " Рокировка " + pos.ToString());
                    Castle(pos);
                    view.DrawField();
                }

                if (isCorrectInMoveAttack(pos))
                {
                    view.AddToLog(Field.GetFigureAt(highlightedfigurepos).GetImage() + " " + highlightedfigurepos.ToString() + "-" + pos.ToString());
                    InMoveAttack(pos);
                    view.DrawField();
                }

                // снять выделение
                if (isHighlightedFigure(pos))
                {
                    MyList<Position> needunhighlight = Escape();
                    foreach (Position unhpos in needunhighlight)
                    {
                        view.CellDefault(unhpos);
                    }
                }

            }

            view.SetTurnText();

            view.WhiteCount(player1.GetCount());
            view.BlackCount(player2.GetCount());
        }