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]); } }
public void UndoTableauMove(TableauPos pos, bool restoreTableauMove) { pos.Card = foundation.Last(); foundation.RemoveAt(foundation.Count - 1); tableauRank += pos.Card.Rank; canPerformTableauMove = restoreTableauMove; }
public TableauTableauMove(Board board, TableauPos pos1, TableauPos pos2) { this.board = board; this.pos1 = pos1; this.pos2 = pos2; card1 = pos1.Card; card2 = pos2.Card; }
public bool ApplyTableauMove(TableauPos pos) { tableauRank -= pos.Card.Rank; foundation.Add(pos.Card); pos.Card = null; bool answer = canPerformTableauMove; canPerformTableauMove = true; return(answer); }
public TableauMove(Board board, TableauPos pos) { this.board = board; this.pos = pos; card = pos.Card; }
public TableauPos(Card card, TableauPos leftChild, TableauPos rightChild) { Card = card; this.leftChild = leftChild; this.rightChild = rightChild; }
public bool IsPairableWith(TableauPos child) { return(null != Card && (LeftChild?.Card == child.Card || RightChild?.Card == child.Card) && (LeftChild?.Card == null || RightChild?.Card == null)); }
public WasteTableau(Board board, TableauPos pos) { this.board = board; this.pos = pos; card = pos.Card; }