コード例 #1
0
        public Board(IList <Card> deck)
        {
            int deckPos = 51;

            for (int i = 0; i < 7; ++i)
            {
                tableau[i] = new TableauPos[i + 1];
                for (int j = 0; j < i + 1; ++j)
                {
                    Card card = deck[deckPos--];
                    tableauRank  += card.Rank;
                    tableau[i][j] = new TableauPos(card);
                }
            }
            for (int i = 0; i < 6; ++i)
            {
                for (int j = 0; j <= i; ++j)
                {
                    tableau[i][j].LeftChild  = tableau[i + 1][j];
                    tableau[i][j].RightChild = tableau[i + 1][j + 1];
                }
            }
            for (int i = 0; i < 52 - 7 - 6 - 5 - 4 - 3 - 2 - 1; ++i)
            {
                stock.Add(deck[i]);
            }
        }
コード例 #2
0
 public void UndoTableauMove(TableauPos pos, bool restoreTableauMove)
 {
     pos.Card = foundation.Last();
     foundation.RemoveAt(foundation.Count - 1);
     tableauRank          += pos.Card.Rank;
     canPerformTableauMove = restoreTableauMove;
 }
コード例 #3
0
 public TableauTableauMove(Board board, TableauPos pos1, TableauPos pos2)
 {
     this.board = board;
     this.pos1  = pos1;
     this.pos2  = pos2;
     card1      = pos1.Card;
     card2      = pos2.Card;
 }
コード例 #4
0
        public bool ApplyTableauMove(TableauPos pos)
        {
            tableauRank -= pos.Card.Rank;
            foundation.Add(pos.Card);
            pos.Card = null;
            bool answer = canPerformTableauMove;

            canPerformTableauMove = true;
            return(answer);
        }
コード例 #5
0
ファイル: Board.cs プロジェクト: adnamsale/Solitaire
 public TableauMove(Board board, TableauPos pos)
 {
     this.board = board;
     this.pos   = pos;
     card       = pos.Card;
 }
コード例 #6
0
ファイル: Board.cs プロジェクト: adnamsale/Solitaire
 public TableauPos(Card card, TableauPos leftChild, TableauPos rightChild)
 {
     Card            = card;
     this.leftChild  = leftChild;
     this.rightChild = rightChild;
 }
コード例 #7
0
 public bool IsPairableWith(TableauPos child)
 {
     return(null != Card && (LeftChild?.Card == child.Card || RightChild?.Card == child.Card) &&
            (LeftChild?.Card == null || RightChild?.Card == null));
 }
コード例 #8
0
 public WasteTableau(Board board, TableauPos pos)
 {
     this.board = board;
     this.pos   = pos;
     card       = pos.Card;
 }