Beispiel #1
0
        /// <summary>
        /// Сохранение записи о перемещении карт между таблицами.
        /// </summary>
        /// <param name="cards"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="faceUp"></param>
        public static void Move(List <Card> cards, Tableau from, Tableau to, bool faceUp)
        {
            var move = new Move {
                Cards       = cards,
                FromTableau = from,
                ToTableau   = to,
                FaceUp      = faceUp,
                Type        = MoveType.ToTableau
            };

            AddToHistory(move);
        }
Beispiel #2
0
 public GameTable()
 {
     _stock           = new Stock();
     _leftFoundation  = new LeftFoundation[Foundations];
     _rightFoundation = new RightFoundation[Foundations];
     for (int i = 0; i < Foundations; i++)
     {
         _leftFoundation[i]  = new LeftFoundation();
         _rightFoundation[i] = new RightFoundation();
     }
     _tableau = new Tableau[Tableaus];
     for (int i = 0; i < Tableaus; i++)
     {
         _tableau[i] = new Tableau();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Перемещение карт между таблицами.
        /// </summary>
        /// <param name="cards">список перемещаемых карт</param>
        /// <param name="from">из какой таблицы перемещаем</param>
        /// <param name="to">в какую таблицу</param>
        /// <param name="saveToHistory">отметить ход в истории изменений</param>
        public void MoveCards(List <Card> cards, Tableau from, Tableau to, bool saveToHistory = true)
        {
            // Удаляем карты из таблицы.
            foreach (var card in cards)
            {
                from.GetList().Remove(card);
            }

            if (saveToHistory)
            {
                bool faceUp = (from.GetTopCard() == null) ? false : from.GetTopCard().IsFaceDown;
                MovesManager.Move(new List <Card>(cards), from, to, faceUp);
            }

            from.FaceUpTopCard();
            to.AddCards(cards);
        }