Ejemplo n.º 1
0
        public void Capture(Move move)
        {
            if (move.Player != NextPlayer || move.From < 0)
            {
                throw new InvalidOperationException();
            }
            else
            {
                GameBoard.RemoveFrom(move.From);
                GameHistory.SaveMove(move);

                bool isDraw = GameHistory.SaveState(GameBoard.ToString());

                if (isDraw)
                {
                    GameEnded = true;
                    GameEndedEvent?.Invoke(this, FieldState.Empty);
                }
                else if (_whitesInHand == 0 && _blacksInHand == 0 && GameBoard.GetFieldsCount((FieldState)(-(int)NextPlayer)) < 3)
                {
                    GameEnded = true;
                    Winner    = NextPlayer;
                    GameEndedEvent?.Invoke(this, NextPlayer);
                }
                else
                {
                    NextPlayer = (FieldState)(-(int)NextPlayer);
                    NextPlayersTurnEvent?.Invoke(this, NextPlayer);
                }
            }
            UpdateStatsEvent?.Invoke(this, move);
        }
Ejemplo n.º 2
0
 public void MakeMove(Move move)
 {
     if (move.From == -1 && move.To > -1)
     {
         PlacePawn(move);
     }
     else
     {
         MovePawn(move);
     }
     UpdateStatsEvent?.Invoke(this, move);
 }