public List <State> mogucaSledecaStanja() { //TODO1: Implementirati metodu tako da odredjuje dozvoljeno kretanje u lavirintu //TODO2: Prosiriti metodu tako da se ne moze prolaziti kroz sive kutije List <State> rez = new List <State>(); //proveravamo za svaki od 10 setova karata for (int i = 0; i < 10; i++) { if (tabla[i].Count > 0) { PlayingCard temp = tabla[i][tabla[i].Count - 1]; List <PlayingCard> listaKarata = new List <PlayingCard>(); listaKarata.Add(temp); int brojac = 2; while (!tabla[i][tabla[i].Count - brojac].IsFaceDown && tabla[i][tabla[i].Count - brojac].Suit == temp.Suit && tabla[i][tabla[i].Count - brojac].Value == temp.Value + 1) { temp = tabla[i][tabla[i].Count - brojac]; listaKarata.Add(temp); brojac++; } for (int j = 0; j < 10; j++) { if (j != i) { if (tabla[j].Count == 0) { State sledece = this.sledeceStanje(); sledece.tabla[i] = sledece.tabla[i].Except(listaKarata).ToList(); sledece.tabla[j].AddRange(tabla[i]); sledece.potez = "Pomeri sa pozicije " + (i + 1) + " na poziciju " + (j + 1); nemaVisePoteza = false; rez.Add(sledece); } else if (!tabla[j][tabla[j].Count - 1].IsFaceDown && temp.Suit == tabla[j][tabla[j].Count - 1].Suit && temp.Value == tabla[j][tabla[j].Count - 1].Value - 1) { State sledece = this.sledeceStanje(); sledece.tabla = this.tabla; sledece.tabla[i] = sledece.tabla[i].Except(listaKarata).ToList(); sledece.tabla[j].AddRange(tabla[i]); sledece.potez = "Pomeri sa pozicije " + (i + 1) + " na poziciju " + (j + 1); nemaVisePoteza = false; rez.Add(sledece); } } } } } return(rez); }
/// <summary> /// Calculates the offsets. /// </summary> /// <returns></returns> private List <Size> CalculateOffsets() { // Calculate the offsets on a card by card basis. List <Size> offsets = new List <Size>(); int n = 0; int total = Children.Count; // Go through each card. foreach (UIElement child in Children) { // Get the card. If we don't have one, skip. PlayingCard card = ((FrameworkElement)child).DataContext as PlayingCard; if (card == null) { continue; } // The amount we'll offset by. double faceDownOffset = 0; double faceUpOffset = 0; // We are now going to offset only if the offset mode is appropriate. switch (OffsetMode) { case OffsetMode.EveryCard: // Offset every card. faceDownOffset = FaceDownOffset; faceUpOffset = FaceUpOffset; break; case OffsetMode.EveryNthCard: // Offset only if n Mod N is zero. if (((n + 1) % NValue) == 0) { faceDownOffset = FaceDownOffset; faceUpOffset = FaceUpOffset; } break; case OffsetMode.TopNCards: // Offset only if (Total - N) <= n < Total if ((total - NValue) <= n && n < total) { faceDownOffset = FaceDownOffset; faceUpOffset = FaceUpOffset; } break; case OffsetMode.BottomNCards: // Offset only if 0 < n < N if (n < NValue) { faceDownOffset = FaceDownOffset; faceUpOffset = FaceUpOffset; } break; case SolitaireGames.OffsetMode.UseCardValues: // Offset each time by the amount specified in the card object. faceDownOffset = card.FaceDownOffset; faceUpOffset = card.FaceUpOffset; break; default: break; } n++; // Create the offset as a size. Size offset = new Size(0, 0); // Offset. switch (Orientation) { case Orientation.Horizontal: offset.Width = card.IsFaceDown ? faceDownOffset : faceUpOffset; break; case Orientation.Vertical: offset.Height = card.IsFaceDown ? faceDownOffset : faceUpOffset; break; default: break; } // Add to the list. offsets.Add(offset); } return(offsets); }