private void shuffleDeck() { coveredDeckCardsRow.coveredCardsInRow.Clear(); //For match reset int max = deck.Length; while (max > 0) { int randIndex = Random.Range(0, max - 1); coveredDeckCardsRow.AddCardToRow(deck[randIndex]); deck [randIndex] = deck [max - 1]; max--; } }
//Called when the button on top of the coverDeck is clicked, loops the cards in it and reset if the finish. public void OnCoverDeckClick() { //If there are still cards in the cover deck if (coveredDeckCardsRow.coveredCardsInRow.Count > 0) { addMove(); Card card = coveredDeckCardsRow.coveredCardsInRow.DropLastMono(); card.Uncover(); uncoveredDeckCardsRow.AddCardToRow(card); undoEnum = UndoEnum.DeckClick; } else //If cover deck is empty reset it and detract 100 points { if (uncoveredDeckCardsRow.uncoveredCardsInRow.Count > 0) { addMove(); coveredDeckCardsRow.addCardsToRow(uncoveredDeckCardsRow.uncoveredCardsInRow, true); uncoveredDeckCardsRow.uncoveredCardsInRow.Clear(); coveredDeckCardsRow.coveredCardsInRow.Reverse(); addPoints(RESET_DECK_SCORE); undoEnum = UndoEnum.DeckReset; } } }
//Move cards back to the last used row public void MoveToLastUsedRow(Row destinationRow, Card card) { List <Card> tempCardsInRow = card.currentRow.uncoveredCardsInRow; int indexHit = tempCardsInRow.IndexOf(card); //Transfert the hit card and children in movableRow for (int i = indexHit; i < tempCardsInRow.Count; i++) { destinationRow.AddCardToRow(tempCardsInRow [i]); } while (tempCardsInRow.Count > indexHit) { tempCardsInRow.RemoveAt(tempCardsInRow.Count - 1); } }