예제 #1
0
        public void checkKing()
        {
            ChessPiece king = Kings[WhitesTurn];

            turnKingInDanger = isTheKingInDanger(Board, WhitesTurn);
            king.Hightlight  = Color.White;
            if (turnKingInDanger)
            {
                bool movesAvailable = hasMoves(Board, WhitesTurn);
                if (movesAvailable)
                {
                    king.Hightlight = Color.Yellow;
                }
                else
                {
                    Winner          = !king.White ? WhitePlayer : BlackPlayer;
                    king.Hightlight = Color.Red;

                    if (Winner == Game1.player.Name)
                    {
                        ChessBoardMod.SyncGameResult(new GameResult(WhitePlayer, BlackPlayer, Winner));
                    }

                    SavedGameData.Sessions.Remove(Id);
                }
            }
        }
예제 #2
0
        public void surrender()
        {
            Winner = Game1.player.Name == WhitePlayer ? BlackPlayer : WhitePlayer;

            ChessBoardMod.SyncGameResult(new GameResult(WhitePlayer, BlackPlayer, Winner));
            nextTurn(new Point(-2, Winner == WhitePlayer ? 0 : 1), Point.Zero);
        }
예제 #3
0
        public void nextTurn(Point from, Point to)
        {
            temp                    = new Point[2];
            selectedPiece           = null;
            GameSession.WhitePlayer = WhitePlayer;
            GameSession.BlackPlayer = BlackPlayer;
            GameSession.Turns.Add(new ValueChangeRequest <Point, Point>(from, to, to));
            GameSession.NextTurnWhite = !WhitesTurn;
            SavedGameData.Sessions.AddOrReplace(GameSession.Id, GameSession);
            ChessBoardMod.SyncSession(GameSession);

            if (from.X == -2)
            {
                WhitesTurn = !WhitesTurn;
                reset(true);
            }
            else
            {
                Kings[WhitesTurn].Hightlight = Color.White;
                checkKing();
                reset(true);
            }
        }