/// <summary> /// Constructor. /// </summary> /// <param name="squares"></param> /// <param name="status"></param> public Board(int currentLevel) { int numberOfCards = (currentLevel * currentLevel) / 2; _cards.Clear(); Card tp; for (int i = 0; i < numberOfCards; i++) { for (int j = 0; j < 2; j++) { do { tp = new Card() { myXCoordinate = F(currentLevel), myYCoordinate = F(currentLevel) }; if (!CardAlreadyExists(tp)) break; } while (true); _cards.Add(tp); } EstablishMatchLink(); } }
bool CardAlreadyExists(Card p) { foreach (Card v in _cards) { if (v.myXCoordinate == p.myXCoordinate && v.myYCoordinate == p.myYCoordinate) return true; } return false; }