public SquareRoyal() { Deck = CardFunctions.GetOrderedDeck(); Deck.Shuffle(); Field = new Card[4, 4]; Cleaning = false; }
public bool AttemptPlaceCard(int x, int y, Card c) { if (CheatCanAlwaysPlaceCard || CanPlace(x, y, c)) { // add and then remove Field[x, y] = c; // set Deck.Remove(Deck.Last()); // empty the status bar messages Won = HasWon(); Cleaning = ShouldClean(); return true; } else { return false; } }
public Image GetFace(Card card) { return (Image)Properties.Resources.ResourceManager .GetObject(String.Format("{0}_{1}", card.Suit, card.Number)); }
public bool CanPlace(int x, int y, Card c) { if (Cleaning) { return false; } // Is the card already occupied? if (!IsEmptyCell(x, y)) { return false; } // Is it a royal? // TODO: refactor it, it could be better if (c.Number == 11) { // jacks belong in the left and right edges if (x == 1 || x == 2) { if (y == 0 || y == 3) { return true; } } return false; } if (c.Number == 12) { // queens belong in the top and bottom edges if (x == 0 || x == 3) { if (y == 1 || y == 2) { return true; } } return false; } if (c.Number == 13) { // kings in the corners if (x == 0 || x == 3) { if (y == 0 || y == 3) { return true; } } return false; } // I guess we can then. return true; }
public void VisuallyPlaceCard(int x, int y, Card c) { SetImage(x, y, GetFace(c)); }