Example #1
0
    /// <summary>
    /// Undos the last move made.
    /// </summary>
    public void Undo()
    {
        if (SelectedChecker != null)
        {
            ReturnChecker();
        }
        else if (m_MovesMade.Count > 0)
        {
            BGMove move = m_MovesMade.Pop();

            Board.GetPoint(move.StartPointID).PlaceInstantly(Board.GetPoint(move.EndPointID).PickUp());

            if (move.IsHit)
            {
                Point jail = Board.GetJail(GetOpponent(CurrentPlayer));
                Board.GetPoint(move.EndPointID).PlaceInstantly(jail.PickUp());
            }

            DiceRoll.Restore(move);
            MoveOptions = new BGMoveOptions(CurrentPlayer.ID, Board.GetBoardMap(), DiceRoll);
            EventHelper.Raise(this, MoveOptionsUpdated);
            EventHelper.Raise(this, CheckerMoved);
        }
    }